Ver código fonte

chore: 定义常量路由

lujialiang 2 semanas atrás
pai
commit
e0e8a1a3b2

+ 52 - 0
src/store/modules/route/constantRoutes.json

@@ -0,0 +1,52 @@
+{
+  "error": false,
+  "data": [
+    {
+      "name": "login",
+      "path": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?",
+      "component": "layout.blank$view.login",
+      "props": true,
+      "meta": {
+        "title": "login",
+        "i18nKey": "route.login",
+        "constant": true,
+        "hideInMenu": true
+      }
+    },
+    {
+      "name": "403",
+      "path": "/403",
+      "component": "layout.blank$view.403",
+      "meta": {
+        "title": "403",
+        "i18nKey": "route.403",
+        "constant": true,
+        "hideInMenu": true
+      }
+    },
+    {
+      "name": "404",
+      "path": "/404",
+      "component": "layout.blank$view.404",
+      "meta": {
+        "title": "404",
+        "i18nKey": "route.404",
+        "constant": true,
+        "hideInMenu": true
+      }
+    },
+    {
+      "name": "500",
+      "path": "/500",
+      "component": "layout.blank$view.500",
+      "meta": {
+        "title": "500",
+        "i18nKey": "route.500",
+        "constant": true,
+        "hideInMenu": true
+      }
+    }
+  ],
+  "code": "200",
+  "msg": "请求成功"
+}

+ 4 - 2
src/store/modules/route/index.ts

@@ -8,10 +8,11 @@ import { router } from '@/router';
 import { createStaticRoutes, getAuthVueRoutes } from '@/router/routes';
 import { ROOT_ROUTE } from '@/router/routes/builtin';
 import { getRouteName, getRoutePath } from '@/router/elegant/transform';
-import { fetchGetConstantRoutes, fetchGetUserRoutes, fetchIsRouteExist } from '@/service/api';
+import { fetchGetUserRoutes, fetchIsRouteExist } from '@/service/api';
 import { useAppStore } from '../app';
 import { useAuthStore } from '../auth';
 import { useTabStore } from '../tab';
+import constantRoutesData from './constantRoutes.json';
 import {
   filterAuthRoutesByRoles,
   getBreadcrumbsByRoute,
@@ -202,7 +203,8 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
     if (authRouteMode.value === 'static') {
       addConstantRoutes(staticRoute.constantRoutes);
     } else {
-      const { data, error } = await fetchGetConstantRoutes();
+      // const { data, error } = await fetchGetConstantRoutes();
+      const { data, error } = constantRoutesData as any;
 
       if (!error) {
         addConstantRoutes(data);