<template>
  <view class="content">
    <!-- 系统管理 -->
    <view class="section-header">
      <text class="section-title">系统管理</text>
    </view>
    <view class="grid-body">
      <view class="grid-wrapper">
        <view 
          v-for="(item, index) in systemGridList" 
          :key="index" 
          @click="navigateTo(item.path)"
          class="grid-item">
          <view class="item-icon" :style="{ background: item.color }">
            <uni-icons :type="item.icon" size="22" color="#ffffff"></uni-icons>
          </view>
          <text class="item-text">{{ item.text }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";

const systemGridList = ref([
  { path: '/pages/system/user/index', text: '用户管理', icon: 'person', color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' },
  { path: '/pages/system/role/index', text: '角色管理', icon: 'staff', color: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)' },
  { path: '/pages/system/menu/index', text: '菜单管理', icon: 'list', color: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)' },
  { path: '/pages/system/dept/index', text: '部门管理', icon: 'chat', color: 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)' },
  { path: '/pages/system/post/index', text: '岗位管理', icon: 'contact', color: 'linear-gradient(135deg, #fd79a8 0%, #e84393 100%)' },
  { path: '/pages_mine/pages/system/dict/list', text: '字典管理', icon: 'bars', color: 'linear-gradient(135deg, #f6d365 0%, #fda085 100%)' },
  { path: '/pages/system/config/index', text: '参数设置', icon: 'gear', color: 'linear-gradient(135deg, #5f72bd 0%, #9b23ea 100%)' },
  { path: '/pages/system/notice/index', text: '通知公告', icon: 'notification', color: 'linear-gradient(135deg, #0be881 0%, #0fbcf9 100%)' },
  { path: '/pages/system/job/index', text: '定时任务', icon: 'calendar', color: 'linear-gradient(135deg, #6366f1 0%, #a855f7 100%)' },
  { path: '/pages/system/log/operlog/index', text: '操作日志', icon: 'compose', color: 'linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%)' },
  { path: '/pages/system/log/logininfor/index', text: '登录日志', icon: 'eye', color: 'linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%)' }
])

function navigateTo(path) {
  // 字典管理已开发完成,可以跳转
  if (path === '/pages_mine/pages/system/dict/list') {
    uni.navigateTo({
      url: path
    });
  } else {
    uni.showToast({
      title: '功能开发中',
      icon: 'none',
      duration: 2000
    });
  }
}
</script>

<style lang="scss">
  .container {
    min-height: 100vh;
    background-color: #f5f5f5;
  }

  /* #ifndef APP-NVUE */
  /* #endif */

  .content {
    padding: 12rpx 0;
  }

  .section-header {
    padding: 12rpx 24rpx 8rpx;
  }

  .section-title {
    font-size: 28rpx;
    font-weight: 700;
    color: #333;
    position: relative;
    padding-left: 16rpx;
  }

  .section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6rpx;
    height: 28rpx;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3rpx;
  }

  .grid-body {
    padding: 0 16rpx;
  }

  .grid-wrapper {
    display: flex;
    flex-wrap: wrap;
  }

  .grid-item {
    width: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16rpx 8rpx;
    box-sizing: border-box;
  }

  .item-icon {
    width: 80rpx;
    height: 80rpx;
    border-radius: 20rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12rpx;
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
  }

  .grid-item:active .item-icon {
    transform: scale(0.95);
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
  }

  .item-text {
    text-align: center;
    font-size: 22rpx;
    color: #333;
    font-weight: 500;
    line-height: 1.3;
  }
</style>
