File tree 6 files changed +10
-16
lines changed
6 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export function setupPageGuard(router: Router) {
8
8
try {
9
9
const data = await authStore . getSession ( )
10
10
if ( String ( data . auth ) === 'false' && authStore . token )
11
- authStore . removeToken ( )
11
+ await authStore . removeToken ( )
12
12
if ( to . path === '/500' )
13
13
next ( { name : 'Root' } )
14
14
else
Original file line number Diff line number Diff line change @@ -53,12 +53,12 @@ export const useAuthStore = defineStore('auth-store', {
53
53
setToken ( token )
54
54
} ,
55
55
56
- removeToken ( ) {
56
+ async removeToken ( ) {
57
57
this . token = undefined
58
58
const userStore = useUserStore ( )
59
59
userStore . resetUserInfo ( )
60
60
const chatStore = useChatStore ( )
61
- chatStore . clearLocalChat ( )
61
+ await chatStore . clearLocalChat ( )
62
62
removeToken ( )
63
63
} ,
64
64
} ,
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const useChatStore = defineStore('chat-store', {
29
29
let uuid = this . active
30
30
this . history = [ ]
31
31
this . chat = [ ]
32
- if ( rooms . findIndex ( ( item : { uuid : number | null } ) => item . uuid === uuid ) <= - 1 && rooms . length > 0 )
32
+ if ( rooms . findIndex ( ( item : { uuid : number | null } ) => item . uuid === uuid ) <= - 1 )
33
33
uuid = null
34
34
35
35
for ( const r of rooms ) {
@@ -237,11 +237,12 @@ export const useChatStore = defineStore('chat-store', {
237
237
}
238
238
} ,
239
239
240
- clearLocalChat ( ) {
240
+ async clearLocalChat ( ) {
241
241
this . chat = [ ]
242
242
this . history = [ ]
243
243
this . active = null
244
244
this . recordState ( )
245
+ await router . push ( { name : 'Chat' } )
245
246
} ,
246
247
247
248
async reloadRoute ( uuid ?: number ) {
Original file line number Diff line number Diff line change @@ -28,10 +28,8 @@ function http<T = any>(
28
28
if ( res . data . status === 'Success' || typeof res . data === 'string' )
29
29
return res . data
30
30
31
- if ( res . data . status === 'Unauthorized' ) {
31
+ if ( res . data . status === 'Unauthorized' )
32
32
authStore . removeToken ( )
33
- window . location . reload ( )
34
- }
35
33
36
34
return Promise . reject ( res . data )
37
35
}
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ async function handleVerify(verifytoken: string) {
57
57
}
58
58
catch (error : any ) {
59
59
ms .error (error .message ?? ' error' )
60
- authStore .removeToken ()
61
60
}
62
61
finally {
63
62
loading .value = false
@@ -87,7 +86,6 @@ async function handleLogin() {
87
86
}
88
87
catch (error : any ) {
89
88
ms .error (error .message ?? ' error' )
90
- authStore .removeToken ()
91
89
password .value = ' '
92
90
}
93
91
finally {
@@ -135,7 +133,7 @@ async function handleRegister() {
135
133
136
134
<!-- Add Tabs -->
137
135
<NTabs v-model:value =" activeTab" type =" line" >
138
- <NTabPane name =" login" :label =" $t('common.login')" >
136
+ <NTabPane name =" login" :tab =" $t('common.login')" >
139
137
<NInput v-model:value =" username" type =" text" :placeholder =" $t('common.email')" class =" mb-2" />
140
138
<NInput v-model:value =" password" type =" password" :placeholder =" $t('common.password')" class =" mb-2" @keypress =" handlePress" />
141
139
@@ -144,7 +142,7 @@ async function handleRegister() {
144
142
</NButton >
145
143
</NTabPane >
146
144
147
- <NTabPane v-if =" authStore.session && authStore.session.allowRegister" name =" register" :label =" $t('common.register')" >
145
+ <NTabPane v-if =" authStore.session && authStore.session.allowRegister" name =" register" :tab =" $t('common.register')" >
148
146
<NInput v-model:value =" username" type =" text" :placeholder =" $t('common.email')" class =" mb-2" />
149
147
<NInput v-model:value =" password" type =" password" :placeholder =" $t('common.password')" class =" mb-2" @input =" handlePasswordInput" />
150
148
<NInput
Original file line number Diff line number Diff line change 1
1
<script setup lang='ts'>
2
2
import { defineAsyncComponent , ref } from ' vue'
3
- import { useRouter } from ' vue-router'
4
3
import { HoverButton , SvgIcon , UserAvatar } from ' @/components/common'
5
4
import { useAuthStore } from ' @/store'
6
5
const Setting = defineAsyncComponent (() => import (' @/components/common/Setting/index.vue' ))
7
6
8
7
const authStore = useAuthStore ()
9
- const router = useRouter ()
10
8
11
9
const show = ref (false )
12
10
13
11
async function handleLogout() {
14
- authStore .removeToken ()
15
- router .go (0 )
12
+ await authStore .removeToken ()
16
13
}
17
14
</script >
18
15
You can’t perform that action at this time.
0 commit comments