From 0d1a86661a31410366440e968a1cbe59f6b9338e Mon Sep 17 00:00:00 2001 From: Litrix2 Date: Sat, 21 Dec 2024 12:06:42 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=94?= =?UTF-8?q?=E5=AD=90=E6=A3=8B=E9=80=80=E5=87=BA=E6=8B=A6=E6=88=AA=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 3 +- src/components/game2048/Game2048.vue | 2 +- src/stores/user.ts | 10 ++- src/views/GobangPlayPage.vue | 104 ++++++++++++++++++--------- 4 files changed, 78 insertions(+), 41 deletions(-) diff --git a/src/App.vue b/src/App.vue index c19941c..8f76550 100644 --- a/src/App.vue +++ b/src/App.vue @@ -160,8 +160,7 @@ provide(registerImplKey, async (params) => { }); async function logout() { showVerticalHeaderMenu.value = false; - if (!(await userStore.logout())) return; - await userStore.updateSelfUserInfo(true); + await userStore.logout(); } const showVerticalHeaderMenu = ref(false); watch(mdLess, (v) => { diff --git a/src/components/game2048/Game2048.vue b/src/components/game2048/Game2048.vue index affbed3..6117b8b 100644 --- a/src/components/game2048/Game2048.vue +++ b/src/components/game2048/Game2048.vue @@ -507,7 +507,7 @@ function mergeLine(line: SingleTileLine): [lineMergeREsult: LineMergeResult, cha /** * 合并所有块. * @param direction 合并方向 - * @return {} 是否有活动空间 + * @return 是否有活动空间 */ async function mergeTiles(direction: Directions) { function getMergedGrid( diff --git a/src/stores/user.ts b/src/stores/user.ts index 0a0e8b1..57bc4e7 100644 --- a/src/stores/user.ts +++ b/src/stores/user.ts @@ -24,8 +24,11 @@ export const useUserStore = defineStore('user', () => { const logined = computed(() => (userInfo.value && userInfo.value.id !== -1) ?? false); watch( userInfo, - () => { - router.push({ path: router.currentRoute.value.fullPath, force: true }); + (info) => { + router.push({ + path: info && info.id !== -1 ? router.currentRoute.value.fullPath : '/', + force: true, + }); }, { flush: 'sync' }, ); @@ -66,6 +69,7 @@ export const useUserStore = defineStore('user', () => { const res = await Promise.all(Array.from(logoutInterceptors).map((fn) => fn())); if (!res.every((r) => r === undefined || r)) return false; token.value = null; + await updateSelfUserInfo(true); return true; } return { @@ -82,7 +86,7 @@ export const useUserStore = defineStore('user', () => { logout, }; }); -export type LogoutInterceptor = () => MaybePromise; +export type LogoutInterceptor = () => MaybePromise; export function useLogoutInterceptor(fn: LogoutInterceptor) { const userStore = useUserStore(); userStore.addLogoutInterceptor(fn); diff --git a/src/views/GobangPlayPage.vue b/src/views/GobangPlayPage.vue index a46dca8..6cb64f6 100644 --- a/src/views/GobangPlayPage.vue +++ b/src/views/GobangPlayPage.vue @@ -80,9 +80,11 @@ class="gobang-play-page-aside !flex flex-col items-center justify-between" >
- - -
{{ otherPrompt }}
+