feat: keepAlive优化
This commit is contained in:
@@ -63,7 +63,14 @@ export function formatTwoStageRoutes(arr: any) {
|
||||
const cacheList: Array<string> = [];
|
||||
arr.forEach((v: any) => {
|
||||
if (v.path === '/') {
|
||||
newArr.push({ component: v.component, name: v.name, path: v.path, redirect: v.redirect, meta: v.meta, children: [] });
|
||||
newArr.push({
|
||||
component: v.component,
|
||||
name: v.name,
|
||||
path: v.path,
|
||||
redirect: v.redirect,
|
||||
meta: v.meta,
|
||||
children: []
|
||||
});
|
||||
} else {
|
||||
// 判断是否是动态路由(xx/:id/:name),用于 tagsView 等中使用
|
||||
// 修复:https://gitee.com/lyt-top/vue-next-admin/issues/I3YX6G
|
||||
@@ -74,7 +81,7 @@ export function formatTwoStageRoutes(arr: any) {
|
||||
newArr[0].children.push({...v});
|
||||
// 存 name 值,keep-alive 中 include 使用,实现路由的缓存
|
||||
// 路径:/@/layout/routerView/parent.vue
|
||||
if (newArr[0].meta.isKeepAlive && v.meta.isKeepAlive) {
|
||||
if (newArr[0].meta.isKeepAlive && v.meta.isKeepAlive && v.component_name != "") {
|
||||
cacheList.push(v.name);
|
||||
const stores = useKeepALiveNames(pinia);
|
||||
stores.setCacheKeepAlive(cacheList);
|
||||
|
||||
@@ -12,7 +12,7 @@ export const handleMenu = (menuData: Array<any>) => {
|
||||
title: item.title,
|
||||
isLink: item.is_link,
|
||||
isHide: !item.visible,
|
||||
isKeepAlive: true,
|
||||
isKeepAlive: item.cache,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin'],
|
||||
|
||||
@@ -71,6 +71,12 @@
|
||||
<el-radio :label="false">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="缓存">
|
||||
<el-radio-group v-model="form.cache">
|
||||
<el-radio :label="true">启用</el-radio>
|
||||
<el-radio :label="false">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="图标" prop="icon">
|
||||
<IconSelector clearable v-model="form.icon"/>
|
||||
</el-form-item>
|
||||
@@ -227,11 +233,12 @@ let form: Form<any> = reactive({
|
||||
component: '',
|
||||
web_path: '',
|
||||
sort: '',
|
||||
status: '',
|
||||
status: true,
|
||||
is_catalog: false,
|
||||
permission: '',
|
||||
icon: '',
|
||||
visible: ''
|
||||
visible: true,
|
||||
cache: true,
|
||||
});
|
||||
|
||||
let menuPermissonList = ref([]);
|
||||
|
||||
Reference in New Issue
Block a user