update:提交我的设备改版

This commit is contained in:
2026-09-17 18:23:41 +08:00
parent 46cbd37102
commit b060d8f987
50 changed files with 897 additions and 590 deletions
+22 -12
View File
@@ -8,9 +8,6 @@
} from "@dcloudio/uni-app";
import websocket from "@/websocket";
import matchWebsocket from "@/matchWebsocket";
import {
getDeviceBatteryAPI
} from "@/apis";
import {
MESSAGETYPES
} from "@/constants";
@@ -27,8 +24,9 @@
} = storeToRefs(store);
const {
updateUser,
updateOnline,
updateDeviceBattery,
updateDeviceStatus,
setDeviceOnline,
clearDeviceStatus,
showDeviceChargingDialog,
clearSessionState,
clearDevice
@@ -70,14 +68,19 @@
});
}
async function emitUpdateOnline() {
const data = await getDeviceBatteryAPI();
function emitUpdateOnline(nextOnline) {
const wasOnline = Boolean(online.value);
const nextOnline = Boolean(data.online);
updateOnline(nextOnline);
updateDeviceBattery(nextOnline ? data?.battery ?? data?.power : null);
if (!device.value.deviceId || wasOnline === nextOnline) return;
audioManager.play(nextOnline ? "设备已连接" : "设备连接已断开");
setDeviceOnline(nextOnline === true);
if (!device.value.deviceId || wasOnline === (nextOnline === true)) return;
audioManager.play(nextOnline === true ? "设备已连接" : "设备连接已断开");
}
function onDeviceStatusPush(status) {
updateDeviceStatus(status);
}
function onShootSocketDisconnected() {
clearDeviceStatus();
}
function onDeviceBindInvalid() {
@@ -113,6 +116,10 @@
}
function onShootWsMsg(content) {
if (content?.event === "/addons/shoot/battery") {
onDeviceStatusPush(content.data);
return;
}
if(content.type === 'shoot-trigger'){
onDeviceShoot()
}
@@ -124,6 +131,7 @@
void audioManager.warmButton();
uni.$on("update-user", emitUpdateUser);
uni.$on("update-online", emitUpdateOnline);
uni.$on("shoot-socket-disconnected", onShootSocketDisconnected);
uni.$on("session-kicked-out", onSessionKickedOut);
uni.$on("device-bind-invalid", onDeviceBindInvalid);
uni.$on("device-charging", onDeviceCharging);
@@ -150,6 +158,7 @@
onHide(() => {
uni.$off("update-user", emitUpdateUser);
uni.$off("update-online", emitUpdateOnline);
uni.$off("shoot-socket-disconnected", onShootSocketDisconnected);
uni.$off("session-kicked-out", onSessionKickedOut);
uni.$off("device-bind-invalid", onDeviceBindInvalid);
uni.$off("device-charging", onDeviceCharging);
@@ -159,6 +168,7 @@
matchWebsocket.closeMatchWebSocket({
reason: "app-hide"
});
clearDeviceStatus();
websocket.closeWebSocket();
});
</script>