增加登录后定时器,修改socket链接

This commit is contained in:
A1300399510
2024-10-21 11:16:14 +08:00
parent f0de39f135
commit 3589d6a3f0
7 changed files with 21 additions and 6 deletions

View File

@@ -65,7 +65,7 @@ export default {
// 开启socket
useSocket() {
let token = this.getMiucmsSessionCookie() || ""
this.socketTask = new WebSocket(`wss://app.gter.net/socket?token=${token}`)
this.socketTask = new WebSocket(`wss://socket.gter.net?token=${token}`)
this.socketTask.onopen = () => {
let user = this.$store.state.user || {}
if (user && token) {

View File

@@ -91,6 +91,9 @@ export default new Vuex.Store({
let data = res.data
let { config, favorite, hotSearchkeywords, recommend, user, menu } = data
console.log("user",user.uid > 0);
const islogin = user.uid > 0 ? true : false;
console.log("islogin",islogin);
commit('setHomeRequestState', true)
commit('setUser', user)
commit('setFavoriteList', favorite)
@@ -98,6 +101,18 @@ export default new Vuex.Store({
commit('setHotSearchkeywords', hotSearchkeywords)
commit('setMenu', menu)
if (user.uid > 0) { // 这个是顶部用户数据的 这样不用监听是否请求成功
setTimeout(() => {
if (typeof xstat !== "undefined") {
xstat.identify({
uid: user.uid,
uin: user.uin,
});
}
}, 600)
}
if (that.userInfo) { // 这个是顶部用户数据的 这样不用监听是否请求成功
that.userInfo = user
that.islogin = user.uid > 0 ? true : false;
@@ -117,6 +132,6 @@ export default new Vuex.Store({
},
modules: {
}
},
})

View File

@@ -32,7 +32,7 @@ service.interceptors.request.use(
// config['headers']['authorization'] = "661aiz52k5e6vqgmkxnz0wvbv8nciz8h"
// if (process.env.NODE_ENV == "development") config['headers']['authorization'] = "0h870ovk2xckoqfsh8a3t3sg4sg5z7eg"
if (process.env.NODE_ENV == "development") config["headers"]["authorization"] = "d515090446191e8cc90d98f9a216af1c"
if (process.env.NODE_ENV == "development") config["headers"]["authorization"] = "5f8215f2105d8b2162d0cc210cdbf1a3"
return config
},