fix: correct path but not found
This commit is contained in:
parent
2e9dd8d7d4
commit
98e60a8929
2 changed files with 17 additions and 2 deletions
|
|
@ -1,7 +1,12 @@
|
|||
import type { RouteRecordRaw } from "vue-router";
|
||||
// import { ref } from "vue";
|
||||
// import { useRoute } from "vue-router";
|
||||
const Error404NotFound = () => import("@/views/Error404NotFound.vue");
|
||||
const data = await fetch("/toc.json").then((r) => r.json());
|
||||
|
||||
// const routes = useRoute();
|
||||
// const hasQueryParam = ref<boolean>(false);
|
||||
const mainDataInfo = data.filter((v: any) => v.path);
|
||||
const manual = data.filter((v: any) => v.children);
|
||||
|
||||
const mergeManual: any[] = [];
|
||||
|
|
@ -24,7 +29,10 @@ const route: RouteRecordRaw[] = [
|
|||
name: "Manual",
|
||||
component: () => import("@/modules/01_manual/MainPage.vue"),
|
||||
beforeEnter: (to, from, next) => {
|
||||
const itemExists = manualRoute.some((item) => item.path === to.fullPath);
|
||||
const mergeAll = [...mainDataInfo, ...manualRoute];
|
||||
const itemExists = mergeAll.some(
|
||||
(item) => item.path === window.location.pathname
|
||||
);
|
||||
|
||||
if (itemExists) {
|
||||
next();
|
||||
|
|
@ -32,6 +40,7 @@ const route: RouteRecordRaw[] = [
|
|||
next({
|
||||
name: "Error404NotFound",
|
||||
params: { pathMatch: to.path.substring(1).split("/") },
|
||||
query: to.query,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -55,7 +64,7 @@ const route: RouteRecordRaw[] = [
|
|||
path: "/:pathMatch(.*)*",
|
||||
name: "Error404NotFound",
|
||||
component: Error404NotFound,
|
||||
props: true,
|
||||
props: (route) => ({ query: route.query }),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ import { useRoute } from "vue-router";
|
|||
|
||||
export default defineComponent({
|
||||
name: "Error404NotFound",
|
||||
// props: {
|
||||
// query: {
|
||||
// type: Object,
|
||||
// default: () => ({}),
|
||||
// },
|
||||
// },
|
||||
setup() {
|
||||
const route = useRoute();
|
||||
const hasQueryParam = ref<boolean>(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue