Commit b410c9e7 authored by youjie's avatar youjie

no message

parent f1f10443
import enUS from './en-US' import enUS from './en-US'
import zhTW from './zh-TW' import zhTW from './zh-TW'
import zhSW from './zh-SW'
export default { export default {
'en-US': enUS, 'en-US': enUS,
'zh-TW': zhTW 'zh-TW': zhTW,
'zh-SW': zhSW,
} }
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
option-value="langLocale" option-value="langLocale"
option-label="langName" option-label="langName"
style="width:180px" style="width:180px"
@update:model-value="getLanguage"
> >
<template v-slot:selected> <template v-slot:selected>
{{$t("lanuage")}} {{$t("lanuage")}}
...@@ -119,12 +120,12 @@ ...@@ -119,12 +120,12 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, reactive } from 'vue' import { defineComponent, reactive, ref } from 'vue'
import useLgoinModule from '../../module/user/loginModule' import useLgoinModule from '../../module/user/loginModule'
import useMetaModule from '../../module/meta/metaModule' import useMetaModule from '../../module/meta/metaModule'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { getLangs } from "../../utils/tools"; import { getLangs } from "../../utils/tools";
import { SitLang } from '../../@types/index'; import { SitLang } from '../../@types';
import {ref } from 'vue'; import {ref } from 'vue';
export default defineComponent({ export default defineComponent({
setup() { setup() {
...@@ -143,8 +144,13 @@ export default defineComponent({ ...@@ -143,8 +144,13 @@ export default defineComponent({
if(data.langs && data.langs.length>0){ if(data.langs && data.langs.length>0){
data.currentLang = data.langs.find(x=> x.langLocale==locale.value) ?? {}; data.currentLang = data.langs.find(x=> x.langLocale==locale.value) ?? {};
} }
// 切换语言
const getLanguage = (val) => {
locale.value = val.langLocale;
}
return { userModel, usernameRef, passwordRef, userValidateRule, loginSubmit, dtNow, stateManager,...data} return { userModel, usernameRef, passwordRef, userValidateRule, loginSubmit, dtNow, stateManager,getLanguage,...data}
} }
}) })
</script> </script>
......
...@@ -36,7 +36,15 @@ export function getLangs() { ...@@ -36,7 +36,15 @@ export function getLangs() {
langLocale:"zh-TW", langLocale:"zh-TW",
langName:"中文繁体" langName:"中文繁体"
} }
const zhSw:SitLang={
langLocale:"zh-SW",
langName:"中文简体"
}
const enUs:SitLang={
langLocale:"en-US",
langName:"English"
}
let langs:SitLang[]=[] let langs:SitLang[]=[]
langs.push(zhTw); langs.push(zhTw,zhSw,enUs);
return langs return langs
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment