Update locale files for English, Traditional Chinese, and Simplified Chinese to add new confirmation prompts for volume adjustments; refactor Home and EQPage components to integrate volume confirmation dialogs and enhance user interaction for setting volume levels.
This commit is contained in:
@@ -172,6 +172,7 @@ export default function Home() {
|
||||
const effectLastTapRef = useRef<number | null>(null);
|
||||
const effectNavigateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const [powerConfirmOpen, setPowerConfirmOpen] = useState(false);
|
||||
const [volumeConfirm, setVolumeConfirm] = useState<null | "min" | "max">(null);
|
||||
const [easterEggActive, setEasterEggActive] = useState(false);
|
||||
const [vuHeights, setVuHeights] = useState<number[]>(idleVuBarHeights);
|
||||
const jackProgressRef = useRef(0);
|
||||
@@ -187,6 +188,28 @@ export default function Home() {
|
||||
return (loc.home ?? {}) as HomeLocale;
|
||||
}, [deviceState]);
|
||||
|
||||
const volumeConfirmCopy = useMemo(() => {
|
||||
if (volumeConfirm === "min") {
|
||||
return {
|
||||
title: homeText.volumeMinConfirmTitle ?? "确认将音量设为最小?",
|
||||
desc:
|
||||
homeText.volumeMinConfirmDesc ??
|
||||
"耳机音量将调至最低(静音),是否继续?",
|
||||
ok: homeText.volumeMinConfirmOk ?? "设为最小",
|
||||
};
|
||||
}
|
||||
if (volumeConfirm === "max") {
|
||||
return {
|
||||
title: homeText.volumeMaxConfirmTitle ?? "确认将音量设为最大?",
|
||||
desc:
|
||||
homeText.volumeMaxConfirmDesc ??
|
||||
"耳机音量将调至最大,是否继续?",
|
||||
ok: homeText.volumeMaxConfirmOk ?? "设为最大",
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}, [volumeConfirm, homeText]);
|
||||
|
||||
const [localVol, setLocalVol] = useState(deviceState?.volume ?? 100);
|
||||
const isDragging = useRef(false);
|
||||
const knobDraggingRef = useRef(false);
|
||||
@@ -562,8 +585,11 @@ export default function Home() {
|
||||
{/* ── Volume slider ── */}
|
||||
<div className="px-4 mb-5">
|
||||
<div className="flex items-center gap-3">
|
||||
<button onClick={() => { setLocalVol(0); setVolume(0); }}
|
||||
className="text-white/50 active:text-white transition-colors flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setVolumeConfirm("min")}
|
||||
className="text-white/50 active:text-white transition-colors flex-shrink-0"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="w-6 h-6">
|
||||
<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/>
|
||||
<line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/>
|
||||
@@ -618,8 +644,11 @@ export default function Home() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button onClick={() => { setLocalVol(200); setVolume(200); }}
|
||||
className="text-white/50 active:text-white transition-colors flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setVolumeConfirm("max")}
|
||||
className="text-white/50 active:text-white transition-colors flex-shrink-0"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="w-6 h-6">
|
||||
<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/>
|
||||
<path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>
|
||||
@@ -824,8 +853,46 @@ export default function Home() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AlertDialog
|
||||
open={volumeConfirm !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setVolumeConfirm(null);
|
||||
}}
|
||||
>
|
||||
<AlertDialogContent className="top-[42%] border-white/10 bg-zinc-900 text-white sm:max-w-md">
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle className="text-white">
|
||||
{volumeConfirmCopy?.title}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription className="text-white/60">
|
||||
{volumeConfirmCopy?.desc}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel className="border-white/20 bg-transparent text-white hover:bg-white/10">
|
||||
{homeText.powerOffConfirmCancel ?? "取消"}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-[#00FFF6] text-black hover:bg-[#00FFF6]/90 focus-visible:ring-[#00FFF6]"
|
||||
onClick={() => {
|
||||
if (volumeConfirm === "min") {
|
||||
setLocalVol(0);
|
||||
setVolume(0);
|
||||
} else if (volumeConfirm === "max") {
|
||||
setLocalVol(200);
|
||||
setVolume(200);
|
||||
}
|
||||
setVolumeConfirm(null);
|
||||
}}
|
||||
>
|
||||
{volumeConfirmCopy?.ok}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<AlertDialog open={powerConfirmOpen} onOpenChange={setPowerConfirmOpen}>
|
||||
<AlertDialogContent className="border-white/10 bg-zinc-900 text-white sm:max-w-md">
|
||||
<AlertDialogContent className="top-[42%] border-white/10 bg-zinc-900 text-white sm:max-w-md">
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle className="text-white">
|
||||
{homeText.powerOffConfirmTitle ?? "确认关闭电源?"}
|
||||
|
||||
Reference in New Issue
Block a user