fix tag style
This commit is contained in:
@@ -59,11 +59,14 @@
|
||||
import PageTransition from "@/components/PageTransition.vue";
|
||||
import {useNavBarStore} from "@/store/navBarStore";
|
||||
import {useTabBarStore} from "@/store/tabBarStore";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { useUserStore } from "timi-web";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const navBarStore = useNavBarStore();
|
||||
const tabBarStore = useTabBarStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
// ---------- 导航高度 ----------
|
||||
|
||||
@@ -113,17 +116,32 @@ const navBarHeight = computed(() => {
|
||||
|
||||
// ---------- Tab 切换 ----------
|
||||
|
||||
type TabItem = {
|
||||
value: string;
|
||||
icon: string;
|
||||
text: string;
|
||||
permission?: string;
|
||||
};
|
||||
|
||||
const tabVal = ref(route.path);
|
||||
const list = [
|
||||
const tabList: TabItem[] = [
|
||||
{ value: "/customers", icon: "usergroup", text: "客户" },
|
||||
{ value: "/store", icon: "shop-3", text: "门店" },
|
||||
{ value: "/store", icon: "shop-3", text: "门店", permission: permissionCodes.stat.read },
|
||||
{ value: "/management", icon: "setting-1", text: "管理" }
|
||||
];
|
||||
const list = computed(() => tabList.filter(item => !item.permission || userStore.hasPermissions(item.permission)));
|
||||
|
||||
watch(() => route.path, (newPath: string) => {
|
||||
tabVal.value = resolveTabValue(newPath);
|
||||
}, { immediate: true });
|
||||
|
||||
watch(list, () => {
|
||||
const visiblePath = resolveVisibleTabValue(route.path);
|
||||
if (tabVal.value !== visiblePath) {
|
||||
tabVal.value = visiblePath;
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
function resolveTabValue(path: string): string {
|
||||
if (path.startsWith("/customers")) {
|
||||
return "/customers";
|
||||
@@ -140,6 +158,15 @@ function resolveTabValue(path: string): string {
|
||||
return path;
|
||||
}
|
||||
|
||||
function resolveVisibleTabValue(path: string): string {
|
||||
const tabPath = resolveTabValue(path);
|
||||
if (list.value.some(item => item.value === tabPath)) {
|
||||
return tabPath;
|
||||
}
|
||||
|
||||
return list.value[0]?.value || tabPath;
|
||||
}
|
||||
|
||||
function onChangeTab(value: string | number): void {
|
||||
const path = String(value);
|
||||
if (resolveTabValue(route.path) === path) {
|
||||
|
||||
Reference in New Issue
Block a user