添加设备在线离线处理

This commit is contained in:
kron
2025-12-31 13:39:16 +08:00
parent 25f51ad53a
commit af852d9b59
8 changed files with 104 additions and 57 deletions

View File

@@ -11,7 +11,7 @@ import { getRoomAPI, joinRoomAPI, isGamingAPI, getBattleDataAPI } from "@/apis";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const { user, device, online } = storeToRefs(store);
import { debounce } from "@/util";
const showModal = ref(false);
@@ -19,7 +19,33 @@ const warnning = ref("");
const roomNumber = ref("");
const data = ref({});
const checkBeforeEnter = async () => {
if (!device.value.deviceId) {
uni.showToast({
title: "请先绑定设备",
icon: "none",
});
return true;
}
if (!online.value) {
uni.showToast({
title: "智能弓未连接",
icon: "none",
});
return true;
}
if (!user.value.trio) {
uni.showToast({
title: "请先完成新手试炼",
icon: "none",
});
return true;
}
return false;
};
const enterRoom = debounce(async () => {
if (checkBeforeEnter()) return;
const isGaming = await isGamingAPI();
if (isGaming) {
uni.$showHint(1);
@@ -54,6 +80,7 @@ const enterRoom = debounce(async () => {
}
});
const onCreateRoom = async () => {
if (checkBeforeEnter()) return;
const isGaming = await isGamingAPI();
if (isGaming) {
uni.$showHint(1);