feat(viewer): album page with locale fallback and timezone display

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-18 09:52:22 +08:00
parent 04b5641901
commit adc45b1563
15 changed files with 879 additions and 61 deletions
+11 -2
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { setLocale, type ViewerLocale } from '../i18n';
import { LOCALE_STORAGE_KEY, type ViewerLocale } from '../i18n';
const { locale, t } = useI18n();
@@ -9,8 +9,17 @@ const nextLocale = computed<ViewerLocale>(() => (locale.value === 'zh-CN' ? 'en'
// 按钮始终显示目标语言的自称,便于不识当前语言的用户发现
const nextLabel = computed(() => (nextLocale.value === 'zh-CN' ? '中文' : 'English'));
// 直接写当前 composer(可写 locale):与注入的 i18n 实例解耦——组件测试可挂载
// 独立实例而不被运行时单例牵制。持久化随切换写入,写失败不阻断。
// 注意先取 next 再赋值:赋值后 nextLocale 已重算为目标的对侧。
function switchLocale(): void {
setLocale(nextLocale.value);
const next = nextLocale.value;
locale.value = next;
try {
localStorage.setItem(LOCALE_STORAGE_KEY, next);
} catch {
// 忽略持久化失败
}
}
</script>