123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
- export const Layout = () => import("@/layout/index.vue");
- // 静态路由
- export const constantRoutes: RouteRecordRaw[] = [
- // {
- // path: "/redirect",
- // component: Layout,
- // meta: { hidden: true },
- // children: [
- // {
- // path: "/redirect/:path(.*)",
- // component: () => import("@/views/redirect/index.vue"),
- // },
- // ],
- // },
- {
- path: "/",
- redirect: "/main/home",
- meta: { hidden: true },
- },
- {
- path: "/main",
- component: () => import("@/views/main/main.vue"),
- meta: { hidden: true },
- redirect: "/main/home",
- children: [
- {
- path: "home",
- component: () => import("@/views/modules/home/home.vue"),
- },
- {
- path: "run-test/:engineerId",
- name: "RunTestPage",
- component: () => import("@/views/modules/runTest/run-test.vue"),
- },
- {
- path: "data-manager",
- component: () =>
- import("@/views/modules/data-manager/data-manager.vue"),
- },
- {
- path: "project-config/:engineerId",
- name: "ProjectConfig",
- component: () =>
- import("@/views/modules/project-config/project-config.vue"),
- },
- {
- path: "report-template",
- component: () =>
- import("@/views/modules/report-template/report-template.vue"),
- },
- {
- path: "person-manager",
- component: () =>
- import("@/views/modules/person-manager/person-manager.vue"),
- },
- ],
- },
- {
- path: "/global-config/:engineerId",
- name: "GlobalConfig",
- component: () => import("@/views/modules/global-config/global-config.vue"),
- meta: { hidden: true },
- },
- {
- path: "/deviceResources",
- component: () =>
- import("@/views/modules/global-config/deviceResources.vue"),
- meta: { hidden: true },
- },
- // {
- // path: "/test",
- // component: () => import("@/views/modules/home/test/test.vue"),
- // meta: { hidden: true },
- // redirect: "/main/home",
- // children: [
- // {
- // path: "test1",
- // component: () => import("@/views/modules/home/home.vue"),
- // },
- // ],
- // },
- {
- path: "/login",
- component: () => import("@/views/demo/test-dark.vue"),
- meta: { hidden: true },
- },
- // {
- // path: "/",
- // name: "/",
- // component: Layout,
- // redirect: "/dashboard",
- // children: [
- // {
- // path: "dashboard",
- // component: () => import("@/views/dashboard/index.vue"),
- // name: "Dashboard", // 用于 keep-alive, 必须与SFC自动推导或者显示声明的组件name一致
- // // https://cn.vuejs.org/guide/built-ins/keep-alive.html#include-exclude
- // meta: {
- // title: "dashboard",
- // icon: "homepage",
- // affix: true,
- // keepAlive: true,
- // alwaysShow: false,
- // },
- // },
- // {
- // path: "401",
- // component: () => import("@/views/error-page/401.vue"),
- // meta: { hidden: true },
- // },
- // {
- // path: "404",
- // component: () => import("@/views/error-page/404.vue"),
- // meta: { hidden: true },
- // },
- // ],
- // },
- {
- path: "/:pathMatch(.*)*", // 必备
- component: () => import("@/views/error-page/404.vue"),
- },
- // 外部链接
- // {
- // path: "/external-link",
- // component: Layout,
- // children: [ {
- // component: () => import("@/views/external-link/index.vue"),
- // path: "https://www.cnblogs.com/haoxianrui/",
- // meta: { title: "外部链接", icon: "link" },
- // },
- // ],
- // },
- // 多级嵌套路由
- /* {
- path: '/nested',
- component: Layout,
- redirect: '/nested/level1/level2',
- name: 'Nested',
- meta: {title: '多级菜单', icon: 'nested'},
- children: [
- {
- path: 'level1',
- component: () => import('@/views/nested/level1/index.vue'),
- name: 'Level1',
- meta: {title: '菜单一级'},
- redirect: '/nested/level1/level2',
- children: [
- {
- path: 'level2',
- component: () => import('@/views/nested/level1/level2/index.vue'),
- name: 'Level2',
- meta: {title: '菜单二级'},
- redirect: '/nested/level1/level2/level3',
- children: [
- {
- path: 'level3-1',
- component: () => import('@/views/nested/level1/level2/level3/index1.vue'),
- name: 'Level3-1',
- meta: {title: '菜单三级-1'}
- },
- {
- path: 'level3-2',
- component: () => import('@/views/nested/level1/level2/level3/index2.vue'),
- name: 'Level3-2',
- meta: {title: '菜单三级-2'}
- }
- ]
- }
- ]
- },
- ]
- }*/
- ];
- /**
- * 创建路由
- */
- const router = createRouter({
- history: createWebHistory(),
- routes: constantRoutes,
- // 刷新时,滚动条位置还原
- scrollBehavior: () => ({ left: 0, top: 0 }),
- });
- /**
- * 重置路由
- */
- export function resetRouter() {
- router.replace({ path: "/login" });
- }
- export default router;
|