File tree Expand file tree Collapse file tree 6 files changed +10
-16
lines changed Expand file tree Collapse file tree 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) {
88 try {
99 const data = await authStore . getSession ( )
1010 if ( String ( data . auth ) === 'false' && authStore . token )
11- authStore . removeToken ( )
11+ await authStore . removeToken ( )
1212 if ( to . path === '/500' )
1313 next ( { name : 'Root' } )
1414 else
Original file line number Diff line number Diff line change @@ -53,12 +53,12 @@ export const useAuthStore = defineStore('auth-store', {
5353 setToken ( token )
5454 } ,
5555
56- removeToken ( ) {
56+ async removeToken ( ) {
5757 this . token = undefined
5858 const userStore = useUserStore ( )
5959 userStore . resetUserInfo ( )
6060 const chatStore = useChatStore ( )
61- chatStore . clearLocalChat ( )
61+ await chatStore . clearLocalChat ( )
6262 removeToken ( )
6363 } ,
6464 } ,
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const useChatStore = defineStore('chat-store', {
2929 let uuid = this . active
3030 this . history = [ ]
3131 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 )
3333 uuid = null
3434
3535 for ( const r of rooms ) {
@@ -237,11 +237,12 @@ export const useChatStore = defineStore('chat-store', {
237237 }
238238 } ,
239239
240- clearLocalChat ( ) {
240+ async clearLocalChat ( ) {
241241 this . chat = [ ]
242242 this . history = [ ]
243243 this . active = null
244244 this . recordState ( )
245+ await router . push ( { name : 'Chat' } )
245246 } ,
246247
247248 async reloadRoute ( uuid ?: number ) {
Original file line number Diff line number Diff line change @@ -28,10 +28,8 @@ function http<T = any>(
2828 if ( res . data . status === 'Success' || typeof res . data === 'string' )
2929 return res . data
3030
31- if ( res . data . status === 'Unauthorized' ) {
31+ if ( res . data . status === 'Unauthorized' )
3232 authStore . removeToken ( )
33- window . location . reload ( )
34- }
3533
3634 return Promise . reject ( res . data )
3735 }
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ async function handleVerify(verifytoken: string) {
5757 }
5858 catch (error : any ) {
5959 ms .error (error .message ?? ' error' )
60- authStore .removeToken ()
6160 }
6261 finally {
6362 loading .value = false
@@ -87,7 +86,6 @@ async function handleLogin() {
8786 }
8887 catch (error : any ) {
8988 ms .error (error .message ?? ' error' )
90- authStore .removeToken ()
9189 password .value = ' '
9290 }
9391 finally {
@@ -135,7 +133,7 @@ async function handleRegister() {
135133
136134 <!-- Add Tabs -->
137135 <NTabs v-model:value =" activeTab" type =" line" >
138- <NTabPane name =" login" :label =" $t('common.login')" >
136+ <NTabPane name =" login" :tab =" $t('common.login')" >
139137 <NInput v-model:value =" username" type =" text" :placeholder =" $t('common.email')" class =" mb-2" />
140138 <NInput v-model:value =" password" type =" password" :placeholder =" $t('common.password')" class =" mb-2" @keypress =" handlePress" />
141139
@@ -144,7 +142,7 @@ async function handleRegister() {
144142 </NButton >
145143 </NTabPane >
146144
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')" >
148146 <NInput v-model:value =" username" type =" text" :placeholder =" $t('common.email')" class =" mb-2" />
149147 <NInput v-model:value =" password" type =" password" :placeholder =" $t('common.password')" class =" mb-2" @input =" handlePasswordInput" />
150148 <NInput
Original file line number Diff line number Diff line change 11<script setup lang='ts'>
22import { defineAsyncComponent , ref } from ' vue'
3- import { useRouter } from ' vue-router'
43import { HoverButton , SvgIcon , UserAvatar } from ' @/components/common'
54import { useAuthStore } from ' @/store'
65const Setting = defineAsyncComponent (() => import (' @/components/common/Setting/index.vue' ))
76
87const authStore = useAuthStore ()
9- const router = useRouter ()
108
119const show = ref (false )
1210
1311async function handleLogout() {
14- authStore .removeToken ()
15- router .go (0 )
12+ await authStore .removeToken ()
1613}
1714 </script >
1815
You can’t perform that action at this time.
0 commit comments