fix(admin): 移除前端WordPress认证调用

This commit is contained in:
sunlei 2026-05-17 17:24:56 +08:00
parent 88310e0ee1
commit 4b4e6de601
2 changed files with 6 additions and 62 deletions

View File

@ -10,6 +10,9 @@ export namespace AuthApi {
/** 登录接口返回值 */
export interface LoginResult {
accessToken: string;
wordpressAuth?: WordpressAuthResult['auth'] & {
user?: Record<string, any>;
};
}
export interface RefreshTokenResult {
@ -26,17 +29,6 @@ export namespace AuthApi {
}
}
interface ApiSuccessResponse<T> {
code: number;
data: T;
msg: string;
}
interface RawApiResponse<T> {
data: ApiSuccessResponse<T>;
status: number;
}
/**
*
*/
@ -72,36 +64,6 @@ export async function logoutApi() {
);
}
/**
* WordPress
*/
export async function wordpressLoginApi() {
const response = await baseRequestClient.post<
RawApiResponse<AuthApi.WordpressAuthResult>
>(
'/wordpress/auth/login',
{},
{
withCredentials: true,
},
);
return response.data.data;
}
/**
* WordPress
*/
export async function wordpressLogoutApi() {
return baseRequestClient.post(
'/wordpress/auth/logout',
{},
{
withCredentials: true,
},
);
}
/**
*
*/

View File

@ -10,14 +10,7 @@ import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
import { notification } from 'antdv-next';
import { defineStore } from 'pinia';
import {
getAccessCodesApi,
getUserInfoApi,
loginApi,
logoutApi,
wordpressLoginApi,
wordpressLogoutApi,
} from '#/api';
import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi } from '#/api';
import { $t } from '#/locales';
export const useAuthStore = defineStore('auth', () => {
@ -111,7 +104,7 @@ export const useAuthStore = defineStore('auth', () => {
let userInfo: null | UserInfo = null;
try {
loginLoading.value = true;
const { accessToken } = await loginApi(params);
const { accessToken, wordpressAuth } = await loginApi(params);
// 如果成功获取到 accessToken
if (accessToken) {
@ -122,16 +115,12 @@ export const useAuthStore = defineStore('auth', () => {
fetchUserInfo(),
getAccessCodesApi(),
]);
const wordpressAuth = await wordpressLoginApi();
userInfo = fetchUserInfoResult;
userStore.setUserInfo(userInfo);
accessStore.setAccessCodes(accessCodes);
accessStore.setWordpressAuth({
...wordpressAuth.auth,
user: wordpressAuth.user,
});
accessStore.setWordpressAuth(wordpressAuth || null);
if (accessStore.loginExpired) {
accessStore.setLoginExpired(false);
@ -158,7 +147,6 @@ export const useAuthStore = defineStore('auth', () => {
userStore.setUserInfo(null);
try {
await wordpressLogoutApi();
await logoutApi();
} catch {
// 不做任何处理
@ -180,12 +168,6 @@ export const useAuthStore = defineStore('auth', () => {
if (isLoggingOut.value) return; // 正在登出中, 说明已进入循环, 直接返回.
isLoggingOut.value = true; // 设置 标识
try {
await wordpressLogoutApi();
} catch {
// 不做任何处理
}
try {
await logoutApi();
} catch {