useLocale.ts 439 B

123456789101112131415161718192021
  1. import type { LocaleType } from '/@/locales/types';
  2. import { appStore } from '/@/store/modules/app';
  3. export function useLocale() {
  4. /**
  5. *
  6. */
  7. function getLocale(): string {
  8. return appStore.getProjectConfig.locale;
  9. }
  10. /**
  11. *
  12. * @param locale
  13. */
  14. async function changeLocale(locale: LocaleType): Promise<void> {
  15. appStore.commitProjectConfigState({ locale: locale });
  16. }
  17. return { getLocale, changeLocale };
  18. }