diff --git a/apps/web-antd/src/api/core/auth.ts b/apps/web-antd/src/api/core/auth.ts index 989135ba..e3a99ef2 100644 --- a/apps/web-antd/src/api/core/auth.ts +++ b/apps/web-antd/src/api/core/auth.ts @@ -1,7 +1,12 @@ import type { GrantType } from '@vben/common-ui'; +import type { HttpResponse } from '@vben/request'; + +import { h } from 'vue'; import { useAppConfig } from '@vben/hooks'; +import { Modal } from 'ant-design-vue'; + import { requestClient } from '#/api/request'; const { clientId, sseEnable } = useAppConfig( @@ -90,8 +95,32 @@ export async function loginApi(data: AuthApi.LoginParams) { * 用户登出 * @returns void */ -export function doLogout() { - return requestClient.post('/auth/logout'); +export async function doLogout() { + const resp = await requestClient.post>( + '/auth/logout', + null, + { + isTransformResponse: false, + }, + ); + // 无奈之举 对错误用法的提示 + if (resp.code === 401 && import.meta.env.DEV) { + Modal.destroyAll(); + Modal.warn({ + title: '后端配置出现错误', + centered: true, + content: h('div', { class: 'flex flex-col gap-2' }, [ + `检测到你的logout接口返回了401, 导致前端一直进入循环逻辑???`, + ...Array.from({ length: 3 }, () => + h( + 'span', + { class: 'font-bold text-red-500 text-[18px]' }, + '去检查你的后端配置!别盯着前端找问题了!这不是前端问题!', + ), + ), + ]), + }); + } } /**