修复bug
This commit is contained in:
+12
-13
@@ -22,7 +22,12 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { INPUT_LABELS, isHomeVolumeLockedByPassthrough, OUTPUT_LABELS } from "@/lib/luxsinApi";
|
||||
import {
|
||||
INPUT_BLUETOOTH_INDEX,
|
||||
INPUT_LABELS,
|
||||
isHomeVolumeLockedByPassthrough,
|
||||
OUTPUT_LABELS,
|
||||
} from "@/lib/luxsinApi";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
ChevronRight,
|
||||
@@ -164,7 +169,7 @@ function ListRow({
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const { isConnected, deviceState, setVolume, updateSetting, api, disconnect, isDemoMode, ip } = useDevice();
|
||||
const { isConnected, deviceState, setVolume, updateSetting, api, isDemoMode, ip } = useDevice();
|
||||
const [, setLocation] = useLocation();
|
||||
const powerActionRef = useRef(false);
|
||||
const hpEqLastTapRef = useRef<number | null>(null);
|
||||
@@ -232,24 +237,18 @@ export default function Home() {
|
||||
if (powerActionRef.current) return;
|
||||
powerActionRef.current = true;
|
||||
try {
|
||||
if (isDemoMode) {
|
||||
toast.info(homeText.powerOffToastDemo ?? "演示模式:已断开与设备的连接");
|
||||
disconnect();
|
||||
return;
|
||||
}
|
||||
if (api) {
|
||||
if (!isDemoMode && api) {
|
||||
try {
|
||||
await api.powerOff();
|
||||
} catch {
|
||||
// 设备可能已掉线或未返回响应,仍断开本地会话
|
||||
// 设备关机后可能已无响应,仍保留当前页面与连接状态
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
toast.success(homeText.powerOffToastSent ?? "已发送关机指令");
|
||||
} finally {
|
||||
powerActionRef.current = false;
|
||||
}
|
||||
}, [api, disconnect, isDemoMode, homeText]);
|
||||
}, [api, isDemoMode, homeText]);
|
||||
|
||||
/** HP-EQ 圆钮:单击在短延迟后切换 peqEnable(避免与双击抢);280ms 内第二次点击则取消开关并进入 /eq */
|
||||
const HP_EQ_DOUBLE_CLICK_MS = 280;
|
||||
@@ -779,8 +778,8 @@ export default function Home() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Bluetooth info */}
|
||||
{ds.bt_status !== 0 && (
|
||||
{/* Bluetooth info — only when input source is Bluetooth */}
|
||||
{ds.input === INPUT_BLUETOOTH_INDEX && ds.bt_status !== 0 && (
|
||||
<div className="mt-3 px-3 py-3 text-center">
|
||||
<div className="flex items-center justify-center gap-1.5 mb-1">
|
||||
<Bluetooth size={14} className="text-[#00FFF6]" />
|
||||
|
||||
Reference in New Issue
Block a user