perf: 同步完整版分支代码

This commit is contained in:
xiaoxian521
2021-11-28 16:39:26 +08:00
parent 1e92bd416e
commit e9dc8274a0
20 changed files with 326 additions and 165 deletions

View File

@@ -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")
);
});