import { RouteName } from "./routeName";
import { appConstant, appRoutes } from "@/app";

export { RouteName };
export type Routes = Route[];
export type RouteMeta = { title: string; icon?: string };
export type Route = {
  name: string;
  path: string;
  component: any;
  meta: RouteMeta;
  children?: Routes;
};

export const system: Routes = [
  {
    name: RouteName.login,
    path: "/login",
    component:
      appConstant.loginComponent || (() => import("@/view/system/index.vue")),
    meta: { title: "登录" },
  },
  {
    name: RouteName.register,
    path: "/register",
    component: () => import("@/view/system/index.vue"),
    meta: { title: "注册" },
  },
  {
    name: RouteName.forget,
    path: "/forget",
    component: () => import("@/view/system/index.vue"),
    meta: { title: "重置密码" },
  },
];

export const routes: Routes = [
  {
    name: RouteName.viewLayout,
    path: "/",
    component: () => import("@/view/layout/index.vue"),
    meta: { title: "VR看房管理" },
    children: [
      ...system,
      {
        name: RouteName.vrmodel,
        path: "home",
        component: () => import("@/view/vrmodel/index.vue"),
        meta: { title: "场景管理", icon: "iconfire_scenes" },
      },
      {
        name: RouteName.camera,
        path: "camera",
        component: () => import("@/view/camera/index.vue"),
        meta: { title: "相机管理", icon: "iconfire_camera" },
      },
      ...appRoutes,
      {
        name: RouteName.organization,
        path: "organization",
        component: () => import("@/view/organization/index.vue"),
        meta: { title: "组织架构", icon: "iconfire_organization" },
      },
      {
        name: RouteName.role,
        path: "role",
        component: () => import("@/view/role/index.vue"),
        meta: { title: "角色管理", icon: "iconfire_role_management" },
      },
      {
        name: RouteName.user,
        path: "user",
        component: () => import("@/view/user/index.vue"),
        meta: { title: "用户管理", icon: "iconfire_user" },
      },
      {
        name: RouteName.caseFile,
        path: "case/file/:caseId",
        component: () => import("@/view/case/caseFile.vue"),
        meta: { title: "卷宗管理" },
      },
      {
        name: RouteName.statistics,
        path: "/statistics",
        component: () => import("@/view/statistics/index.vue"),
        meta: { title: "数据统计", icon: "icon-fire_statistics" },
      },
      {
        name: RouteName.downloadLog,
        path: "download-log",
        component: () => import("@/view/vrmodel/downloadLog.vue"),
        meta: { title: "下载记录", icon: "icon-query_home" },
      },
    ],
  },
  {
    name: RouteName.drawCaseFile,
    path: "/case/file/:caseId/:type/:id",
    component: () => import("@/view/case/draw/index.vue"),
    meta: { title: "绘制卷宗图" },
  },
];
