mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 14:26:36 +08:00
[优化] 格式化
This commit is contained in:
@@ -1,41 +1,43 @@
|
||||
import { apiRequest } from '@/lib/api/client';
|
||||
|
||||
import type {
|
||||
ManageUserAction,
|
||||
ManageUserResult,
|
||||
UserItem,
|
||||
UserMutationPayload,
|
||||
} from '@/features/users/types';
|
||||
|
||||
export function getUsers(page: number) {
|
||||
return apiRequest<UserItem[]>(`/user/?p=${page}`);
|
||||
}
|
||||
|
||||
export function searchUsers(keyword: string) {
|
||||
return apiRequest<UserItem[]>(`/user/search?keyword=${encodeURIComponent(keyword)}`);
|
||||
}
|
||||
|
||||
export function getUser(id: number) {
|
||||
return apiRequest<UserItem>(`/user/${id}`);
|
||||
}
|
||||
|
||||
export function createUser(payload: UserMutationPayload) {
|
||||
return apiRequest<void>('/user/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
import { apiRequest } from '@/lib/api/client';
|
||||
|
||||
import type {
|
||||
ManageUserAction,
|
||||
ManageUserResult,
|
||||
UserItem,
|
||||
UserMutationPayload,
|
||||
} from '@/features/users/types';
|
||||
|
||||
export function getUsers(page: number) {
|
||||
return apiRequest<UserItem[]>(`/user/?p=${page}`);
|
||||
}
|
||||
|
||||
export function searchUsers(keyword: string) {
|
||||
return apiRequest<UserItem[]>(
|
||||
`/user/search?keyword=${encodeURIComponent(keyword)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function getUser(id: number) {
|
||||
return apiRequest<UserItem>(`/user/${id}`);
|
||||
}
|
||||
|
||||
export function createUser(payload: UserMutationPayload) {
|
||||
return apiRequest<void>('/user/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateUser(payload: UserMutationPayload & { id: number }) {
|
||||
return apiRequest<void>('/user/update', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function manageUser(username: string, action: ManageUserAction) {
|
||||
return apiRequest<ManageUserResult>('/user/manage', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ username, action }),
|
||||
});
|
||||
}
|
||||
|
||||
export function manageUser(username: string, action: ManageUserAction) {
|
||||
return apiRequest<ManageUserResult>('/user/manage', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ username, action }),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user