import { RouteRecordRaw } from "vue-router";
import { HOME_URL, LOGIN_URL } from "@/config";

/**
 * staticRouter (静态路由)
 */
export const staticRouter: RouteRecordRaw[] = [
  {
    path: LOGIN_URL,
    name: "login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      title: "登录"
    }
  },
  {
    path: "/layout",
    name: "layout",
    component: () => import("@/layouts/index.vue"),
    redirect: HOME_URL,
    children: []
  }
];

/**
 * errorRouter (错误页面路由)
 */
export const errorRouter = [
  {
    path: "/403",
    name: "403",
    component: () => import("@/components/ErrorMessage/403.vue"),
    meta: {
      title: "403页面"
    }
  },
  {
    path: "/404",
    name: "404",
    component: () => import("@/components/ErrorMessage/404.vue"),
    meta: {
      title: "404页面"
    }
  },
  {
    path: "/500",
    name: "500",
    component: () => import("@/components/ErrorMessage/500.vue"),
    meta: {
      title: "500页面"
    }
  },
  // Resolve refresh page, route warnings
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/components/ErrorMessage/404.vue")
  }
];

// 权限静态路由，基于用户权限动态去加载
export const patchRoutes: Menu.MenuOptions[] = [
  {
    path: "/system/dictData/:id",
    name: "dictData",
    component: "/system/dictManage/dictData",
    permissions: ["system:dict:list"],
    meta: {
      isHide: true,
      title: "字典数据",
      isFull: false,
      activeMenu: "/system/dictManage"
    }
  },
  {
    path: "/corpus/clause-detail",
    name: "SjDetail",
    component: "/corpus/first-clause/detail",
    permissions: ["article:first:view"],
    meta: {
      isHide: true,
      title: "详情",
      isFull: false,
      activeMenu: "/corpus/first-clause"
    }
  },
  {
    path: "/corpus/trace-detail",
    name: "TraceDetail",
    component: "/corpus/trace-origin/detail",
    permissions: ["article:trace:write"],
    meta: {
      isHide: true,
      title: "结果详情",
      isFull: false,
      activeMenu: "/corpus/trace-origin"
    }
  },
  {
    path: "/annotation/home-detail",
    name: "AnnoHomeDetail",
    component: "/annotation/home/detail",
    permissions: ["article:home:view"],
    meta: {
      isHide: true,
      title: "标注结果详情",
      isFull: false,
      activeMenu: "/annotation/home"
    }
  },
  {
    path: "/annotation/labeling-detail",
    name: "AnnoLabelDetail",
    component: "/annotation/labeling/detail",
    permissions: ["article:anno:write"],
    meta: {
      isHide: true,
      title: "标注操作页面",
      isFull: false,
      activeMenu: "/annotation/labeling"
    }
  },
  {
    path: "/annotation/audit-detail",
    name: "AnnoAuditDetail",
    component: "/annotation/audit/detail",
    permissions: ["article:audit:process"],
    meta: {
      isHide: true,
      title: "详情",
      isFull: false,
      activeMenu: "/annotation/audit"
    }
  },
  {
    path: "/annotation/lexicon-detail",
    name: "AnnoLexiconDetail",
    component: "/annotation/lexicon/detail",
    permissions: ["wordLib:view"],
    meta: {
      isHide: true,
      title: "词表详情",
      isFull: false,
      activeMenu: "/annotation/lexicon"
    }
  },
  {
    path: "/retrieval-detail",
    name: "RetrievalDetail",
    component: "/retrieval/detail",
    permissions: ["search:common", "search:advance"],
    meta: {
      isHide: true,
      title: "结果详情",
      isFull: false,
      activeMenu: "/retrieval"
    }
  }
  // {
  //   path: "/task/indexData/OperatIndex",
  //   name: "OperatIndex",
  //   // component: () => import("@/views/indexData/index.vue"),
  //   component: "/task/indexData/OperatIndex",
  //   permissions: ["search:common", "search:advance"],
  //   meta: {
  //     title: "标引",
  //     isHide: true,
  //     isFull: false,
  //     // activeMenu: "/system/dictManage"
  //   }
  // }
];
