fix: 完善平台国际化覆盖
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
import { createDiscreteApi } from 'naive-ui';
|
||||
import { computed } from 'vue';
|
||||
import { createDiscreteApi, darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from 'naive-ui';
|
||||
import { i18n } from '@/locales';
|
||||
import { themeOverrides } from '@/theme';
|
||||
import { useTheme } from '@/composables/useTheme';
|
||||
|
||||
// 全局可用的消息/对话框/加载条(含在 setup 之外,如 axios 拦截器)
|
||||
const { isDark } = useTheme();
|
||||
const { message, dialog, loadingBar } = createDiscreteApi(['message', 'dialog', 'loadingBar'], {
|
||||
configProviderProps: { themeOverrides },
|
||||
configProviderProps: computed(() => {
|
||||
const isEnglish = i18n.global.locale.value === 'en-US';
|
||||
return {
|
||||
theme: isDark.value ? darkTheme : null,
|
||||
themeOverrides,
|
||||
locale: isEnglish ? enUS : zhCN,
|
||||
dateLocale: isEnglish ? dateEnUS : dateZhCN,
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
export { message, dialog, loadingBar };
|
||||
|
||||
Reference in New Issue
Block a user