locale中英文
This commit is contained in:
1 parent
57fda355e6
commit
1e125254eb
3 files changed
+89
-6
No files matched your search
@@ -19,6 +19,25 @@
|
||||
<a-form-item>
|
||||
<a-button type="primary" html-type="submit" size="large" block> 登录 </a-button>
|
||||
</a-form-item>
|
||||
<div class="culture-switch">
|
||||
<a-button
|
||||
type="text"
|
||||
size="large"
|
||||
:class="{ 'culture-active': currentLocale === 'zh-cn' }"
|
||||
@click="changeLocale('zh-cn')"
|
||||
>
|
||||
{{ t('CulturePolicy.zh-cn') }}
|
||||
</a-button>
|
||||
<a-divider type="vertical" />
|
||||
<a-button
|
||||
type="text"
|
||||
size="large"
|
||||
:class="{ 'culture-active': currentLocale === 'en' }"
|
||||
@click="changeLocale('en')"
|
||||
>
|
||||
{{ t('CulturePolicy.en') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<!-- Biometric (WebAuthn) — only visible if the user has a stored
|
||||
credential on this device. The credential id is read from
|
||||
localStorage (key: biometric_<username>). -->
|
||||
@@ -47,6 +66,8 @@
|
||||
style="width: 80px; margin-top: 16px; margin-left: 24px">
|
||||
首页
|
||||
</a-button>
|
||||
|
||||
|
||||
</a-form>
|
||||
</div>
|
||||
</a-spin>
|
||||
@@ -73,6 +94,7 @@ const { t } = i18n.global;
|
||||
//const props = defineProps(['id'])
|
||||
|
||||
const router = useRouter();
|
||||
const userLoginProfile = useLoginProfileStore();
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
@@ -82,6 +104,16 @@ const state = reactive({
|
||||
},
|
||||
});
|
||||
|
||||
// 当前语言(默认取本地存储,其次中文)
|
||||
const currentLocale = ref<string>(userLoginProfile.getLocale() ?? "zh-cn");
|
||||
|
||||
// 切换中英文并持久化
|
||||
const changeLocale = (locale: string) => {
|
||||
currentLocale.value = locale;
|
||||
userLoginProfile.setLocale(locale);
|
||||
(i18n.global.locale as any).value = locale;
|
||||
};
|
||||
|
||||
const onRegister = () => {
|
||||
router.push({ path: "/register" });
|
||||
};
|
||||
@@ -101,7 +133,7 @@ const handleSubmit = async () => {
|
||||
UserMobile: state.LoginData.UserMobile,
|
||||
UserPassword: "",
|
||||
Guid: uuidv4(),
|
||||
Culture: "zh-cn",
|
||||
Culture: currentLocale.value,
|
||||
};
|
||||
|
||||
let key = await authService.GetRsaPublicKey();
|
||||
@@ -114,8 +146,6 @@ const handleSubmit = async () => {
|
||||
|
||||
let profile: LoginProfile = await authService.Login(data);
|
||||
|
||||
const userLoginProfile = useLoginProfileStore();
|
||||
|
||||
userLoginProfile.updateLoginProfile(profile);
|
||||
|
||||
router.push({ path: "/dashboard" });
|
||||
@@ -248,8 +278,6 @@ const onBiometricLogin = async () => {
|
||||
|
||||
// 4. Persist the JWT locally and navigate. installProfile is the
|
||||
// same call LoginView makes after a successful password login.
|
||||
const userLoginProfile = useLoginProfileStore();
|
||||
|
||||
userLoginProfile.updateLoginProfile(profile);
|
||||
|
||||
router.push({ path: "/dashboard" });
|
||||
@@ -354,5 +382,21 @@ const onBiometricLogin = async () => {
|
||||
padding-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.culture-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 16px;
|
||||
|
||||
.ant-btn-text {
|
||||
color: #08c;
|
||||
}
|
||||
|
||||
.culture-active {
|
||||
font-weight: 600;
|
||||
color: #1677ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user