mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix: 修复menu问题
This commit is contained in:
parent
6b48e89e90
commit
c31196ab76
@ -6,7 +6,7 @@ export const transTitle = (name) => {
|
|||||||
}
|
}
|
||||||
const sharedLocale = plugin.getShared('locale');
|
const sharedLocale = plugin.getShared('locale');
|
||||||
if (sharedLocale) {
|
if (sharedLocale) {
|
||||||
const { t } = sharedLocale.useI18n();
|
const { t } = sharedLocale.locale;
|
||||||
return t(name.slice(1));
|
return t(name.slice(1));
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<f-menu
|
<f-menu
|
||||||
|
v-model:expandedKeys="expandedKeysRef"
|
||||||
:modelValue="activePath"
|
:modelValue="activePath"
|
||||||
:expandedKeys="expandedKeysRef"
|
|
||||||
:inverted="inverted"
|
:inverted="inverted"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
:options="transformedMenus"
|
:options="transformedMenus"
|
||||||
@ -20,12 +20,12 @@ import { transform as transformByLocale } from '../helpers/pluginLocale';
|
|||||||
import { flatNodes } from '../helpers/utils';
|
import { flatNodes } from '../helpers/utils';
|
||||||
import MenuIcon from './MenuIcon.vue';
|
import MenuIcon from './MenuIcon.vue';
|
||||||
|
|
||||||
const transform = (menus) =>
|
const transform = (menus, level = 1) =>
|
||||||
menus.map((menu) => {
|
menus.map((menu, index) => {
|
||||||
const copy = {
|
const copy = {
|
||||||
...menu,
|
...menu,
|
||||||
label: menu.title,
|
label: menu.title,
|
||||||
value: menu.path || Date.now(),
|
value: menu.path || `${level}_${index}`,
|
||||||
};
|
};
|
||||||
if (menu.icon) {
|
if (menu.icon) {
|
||||||
copy.icon = () =>
|
copy.icon = () =>
|
||||||
@ -34,7 +34,7 @@ const transform = (menus) =>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (menu.children) {
|
if (menu.children) {
|
||||||
copy.children = transform(menu.children);
|
copy.children = transform(menu.children, level + 1);
|
||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
});
|
});
|
||||||
|
@ -85,19 +85,19 @@ const getAllLocales = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const install = (app) => {
|
const install = (app) => {
|
||||||
const runtimeConfig = plugin.applyPlugins({
|
|
||||||
key: "locale",
|
|
||||||
type: ApplyPluginsType.modify,
|
|
||||||
initialValue: {},
|
|
||||||
});
|
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const t = (key) => {
|
||||||
|
return i18n.global.t(key)
|
||||||
|
}
|
||||||
|
|
||||||
const locale = {
|
const locale = {
|
||||||
setLocale,
|
setLocale,
|
||||||
addLocale,
|
addLocale,
|
||||||
getAllLocales,
|
getAllLocales,
|
||||||
messages,
|
messages,
|
||||||
|
t
|
||||||
};
|
};
|
||||||
|
|
||||||
export { useI18n, locale, install };
|
export { useI18n, locale, install };
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { plugin } from '@@/core/coreExports';
|
import { plugin } from '@@/core/coreExports';
|
||||||
// eslint-disable-next-line import/extensions
|
// eslint-disable-next-line import/extensions
|
||||||
import { useI18n, install } from './core';
|
import { useI18n, locale, install } from './core';
|
||||||
import SelectLang from './views/SelectLang.vue';
|
import SelectLang from './views/SelectLang.vue';
|
||||||
|
|
||||||
// 共享出去
|
// 共享出去
|
||||||
plugin.share('locale', { useI18n, SelectLang });
|
plugin.share('locale', { useI18n, locale, SelectLang });
|
||||||
|
|
||||||
export function onAppCreated({ app }) {
|
export function onAppCreated({ app }) {
|
||||||
install(app);
|
install(app);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user