|
@@ -1,172 +1,30 @@
|
|
-import { createRouter, createWebHashHistory, 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: "/login",
|
|
|
|
- component: () => import("@/views/login/index.vue"),
|
|
|
|
- meta: { hidden: true },
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- path: "/",
|
|
|
|
- name: "/",
|
|
|
|
- component: Layout,
|
|
|
|
- redirect: "/process",
|
|
|
|
- children: [
|
|
|
|
- {
|
|
|
|
- path: "process",
|
|
|
|
- component: () => import("@/views/process/main.vue"),
|
|
|
|
- name: "ProcessMain",
|
|
|
|
- meta: {
|
|
|
|
- title: "process",
|
|
|
|
- icon: "homepage",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "pro-steps",
|
|
|
|
- component: () => import("@/views/pro-steps/index.vue"),
|
|
|
|
- name: "ProSteps",
|
|
|
|
- meta: {
|
|
|
|
- title: "",
|
|
|
|
- icon: "homepage",
|
|
|
|
- keepAlive: true,
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- children: [
|
|
|
|
- {
|
|
|
|
- path: "dianjian",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/dianjian.vue"),
|
|
|
|
- name: "Dianjian",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "duomeiticaiji",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/duomeiticaiji.vue"),
|
|
|
|
- name: "Duomeiticaiji",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "esop",
|
|
|
|
- component: () => import("@/views/pro-steps/components/ESOP.vue"),
|
|
|
|
- name: "Esop",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "jingu",
|
|
|
|
- component: () => import("@/views/pro-steps/components/jingu.vue"),
|
|
|
|
- name: "Jingu",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "mingpaibangding",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/mingpaibangding.vue"),
|
|
|
|
- name: "Mingpaibangding",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "jiluxiang",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/jiluxiang.vue"),
|
|
|
|
- name: "Jiluxiang",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- keepAlive: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "shebeijilu",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/shebeijilu.vue"),
|
|
|
|
- name: "Shebeijilu",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "tiaoshipipei",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/tiaoshipipei.vue"),
|
|
|
|
- name: "Tiaoshipipei",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "wuliaocaiji",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-steps/components/wuliaocaiji.vue"),
|
|
|
|
- name: "Wuliaocaiji",
|
|
|
|
- meta: {
|
|
|
|
- back: true,
|
|
|
|
- keepAlive: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "call-materiel",
|
|
|
|
- component: () =>
|
|
|
|
- import("@/views/pro-operation/call-materiel/index.vue"),
|
|
|
|
- name: "call-materiel",
|
|
|
|
- meta: {
|
|
|
|
- title: "叫料",
|
|
|
|
- icon: "homepage",
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path: "drawing",
|
|
|
|
- component: () => import("@/views/pro-operation/drawing/index.vue"),
|
|
|
|
- name: "drawing-list",
|
|
|
|
- meta: {
|
|
|
|
- title: "图纸",
|
|
|
|
- icon: "homepage",
|
|
|
|
- back: true,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- path: "/:pathMatch(.*)*", // 必备
|
|
|
|
- component: () => import("@/views/error-page/404.vue"),
|
|
|
|
|
|
+import { createRouter, createWebHashHistory } from "vue-router";
|
|
|
|
+
|
|
|
|
+const moduleFiles: any = import.meta.glob("./modules/*.ts", { eager: true });
|
|
|
|
+
|
|
|
|
+// 通过 reduce 去搜集所有的模块的导出内容
|
|
|
|
+const configRoutes = Object.keys(moduleFiles).reduce(
|
|
|
|
+ (routes: any, filepath: string) => {
|
|
|
|
+ const value = moduleFiles[filepath].default;
|
|
|
|
+
|
|
|
|
+ // 我们判断导出的是不是数组,是则进行拓展解构
|
|
|
|
+ if (Array.isArray(value)) {
|
|
|
|
+ routes.push(...value);
|
|
|
|
+ } else {
|
|
|
|
+ // 否则直接加到routes中
|
|
|
|
+ routes.push(value);
|
|
|
|
+ }
|
|
|
|
+ return routes;
|
|
},
|
|
},
|
|
-];
|
|
|
|
|
|
+ []
|
|
|
|
+);
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建路由
|
|
* 创建路由
|
|
*/
|
|
*/
|
|
const router = createRouter({
|
|
const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
history: createWebHashHistory(),
|
|
- routes: constantRoutes,
|
|
|
|
|
|
+ routes: configRoutes,
|
|
// 刷新时,滚动条位置还原
|
|
// 刷新时,滚动条位置还原
|
|
scrollBehavior: () => ({ left: 0, top: 0 }),
|
|
scrollBehavior: () => ({ left: 0, top: 0 }),
|
|
});
|
|
});
|