perf: login

This commit is contained in:
lrl
2022-07-27 15:08:44 +08:00
parent d824c99489
commit 114d5427cc
7 changed files with 293 additions and 196 deletions

View File

@@ -0,0 +1,38 @@
import { useNav } from "./nav";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { watch, getCurrentInstance } from "vue";
export default function useTranslationLang() {
const { changeTitle, changeWangeditorLanguage } = useNav();
const { locale, t } = useI18n();
const route = useRoute();
const instance =
getCurrentInstance().appContext.config.globalProperties.$storage;
function translationCh() {
instance.locale = { locale: "zh" };
locale.value = "zh";
}
function translationEn() {
instance.locale = { locale: "en" };
locale.value = "en";
}
watch(
() => locale.value,
() => {
changeTitle(route.meta);
locale.value === "en"
? changeWangeditorLanguage(locale.value)
: changeWangeditorLanguage("zh-CN");
}
);
return {
t,
locale,
translationCh,
translationEn
};
}