feat: localize authentication and account shell

This commit is contained in:
biss committed 2026-10-30 21:26:10 +08:00
1 parent c7499f05e3
commit 6727f72121
20 files changed
+518 -204

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { currentLocale, setLocale, supportedLocales, type AppLocale } from '../i18n'
const { t } = useI18n()
const options = computed(() => supportedLocales.map((value) => ({
value,
label: value === 'zh-CN' ? t('locale.zhCN') : t('locale.enUS'),
})))
</script>
<template>
<el-select
:model-value="currentLocale"
class="locale-switcher"
size="small"
:aria-label="t('locale.label')"
@update:model-value="(value: AppLocale) => setLocale(value)"
>
<el-option
v-for="option in options"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
</template>
<style scoped>
.locale-switcher { width: 126px; }
</style>
+10 -8
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import http from '../api/http'
interface CaptchaChoice {
@@ -16,6 +17,7 @@ interface CaptchaChallenge {
}
const emit = defineEmits<{ change: [captchaId: string, captchaCode: string] }>()
const { t } = useI18n()
const captcha = ref<CaptchaChallenge | null>(null)
const code = ref('')
const loading = ref(false)
@@ -40,20 +42,20 @@ defineExpose({ refresh })
</script>
<template>
<section class="login-captcha" aria-label="验证码">
<section class="login-captcha" :aria-label="t('auth.captcha.label')">
<div class="captcha-heading">
<span>验证码</span>
<button type="button" :disabled="loading" @click="refresh">换一张</button>
<span>{{ t('auth.captcha.label') }}</span>
<button type="button" :disabled="loading" @click="refresh">{{ t('auth.captcha.refresh') }}</button>
</div>
<div v-loading="loading" class="captcha-input">
<template v-if="captcha?.type === 'TextImage' || captcha?.type === 'MathImage'">
<img v-if="captcha.imageData" :src="captcha.imageData" alt="验证码图片,点击可更换" @click="refresh" />
<el-input v-model="code" maxlength="8" autocomplete="off" placeholder="输入图中字符" />
<img v-if="captcha.imageData" :src="captcha.imageData" :alt="t('auth.captcha.imageAlt')" @click="refresh" />
<el-input v-model="code" maxlength="8" autocomplete="off" :placeholder="t('auth.captcha.placeholder')" />
</template>
<div v-else-if="captcha" class="captcha-question">
<p>{{ captcha.prompt }}</p>
<img v-if="captcha.imageData" :src="captcha.imageData" alt="验证码图片,点击可更换" @click="refresh" />
<div v-if="captcha.type === 'Selection'" class="captcha-choices" role="group" aria-label="验证码选项">
<img v-if="captcha.imageData" :src="captcha.imageData" :alt="t('auth.captcha.imageAlt')" @click="refresh" />
<div v-if="captcha.type === 'Selection'" class="captcha-choices" role="group" :aria-label="t('auth.captcha.choices')">
<el-button
v-for="choice in captcha.choices ?? []"
:key="choice.id"
@@ -64,7 +66,7 @@ defineExpose({ refresh })
</el-button>
</div>
<el-button v-else type="primary" :plain="code !== 'CONFIRM'" @click="choose('CONFIRM')">
我确认是本人操作
{{ t('auth.captcha.confirm') }}
</el-button>
</div>
</div>
+5 -3
View File
@@ -2,10 +2,12 @@
import { onMounted, ref } from 'vue'
import http from '../api/http'
import { branding } from '../config/branding'
import { useI18n } from 'vue-i18n'
const currentYear = new Date().getFullYear()
const frontendVersion = __APP_VERSION__
const backendVersion = ref<string>()
const { t } = useI18n()
onMounted(async () => {
try {
@@ -18,13 +20,13 @@ onMounted(async () => {
</script>
<template>
<footer class="site-footer" aria-label="网站版权信息">
<footer class="site-footer" :aria-label="t('footer.aria')">
<div class="site-footer-inner">
<p>© {{ currentYear }} {{ branding.shortName }} · 版权所有</p>
<p>{{ t('footer.copyright', { year: currentYear, name: branding.shortName }) }}</p>
<div class="footer-meta">
<span class="footer-note">{{ branding.tagline }}</span>
<span class="footer-versions" aria-live="polite">
前端 v{{ frontendVersion }} · 后端 v{{ backendVersion ?? '—' }}
{{ t('footer.versions', { frontend: frontendVersion, backend: backendVersion ?? '—' }) }}
</span>
</div>
</div>
Loaded 3 of 20 files, more files were not shown because too many files have changed in this diff. Show more