Skip to content

Commit

Permalink
perf: 优化用户session 会话过期
Browse files Browse the repository at this point in the history
  • Loading branch information
feng626 committed Feb 2, 2024
1 parent 167d546 commit a6eb82d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ui/src/utils/luna.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ export const MESSAGES = {
PONG: 'PONG',
PING: 'PING',
CLOSE: 'CLOSE',
CONNECTED: 'CONNECTED'
CONNECTED: 'CONNECTED',
RENEWAL: 'RENEWAL'
}

export class LunaEvent {
constructor() {
this.init()
}

init() {
window.addEventListener('message',
this.handleEventFromLuna.bind(this),
Expand Down
1 change: 1 addition & 0 deletions ui/src/utils/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function createWebSocket(uri = globalUri, callback = globalCallback) {
// 发送消息
export function onSend(message){
console.log(`发送消息`)
lunaEvent.sendEventToLuna(MESSAGES.RENEWAL)
if (typeof message !== 'string') {
message = JSON.stringify(message)
}
Expand Down
1 change: 0 additions & 1 deletion ui/src/views/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const onSwitchSidebar = () => {
}
onMounted(() => {
lunaEvent.init()
if (isMobile()) {
isShowMobile.value = true
}
Expand Down

0 comments on commit a6eb82d

Please sign in to comment.