Refactor BottomNav and CommunityPage to enhance community forum integration; update navigation logic for mobile and desktop views. Add new localized strings for community page and system settings, including device information and user prompts.

This commit is contained in:
yangy
2026-05-13 17:42:26 +08:00
parent 5285b886ea
commit b3d3f0edcb
9 changed files with 372 additions and 92 deletions
+39 -15
View File
@@ -67,6 +67,7 @@ function ListRow({ label, description, value, onClick, toggle, checked, onToggle
type LocaleSettings = {
settings: {
vu: string;
vuMeter?: 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 }> };
@@ -75,6 +76,22 @@ type LocaleSettings = {
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 }> };
systemPage: {
sectionDisplay: string;
sectionGeneral: string;
sectionAbout: string;
screenBrightnessDesc: string;
turnOffScreenDesc: string;
knobBrightnessDesc: string;
buttonLightDesc: string;
languageDesc: string;
automaticDesc: string;
sleepDesc: string;
deviceName: string;
firmwareVersion: string;
macAddress: string;
disconnect: string;
};
};
};
@@ -111,6 +128,7 @@ export default function SystemPage() {
const knobBreathLightOn = (ds?.knob_breathlight ?? 1) === 0;
const localeData = LOCALE_BY_LANG[langIdx] ?? localeZh;
const settingsText = localeData.settings;
const ui = settingsText.systemPage;
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分钟"]);
@@ -118,6 +136,12 @@ export default function SystemPage() {
const AUTO_HOME_OPTIONS = optionLabels(settingsText.Automatic?.options, ["关闭", "20秒", "40秒", "60秒"]);
const LANG_OPTIONS = optionLabels(settingsText.language?.options, ["English", "繁體中文", "简体中文"]);
const sleepRowLabel =
settingsText.sleepTime?.label ??
settingsText.sleep?.label ??
(localeEn as LocaleSettings).settings.sleep?.label ??
"Sleep";
const goSelect = (title: string, options: string[], selected: number, key: string) => {
navigateToSelect(title, options, selected, "/system", key);
setLocation("/select");
@@ -135,49 +159,49 @@ export default function SystemPage() {
<div className="px-4 pb-32">
{/* ── 显示 ── */}
<SectionHeader title="显示" />
<SectionHeader title={ui.sectionDisplay} />
<div className="ios-list-group">
<ListRow label={settingsText.screenBrightness.label} description="调节屏幕的整体亮度"
<ListRow label={settingsText.screenBrightness.label} description={ui.screenBrightnessDesc}
value={SCREEN_LIGHT_OPTIONS[screenLightIdx]}
onClick={() => goSelect(settingsText.screenBrightness.label, SCREEN_LIGHT_OPTIONS, screenLightIdx, "screenLight")} />
<ListRow label={settingsText.turnOffScreen.label} description="设备无操作后自动关闭屏幕的时间"
<ListRow label={settingsText.turnOffScreen.label} description={ui.turnOffScreenDesc}
value={SCREEN_OFF_OPTIONS[screenOffIdx]}
onClick={() => goSelect(settingsText.turnOffScreen.label, SCREEN_OFF_OPTIONS, screenOffIdx, "screenOff")} />
<ListRow label={settingsText.knobBrightness.label} description="调节旋钮指示灯的亮度"
<ListRow label={settingsText.knobBrightness.label} description={ui.knobBrightnessDesc}
value={KNOB_LIGHT_OPTIONS[buttonLightIdx]}
onClick={() => goSelect(settingsText.knobBrightness.label, KNOB_LIGHT_OPTIONS, buttonLightIdx, "buttonLight")} />
<ListRow label={settingsText.buttonLight.label} description="锁屏后旋钮是否显示呼吸灯效果"
<ListRow label={settingsText.buttonLight.label} description={ui.buttonLightDesc}
toggle checked={knobBreathLightOn}
onToggle={(v) => updateSetting({ knob_breathlight: v ? 0 : 1 })} />
</div>
{/* ── 通用 ── */}
<SectionHeader title="通用" />
<SectionHeader title={ui.sectionGeneral} />
<div className="ios-list-group">
<ListRow label={settingsText.language.label} description="设置系统显示语言"
<ListRow label={settingsText.language.label} description={ui.languageDesc}
value={LANG_OPTIONS[langIdx]}
onClick={() => goSelect(settingsText.language.label, LANG_OPTIONS, langIdx, "language")} />
<ListRow label={settingsText.Automatic.label} description="闲置一段时间后自动回到主界面"
<ListRow label={settingsText.Automatic.label} description={ui.automaticDesc}
value={AUTO_HOME_OPTIONS[autoHomeIdx]}
onClick={() => goSelect(settingsText.Automatic.label, AUTO_HOME_OPTIONS, autoHomeIdx, "autoHome")} />
<ListRow label={settingsText.sleepTime?.label ?? settingsText.sleep?.label ?? "休眠"} description="设置设备进入低功耗模式的时间"
<ListRow label={sleepRowLabel} description={ui.sleepDesc}
value={SLEEP_OPTIONS[sleepIdx]}
onClick={() => goSelect(settingsText.sleepTime?.label ?? settingsText.sleep?.label ?? "休眠", SLEEP_OPTIONS, sleepIdx, "sleep")} />
onClick={() => goSelect(sleepRowLabel, SLEEP_OPTIONS, sleepIdx, "sleep")} />
</div>
{/* ── 关于 ── */}
<SectionHeader title="关于" />
<SectionHeader title={ui.sectionAbout} />
<div className="ios-list-group">
<div className="ios-list-row">
<span className="flex-1 text-[16px] text-white"></span>
<span className="flex-1 text-[16px] text-white">{ui.deviceName}</span>
<span className="ios-row-value">{ds?.device ?? "Luxsin X9"}</span>
</div>
<div className="ios-list-row">
<span className="flex-1 text-[16px] text-white"></span>
<span className="flex-1 text-[16px] text-white">{ui.firmwareVersion}</span>
<span className="ios-row-value">{ds?.version ?? "—"}</span>
</div>
<div className="ios-list-row">
<span className="flex-1 text-[16px] text-white">MAC </span>
<span className="flex-1 text-[16px] text-white">{ui.macAddress}</span>
<span className="ios-row-value text-[12px]">{ds?.mac ?? "—"}</span>
</div>
</div>
@@ -188,7 +212,7 @@ export default function SystemPage() {
className="w-full py-4 rounded-[14px] text-[16px] font-medium transition-all duration-150 active:scale-[0.98]"
style={{ background: "rgba(239,68,68,0.1)", border: "1px solid rgba(239,68,68,0.2)", color: "#ef4444" }}
onClick={() => { disconnect(); setLocation("/"); }}>
{ui.disconnect}
</button>
</div>
</div>