feat(other): The menu supports jumping to external links and fixing some known problems

This commit is contained in:
vben
2024-05-21 21:45:48 +08:00
parent 399334ac57
commit c31d21be50
43 changed files with 505 additions and 243 deletions

View File

@@ -12,7 +12,12 @@ import {
MdiPinOff,
} from '@vben-core/iconify';
import { filterTree } from '@vben-core/toolkit';
import type {
RouteLocationNormalized,
RouteRecordNormalized,
} from 'vue-router';
import { $t } from '@vben/locales';
import { storeToRefs, useAccessStore, useTabsStore } from '@vben/stores';
import { computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
@@ -39,6 +44,9 @@ function useTabs() {
const affixTabs = filterTree(router.getRoutes(), (route) => {
return !!route.meta?.affixTab;
});
affixTabs.forEach((tab) => {
Object.assign(tab, wrapperTabLocale(tab));
});
tabsStore.setAffixTabs(affixTabs);
};
@@ -52,6 +60,18 @@ function useTabs() {
await tabsStore.closeTabByKey(key, router);
};
function wrapperTabLocale(
tab: RouteLocationNormalized | RouteRecordNormalized,
) {
return {
...tab,
meta: {
...tab.meta,
title: $t(tab.meta.title as string),
},
};
}
watch(
() => accessMenus.value,
() => {
@@ -63,7 +83,7 @@ function useTabs() {
watch(
() => route.path,
() => {
tabsStore.addTab(route);
tabsStore.addTab(wrapperTabLocale(route) as RouteLocationNormalized);
},
{ immediate: true },
);