mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 菜单字典适配 i18n
This commit is contained in:
@ -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[]) => {
|
||||
|
@ -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';
|
||||
|
Reference in New Issue
Block a user