import type { RouteRecordRaw } from 'vue-router';
import { HOME_URL } from '@/config';

// LayoutRouter[布局路由]
export const layoutRouter: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: HOME_URL,
    component: () => import('@/layouts/index.vue'),
    children: [
      {
        path: HOME_URL,
        name: 'dashboard',
        component: () => import('@/pages/dashboard/index.vue'),
        meta: {
          title: '工作台',
          subtitle: '欢迎使用汇智中台',
          icon: 'Odometer',
        },
      },
      {
        path: '/approval',
        name: 'approval',
        component: () => import('@/pages/approval/index.vue'),
        meta: {
          title: '审批中心',
          subtitle: '处理业务审批流程',
          icon: 'Stamp',
        },
      },
      {
        path: '/dealer',
        name: 'dealer',
        component: () => import('@/pages/dealer/index.vue'),
        meta: {
          title: '客户管理',
          subtitle: '客户信息管理',
          icon: 'Shop',
        },
      },
      {
        path: '/opportunity',
        name: 'opportunity',
        component: () => import('@/pages/opportunity/index.vue'),
        meta: {
          title: '商机中心',
          subtitle: '商机管道管理',
          icon: 'TrendCharts',
        },
      },
      {
        path: '/lead',
        name: 'lead',
        component: () => import('@/pages/lead/index.vue'),
        meta: {
          title: '线索中心',
          subtitle: '线索跟进转化',
          icon: 'UserFilled',
        },
      },
      {
        path: '/supply',
        name: 'supply',
        component: () => import('@/pages/supply/index.vue'),
        meta: {
          title: '供应链管理',
          subtitle: '供应链协同管理',
          icon: 'Box',
        },
      },
      {
        path: '/bi',
        name: 'bi',
        component: () => import('@/pages/bi/index.vue'),
        meta: {
          title: 'BI报表',
          subtitle: '数据分析与可视化',
          icon: 'DataAnalysis',
        },
      },
      {
        path: '/system-settings',
        name: 'system-settings',
        component: () => import('@/pages/system-settings/index.vue'),
        meta: {
          title: '系统设置',
          subtitle: '系统参数配置',
          icon: 'Setting',
        },
      },
      {
        path: '/menu-settings',
        name: 'menu-settings',
        component: () => import('@/pages/menu-settings/index.vue'),
        meta: {
          title: '菜单设置',
          subtitle: '菜单权限管理',
          icon: 'Menu',
        },
      },
      {
        path: '/profile',
        name: 'profile',
        component: () => import('@/pages/profile/index.vue'),
        meta: {
          title: '个人中心',
          subtitle: '个人信息与设置',
          icon: 'User',
          // isHide: '1', // 移除隐藏配置，允许添加到标签页
        },
      },
      {
        path: '/erp-test',
        name: 'erp-test',
        component: () => import('@/pages/erp/index.vue'),
        meta: {
          title: 'ERP测试',
          subtitle: 'ERP服务连接测试',
          icon: 'Monitor',
        },
      },
      {
        path: '/chat/:id',
        name: 'chatWithId',
        component: () => import('@/pages/chat/index.vue'),
        meta: {
          title: 'AI对话',
          isHide: '1', // Hidden from nav menu
        },
      },
    ],
  },
];

// staticRouter[静态路由]
export const staticRouter: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/pages/login/index.vue'),
    meta: {
      title: '登录',
    },
  },
];

// errorRouter (错误页面路由)
export const errorRouter = [
  {
    path: '/403',
    name: '403',
    component: () => import('@/pages/error/403.vue'),
    meta: {
      title: '403页面',
      enName: '403 Page', // 英文名称
      icon: 'QuestionFilled', // 菜单图标
      isHide: '1', // 代表路由在菜单中是否隐藏，是否隐藏[0隐藏，1显示]
      isLink: '1', // 是否外链[有值则是外链]
      isKeepAlive: '0', // 是否缓存路由数据[0是，1否]
      isFull: '1', // 是否缓存全屏[0是，1否]
      isAffix: '1', // 是否缓存固定路由[0是，1否]
    },
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/pages/error/404.vue'),
    meta: {
      title: '404页面',
      enName: '404 Page', // 英文名称
      icon: 'CircleCloseFilled', // 菜单图标
      isHide: '1', // 代表路由在菜单中是否隐藏，是否隐藏[0隐藏，1显示]
      isLink: '1', // 是否外链[有值则是外链]
      isKeepAlive: '0', // 是否缓存路由数据[0是，1否]
      isFull: '1', // 是否缓存全屏[0是，1否]
      isAffix: '1', // 是否缓存固定路由[0是，1否]
    },
  },
  // 找不到path将跳转404页面
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/pages/error/404.vue'),
  },
];
