新增社区页面路由,更新底部导航以移除占位符,优化音量控制按钮样式和功能

This commit is contained in:
yangy
2026-04-29 17:56:03 +08:00
parent c7b340087a
commit 22ec4bb710
5 changed files with 82 additions and 11 deletions
+46 -2
View File
@@ -46,7 +46,7 @@ type HomeLocale = NonNullable<(typeof localeZh)["home"]>;
// ── Volume in dB (0-200 → -100dB to 0dB) ──
function volToDB(v: number) {
if (v === 0) return "-";
if (v === 0) return "-100dB";
const db = (v - 200) / 2;
return `${db >= 0 ? "+" : ""}${db.toFixed(1)}dB`;
}
@@ -165,6 +165,12 @@ export default function Home() {
const vuLabel = `${homeText.vu ?? "VU表"}${(ds.vu ?? 0) + 1}`;
const bypassOn = (ds.dsp_enable ?? 0) === 0;
// Home 的 volume 取值为 0..200,对应 dB = (v - 200) / 2
// 因此 1 个 volume 单位 = 0.5dB
// AudioPage 的 soundStep0->0.5dB, 1->1dB, 2->2dB, 3->3dB
// 换算为 volume 单位:0.5/1/2/3 dB -> 1/2/4/6
const fineVolumeStep = [1, 2, 4, 6][ds.soundStep ?? 1] ?? 1;
// Slider fill % (0-200 → 0-100%)
const fillPct = (localVol / 200) * 100;
// Knob angle (map 0..200 -> -135..+135 degrees)
@@ -369,10 +375,48 @@ export default function Home() {
</button>
</div>
{/* dB value */}
<div className="text-center mt-1">
<div className="mt-[6px] flex items-center justify-center gap-3">
<button
type="button"
aria-label="Decrease volume"
disabled={localVol <= 0}
className="w-10 h-10 rounded-full flex items-center justify-center transition-all active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed"
style={{
background: "rgba(44,44,46,0.6)",
border: "1px solid rgba(255,255,255,0.08)",
color: "rgba(255,255,255,0.55)",
}}
onClick={() => {
const next = Math.max(0, Math.min(200, localVol - fineVolumeStep));
setLocalVol(next);
setVolume(next);
}}
>
<span className="text-[20px] leading-none">-</span>
</button>
<span className="text-[22px] font-bold tracking-tight" style={{ color: "#00FFF6" }}>
{volToDB(localVol)}
</span>
<button
type="button"
aria-label="Increase volume"
disabled={localVol >= 200}
className="w-10 h-10 rounded-full flex items-center justify-center transition-all active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed"
style={{
background: "rgba(44,44,46,0.6)",
border: "1px solid rgba(255,255,255,0.08)",
color: "rgba(255,255,255,0.55)",
}}
onClick={() => {
const next = Math.max(0, Math.min(200, localVol + fineVolumeStep));
setLocalVol(next);
setVolume(next);
}}
>
<span className="text-[20px] leading-none">+</span>
</button>
</div>
{/* Bluetooth info */}