import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/ai-home',
  },
  {
    path: '/ai-home',
    name: 'AiHome',
    component: () => import('../views/AiHome.vue'),
    meta: { title: 'AI Chat' },
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    component: () => import('../views/Dashboard.vue'),
    meta: { title: '总览' },
  },
  {
    path: '/ideas',
    name: 'Ideas',
    component: () => import('../views/Ideas.vue'),
    meta: { title: '灵感' },
  },
  {
    path: '/ideas/:id',
    name: 'IdeasDetail',
    component: () => import('../views/Ideas.vue'),
    meta: { title: '灵感详情' },
  },
  {
    path: '/projects',
    name: 'Projects',
    component: () => import('../views/Projects.vue'),
    meta: { title: '项目' },
  },
  {
    path: '/projects/:id',
    name: 'ProjectDetail',
    component: () => import('../views/ProjectDetail.vue'),
    meta: { title: '项目详情' },
  },
  {
    path: '/tasks',
    name: 'Tasks',
    component: () => import('../views/Tasks.vue'),
    meta: { title: '任务' },
  },
  {
    path: '/tasks/:id',
    name: 'TaskDetail',
    component: () => import('../views/TaskDetail.vue'),
    meta: { title: '任务详情' },
  },
  {
    path: '/knowledge',
    name: 'Knowledge',
    component: () => import('../views/Knowledge.vue'),
    meta: { title: '知识库' },
  },
  {
    path: '/audit',
    name: 'AuditLog',
    component: () => import('../views/AuditLog.vue'),
    meta: { title: '审批历史' },
  },
  {
    path: '/dev/x6',
    name: 'X6Demo',
    component: () => import('../components/dev/X6Demo.vue'),
    meta: { title: 'X6 v3 验证' },
  },
  {
    path: '/settings',
    name: 'Settings',
    component: () => import('../views/Settings.vue'),
    meta: { title: '设置' },
  },
  {
    path: '/ai-detached',
    name: 'AiDetached',
    component: () => import('../views/AiDetached.vue'),
    meta: { title: 'AI Chat' },
  },
  {
    path: '/file-explorer-detached',
    name: 'FileExplorerDetached',
    component: () => import('../views/FileExplorerDetached.vue'),
    meta: { title: '文件浏览器' },
  },
  {
    // 系统级审批提示浮窗(独立 WebviewWindow 内容):无边框 + alwaysOnTop + skipTaskbar
    path: '/approval-popup',
    name: 'ApprovalPopup',
    component: () => import('../views/ApprovalPopup.vue'),
    meta: { title: '审批待办' },
  },
  // catch-all:无效路由重定向首页(防白屏)
  {
    path: '/:pathMatch(.*)*',
    redirect: '/',
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
