mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-06-06 16:37:51 +08:00
38 lines
765 B
TypeScript
38 lines
765 B
TypeScript
import { useNav } from "./useNav";
|
|
import { useI18n } from "vue-i18n";
|
|
import { useRoute } from "vue-router";
|
|
import { watch, type Ref } from "vue";
|
|
|
|
export function useTranslationLang(ref?: Ref) {
|
|
const { $storage, changeTitle, handleResize } = useNav();
|
|
const { locale, t } = useI18n();
|
|
const route = useRoute();
|
|
|
|
function translationCh() {
|
|
$storage.locale = { locale: "zh" };
|
|
locale.value = "zh";
|
|
ref && handleResize(ref.value);
|
|
}
|
|
|
|
function translationEn() {
|
|
$storage.locale = { locale: "en" };
|
|
locale.value = "en";
|
|
ref && handleResize(ref.value);
|
|
}
|
|
|
|
watch(
|
|
() => locale.value,
|
|
() => {
|
|
changeTitle(route.meta);
|
|
}
|
|
);
|
|
|
|
return {
|
|
t,
|
|
route,
|
|
locale,
|
|
translationCh,
|
|
translationEn
|
|
};
|
|
}
|