Browse Source

📦 add 404 page

晓晓晓晓丶vv 4 years ago
parent
commit
8efb5176d3
3 changed files with 8 additions and 8 deletions
  1. 5 8
      src/router/modules/constant.ts
  2. 3 0
      src/router/permission.ts
  3. 0 0
      src/views/404.vue

+ 5 - 8
src/router/modules/constant.ts

@@ -10,16 +10,13 @@ export const Login: RouteConfig = {
   component: () => import("@/views/Login.vue"),
 };
 
-export const About: RouteConfig = {
-  name: "About",
-  path: "/about",
+export const NotFound: RouteConfig = {
+  name: "NotFound",
+  path: "/:pathMatch(.*)*",
   hidden: true,
-  meta: {
-    title: "关于我",
-  },
-  component: () => import("@/views/About.vue"),
+  component: () => import("@/views/404.vue"),
 };
 
-const constantRoutes: RouteConfig[] = [Login, About];
+const constantRoutes: RouteConfig[] = [Login];
 
 export default constantRoutes;

+ 3 - 0
src/router/permission.ts

@@ -7,6 +7,7 @@ import Layout from "@/layout/index.vue";
 
 import { RouteConfig } from "@/types/route";
 import { ActionType } from "@/store/modules/app/_type";
+import { NotFound } from "./modules/constant";
 
 const WHITE_URL_LIST: string[] = ["/login", "/forget"];
 
@@ -54,6 +55,8 @@ router.beforeEach(
         children: webRoutes,
       };
       router.addRoute(AppRoute);
+      // 添加全局Not Found Page
+      router.addRoute(NotFound);
       next({ ...to, replace: true, name: to.name! });
     }
     //  redirectRoutes(to, next);

src/views/About.vue → src/views/404.vue