修改 ui 包结构.
This commit is contained in:
@@ -15,5 +15,7 @@ export interface AppState {
|
||||
device: string;
|
||||
tabBar: boolean;
|
||||
serverMenu: RouteRecordNormalized[];
|
||||
menuFetched: boolean;
|
||||
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
import type { RouteLocationNormalized } from 'vue-router';
|
||||
import { defineStore } from 'pinia';
|
||||
import { DEFAULT_TAB, DEFAULT_ROUTE_NAME, REDIRECT_ROUTE_NAME, } from '@/router/constants';
|
||||
import { DEFAULT_TAB, DEFAULT_ROUTE_NAME, BAN_TAB_LIST, routerToTag } from '@/router/constants';
|
||||
import { isString } from '@/utils/is';
|
||||
import { TabBarState, TagProps } from './types';
|
||||
|
||||
/**
|
||||
* router 转 tag
|
||||
*/
|
||||
const formatTag = (route: RouteLocationNormalized): TagProps => {
|
||||
const { name, meta, fullPath, query } = route;
|
||||
return {
|
||||
title: meta.locale || '',
|
||||
name: String(name),
|
||||
fullPath,
|
||||
query,
|
||||
ignoreCache: meta.ignoreCache,
|
||||
};
|
||||
};
|
||||
|
||||
// 不添加的 tab 集合
|
||||
const BAN_LIST = [REDIRECT_ROUTE_NAME];
|
||||
|
||||
const useTabBarStore = defineStore('tabBar', {
|
||||
state: (): TabBarState => ({
|
||||
cacheTabList: new Set([DEFAULT_ROUTE_NAME]),
|
||||
@@ -41,8 +24,8 @@ const useTabBarStore = defineStore('tabBar', {
|
||||
* 添加 tab
|
||||
*/
|
||||
updateTabList(route: RouteLocationNormalized) {
|
||||
if (BAN_LIST.includes(route.name as string)) return;
|
||||
this.tagList.push(formatTag(route));
|
||||
if (BAN_TAB_LIST.includes(route.name as string)) return;
|
||||
this.tagList.push(routerToTag(route));
|
||||
if (!route.meta.ignoreCache) {
|
||||
this.cacheTabList.add(route.name as string);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ export interface UserState {
|
||||
username?: string;
|
||||
nickname?: string;
|
||||
avatar?: string;
|
||||
permission?: string[];
|
||||
roles?: string[];
|
||||
permission?: string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user