mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-11-26 04:23:40 +08:00
perf: 同步完整版分支代码
This commit is contained in:
@@ -13,6 +13,7 @@ import NProgress from "/@/utils/progress";
|
||||
import { useTimeoutFn } from "@vueuse/core";
|
||||
import { storageSession, storageLocal } from "/@/utils/storage";
|
||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
||||
|
||||
// 静态路由
|
||||
import homeRouter from "./modules/home";
|
||||
@@ -126,7 +127,7 @@ export const addAsyncRoutes = (arrRoutes: Array<RouteComponent>) => {
|
||||
// 创建路由实例
|
||||
export const router: Router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: filterTree(ascending(constantRoutes)).concat(...remainingRouter),
|
||||
routes: ascending(constantRoutes).concat(...remainingRouter),
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
return new Promise(resolve => {
|
||||
if (savedPosition) {
|
||||
@@ -222,11 +223,12 @@ router.beforeEach((to, _from, next) => {
|
||||
// 刷新
|
||||
if (usePermissionStoreHook().wholeRoutes.length === 0)
|
||||
initRouter(name.username).then((router: Router) => {
|
||||
if (!useMultiTagsStoreHook().getMultiTagsCache) {
|
||||
return router.push("/");
|
||||
}
|
||||
router.push(to.path);
|
||||
// 刷新页面更新标签栏与页面路由匹配
|
||||
const localRoutes = storageLocal.getItem(
|
||||
"responsive-routesInStorage"
|
||||
);
|
||||
const localRoutes = storageLocal.getItem("responsive-tags");
|
||||
const optionsRoutes = router.options?.routes;
|
||||
const newLocalRoutes = [];
|
||||
optionsRoutes.forEach(ors => {
|
||||
@@ -237,7 +239,7 @@ router.beforeEach((to, _from, next) => {
|
||||
});
|
||||
});
|
||||
storageLocal.setItem(
|
||||
"responsive-routesInStorage",
|
||||
"responsive-tags",
|
||||
uniqBy(newLocalRoutes, "path")
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user