import type { RouteRecordRaw } from 'vue-router'

/**
 * 业务路由（按权限动态挂载）
 * 与 router/index.ts 中的 asyncRoutes 内容保持一致
 */
const asyncRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/layouts/BasicLayout.vue'),
    redirect: '/dashboard',
    meta: { order: 0 },
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '仪表盘', icon: 'Odometer', keepAlive: true }
      }
    ]
  },
  {
    path: '/product',
    component: () => import('@/layouts/BasicLayout.vue'),
    redirect: '/product/list',
    meta: { title: '商品管理', icon: 'Goods' },
    children: [
      {
        path: 'list',
        name: 'ProductList',
        component: () => import('@/views/product/list.vue'),
        meta: { title: '商品列表', icon: 'List' }
      },
      {
        path: 'category',
        name: 'ProductCategory',
        component: () => import('@/views/product/category.vue'),
        meta: { title: '商品分类', icon: 'Menu' }
      }
    ]
  },
  {
    path: '/order',
    component: () => import('@/layouts/BasicLayout.vue'),
    redirect: '/order/list',
    children: [
      {
        path: 'list',
        name: 'OrderList',
        component: () => import('@/views/order/list.vue'),
        meta: { title: '订单管理', icon: 'Document' }
      }
    ]
  },
  {
    path: '/system',
    component: () => import('@/layouts/BasicLayout.vue'),
    redirect: '/system/admin',
    meta: { title: '系统管理', icon: 'Setting', order: 1 },
    children: [
      {
        path: 'admin',
        name: 'AdminList',
        component: () => import('@/views/admin/index.vue'),
        meta: { title: '管理员管理', icon: 'UserFilled' }
      },
      {
        path: 'user',
        name: 'UserList',
        component: () => import('@/views/user/list.vue'),
        meta: { title: '用户管理', icon: 'User' }
      },
      {
        path: 'notice/list',
        name: 'NoticeList',
        component: () => import('@/views/notice/list.vue'),
        meta: { title: '系统公告', icon: 'Bell' }
      }
    ]
  },
  {
    path: '/chat',
    component: () => import('@/layouts/BasicLayout.vue'),
    redirect: '/chat/list',
    children: [
      {
        path: 'list',
        name: 'ChatList',
        component: () => import('@/views/chat/list.vue'),
        meta: { title: '客服消息', icon: 'ChatDotRound' }
      }
    ]
  }
]

export default asyncRoutes
