| | |
| | | import moment from 'moment'; |
| | | |
| | | import { i18n } from './setupI18n'; |
| | | import { localeStore } from '/@/store/modules/locale'; |
| | | import { useLocaleStoreWithOut } from '/@/store/modules/locale'; |
| | | import { unref, computed } from 'vue'; |
| | | |
| | | interface LangModule { |
| | |
| | | const loadLocalePool: LocaleType[] = []; |
| | | |
| | | function setI18nLanguage(locale: LocaleType) { |
| | | const localeStore = useLocaleStoreWithOut(); |
| | | |
| | | if (i18n.mode === 'legacy') { |
| | | i18n.global.locale = locale; |
| | | } else { |
| | |
| | | } |
| | | |
| | | export function useLocale() { |
| | | const localeStore = useLocaleStoreWithOut(); |
| | | const getLocale = computed(() => localeStore.getLocale); |
| | | const getShowLocalePicker = computed(() => localeStore.getShowPicker); |
| | | |
| | |
| | | async function changeLocale(locale: LocaleType) { |
| | | const globalI18n = i18n.global; |
| | | const currentLocale = unref(globalI18n.locale); |
| | | if (currentLocale === locale) return locale; |
| | | if (currentLocale === locale) { |
| | | return locale; |
| | | } |
| | | |
| | | if (loadLocalePool.includes(locale)) { |
| | | setI18nLanguage(locale); |