mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-03 11:20:50 +08:00
feat: add Ampcode (Amp CLI Integration) support with configuration UI and i18n
- Add ampcodeApi service for upstream URL, API key, and model mappings management - Implement Ampcode configuration modal in AiProvidersPage - Add complete i18n translations for Ampcode features (en and zh-CN) - Enhance UsagePage with mobile-responsive chart improvements and legend display - Optimize chart rendering for smaller screens - Improve page layout styles (SystemPage, AiProvidersPage alignment)
This commit is contained in:
40
src/services/api/ampcode.ts
Normal file
40
src/services/api/ampcode.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Amp CLI Integration (ampcode) 相关 API
|
||||
*/
|
||||
|
||||
import { apiClient } from './client';
|
||||
import { normalizeAmpcodeConfig, normalizeAmpcodeModelMappings } from './transformers';
|
||||
import type { AmpcodeConfig, AmpcodeModelMapping } from '@/types';
|
||||
|
||||
export const ampcodeApi = {
|
||||
async getAmpcode(): Promise<AmpcodeConfig> {
|
||||
const data = await apiClient.get('/ampcode');
|
||||
return normalizeAmpcodeConfig(data) ?? {};
|
||||
},
|
||||
|
||||
updateUpstreamUrl: (url: string) => apiClient.put('/ampcode/upstream-url', { value: url }),
|
||||
clearUpstreamUrl: () => apiClient.delete('/ampcode/upstream-url'),
|
||||
|
||||
updateUpstreamApiKey: (apiKey: string) => apiClient.put('/ampcode/upstream-api-key', { value: apiKey }),
|
||||
clearUpstreamApiKey: () => apiClient.delete('/ampcode/upstream-api-key'),
|
||||
|
||||
updateRestrictManagementToLocalhost: (enabled: boolean) =>
|
||||
apiClient.put('/ampcode/restrict-management-to-localhost', { value: enabled }),
|
||||
|
||||
async getModelMappings(): Promise<AmpcodeModelMapping[]> {
|
||||
const data = await apiClient.get('/ampcode/model-mappings');
|
||||
const list = data?.['model-mappings'] ?? data?.modelMappings ?? data?.items ?? data;
|
||||
return normalizeAmpcodeModelMappings(list);
|
||||
},
|
||||
|
||||
saveModelMappings: (mappings: AmpcodeModelMapping[]) =>
|
||||
apiClient.put('/ampcode/model-mappings', { value: mappings }),
|
||||
patchModelMappings: (mappings: AmpcodeModelMapping[]) =>
|
||||
apiClient.patch('/ampcode/model-mappings', { value: mappings }),
|
||||
clearModelMappings: () => apiClient.delete('/ampcode/model-mappings'),
|
||||
deleteModelMappings: (fromList: string[]) =>
|
||||
apiClient.delete('/ampcode/model-mappings', { data: { value: fromList } }),
|
||||
|
||||
updateForceModelMappings: (enabled: boolean) => apiClient.put('/ampcode/force-model-mappings', { value: enabled })
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user