mirror of https://github.com/certd/certd
perf: 修复tab页缓存问题
parent
a0eeb17d73
commit
64e5449ab3
|
@ -22,7 +22,7 @@ function buildAccessedMenus(menus: any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const item: any = {
|
const item: any = {
|
||||||
...sub
|
...sub,
|
||||||
};
|
};
|
||||||
|
|
||||||
list.push(item);
|
list.push(item);
|
||||||
|
@ -40,7 +40,7 @@ export function setupCommonGuard(router: Router) {
|
||||||
// 记录已经加载的页面
|
// 记录已经加载的页面
|
||||||
const loadedPaths = new Set<string>();
|
const loadedPaths = new Set<string>();
|
||||||
|
|
||||||
router.beforeEach(async (to) => {
|
router.beforeEach(async to => {
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
await settingStore.initOnce();
|
await settingStore.initOnce();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export function setupCommonGuard(router: Router) {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
router.afterEach((to) => {
|
router.afterEach(to => {
|
||||||
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
||||||
|
|
||||||
loadedPaths.add(to.path);
|
loadedPaths.add(to.path);
|
||||||
|
@ -71,6 +71,10 @@ export function setupCommonGuard(router: Router) {
|
||||||
*/
|
*/
|
||||||
function setupAccessGuard(router: Router) {
|
function setupAccessGuard(router: Router) {
|
||||||
router.beforeEach(async (to, from) => {
|
router.beforeEach(async (to, from) => {
|
||||||
|
if (to.matched && to.matched.length > 2) {
|
||||||
|
to.matched.splice(1, to.matched.length - 2);
|
||||||
|
}
|
||||||
|
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
// 是否已经生成过动态路由
|
// 是否已经生成过动态路由
|
||||||
if (!accessStore.isAccessChecked) {
|
if (!accessStore.isAccessChecked) {
|
||||||
|
@ -93,7 +97,7 @@ function setupAccessGuard(router: Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 基本路由,这些路由不需要进入权限拦截
|
// 基本路由,这些路由不需要进入权限拦截
|
||||||
const needAuth = to.matched.some((r) => {
|
const needAuth = to.matched.some(r => {
|
||||||
return r.meta?.auth || r.meta?.permission;
|
return r.meta?.auth || r.meta?.permission;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -108,7 +112,7 @@ function setupAccessGuard(router: Router) {
|
||||||
// 如不需要,直接删除 query
|
// 如不需要,直接删除 query
|
||||||
query: to.fullPath === DEFAULT_HOME_PATH ? {} : { redirect: encodeURIComponent(to.fullPath) },
|
query: to.fullPath === DEFAULT_HOME_PATH ? {} : { redirect: encodeURIComponent(to.fullPath) },
|
||||||
// 携带当前跳转的页面,登录后重新跳转该页面
|
// 携带当前跳转的页面,登录后重新跳转该页面
|
||||||
replace: true
|
replace: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default router;
|
||||||
// // 多页控制 打开新的页面
|
// // 多页控制 打开新的页面
|
||||||
// const pageStore = usePageStore();
|
// const pageStore = usePageStore();
|
||||||
// // for (const item of to.matched) {
|
// // for (const item of to.matched) {
|
||||||
// // pageStore.cachePush(item.name);
|
// // pageStore.keepAlivePush(item.name);
|
||||||
// // }
|
// // }
|
||||||
// pageStore.open(to);
|
// pageStore.open(to);
|
||||||
// // 更改标题
|
// // 更改标题
|
||||||
|
|
|
@ -40,11 +40,11 @@ function transformOneResource(resource: any, parent: any) {
|
||||||
if (route.component == null) {
|
if (route.component == null) {
|
||||||
route.component = LayoutPass;
|
route.component = LayoutPass;
|
||||||
}
|
}
|
||||||
if (route?.meta?.cache !== true) {
|
if (route?.meta?.keepAlive !== true) {
|
||||||
if (route.meta == null) {
|
if (route.meta == null) {
|
||||||
route.meta = {};
|
route.meta = {};
|
||||||
}
|
}
|
||||||
route.meta.cache = false;
|
route.meta.keepAlive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resource.children) {
|
if (resource.children) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const certdResources = [
|
||||||
component: "/certd/pipeline/index.vue",
|
component: "/certd/pipeline/index.vue",
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:analytics-sharp",
|
icon: "ion:analytics-sharp",
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ export const certdResources = [
|
||||||
component: "/certd/history/index.vue",
|
component: "/certd/history/index.vue",
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:timer-outline",
|
icon: "ion:timer-outline",
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,7 @@ export const certdResources = [
|
||||||
icon: "ion:shield-checkmark-outline",
|
icon: "ion:shield-checkmark-outline",
|
||||||
auth: true,
|
auth: true,
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -61,6 +62,7 @@ export const certdResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:videocam-outline",
|
icon: "ion:videocam-outline",
|
||||||
auth: true,
|
auth: true,
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -71,7 +73,7 @@ export const certdResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:settings-outline",
|
icon: "ion:settings-outline",
|
||||||
auth: true,
|
auth: true,
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -82,7 +84,7 @@ export const certdResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:disc-outline",
|
icon: "ion:disc-outline",
|
||||||
auth: true,
|
auth: true,
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -114,7 +116,7 @@ export const certdResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "hugeicons:api",
|
icon: "hugeicons:api",
|
||||||
auth: true,
|
auth: true,
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -125,7 +127,7 @@ export const certdResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:megaphone-outline",
|
icon: "ion:megaphone-outline",
|
||||||
auth: true,
|
auth: true,
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ export const sysResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:earth-outline",
|
icon: "ion:earth-outline",
|
||||||
permission: "sys:settings:view",
|
permission: "sys:settings:view",
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ export const sysResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:extension-puzzle-outline",
|
icon: "ion:extension-puzzle-outline",
|
||||||
permission: "sys:settings:view",
|
permission: "sys:settings:view",
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ export const sysResources = [
|
||||||
isMenu: false,
|
isMenu: false,
|
||||||
icon: "ion:extension-puzzle",
|
icon: "ion:extension-puzzle",
|
||||||
permission: "sys:settings:view",
|
permission: "sys:settings:view",
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ export const sysResources = [
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:golf-outline",
|
icon: "ion:golf-outline",
|
||||||
permission: "sys:settings:view",
|
permission: "sys:settings:view",
|
||||||
cache: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue