|
@@ -25,7 +25,7 @@ import { buildHierarchyTree } from "@/utils/tree";
|
|
|
import { isUrl, openLink, storageSession } from "@pureadmin/utils";
|
|
|
|
|
|
import remainingRouter from "./modules/remaining";
|
|
|
-import { ShakeDownDecrypt } from "@/utils/CryptoJS";
|
|
|
+import { ShakeDownDecrypt, ShakeDownEncrypt } from "@/utils/CryptoJS";
|
|
|
|
|
|
/** 自动导入全部静态路由,无需再手动引入!匹配 src/router/modules 目录(任何嵌套级别)中具有 .ts 扩展名的所有文件,除了 remaining.ts 文件
|
|
|
* 如何匹配所有文件请看:https://github.com/mrmlnc/fast-glob#basic-syntax
|
|
@@ -107,8 +107,8 @@ router.beforeEach((to: toRouteType, _from, next) => {
|
|
|
}
|
|
|
}
|
|
|
const userInfo =
|
|
|
- storageSession().getItem<DataInfo<number>>(sessionKey) &&
|
|
|
- ShakeDownDecrypt(storageSession().getItem<DataInfo<number>>(sessionKey));
|
|
|
+ storageSession().getItem(sessionKey) &&
|
|
|
+ ShakeDownDecrypt(storageSession().getItem(sessionKey));
|
|
|
// NProgress.start();
|
|
|
const externalLink = isUrl(to?.name as string);
|
|
|
if (!externalLink) {
|
|
@@ -135,10 +135,15 @@ router.beforeEach((to: toRouteType, _from, next) => {
|
|
|
openLink(to?.name as string);
|
|
|
// NProgress.done();
|
|
|
} else {
|
|
|
+ if (Object.keys(to?.query).length > 0) {
|
|
|
+ storageSession().setItem(to?.path, ShakeDownEncrypt(to?.query));
|
|
|
+ }
|
|
|
+ putRouterQuery(to);
|
|
|
toCorrectRoute();
|
|
|
}
|
|
|
} else {
|
|
|
// 刷新
|
|
|
+ putRouterQuery(to);
|
|
|
if (
|
|
|
usePermissionStoreHook().wholeMenus.length === 0 &&
|
|
|
to.path !== "/login"
|
|
@@ -175,8 +180,29 @@ router.beforeEach((to: toRouteType, _from, next) => {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+const putRouterQuery = to => {
|
|
|
+ const routerQuery = setRouterQuery(to.path);
|
|
|
+
|
|
|
+ if (Object.keys(routerQuery).length > 0) {
|
|
|
+ to.query = routerQuery;
|
|
|
+ to.fullPath = forMatterRouterLink(to.path, routerQuery);
|
|
|
+ to.href = forMatterRouterLink(to.path, routerQuery);
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
-router.afterEach(() => {
|
|
|
+function setRouterQuery(toUrl: string) {
|
|
|
+ return storageSession().getItem(toUrl)
|
|
|
+ ? ShakeDownDecrypt(storageSession().getItem(toUrl))
|
|
|
+ : {};
|
|
|
+}
|
|
|
+function forMatterRouterLink(url: string, object: object) {
|
|
|
+ url += "?";
|
|
|
+ for (const iterator in object) {
|
|
|
+ url += `${iterator}=${object[iterator]}`;
|
|
|
+ }
|
|
|
+ return url;
|
|
|
+}
|
|
|
+router.afterEach(to => {
|
|
|
// NProgress.done();
|
|
|
});
|
|
|
export default router;
|