给token区分环境

This commit is contained in:
kron
2025-09-12 17:49:26 +08:00
parent 24b776f327
commit 0a151de3c9
6 changed files with 36 additions and 15 deletions

View File

@@ -15,7 +15,9 @@ export const checkConnection = () => {
data: JSON.stringify({ event: "ping", data: {} }),
fail: () => {
websocket.closeWebSocket();
const token = uni.getStorageSync("token");
const token = uni.getStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
if (!token) return;
// 如果发送失败,说明连接已断开,需要重新连接
websocket.createWebSocket(token, (content) => {