Skip to content

Commit

Permalink
feat: 优化缓存二级路由方式 (#6944)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 authored Nov 4, 2024
1 parent eab475a commit b31ed9b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
16 changes: 14 additions & 2 deletions frontend/src/components/complex-table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const props = defineProps({
type: Number,
default: 0,
},
height: {
type: Number,
default: 0,
},
});
const emit = defineEmits(['search', 'update:selects', 'update:paginationConfig']);
const globalStore = GlobalStore();
Expand Down Expand Up @@ -105,11 +109,19 @@ onMounted(() => {
if (props.heightDiff) {
heightDiff = props.heightDiff;
}
if (props.height) {
tableHeight.value = props.height;
} else {
tableHeight.value = window.innerHeight - heightDiff;
}
tableHeight.value = window.innerHeight - heightDiff;
window.onresize = () => {
return (() => {
tableHeight.value = window.innerHeight - heightDiff;
if (props.height) {
tableHeight.value = props.height;
} else {
tableHeight.value = window.innerHeight - heightDiff;
}
})();
};
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/layout-content/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<div class="content-container__main" v-if="slots.main">
<el-card>
<div class="content-container__title" v-if="title">
<div class="content-container__title">
<slot name="title">
<div v-if="showBack">
<div class="flex justify-between">
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/routers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ router.beforeEach((to, from, next) => {

router.afterEach((to) => {
if (to.meta.activeMenu && !isRedirecting) {
localStorage.setItem('cachedRoute' + to.meta.activeMenu, to.path);
let notMathParam = true;
if (to.matched.some((record) => record.path.includes(':'))) {
notMathParam = false;
}
if (notMathParam) {
localStorage.setItem('cachedRoute' + to.meta.activeMenu, to.path);
}
}

isRedirecting = false;
NProgress.done();
});
Expand Down
1 change: 1 addition & 0 deletions frontend/src/routers/modules/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const webSiteRouter = {
component: () => import('@/views/website/runtime/php/index.vue'),
meta: {
title: 'menu.runtime',
activeMenu: '/websites/runtimes/php',
requiresAuth: false,
},
},
Expand Down

0 comments on commit b31ed9b

Please sign in to comment.