import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/install',
    name: 'Install',
    component: () => import('@/pages/install/index.vue'),
    meta: {
      title: '安装 - 管理平台',
      layout: false,
    },
  },
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/pages/auth/login.vue'),
    meta: {
      title: '登录 - 管理平台',
      layout: false,
    },
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/pages/auth/register.vue'),
    meta: {
      title: '注册 - 管理平台',
      layout: false,
    },
  },
  {
    path: '/admin',
    component: () => import('@/layouts/admin.vue'),
    meta: { auth: true, role: 'admin' },
    children: [
      {
        path: '',
        name: 'AdminDashboard',
        component: () => import('@/pages/admin/index.vue'),
        meta: { title: '控制台 - 管理后台' },
      },
      {
        path: 'applications',
        name: 'AdminApplications',
        component: () => import('@/pages/admin/applications.vue'),
        meta: { title: '应用管理 - 管理后台' },
      },
      {
        path: 'applications/create',
        name: 'AdminApplicationCreate',
        component: () => import('@/pages/admin/applications/create.vue'),
        meta: { title: '创建应用 - 管理后台' },
      },
      {
        path: 'applications/:id',
        redirect: to => `/admin/applications/${to.params.id}/settings`,
      },
      {
        path: 'applications/:id/settings',
        name: 'AdminApplicationSettings',
        component: () => import('@/pages/admin/applications/[id]/settings.vue'),
        meta: { title: '基本设置 - 管理后台' },
      },
      {
        path: 'applications/:id/security',
        name: 'AdminApplicationSecurity',
        component: () => import('@/pages/admin/applications/[id]/security.vue'),
        meta: { title: '安全设置 - 管理后台' },
      },
      {
        path: 'cards',
        name: 'AdminCards',
        component: () => import('@/pages/admin/cards/index.vue'),
        meta: { title: '卡密管理 - 管理后台' },
      },
      {
        path: 'cards/create',
        name: 'AdminCardCreate',
        component: () => import('@/pages/admin/cards/create.vue'),
        meta: { title: '生成卡密 - 管理后台' },
      },
      {
        path: 'announcements',
        name: 'AdminAnnouncements',
        component: () => import('@/pages/admin/announcements/index.vue'),
        meta: { title: '公告管理 - 管理后台' },
      },
      {
        path: 'announcements/create',
        name: 'AdminAnnouncementCreate',
        component: () => import('@/pages/admin/announcements/create.vue'),
        meta: { title: '创建公告 - 管理后台' },
      },
      {
        path: 'announcements/:id',
        name: 'AdminAnnouncementEdit',
        component: () => import('@/pages/admin/announcements/[id].vue'),
        meta: { title: '编辑公告 - 管理后台' },
      },
      {
        path: 'versions',
        name: 'AdminVersions',
        component: () => import('@/pages/admin/versions/index.vue'),
        meta: { title: '版本管理 - 管理后台' },
      },
      {
        path: 'versions/create',
        name: 'AdminVersionCreate',
        component: () => import('@/pages/admin/versions/create.vue'),
        meta: { title: '创建版本 - 管理后台' },
      },
      {
        path: 'versions/:id',
        name: 'AdminVersionEdit',
        component: () => import('@/pages/admin/versions/[id].vue'),
        meta: { title: '编辑版本 - 管理后台' },
      },
      {
        path: 'card-types',
        name: 'AdminCardTypes',
        component: () => import('@/pages/admin/card-types/index.vue'),
        meta: { title: '卡类管理 - 管理后台' },
      },
      {
        path: 'card-types/create',
        name: 'AdminCardTypeCreate',
        component: () => import('@/pages/admin/card-types/create.vue'),
        meta: { title: '创建卡类 - 管理后台' },
      },
      {
        path: 'card-types/:id',
        name: 'AdminCardTypeEdit',
        component: () => import('@/pages/admin/card-types/[id].vue'),
        meta: { title: '编辑卡类 - 管理后台' },
      },
      {
        path: 'users',
        name: 'AdminUsers',
        component: () => import('@/pages/admin/users/index.vue'),
        meta: { title: '用户管理 - 管理后台' },
      },
      {
        path: 'users/create',
        name: 'AdminUserCreate',
        component: () => import('@/pages/admin/users/create.vue'),
        meta: { title: '添加用户 - 管理后台' },
      },
      {
        path: 'users/:id',
        name: 'AdminUserEdit',
        component: () => import('@/pages/admin/users/[id].vue'),
        meta: { title: '编辑用户 - 管理后台' },
      },
      {
        path: 'devices',
        name: 'AdminDevices',
        component: () => import('@/pages/admin/devices/index.vue'),
        meta: { title: '设备管理 - 管理后台' },
      },
      {
        path: 'sessions',
        name: 'AdminSessions',
        component: () => import('@/pages/admin/sessions/index.vue'),
        meta: { title: '在线实例 - 管理后台' },
      },
      {
        path: 'agent-apps',
        name: 'AdminAgentApps',
        component: () => import('@/pages/admin/agent-apps/index.vue'),
        meta: { title: '代理授权 - 管理后台' },
      },
      {
        path: 'agents',
        name: 'AdminAgents',
        component: () => import('@/pages/admin/agents/index.vue'),
        meta: { title: '代理管理 - 管理后台' },
      },
      {
        path: 'agents/create',
        name: 'AdminAgentsCreate',
        component: () => import('@/pages/admin/agents/create.vue'),
        meta: { title: '添加代理 - 管理后台' },
      },
      {
        path: 'agents/:id/edit',
        name: 'AdminAgentsEdit',
        component: () => import('@/pages/admin/agents/[id].vue'),
        meta: { title: '编辑代理 - 管理后台' },
      },
      {
        path: 'agent-apps/request',
        name: 'AdminAgentAppRequest',
        component: () => import('@/pages/admin/agent-apps/request.vue'),
        meta: { title: '申请授权 - 管理后台' },
      },
      {
        path: 'agent-apps/invite',
        name: 'AdminAgentAppInvite',
        component: () => import('@/pages/admin/agent-apps/invite.vue'),
        meta: { title: '邀请授权 - 管理后台' },
      },
      {
        path: 'agent-apps/:id/edit',
        name: 'AdminAgentAppEdit',
        component: () => import('@/pages/admin/agent-apps/[id]/edit.vue'),
        meta: { title: '编辑授权 - 管理后台' },
      },
      {
        path: 'agent-apps/:id/card-types',
        name: 'AdminAgentAppCardTypes',
        component: () => import('@/pages/admin/agent-apps/[id]/card-types.vue'),
        meta: { title: '卡密权限配置 - 管理后台' },
      },
      {
        path: 'agent-apps/:id/recharge',
        name: 'AdminAgentAppRecharge',
        component: () => import('@/pages/admin/agent-apps/[id]/recharge.vue'),
        meta: { title: '充值余额 - 管理后台' },
      },
      {
        path: 'finance',
        name: 'AdminFinance',
        component: () => import('@/pages/admin/finance/index.vue'),
        meta: { title: '财务管理 - 管理后台' },
      },
      {
        path: 'logs',
        name: 'AdminLogs',
        component: () => import('@/pages/admin/logs/index.vue'),
        meta: { title: '日志记录 - 管理后台' },
      },
      {
        path: 'tickets',
        name: 'AdminTickets',
        component: () => import('@/pages/admin/tickets.vue'),
        meta: { title: '工单系统 - 管理后台' },
      },
      {
        path: 'tickets/create',
        name: 'AdminTicketCreate',
        component: () => import('@/pages/admin/tickets/create.vue'),
        meta: { title: '创建工单 - 管理后台' },
      },
      {
        path: 'tickets/:id',
        name: 'AdminTicketDetail',
        component: () => import('@/pages/admin/tickets/[id].vue'),
        meta: { title: '工单详情 - 管理后台' },
      },
      {
        path: 'cloud-constants',
        name: 'AdminCloudConstants',
        component: () => import('@/pages/admin/cloud-constants/index.vue'),
        meta: { title: '云端常量 - 管理后台' },
      },
      {
        path: 'cloud-constants/create',
        name: 'AdminCloudConstantCreate',
        component: () => import('@/pages/admin/cloud-constants/create.vue'),
        meta: { title: '添加云端常量 - 管理后台' },
      },
      {
        path: 'cloud-constants/:id',
        name: 'AdminCloudConstantEdit',
        component: () => import('@/pages/admin/cloud-constants/[id].vue'),
        meta: { title: '编辑云端常量 - 管理后台' },
      },
      {
        path: 'cloud-variables',
        name: 'AdminCloudVariables',
        component: () => import('@/pages/admin/cloud-variables/index.vue'),
        meta: { title: '云端变量 - 管理后台' },
      },
      {
        path: 'cloud-variables/create',
        name: 'AdminCloudVariableCreate',
        component: () => import('@/pages/admin/cloud-variables/create.vue'),
        meta: { title: '添加云端变量 - 管理后台' },
      },
      {
        path: 'cloud-variables/:id',
        name: 'AdminCloudVariableEdit',
        component: () => import('@/pages/admin/cloud-variables/[id].vue'),
        meta: { title: '编辑云端变量 - 管理后台' },
      },
      {
        path: 'cloud-function',
        name: 'AdminCloudFunction',
        component: () => import('@/pages/admin/dynamic-code/index.vue'),
        meta: { title: '云端函数 - 管理后台' },
      },
      {
        path: 'cloud-function/create',
        name: 'AdminCloudFunctionCreate',
        component: () => import('@/pages/admin/dynamic-code/create.vue'),
        meta: { title: '创建云端函数 - 管理后台' },
      },
      {
        path: 'cloud-function/:id',
        name: 'AdminCloudFunctionEdit',
        component: () => import('@/pages/admin/dynamic-code/[id].vue'),
        meta: { title: '编辑云端函数 - 管理后台' },
      },
      {
        path: 'risk-control',
        name: 'AdminRiskControl',
        component: () => import('@/pages/admin/risk-control/index.vue'),
        meta: { title: '风控管理 - 管理后台' },
      },
      {
        path: 'risk-control/create',
        name: 'AdminRiskControlCreate',
        component: () => import('@/pages/admin/risk-control/create.vue'),
        meta: { title: '添加风控规则 - 管理后台' },
      },
      {
        path: 'risk-control/:id',
        name: 'AdminRiskControlEdit',
        component: () => import('@/pages/admin/risk-control/[id].vue'),
        meta: { title: '编辑风控规则 - 管理后台' },
      },
      {
        path: 'extension',
        name: 'AdminExtension',
        component: () => import('@/pages/admin/extension/index.vue'),
        meta: { title: '扩展配置 - 管理后台' },
      },
      {
        path: 'extension/webhooks/create',
        name: 'AdminExtensionWebhookCreate',
        component: () => import('@/pages/admin/extension/webhooks/create.vue'),
        meta: { title: '创建Webhook - 管理后台' },
      },
      {
        path: 'extension/api-keys/create',
        name: 'AdminExtensionAPIKeyCreate',
        component: () => import('@/pages/admin/extension/api-keys/create.vue'),
        meta: { title: '创建API密钥 - 管理后台' },
      },
      {
        path: 'profile',
        name: 'AdminProfile',
        component: () => import('@/pages/profile/index.vue'),
        meta: { title: '个人中心 - 管理后台' },
      },
      {
        path: 'system-settings',
        name: 'AdminSystemSettings',
        component: () => import('@/pages/admin/system-settings/index.vue'),
        meta: { title: '系统设置 - 管理后台' },
      },
      {
        path: 'payment-channels',
        name: 'AdminPaymentChannels',
        component: () => import('@/pages/admin/payment-channels/index.vue'),
        meta: { title: '支付渠道 - 管理后台' },
      },
      {
        path: 'payment-channels/create',
        name: 'AdminPaymentChannelCreate',
        component: () => import('@/pages/admin/payment-channels/create.vue'),
        meta: { title: '添加支付渠道 - 管理后台' },
      },
      {
        path: 'payment-channels/:id',
        name: 'AdminPaymentChannelEdit',
        component: () => import('@/pages/admin/payment-channels/[id].vue'),
        meta: { title: '编辑支付渠道 - 管理后台' },
      },
      {
        path: 'email-settings',
        name: 'AdminEmailSettings',
        component: () => import('@/pages/admin/email-settings/index.vue'),
        meta: { title: '邮箱配置 - 管理后台' },
      },
      {
        path: 'email-settings/create',
        name: 'AdminEmailSettingCreate',
        component: () => import('@/pages/admin/email-settings/create.vue'),
        meta: { title: '添加邮箱配置 - 管理后台' },
      },
      {
        path: 'email-settings/:id',
        name: 'AdminEmailSettingEdit',
        component: () => import('@/pages/admin/email-settings/[id].vue'),
        meta: { title: '编辑邮箱配置 - 管理后台' },
      },
      {
        path: 'sms-settings',
        name: 'AdminSmsSettings',
        component: () => import('@/pages/admin/sms-settings/index.vue'),
        meta: { title: '短信配置 - 管理后台' },
      },
      {
        path: 'sms-settings/create',
        name: 'AdminSmsSettingCreate',
        component: () => import('@/pages/admin/sms-settings/create.vue'),
        meta: { title: '添加短信配置 - 管理后台' },
      },
      {
        path: 'sms-settings/:id',
        name: 'AdminSmsSettingEdit',
        component: () => import('@/pages/admin/sms-settings/[id].vue'),
        meta: { title: '编辑短信配置 - 管理后台' },
      },
      {
        path: 'storage-configs',
        name: 'AdminStorageConfigs',
        component: () => import('@/pages/admin/storage-configs/index.vue'),
        meta: { title: '存储管理 - 管理后台' },
      },
      {
        path: 'storage-configs/create',
        name: 'AdminStorageConfigCreate',
        component: () => import('@/pages/admin/storage-configs/create.vue'),
        meta: { title: '添加存储配置 - 管理后台' },
      },
      {
        path: 'storage-configs/:id',
        name: 'AdminStorageConfigEdit',
        component: () => import('@/pages/admin/storage-configs/[id].vue'),
        meta: { title: '编辑存储配置 - 管理后台' },
      },
    ],
  },
  {
    path: '/agent',
    component: () => import('@/layouts/agent.vue'),
    meta: { auth: true, role: 'agent' },
    children: [
      {
        path: '',
        name: 'AgentDashboard',
        component: () => import('@/pages/agent/index.vue'),
        meta: { title: '控制台 - 代理商后台' },
      },
      {
        path: 'apps',
        name: 'AgentApps',
        component: () => import('@/pages/agent/apps/index.vue'),
        meta: { title: '应用管理 - 代理商后台' },
      },
      {
        path: 'apps/:id',
        name: 'AgentAppDetail',
        component: () => import('@/pages/agent/apps/[id].vue'),
        meta: { title: '应用详情 - 代理商后台' },
      },
      {
        path: 'cards',
        name: 'AgentCards',
        component: () => import('@/pages/agent/cards/index.vue'),
        meta: { title: '卡密管理 - 代理商后台' },
      },
      {
        path: 'cards/create',
        name: 'AgentCardCreate',
        component: () => import('@/pages/agent/cards/create.vue'),
        meta: { title: '生成卡密 - 代理商后台' },
      },
      {
        path: 'users',
        name: 'AgentUsers',
        component: () => import('@/pages/agent/users/index.vue'),
        meta: { title: '用户管理 - 代理商后台' },
      },
      {
        path: 'finance',
        name: 'AgentFinance',
        component: () => import('@/pages/agent/finance/index.vue'),
        meta: { title: '财务管理 - 代理商后台' },
      },
      {
        path: 'profile',
        name: 'AgentProfile',
        component: () => import('@/pages/profile/index.vue'),
        meta: { title: '个人中心 - 代理商后台' },
      },
    ],
  },
]

export default routes
