给token区分环境
This commit is contained in:
@@ -11,7 +11,9 @@ const { updateUser } = store;
|
||||
watch(
|
||||
() => user.value.id,
|
||||
(newVal) => {
|
||||
const token = uni.getStorageSync("token");
|
||||
const token = uni.getStorageSync(
|
||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||
);
|
||||
if (newVal && token) {
|
||||
websocket.createWebSocket(token, (content) => {
|
||||
uni.$emit("socket-inbox", content);
|
||||
@@ -28,7 +30,9 @@ watch(
|
||||
);
|
||||
|
||||
onShow(() => {
|
||||
const token = uni.getStorageSync("token");
|
||||
const token = uni.getStorageSync(
|
||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||
);
|
||||
if (user.value.id && token) {
|
||||
console.log("回到前台,重新连接 websocket");
|
||||
websocket.createWebSocket(token, (content) => {
|
||||
|
||||
Reference in New Issue
Block a user