mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
4f8970ff5c
- 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.
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
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');
|
|
}
|