新增听力补偿,将有版本限制的功能,提取到配置文件,不再硬编码,优化部署文件参数

This commit is contained in:
eafonyang
2026-06-26 15:03:36 +08:00
parent 522bb602b3
commit 1e5e6f5548
11 changed files with 209 additions and 29 deletions
+46 -2
View File
@@ -14,7 +14,8 @@ import BottomNav from "@/components/BottomNav";
import SubwooferLpfChart from "@/components/SubwooferLpfChart";
import { FeatureGate } from "@/components/FeatureGate";
import { navigateToSelect } from "./SelectPage";
import { parseFirmwareVersion } from "@/lib/luxsinApi";
import { parseFirmwareVersion, parseHearingData } from "@/lib/luxsinApi";
import { isFirmwareFeatureAvailable } from "@/config/firmwareFeatures";
import localeZh from "@/locales/data-zh.json";
import localeZhHK from "@/locales/data-zh-HK.json";
import localeEn from "@/locales/data-en.json";
@@ -247,6 +248,16 @@ export default function EffectsPage() {
const widthVal = ds?.width_value ?? 50;
const crossfeedOn = (ds?.crossfeed_enable ?? 0) === 1;
const crossfeedVal = ds?.crossfeed_value ?? 0;
const hearingOn = (ds?.hearing_enable ?? 0) === 1;
const hearingSelect = ds?.hearing_select ?? 0;
const hearingProfiles = useMemo(
() => parseHearingData(ds?.hearing_data),
[ds?.hearing_data],
);
const hearingLabels = useMemo(
() => hearingProfiles.map((profile) => profile.n),
[hearingProfiles],
);
const sceneOn = (ds?.effect_enable ?? 0) === 1;
const sceneVal = ds?.effect_value ?? 0;
const colorOn = (ds?.color_enable ?? 0) === 1;
@@ -265,7 +276,8 @@ export default function EffectsPage() {
const subwooferLpfOn = (ds?.subwoofer_lpf_enable ?? 0) === 1;
const subwooferHpfOn = (ds?.subwoofer_hpf_enable ?? 0) === 1;
const firmwareVersion = parseFirmwareVersion(ds?.version);
const showSubwooferFullRange = firmwareVersion >= 2001;
const showSubwooferFullRange = isFirmwareFeatureAvailable("subwooferFullRange", firmwareVersion);
const showHearingCompensation = isFirmwareFeatureAvailable("hearingCompensation", firmwareVersion);
const subwooferDelayMainL = clampSubwooferDelayValue(ds?.subwoofer_delay_main ?? 0);
const subwooferDelaySubL = clampSubwooferDelayValue(ds?.subwoofer_delay ?? 0);
@@ -393,6 +405,9 @@ export default function EffectsPage() {
const sceneDisplay = sceneLabels[sceneIdx] ?? "";
const crossIdx = clampPickIndex(crossfeedVal, crossfeedLabels.length);
const crossfeedDisplay = crossfeedLabels[crossIdx] ?? "";
const hearingIdx = clampPickIndex(hearingSelect, hearingLabels.length);
const hearingDisplay =
hearingLabels[hearingIdx] ?? effectText.hearing?.emptyProfile ?? "—";
const subRateIdx = clampPickIndex(subwooferRate, subwooferRateLabels.length);
const subRateDisplay = subwooferRateLabels[subRateIdx] ?? "";
const subMixIdx = clampPickIndex(subwooferMixType, subwooferOutputLabels.length);
@@ -870,6 +885,35 @@ export default function EffectsPage() {
</div>
)}
</div>
{/* ── 听力补偿 ── */}
{showHearingCompensation && (
<div className="ios-list-group p-4">
<div className="flex items-center justify-between mb-3">
<span className="text-[16px] font-medium text-white">{effectText.hearing?.label ?? "听力补偿"}</span>
<IOSToggle checked={hearingOn} onChange={(v) => updateSetting({ hearing_enable: v ? 1 : 0 })} />
</div>
<button
type="button"
disabled={!hearingOn || hearingLabels.length === 0}
className={`flex items-center justify-between w-full transition-opacity ${
hearingOn && hearingLabels.length > 0 ? "active:opacity-70" : "cursor-default opacity-50"
}`}
onClick={() => {
if (!hearingOn || hearingLabels.length === 0) return;
goSelect(
effectText.selectHearingTitle ?? effectText.hearing?.label ?? "听力补偿",
hearingLabels,
hearingSelect,
"hearing_select",
);
}}
>
<span className="text-[14px] text-white/45">{hearingDisplay}</span>
<ChevronRight size={16} className="ios-chevron" />
</button>
</div>
)}
</FeatureGate>
</div>
+1 -1
View File
@@ -111,7 +111,7 @@ const KEY_TO_SETTING: Record<string, string> = {
effect_value: "effect_value",
crossfeed_value: "crossfeed_value",
hearing_select: "hearing_select",
subwoofer_rate: "subwoofer_rate",
subwoofer_mix_type: "subwoofer_mix_type",