Enhance audio page functionality: Added vuSensor state management and updated balance and vu sensitivity calculations. Adjusted slider ranges and improved real-time updates for audio settings. Localized system page labels for better user experience.
This commit is contained in:
@@ -14,6 +14,9 @@ import { useLocation } from "wouter";
|
||||
import { useEffect } from "react";
|
||||
import BottomNav from "@/components/BottomNav";
|
||||
import { navigateToSelect } from "./SelectPage";
|
||||
import localeZh from "@/locales/data-zh.json";
|
||||
import localeZhHK from "@/locales/data-zh-HK.json";
|
||||
import localeEn from "@/locales/data-en.json";
|
||||
|
||||
function IOSToggle({ checked, onChange }: { checked: boolean; onChange: (v: boolean) => void }) {
|
||||
return (
|
||||
@@ -61,12 +64,31 @@ function ListRow({ label, description, value, onClick, toggle, checked, onToggle
|
||||
);
|
||||
}
|
||||
|
||||
const SCREEN_LIGHT_OPTIONS = ["亮", "中等", "暗"];
|
||||
const KNOB_LIGHT_OPTIONS = ["关闭", "亮", "中等", "暗"];
|
||||
const SCREEN_OFF_OPTIONS = ["常亮", "30秒", "1分钟", "3分钟", "5分钟"];
|
||||
const SLEEP_OPTIONS = ["关闭", "1分钟", "5分钟", "10分钟"];
|
||||
const AUTO_HOME_OPTIONS = ["关闭", "20秒", "40秒", "60秒"];
|
||||
const LANG_OPTIONS = ["English", "繁體中文", "简体中文"];
|
||||
type LocaleSettings = {
|
||||
settings: {
|
||||
vu: string;
|
||||
screenBrightness: { label: string; options: Array<{ index: number; label: string }> };
|
||||
turnOffScreen: { label: string; options: Array<{ index: number; label: string }> };
|
||||
knobBrightness: { label: string; options: Array<{ index: number; label: string }> };
|
||||
buttonLight: { label: string; options: Array<{ index: number; label: string }> };
|
||||
language: { label: string; options: Array<{ index: number; label: string }> };
|
||||
Automatic: { label: string; options: Array<{ index: number; label: string }> };
|
||||
sleepTime?: { label: string; options: Array<{ index: number; label: string }> };
|
||||
sleep?: { label: string; options: Array<{ index: number; label: string }> };
|
||||
};
|
||||
};
|
||||
|
||||
const LOCALE_BY_LANG: Record<number, LocaleSettings> = {
|
||||
0: localeEn as LocaleSettings,
|
||||
1: localeZhHK as LocaleSettings,
|
||||
2: localeZh as LocaleSettings,
|
||||
};
|
||||
|
||||
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);
|
||||
return sorted.map((item) => item.label);
|
||||
}
|
||||
|
||||
export default function SystemPage() {
|
||||
const [, setLocation] = useLocation();
|
||||
@@ -87,6 +109,14 @@ export default function SystemPage() {
|
||||
const autoHomeIdx = ds?.autoHome ?? 1;
|
||||
const langIdx = ds?.language ?? 2;
|
||||
const knobBreathLightOn = (ds?.knob_breathlight ?? 1) === 0;
|
||||
const localeData = LOCALE_BY_LANG[langIdx] ?? localeZh;
|
||||
const settingsText = localeData.settings;
|
||||
const SCREEN_LIGHT_OPTIONS = optionLabels(settingsText.screenBrightness?.options, ["亮", "中等", "暗"]);
|
||||
const KNOB_LIGHT_OPTIONS = optionLabels(settingsText.knobBrightness?.options, ["关闭", "亮", "中等", "暗"]);
|
||||
const SCREEN_OFF_OPTIONS = optionLabels(settingsText.turnOffScreen?.options, ["常亮", "30秒", "1分钟", "3分钟", "5分钟"]);
|
||||
const SLEEP_OPTIONS = optionLabels(settingsText.sleepTime?.options ?? settingsText.sleep?.options, ["关闭", "1分钟", "5分钟", "10分钟"]);
|
||||
const AUTO_HOME_OPTIONS = optionLabels(settingsText.Automatic?.options, ["关闭", "20秒", "40秒", "60秒"]);
|
||||
const LANG_OPTIONS = optionLabels(settingsText.language?.options, ["English", "繁體中文", "简体中文"]);
|
||||
|
||||
const goSelect = (title: string, options: string[], selected: number, key: string) => {
|
||||
navigateToSelect(title, options, selected, "/system", key);
|
||||
@@ -99,7 +129,7 @@ export default function SystemPage() {
|
||||
<button onClick={() => setLocation("/")} className="mr-4 text-white/60 active:text-white transition-colors">
|
||||
<ChevronLeft size={24} />
|
||||
</button>
|
||||
<h1 className="flex-1 text-center text-[17px] font-semibold text-white">设置</h1>
|
||||
<h1 className="flex-1 text-center text-[17px] font-semibold text-white">{settingsText.vu}</h1>
|
||||
<div className="w-8" />
|
||||
</div>
|
||||
|
||||
@@ -107,16 +137,16 @@ export default function SystemPage() {
|
||||
{/* ── 显示 ── */}
|
||||
<SectionHeader title="显示" />
|
||||
<div className="ios-list-group">
|
||||
<ListRow label="屏幕亮度" description="调节屏幕的整体亮度"
|
||||
<ListRow label={settingsText.screenBrightness.label} description="调节屏幕的整体亮度"
|
||||
value={SCREEN_LIGHT_OPTIONS[screenLightIdx]}
|
||||
onClick={() => goSelect("屏幕亮度", SCREEN_LIGHT_OPTIONS, screenLightIdx, "screenLight")} />
|
||||
<ListRow label="自动锁屏" description="设备无操作后自动关闭屏幕的时间"
|
||||
onClick={() => goSelect(settingsText.screenBrightness.label, SCREEN_LIGHT_OPTIONS, screenLightIdx, "screenLight")} />
|
||||
<ListRow label={settingsText.turnOffScreen.label} description="设备无操作后自动关闭屏幕的时间"
|
||||
value={SCREEN_OFF_OPTIONS[screenOffIdx]}
|
||||
onClick={() => goSelect("自动锁屏", SCREEN_OFF_OPTIONS, screenOffIdx, "screenOff")} />
|
||||
<ListRow label="旋钮亮度" description="调节旋钮指示灯的亮度"
|
||||
onClick={() => goSelect(settingsText.turnOffScreen.label, SCREEN_OFF_OPTIONS, screenOffIdx, "screenOff")} />
|
||||
<ListRow label={settingsText.knobBrightness.label} description="调节旋钮指示灯的亮度"
|
||||
value={KNOB_LIGHT_OPTIONS[buttonLightIdx]}
|
||||
onClick={() => goSelect("旋钮亮度", KNOB_LIGHT_OPTIONS, buttonLightIdx, "buttonLight")} />
|
||||
<ListRow label="旋钮熄屏呼吸灯" description="锁屏后旋钮是否显示呼吸灯效果"
|
||||
onClick={() => goSelect(settingsText.knobBrightness.label, KNOB_LIGHT_OPTIONS, buttonLightIdx, "buttonLight")} />
|
||||
<ListRow label={settingsText.buttonLight.label} description="锁屏后旋钮是否显示呼吸灯效果"
|
||||
toggle checked={knobBreathLightOn}
|
||||
onToggle={(v) => updateSetting({ knob_breathlight: v ? 0 : 1 })} />
|
||||
</div>
|
||||
@@ -124,15 +154,15 @@ export default function SystemPage() {
|
||||
{/* ── 通用 ── */}
|
||||
<SectionHeader title="通用" />
|
||||
<div className="ios-list-group">
|
||||
<ListRow label="语言" description="设置系统显示语言"
|
||||
<ListRow label={settingsText.language.label} description="设置系统显示语言"
|
||||
value={LANG_OPTIONS[langIdx]}
|
||||
onClick={() => goSelect("选择语言", LANG_OPTIONS, langIdx, "language")} />
|
||||
<ListRow label="自动返回首页" description="闲置一段时间后自动回到主界面"
|
||||
onClick={() => goSelect(settingsText.language.label, LANG_OPTIONS, langIdx, "language")} />
|
||||
<ListRow label={settingsText.Automatic.label} description="闲置一段时间后自动回到主界面"
|
||||
value={AUTO_HOME_OPTIONS[autoHomeIdx]}
|
||||
onClick={() => goSelect("自动返回首页", AUTO_HOME_OPTIONS, autoHomeIdx, "autoHome")} />
|
||||
<ListRow label="休眠" description="设置设备进入低功耗模式的时间"
|
||||
onClick={() => goSelect(settingsText.Automatic.label, AUTO_HOME_OPTIONS, autoHomeIdx, "autoHome")} />
|
||||
<ListRow label={settingsText.sleepTime?.label ?? settingsText.sleep?.label ?? "休眠"} description="设置设备进入低功耗模式的时间"
|
||||
value={SLEEP_OPTIONS[sleepIdx]}
|
||||
onClick={() => goSelect("休眠时间", SLEEP_OPTIONS, sleepIdx, "sleep")} />
|
||||
onClick={() => goSelect(settingsText.sleepTime?.label ?? settingsText.sleep?.label ?? "休眠", SLEEP_OPTIONS, sleepIdx, "sleep")} />
|
||||
</div>
|
||||
|
||||
{/* ── 关于 ── */}
|
||||
|
||||
Reference in New Issue
Block a user