review: 修改 api 结构.
This commit is contained in:
@@ -53,19 +53,19 @@ axios.interceptors.response.use(
|
||||
});
|
||||
}
|
||||
// 业务判断
|
||||
if (
|
||||
[401, 700, 701, 702].includes(code) &&
|
||||
response.config.url !== '/infra/auth/login'
|
||||
) {
|
||||
if ([401, 700, 701, 702].includes(code)) {
|
||||
Notification.error({
|
||||
closable: true,
|
||||
content: res.msg,
|
||||
});
|
||||
setTimeout(async () => {
|
||||
// 登出
|
||||
await useUserStore().logout();
|
||||
window.location.reload();
|
||||
});
|
||||
// 非登录页面跳转登录页面
|
||||
if (response.config.url !== '/infra/auth/login') {
|
||||
setTimeout(async () => {
|
||||
// 登出
|
||||
await useUserStore().logout();
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
return Promise.reject(new Error(res.msg || 'Error'));
|
||||
},
|
||||
|
||||
@@ -15,14 +15,6 @@ export interface LoginResponse {
|
||||
token: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码请求
|
||||
*/
|
||||
export interface UserUpdatePasswordRequest {
|
||||
beforePassword?: string;
|
||||
password?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@@ -37,13 +29,6 @@ export function logout() {
|
||||
return axios.get('/infra/auth/logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
export function updatePassword(request: UserUpdatePasswordRequest) {
|
||||
return axios.put('/infra/auth/update-password', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
|
||||
40
orion-ops-ui/src/api/user/mine.ts
Normal file
40
orion-ops-ui/src/api/user/mine.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { LoginHistoryQueryResponse } from './operator-log';
|
||||
import type { UserQueryResponse, UserUpdateRequest } from './user';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 修改密码请求
|
||||
*/
|
||||
export interface UserUpdatePasswordRequest {
|
||||
beforePassword?: string;
|
||||
password?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改当前用户密码
|
||||
*/
|
||||
export function updateCurrentUserPassword(request: UserUpdatePasswordRequest) {
|
||||
return axios.put('/infra/mine/update-password', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户
|
||||
*/
|
||||
export function getCurrentUser() {
|
||||
return axios.get<UserQueryResponse>('/infra/mine/get-user');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前用户
|
||||
*/
|
||||
export function updateCurrentUser(request: UserUpdateRequest) {
|
||||
return axios.put('/infra/mine/update-user', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户登录日志
|
||||
*/
|
||||
export function getCurrentLoginHistory() {
|
||||
return axios.get<LoginHistoryQueryResponse[]>('/infra/mine/login-history');
|
||||
}
|
||||
|
||||
@@ -66,10 +66,3 @@ export function getOperatorLogPage(request: OperatorLogQueryRequest) {
|
||||
export function getLoginHistory(username: string) {
|
||||
return axios.get<LoginHistoryQueryResponse[]>('/infra/operator-log/login-history', { params: { username } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户登录日志
|
||||
*/
|
||||
export function getCurrentLoginHistory() {
|
||||
return axios.get<LoginHistoryQueryResponse[]>('/infra/operator-log/current-login-history');
|
||||
}
|
||||
|
||||
@@ -91,20 +91,6 @@ export function resetUserPassword(request: UserUpdateRequest) {
|
||||
return axios.put('/infra/system-user/reset-password', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户
|
||||
*/
|
||||
export function getCurrentUser() {
|
||||
return axios.get<UserQueryResponse>('/infra/system-user/get-current');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前用户
|
||||
*/
|
||||
export function updateCurrentUser(request: UserUpdateRequest) {
|
||||
return axios.put('/infra/system-user/update-current', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 id 查询用户
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user