From df48409814db024ef220e644a2d93c51f55f98ef Mon Sep 17 00:00:00 2001 From: Vben Date: Thu, 19 Sep 2024 23:03:20 +0800 Subject: [PATCH] fix: when the api returns 401, the page is refreshed not as expected (#4440) --- apps/web-antd/src/store/auth.ts | 6 +++++- apps/web-ele/src/store/auth.ts | 6 +++++- apps/web-naive/src/store/auth.ts | 6 +++++- docs/src/components/common-ui/vben-drawer.md | 8 ++++++++ docs/src/components/common-ui/vben-modal.md | 8 ++++++++ docs/src/components/introduction.md | 2 +- playground/src/store/auth.ts | 6 +++++- 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/apps/web-antd/src/store/auth.ts b/apps/web-antd/src/store/auth.ts index e9e89634861..87ee0cc4462 100644 --- a/apps/web-antd/src/store/auth.ts +++ b/apps/web-antd/src/store/auth.ts @@ -76,7 +76,11 @@ export const useAuthStore = defineStore('auth', () => { } async function logout(redirect: boolean = true) { - await logoutApi(); + try { + await logoutApi(); + } catch { + // 不做任何处理 + } resetAllStores(); accessStore.setLoginExpired(false); diff --git a/apps/web-ele/src/store/auth.ts b/apps/web-ele/src/store/auth.ts index d34ef3e7ba5..052def8559a 100644 --- a/apps/web-ele/src/store/auth.ts +++ b/apps/web-ele/src/store/auth.ts @@ -77,7 +77,11 @@ export const useAuthStore = defineStore('auth', () => { } async function logout(redirect: boolean = true) { - await logoutApi(); + try { + await logoutApi(); + } catch { + // 不做任何处理 + } resetAllStores(); accessStore.setLoginExpired(false); diff --git a/apps/web-naive/src/store/auth.ts b/apps/web-naive/src/store/auth.ts index b8cf61d648e..8552252625d 100644 --- a/apps/web-naive/src/store/auth.ts +++ b/apps/web-naive/src/store/auth.ts @@ -77,7 +77,11 @@ export const useAuthStore = defineStore('auth', () => { } async function logout(redirect: boolean = true) { - await logoutApi(); + try { + await logoutApi(); + } catch { + // 不做任何处理 + } resetAllStores(); accessStore.setLoginExpired(false); diff --git a/docs/src/components/common-ui/vben-drawer.md b/docs/src/components/common-ui/vben-drawer.md index 636ec24a901..cbd92f5dfc9 100644 --- a/docs/src/components/common-ui/vben-drawer.md +++ b/docs/src/components/common-ui/vben-drawer.md @@ -6,6 +6,14 @@ outline: deep 框架提供的抽屉组件,支持`自动高度`、`loading`等功能。 +> 如果文档内没有参数说明,可以尝试在在线示例内寻找 + +::: info 写在前面 + +如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。 + +::: + ## 基础用法 使用 `useVbenDrawer` 创建最基础的模态框。 diff --git a/docs/src/components/common-ui/vben-modal.md b/docs/src/components/common-ui/vben-modal.md index f4bb7aaf57f..26389fc6bea 100644 --- a/docs/src/components/common-ui/vben-modal.md +++ b/docs/src/components/common-ui/vben-modal.md @@ -6,6 +6,14 @@ outline: deep 框架提供的模态框组件,支持`拖拽`、`全屏`、`自动高度`、`loading`等功能。 +> 如果文档内没有参数说明,可以尝试在在线示例内寻找 + +::: info 写在前面 + +如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。 + +::: + ## 基础用法 使用 `useVbenModal` 创建最基础的模态框。 diff --git a/docs/src/components/introduction.md b/docs/src/components/introduction.md index 66e416fbc3e..039ec8cd832 100644 --- a/docs/src/components/introduction.md +++ b/docs/src/components/introduction.md @@ -2,7 +2,7 @@ ::: info README -该文档介绍的是框架组件的使用方法、属性、事件等。如果你觉得组件封装的不好,或者不符合你的需求,你可以直接使用原生的组件,或者自己封装一个组件,不需要拘泥于框架提供的组件。我们只是提供了一些常用的组件,方便你快速开发。是否使用,取决于你的需求。 +该文档介绍的是框架组件的使用方法、属性、事件等。如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。 ::: diff --git a/playground/src/store/auth.ts b/playground/src/store/auth.ts index 5c50b150ea6..39b80a27485 100644 --- a/playground/src/store/auth.ts +++ b/playground/src/store/auth.ts @@ -77,7 +77,11 @@ export const useAuthStore = defineStore('auth', () => { } async function logout(redirect: boolean = true) { - await logoutApi(); + try { + await logoutApi(); + } catch { + // 不做任何处理 + } resetAllStores(); accessStore.setLoginExpired(false);