mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
🐛 修复路由跳转不生效
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file router index.ts
|
* @file router index.ts
|
||||||
* @description 路由入口
|
* @description 路由入口
|
||||||
* @since Beta v0.6.8
|
* @since Beta v0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createRouter, createWebHistory } from "vue-router";
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
@@ -9,11 +9,13 @@ import { createRouter, createWebHistory } from "vue-router";
|
|||||||
import routes from "./routes.js";
|
import routes from "./routes.js";
|
||||||
|
|
||||||
const router = createRouter({ history: createWebHistory(), routes: routes });
|
const router = createRouter({ history: createWebHistory(), routes: routes });
|
||||||
|
// 只有在特定页面忽略参数变化
|
||||||
|
const ignoreRoutes: ReadonlyArray<string> = ["酒馆", "话题"];
|
||||||
|
|
||||||
// 解决路由重复问题
|
// 解决路由重复问题
|
||||||
router.afterEach((to, from) => {
|
router.afterEach((to, from) => {
|
||||||
if (from.name === to.name) {
|
if (from.name === to.name) {
|
||||||
if (from.query !== to.query) return;
|
if (from.query !== to.query && ignoreRoutes.includes(from.name?.toString() ?? "")) return;
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user