update:优化多端登录

This commit is contained in:
2026-05-11 14:11:25 +08:00
parent 19391808ef
commit 8b9c862b96
3 changed files with 132 additions and 54 deletions

View File

@@ -21,7 +21,10 @@
} = storeToRefs(store);
const {
updateUser,
updateOnline
updateOnline,
updateDevice,
updateGame,
updateRoomNumber
} = store;
watch(
@@ -46,6 +49,22 @@
updateUser(value);
}
function onSessionKickedOut() {
uni.removeStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
updateUser();
updateDevice("", "");
updateOnline(false);
updateGame(false, "");
updateRoomNumber("");
uni.showModal({
title: "提示",
content: "账号已在其他设备登录",
showCancel: false,
});
}
async function emitUpdateOnline() {
const data = await getDeviceBatteryAPI();
updateOnline(data.online);
@@ -65,6 +84,7 @@
onShow(() => {
uni.$on("update-user", emitUpdateUser);
uni.$on("update-online", emitUpdateOnline);
uni.$on("session-kicked-out", onSessionKickedOut);
const token = uni.getStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
@@ -77,6 +97,7 @@
onHide(() => {
uni.$off("update-user", emitUpdateUser);
uni.$off("update-online", emitUpdateOnline);
uni.$off("session-kicked-out", onSessionKickedOut);
websocket.closeWebSocket();
});
</script>
@@ -289,4 +310,4 @@
font-style: normal;
font-display: swap;
}
</style>
</style>