mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
perf: storage tags
This commit is contained in:
parent
6d3a8c5a88
commit
be3a8a6949
@ -17,6 +17,7 @@ import fullScreen from "/@/assets/svg/full_screen.svg";
|
|||||||
import exitScreen from "/@/assets/svg/exit_screen.svg";
|
import exitScreen from "/@/assets/svg/exit_screen.svg";
|
||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
import { useSettingStoreHook } from "/@/store/modules/settings";
|
import { useSettingStoreHook } from "/@/store/modules/settings";
|
||||||
|
import { useMultiTagsStore } from "/@/store/modules/multiTags";
|
||||||
|
|
||||||
import navbar from "./components/navbar.vue";
|
import navbar from "./components/navbar.vue";
|
||||||
import tag from "./components/tag/index.vue";
|
import tag from "./components/tag/index.vue";
|
||||||
@ -32,7 +33,10 @@ const instance = getCurrentInstance().appContext.app.config.globalProperties;
|
|||||||
// 清空缓存后从serverConfig.json读取默认配置并赋值到storage中
|
// 清空缓存后从serverConfig.json读取默认配置并赋值到storage中
|
||||||
const layout = computed(() => {
|
const layout = computed(() => {
|
||||||
// 路由
|
// 路由
|
||||||
if (!instance.$storage.tags || instance.$storage.tags.length === 0) {
|
if (
|
||||||
|
useMultiTagsStore().multiTagsCache &&
|
||||||
|
(!instance.$storage.tags || instance.$storage.tags.length === 0)
|
||||||
|
) {
|
||||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||||
instance.$storage.tags = routerArrays;
|
instance.$storage.tags = routerArrays;
|
||||||
}
|
}
|
||||||
|
@ -231,9 +231,10 @@ router.beforeEach((to, _from, next) => {
|
|||||||
// 刷新
|
// 刷新
|
||||||
if (usePermissionStoreHook().wholeRoutes.length === 0)
|
if (usePermissionStoreHook().wholeRoutes.length === 0)
|
||||||
initRouter(name.username).then((router: Router) => {
|
initRouter(name.username).then((router: Router) => {
|
||||||
useMultiTagsStoreHook().getMultiTagsCache
|
if (!useMultiTagsStoreHook().getMultiTagsCache) {
|
||||||
? router.push(to.path)
|
return router.push("/");
|
||||||
: router.push("/");
|
}
|
||||||
|
router.push(to.path);
|
||||||
// 刷新页面更新标签栏与页面路由匹配
|
// 刷新页面更新标签栏与页面路由匹配
|
||||||
const localRoutes = storageLocal.getItem("responsive-tags");
|
const localRoutes = storageLocal.getItem("responsive-tags");
|
||||||
const optionsRoutes = router.options?.routes;
|
const optionsRoutes = router.options?.routes;
|
||||||
|
@ -3,23 +3,8 @@ import { App } from "vue";
|
|||||||
import Storage from "responsive-storage";
|
import Storage from "responsive-storage";
|
||||||
|
|
||||||
export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
|
export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
|
||||||
app.use(Storage, {
|
const configObj = Object.assign(
|
||||||
// 默认显示首页tag
|
|
||||||
tags: {
|
|
||||||
type: Array,
|
|
||||||
default: Storage.getData(undefined, "tags") ?? [
|
|
||||||
{
|
{
|
||||||
path: "/welcome",
|
|
||||||
parentPath: "/",
|
|
||||||
meta: {
|
|
||||||
title: "message.hshome",
|
|
||||||
i18n: true,
|
|
||||||
icon: "HomeFilled",
|
|
||||||
showLink: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// 国际化 默认中文zh
|
// 国际化 默认中文zh
|
||||||
locale: {
|
locale: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -43,5 +28,28 @@ export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
|
|||||||
hideTabs: config.HideTabs ?? false
|
hideTabs: config.HideTabs ?? false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
config.MultiTagsCache
|
||||||
|
? {
|
||||||
|
// 默认显示首页tag
|
||||||
|
tags: {
|
||||||
|
type: Array,
|
||||||
|
default: Storage.getData(undefined, "tags") ?? [
|
||||||
|
{
|
||||||
|
path: "/welcome",
|
||||||
|
parentPath: "/",
|
||||||
|
meta: {
|
||||||
|
title: "message.hshome",
|
||||||
|
i18n: true,
|
||||||
|
icon: "HomeFilled",
|
||||||
|
showLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
);
|
||||||
|
|
||||||
|
app.use(Storage, configObj);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user