当设备未连接时,各页面默认显示英文语言的文本,并在标题追加 (Disconnect)

This commit is contained in:
eafonyang
2026-07-01 11:23:12 +08:00
parent 1e5e6f5548
commit ac9bac4d18
21 changed files with 113 additions and 460 deletions
+6 -11
View File
@@ -19,9 +19,9 @@ import {
parseFirmwareVersion,
readBootSoundFromState,
} from "@/lib/luxsinApi";
import localeZh from "@/locales/data-zh.json";
import localeZhHK from "@/locales/data-zh-HK.json";
import localeEn from "@/locales/data-en.json";
import { resolveLocalePack } from "@/locales/resolveLocale";
import { usePageTitleWithConnection } from "@/hooks/usePageTitleWithConnection";
function CyanSlider({ value, min, max, step = 1, onChange, onRelease }: {
value: number;
@@ -123,12 +123,6 @@ type LocaleDac = {
home?: { audioSet?: string };
};
const LOCALE_BY_LANG: Record<number, LocaleDac> = {
0: localeEn as LocaleDac,
1: localeZhHK as LocaleDac,
2: localeZh as LocaleDac,
};
function optionLabels(items: Array<{ index: number; label: string }> | undefined, fallback: string[]) {
if (!items || items.length === 0) return fallback;
const sorted = [...items].sort((a, b) => a.index - b.index);
@@ -182,8 +176,7 @@ export default function AudioPage() {
const { deviceState, updateSetting, refresh, isConnected, api } = useDevice();
const ds = deviceState;
const vuSensor = (ds as ({ vuSensor?: number } | null))?.vuSensor;
const langIdx = ds?.language ?? 2;
const localeData = LOCALE_BY_LANG[langIdx] ?? (localeZh as LocaleDac);
const localeData = resolveLocalePack(ds?.language) as LocaleDac;
const dacText = localeData.dac ?? {};
// balance 从接口获取的是乘以 10 后的值,需要除以 10 显示(例如:-130 → -13.0
@@ -241,6 +234,8 @@ export default function AudioPage() {
const DAC_ARC_OPTIONS = optionLabels(dacText.dacArc?.options, ["ARC", "EARC"]);
const XLR_OPTIONS = optionLabels(dacText.xlr?.options, ["正常", "反转"]);
const pageTitle = usePageTitleWithConnection(localeData.home?.audioSet ?? "Audio");
const goSelect = (title: string, options: string[], selected: number, key: string) => {
navigateToSelect(title, options, selected, "/audio", key);
setLocation("/select");
@@ -253,7 +248,7 @@ export default function AudioPage() {
<ChevronLeft size={24} />
</button>
<h1 className="flex-1 text-center text-[17px] font-semibold text-white">
{localeData.home?.audioSet ?? "音频设置"}
{pageTitle}
</h1>
<div className="w-8" />
</div>