mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 14:56:38 +08:00
feat: add user management features including user creation, editing, and role management
- Implemented user API functions for fetching, creating, updating, and managing users. - Created a UsersPage component for displaying and managing users with search and pagination. - Added types for user data and mutation payloads. - Introduced a LegacyRouteRedirect component for handling legacy routes. - Defined settings-related types for better type safety in settings management.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { apiRequest } from '@/lib/api/client';
|
||||
|
||||
import type {
|
||||
BootstrapTokenPayload,
|
||||
LatestReleaseInfo,
|
||||
OptionItem,
|
||||
SettingsProfile,
|
||||
UpdateSelfPayload,
|
||||
} from '@/features/settings/types';
|
||||
|
||||
export function getOptions() {
|
||||
return apiRequest<OptionItem[]>('/option/');
|
||||
}
|
||||
|
||||
export function updateOption(key: string, value: string) {
|
||||
return apiRequest<void>('/option/', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ key, value }),
|
||||
});
|
||||
}
|
||||
|
||||
export function getBootstrapToken() {
|
||||
return apiRequest<BootstrapTokenPayload>('/nodes/bootstrap-token');
|
||||
}
|
||||
|
||||
export function rotateBootstrapToken() {
|
||||
return apiRequest<BootstrapTokenPayload>('/nodes/bootstrap-token/rotate', {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
export function getLatestRelease() {
|
||||
return apiRequest<LatestReleaseInfo>('/update/latest-release');
|
||||
}
|
||||
|
||||
export function getSettingsProfile() {
|
||||
return apiRequest<SettingsProfile>('/user/self');
|
||||
}
|
||||
|
||||
export function updateSelf(payload: UpdateSelfPayload) {
|
||||
return apiRequest<void>('/user/self', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function generateAccessToken() {
|
||||
return apiRequest<string>('/user/token');
|
||||
}
|
||||
|
||||
export function bindWeChat(code: string) {
|
||||
return apiRequest<void>(`/oauth/wechat/bind?code=${encodeURIComponent(code)}`);
|
||||
}
|
||||
|
||||
export function bindEmail(email: string, code: string) {
|
||||
const searchParams = new URLSearchParams({ email, code });
|
||||
return apiRequest<void>(`/oauth/email/bind?${searchParams.toString()}`);
|
||||
}
|
||||
|
||||
export function getAboutContent() {
|
||||
return apiRequest<string>('/about');
|
||||
}
|
||||
Reference in New Issue
Block a user