diff --git a/src/api/system/personal/index.ts b/src/api/system/personal/index.ts
index 24eb1f6..3b23cbd 100644
--- a/src/api/system/personal/index.ts
+++ b/src/api/system/personal/index.ts
@@ -25,4 +25,9 @@ export function resetPwdPersonal(data:object) {
})
}
-
+export function refreshToken() {
+ return request({
+ url: '/api/v1/system/personal/refreshToken',
+ method: 'get'
+ })
+}
diff --git a/src/utils/websocket.ts b/src/utils/websocket.ts
index 7d0ac03..cb70efa 100644
--- a/src/utils/websocket.ts
+++ b/src/utils/websocket.ts
@@ -1,5 +1,8 @@
-import {getToken} from "/@/utils/gfast"
+import {getToken, getUpFileUrl} from "/@/utils/gfast"
import {noticeStore} from "/@/stores/noticeStore";
+import {refreshToken} from "/@/api/system/personal";
+import {Session} from "/@/utils/storage";
+import {useUserInfo} from "/@/stores/userInfo";
const noticeStoreAct = noticeStore()
const webSocketURL = import.meta.env.VITE_WEBSOCKET_URL
let socket: WebSocket;
@@ -139,6 +142,19 @@ export default (onMessage: Function) => {
noticeStoreAct.setMessages(message.data)
return;
}
+ //更新token
+ if(message.event == 'tokenUpdated'){
+ refreshToken().then((res:any)=>{
+ const userInfo = res.data.userInfo
+ userInfo.avatar = getUpFileUrl(userInfo.avatar)
+ // 存储 token 到浏览器缓存
+ Session.set('token', res.data.token);
+ // 存储用户信息到浏览器缓存
+ Session.set('userInfo', userInfo);
+ useUserInfo().setUserInfos();
+ })
+ return;
+ }
if (onMessage && !isHeart) {
onMessage.call(null, event);
}
diff --git a/src/views/system/role/component/dataScope.vue b/src/views/system/role/component/dataScope.vue
index 6e2bc03..2726353 100644
--- a/src/views/system/role/component/dataScope.vue
+++ b/src/views/system/role/component/dataScope.vue
@@ -33,7 +33,7 @@