feat(projects): 菜单字典适配 i18n

This commit is contained in:
xlsea
2025-06-11 20:36:53 +08:00
parent d141ed5bef
commit 39dd9acca9
8 changed files with 52 additions and 10 deletions

View File

@ -1,11 +1,17 @@
import { ref } from 'vue';
import { defineStore } from 'pinia';
import { $t } from '@/locales';
export const useDictStore = defineStore('dict', () => {
const dictData = ref<{ [key: string]: Api.System.DictData[] }>({});
const getDict = (key: string) => {
return dictData.value[key];
return dictData.value[key]?.map(item => ({
...item,
dictLabel: item.dictLabel?.startsWith(`dict.${item.dictType}.`)
? $t(item.dictLabel as App.I18n.I18nKey)
: item.dictLabel
}));
};
const setDict = (key: string, dict: Api.System.DictData[]) => {

View File

@ -103,6 +103,9 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
// eslint-disable-next-line complexity
function parseRouter(route: ElegantConstRoute, parent?: ElegantConstRoute) {
route.meta = route.meta ? route.meta : { title: route.name };
if (route.meta.title.startsWith('route.')) {
route.meta.i18nKey = route.meta.title as App.I18n.I18nKey;
}
const isLayout = route.component === 'Layout';
const isFramePage = route.component === 'FrameView';
const isParentLayout = route.component === 'ParentView';