对错误用法的提示(完全无奈...)

This commit is contained in:
dap 2025-05-18 14:28:57 +08:00
parent 96b8ae94fd
commit 79d89005b6

View File

@ -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<void>('/auth/logout');
export async function doLogout() {
const resp = await requestClient.post<HttpResponse<void>>(
'/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]' },
'去检查你的后端配置!别盯着前端找问题了!这不是前端问题!',
),
),
]),
});
}
}
/**