From f6272155af39efe4330aaa9f8b8f4edf8bf46c23 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 26 Mar 2022 02:09:12 +0800 Subject: [PATCH] Show page not found for invalid routes --- src/layouts/Layout.vue | 2 +- src/pages/NotFound.vue | 99 ++++++++++++++++++++++++++++++++++++++++++ src/router.js | 5 +++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/pages/NotFound.vue diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index 09c8b7db..fc753348 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -48,7 +48,7 @@
- +
diff --git a/src/pages/NotFound.vue b/src/pages/NotFound.vue new file mode 100644 index 00000000..16ba8a55 --- /dev/null +++ b/src/pages/NotFound.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/router.js b/src/router.js index 76dfa5cb..f59192d3 100644 --- a/src/router.js +++ b/src/router.js @@ -20,6 +20,7 @@ import Backup from "./components/settings/Backup.vue"; import About from "./components/settings/About.vue"; import ManageStatusPage from "./pages/ManageStatusPage.vue"; import AddStatusPage from "./pages/AddStatusPage.vue"; +import NotFound from "./pages/NotFound.vue"; const routes = [ { @@ -128,6 +129,10 @@ const routes = [ path: "/status/:slug", component: StatusPage, }, + { + path: "/:pathMatch(.*)*", + component: NotFound, + }, ]; export const router = createRouter({