From a58e2a65024c85936c55aef02431fd0710acf8e1 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Fri, 30 Jan 2026 09:39:36 +0800 Subject: [PATCH] feat: add S2A API client for dashboard, account, group, and proxy management with backend proxy handling. --- frontend/src/api/s2a.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/s2a.ts b/frontend/src/api/s2a.ts index 11ae1ad..c230b87 100644 --- a/frontend/src/api/s2a.ts +++ b/frontend/src/api/s2a.ts @@ -42,7 +42,19 @@ export class S2AClient { ) } - return response.json() + const json = await response.json() + + // S2A API 返回格式: { code: 0, message: "success", data: {...} } + // 需要提取 data 字段 + if (json && typeof json === 'object' && 'code' in json && 'data' in json) { + if (json.code !== 0) { + throw new Error(json.message || 'API error') + } + return json.data as T + } + + // 如果不是标准格式,直接返回 + return json as T } // Dashboard APIs