test: web
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import request from './index';
|
||||
import type { DashboardStats } from '@/types/models';
|
||||
|
||||
export const getDashboardStats = (): Promise<DashboardStats> => {
|
||||
return request.get('/dashboard/stats');
|
||||
export const getDashboardData = (timeRange: string, groupId: number | null): Promise<DashboardStats> => {
|
||||
const params = new URLSearchParams();
|
||||
params.append('time_range', timeRange);
|
||||
if (groupId) {
|
||||
params.append('group_id', groupId.toString());
|
||||
}
|
||||
return request.get(`/dashboard/data?${params.toString()}`);
|
||||
};
|
@@ -20,7 +20,7 @@ export const fetchGroup = (id: string): Promise<Group> => {
|
||||
* 创建一个新的分组
|
||||
* @param groupData 新分组的数据
|
||||
*/
|
||||
export const createGroup = (groupData: Omit<Group, 'id' | 'created_at' | 'updated_at'>): Promise<Group> => {
|
||||
export const createGroup = (groupData: Omit<Group, 'id' | 'created_at' | 'updated_at' | 'api_keys'>): Promise<Group> => {
|
||||
return apiClient.post('/groups', groupData).then(res => res.data.data);
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ export const createGroup = (groupData: Omit<Group, 'id' | 'created_at' | 'update
|
||||
* @param id 分组ID
|
||||
* @param groupData 要更新的数据
|
||||
*/
|
||||
export const updateGroup = (id: string, groupData: Partial<Omit<Group, 'id' | 'created_at' | 'updated_at'>>): Promise<Group> => {
|
||||
export const updateGroup = (id: string, groupData: Partial<Omit<Group, 'id' | 'created_at' | 'updated_at' | 'api_keys'>>): Promise<Group> => {
|
||||
return apiClient.put(`/groups/${id}`, groupData).then(res => res.data.data);
|
||||
};
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import apiClient from './index';
|
||||
import type { Key } from '../types/models';
|
||||
import apiClient from "./index";
|
||||
import type { Key } from "../types/models";
|
||||
|
||||
/**
|
||||
* 获取指定分组下的所有密钥列表
|
||||
* @param groupId 分组ID
|
||||
*/
|
||||
export const fetchKeysInGroup = (groupId: string): Promise<Key[]> => {
|
||||
return apiClient.get(`/groups/${groupId}/keys`).then(res => res.data.data);
|
||||
return apiClient.get(`/groups/${groupId}/keys`).then((res) => res.data.data);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -14,8 +14,21 @@ export const fetchKeysInGroup = (groupId: string): Promise<Key[]> => {
|
||||
* @param groupId 分组ID
|
||||
* @param keyData 新密钥的数据
|
||||
*/
|
||||
export const createKey = (groupId: string, keyData: Omit<Key, 'id' | 'group_id' | 'usage' | 'created_at' | 'updated_at'>): Promise<Key> => {
|
||||
return apiClient.post(`/groups/${groupId}/keys`, keyData).then(res => res.data.data);
|
||||
export const createKey = (
|
||||
groupId: string,
|
||||
keyData: Omit<
|
||||
Key,
|
||||
| "id"
|
||||
| "group_id"
|
||||
| "created_at"
|
||||
| "updated_at"
|
||||
| "request_count"
|
||||
| "failure_count"
|
||||
>
|
||||
): Promise<Key> => {
|
||||
return apiClient
|
||||
.post(`/groups/${groupId}/keys`, keyData)
|
||||
.then((res) => res.data.data);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -23,8 +36,8 @@ export const createKey = (groupId: string, keyData: Omit<Key, 'id' | 'group_id'
|
||||
* @param id 密钥ID
|
||||
* @param keyData 要更新的数据
|
||||
*/
|
||||
export const updateKey = (id: string, keyData: Partial<Omit<Key, 'id' | 'group_id' | 'usage' | 'created_at' | 'updated_at'>>): Promise<Key> => {
|
||||
return apiClient.put(`/keys/${id}`, keyData).then(res => res.data.data);
|
||||
export const updateKey = (id: string, keyData: Partial<Key>): Promise<Key> => {
|
||||
return apiClient.put(`/keys/${id}`, keyData).then((res) => res.data.data);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -32,5 +45,27 @@ export const updateKey = (id: string, keyData: Partial<Omit<Key, 'id' | 'group_i
|
||||
* @param id 密钥ID
|
||||
*/
|
||||
export const deleteKey = (id: string): Promise<void> => {
|
||||
return apiClient.delete(`/keys/${id}`).then(res => res.data);
|
||||
};
|
||||
return apiClient.delete(`/keys/${id}`).then((res) => res.data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量更新密钥
|
||||
* @param ids 密钥ID列表
|
||||
* @param data 要更新的数据
|
||||
*/
|
||||
export const batchUpdateKeys = (
|
||||
ids: string[],
|
||||
data: Partial<Key>
|
||||
): Promise<void> => {
|
||||
return apiClient
|
||||
.post("/keys/batch-update", { ids, data })
|
||||
.then((res) => res.data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除密钥
|
||||
* @param ids 密钥ID列表
|
||||
*/
|
||||
export const batchDeleteKeys = (ids: string[]): Promise<void> => {
|
||||
return apiClient.post("/keys/batch-delete", { ids }).then((res) => res.data);
|
||||
};
|
||||
|
@@ -1,10 +1,22 @@
|
||||
import request from './index';
|
||||
import type { Setting } from '@/types/models';
|
||||
import type { SettingCategory, SystemSettings } from '@/types/models';
|
||||
|
||||
export function getSettings() {
|
||||
return request.get<Setting[]>('/settings');
|
||||
// A generic function to get settings for a specific category
|
||||
export function getSettings<T>(category: SettingCategory) {
|
||||
// The backend API would need to support this, e.g., /api/settings/system
|
||||
return request.get<T>(`/settings/${category}`);
|
||||
}
|
||||
|
||||
export function updateSettings(settings: Setting[]) {
|
||||
return request.put('/settings', settings);
|
||||
// A generic function to update settings for a specific category
|
||||
export function updateSettings<T>(category: SettingCategory, settings: T) {
|
||||
return request.put(`/settings/${category}`, settings);
|
||||
}
|
||||
|
||||
// Specific functions for system settings as an example
|
||||
export function getSystemSettings() {
|
||||
return getSettings<SystemSettings>('system');
|
||||
}
|
||||
|
||||
export function updateSystemSettings(settings: SystemSettings) {
|
||||
return updateSettings('system', settings);
|
||||
}
|
Reference in New Issue
Block a user