mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-03 03:10:50 +08:00
76 lines
1.8 KiB
TypeScript
76 lines
1.8 KiB
TypeScript
/**
|
|
* 配置相关 API
|
|
*/
|
|
|
|
import { apiClient } from './client';
|
|
import type { Config } from '@/types';
|
|
import { normalizeConfigResponse } from './transformers';
|
|
|
|
export const configApi = {
|
|
/**
|
|
* 获取配置(会进行字段规范化)
|
|
*/
|
|
async getConfig(): Promise<Config> {
|
|
const raw = await apiClient.get('/config');
|
|
return normalizeConfigResponse(raw);
|
|
},
|
|
|
|
/**
|
|
* 获取原始配置(不做转换)
|
|
*/
|
|
getRawConfig: () => apiClient.get('/config'),
|
|
|
|
/**
|
|
* 更新 Debug 模式
|
|
*/
|
|
updateDebug: (enabled: boolean) => apiClient.put('/debug', { value: enabled }),
|
|
|
|
/**
|
|
* 更新代理 URL
|
|
*/
|
|
updateProxyUrl: (proxyUrl: string) => apiClient.put('/proxy-url', { value: proxyUrl }),
|
|
|
|
/**
|
|
* 清除代理 URL
|
|
*/
|
|
clearProxyUrl: () => apiClient.delete('/proxy-url'),
|
|
|
|
/**
|
|
* 更新重试次数
|
|
*/
|
|
updateRequestRetry: (retryCount: number) => apiClient.put('/request-retry', { value: retryCount }),
|
|
|
|
/**
|
|
* 配额回退:切换项目
|
|
*/
|
|
updateSwitchProject: (enabled: boolean) =>
|
|
apiClient.put('/quota-exceeded/switch-project', { value: enabled }),
|
|
|
|
/**
|
|
* 配额回退:切换预览模型
|
|
*/
|
|
updateSwitchPreviewModel: (enabled: boolean) =>
|
|
apiClient.put('/quota-exceeded/switch-preview-model', { value: enabled }),
|
|
|
|
/**
|
|
* 使用统计开关
|
|
*/
|
|
updateUsageStatistics: (enabled: boolean) =>
|
|
apiClient.put('/usage-statistics-enabled', { value: enabled }),
|
|
|
|
/**
|
|
* 请求日志开关
|
|
*/
|
|
updateRequestLog: (enabled: boolean) => apiClient.put('/request-log', { value: enabled }),
|
|
|
|
/**
|
|
* 写日志到文件开关
|
|
*/
|
|
updateLoggingToFile: (enabled: boolean) => apiClient.put('/logging-to-file', { value: enabled }),
|
|
|
|
/**
|
|
* WebSocket 鉴权开关
|
|
*/
|
|
updateWsAuth: (enabled: boolean) => apiClient.put('/ws-auth', { value: enabled }),
|
|
};
|