fix:修复多个问题

This commit is contained in:
3030332422
2026-04-15 17:53:51 +08:00
parent 4225f1525f
commit 36ea5c5e13
2 changed files with 75 additions and 10 deletions
@@ -6,6 +6,7 @@ let reconnectTimer = null;
let reconnectAttempts = 0;
let shouldReconnect = true;
let wakewordRequestSeq = 0;
let onNextBridgeConnectedCallback = null;
const pendingWakewordRequests = new Map();
@@ -53,6 +54,11 @@ function tryConnect() {
if (message.type === 'bridge_connected') {
log('本地唤醒监听已就绪', 'info');
if (onNextBridgeConnectedCallback) {
const cb = onNextBridgeConnectedCallback;
onNextBridgeConnectedCallback = null;
cb(message);
}
return;
}
@@ -125,6 +131,7 @@ export function stopWakewordBridgeListener() {
return;
}
wakewordSocket.onclose = null;
wakewordSocket.close();
wakewordSocket = null;
}
@@ -162,6 +169,17 @@ export function requestWakewordBridge(type, payload = {}, timeout = 5000) {
});
}
export function getWakewordBridgeUrl() {
if (wakewordSocket && wakewordSocket.url) {
return wakewordSocket.url;
}
return buildWakewordBridgeUrl();
}
export function onNextBridgeConnected(callback) {
onNextBridgeConnectedCallback = callback;
}
function buildWakewordBridgeUrl() {
const configured = localStorage.getItem('xz_tester_wakewordWsUrl');
if (configured && configured.trim()) {