Skip to content

Commit df48409

Browse files
authored
fix: when the api returns 401, the page is refreshed not as expected (#4440)
1 parent 4765158 commit df48409

7 files changed

Lines changed: 37 additions & 5 deletions

File tree

‎apps/web-antd/src/store/auth.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ export const useAuthStore = defineStore('auth', () => {
7676
}
7777

7878
async function logout(redirect: boolean = true) {
79-
await logoutApi();
79+
try {
80+
await logoutApi();
81+
} catch {
82+
// 不做任何处理
83+
}
8084
resetAllStores();
8185
accessStore.setLoginExpired(false);
8286

‎apps/web-ele/src/store/auth.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ export const useAuthStore = defineStore('auth', () => {
7777
}
7878

7979
async function logout(redirect: boolean = true) {
80-
await logoutApi();
80+
try {
81+
await logoutApi();
82+
} catch {
83+
// 不做任何处理
84+
}
8185
resetAllStores();
8286
accessStore.setLoginExpired(false);
8387

‎apps/web-naive/src/store/auth.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ export const useAuthStore = defineStore('auth', () => {
7777
}
7878

7979
async function logout(redirect: boolean = true) {
80-
await logoutApi();
80+
try {
81+
await logoutApi();
82+
} catch {
83+
// 不做任何处理
84+
}
8185
resetAllStores();
8286
accessStore.setLoginExpired(false);
8387

‎docs/src/components/common-ui/vben-drawer.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ outline: deep
66

77
框架提供的抽屉组件,支持`自动高度`、`loading`等功能。
88

9+
> 如果文档内没有参数说明,可以尝试在在线示例内寻找
10+
11+
::: info 写在前面
12+
13+
如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
14+
15+
:::
16+
917
## 基础用法
1018

1119
使用 `useVbenDrawer` 创建最基础的模态框。

‎docs/src/components/common-ui/vben-modal.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ outline: deep
66

77
框架提供的模态框组件,支持`拖拽`、`全屏`、`自动高度`、`loading`等功能。
88

9+
> 如果文档内没有参数说明,可以尝试在在线示例内寻找
10+
11+
::: info 写在前面
12+
13+
如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
14+
15+
:::
16+
917
## 基础用法
1018

1119
使用 `useVbenModal` 创建最基础的模态框。

‎docs/src/components/introduction.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
::: info README
44

5-
该文档介绍的是框架组件的使用方法、属性、事件等。如果你觉得组件封装的不好,或者不符合你的需求,你可以直接使用原生的组件,或者自己封装一个组件,不需要拘泥于框架提供的组件。我们只是提供了一些常用的组件,方便你快速开发。是否使用,取决于你的需求。
5+
该文档介绍的是框架组件的使用方法、属性、事件等。如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
66

77
:::
88

‎playground/src/store/auth.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ export const useAuthStore = defineStore('auth', () => {
7777
}
7878

7979
async function logout(redirect: boolean = true) {
80-
await logoutApi();
80+
try {
81+
await logoutApi();
82+
} catch {
83+
// 不做任何处理
84+
}
8185

8286
resetAllStores();
8387
accessStore.setLoginExpired(false);

0 commit comments

Comments
 (0)