|
|
|
@ -1,7 +1,12 @@
|
|
|
|
import type { GrantType } from '@vben/common-ui';
|
|
|
|
import type { GrantType } from '@vben/common-ui';
|
|
|
|
|
|
|
|
import type { HttpResponse } from '@vben/request';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { h } from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
import { useAppConfig } from '@vben/hooks';
|
|
|
|
import { useAppConfig } from '@vben/hooks';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Modal } from 'ant-design-vue';
|
|
|
|
|
|
|
|
|
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
|
|
|
|
|
|
|
|
const { clientId, sseEnable } = useAppConfig(
|
|
|
|
const { clientId, sseEnable } = useAppConfig(
|
|
|
|
@ -90,8 +95,32 @@ export async function loginApi(data: AuthApi.LoginParams) {
|
|
|
|
* 用户登出
|
|
|
|
* 用户登出
|
|
|
|
* @returns void
|
|
|
|
* @returns void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function doLogout() {
|
|
|
|
export async function doLogout() {
|
|
|
|
return requestClient.post<void>('/auth/logout');
|
|
|
|
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]' },
|
|
|
|
|
|
|
|
'去检查你的后端配置!别盯着前端找问题了!这不是前端问题!',
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|