yiranxiaohui Claude Opus 4.7 (1M context) commited on
Commit
2f65061
·
1 Parent(s): 63bfd99

fix(sub2api): 分组列表不再按 platform 过滤

Browse files

- list_remote_groups 去掉 platform=openai 查询参数,拉取全部分组
- 返回 DTO 增加 platform 字段
- 前端下拉项显示 platform 标签,方便用户识别(如 openai / claude / gemini)

Why: sub2api 的分组有严格平台字段,若用户只建了 Claude 分组或跨平台分组会被过滤为空。让前端列出全部,由用户自行选择。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

services/sub2api_service.py CHANGED
@@ -325,7 +325,6 @@ def list_remote_groups(server: dict) -> list[dict]:
325
  f"{base_url.rstrip('/')}/api/v1/admin/groups",
326
  headers=headers,
327
  params={
328
- "platform": "openai",
329
  "page": page,
330
  "page_size": 200,
331
  },
@@ -349,6 +348,7 @@ def list_remote_groups(server: dict) -> list[dict]:
349
  "id": str(group_id),
350
  "name": _clean(group.get("name")),
351
  "description": _clean(group.get("description")),
 
352
  "status": _clean(group.get("status")),
353
  "account_count": int(group.get("account_count") or 0),
354
  "active_account_count": int(group.get("active_account_count") or 0),
 
325
  f"{base_url.rstrip('/')}/api/v1/admin/groups",
326
  headers=headers,
327
  params={
 
328
  "page": page,
329
  "page_size": 200,
330
  },
 
348
  "id": str(group_id),
349
  "name": _clean(group.get("name")),
350
  "description": _clean(group.get("description")),
351
+ "platform": _clean(group.get("platform")),
352
  "status": _clean(group.get("status")),
353
  "account_count": int(group.get("account_count") or 0),
354
  "active_account_count": int(group.get("active_account_count") or 0),
web/src/app/settings/components/sub2api-connections.tsx CHANGED
@@ -205,7 +205,7 @@ export function Sub2APIConnections() {
205
  const data = await fetchSub2APIServerGroups(editingServer.id);
206
  setRemoteGroups(data.groups);
207
  if (data.groups.length === 0) {
208
- toast.message("远端没有 platform=openai 的分组");
209
  } else {
210
  toast.success(`读取到 ${data.groups.length} 个分组`);
211
  }
@@ -667,8 +667,9 @@ export function Sub2APIConnections() {
667
  {remoteGroups.map((group) => (
668
  <SelectItem key={group.id} value={group.id}>
669
  {group.name || `Group ${group.id}`}
 
670
  {group.account_count
671
- ? `${group.active_account_count}/${group.account_count}`
672
  : ""}
673
  </SelectItem>
674
  ))}
 
205
  const data = await fetchSub2APIServerGroups(editingServer.id);
206
  setRemoteGroups(data.groups);
207
  if (data.groups.length === 0) {
208
+ toast.message("远端没有配置分组");
209
  } else {
210
  toast.success(`读取到 ${data.groups.length} 个分组`);
211
  }
 
667
  {remoteGroups.map((group) => (
668
  <SelectItem key={group.id} value={group.id}>
669
  {group.name || `Group ${group.id}`}
670
+ {group.platform ? `(${group.platform})` : ""}
671
  {group.account_count
672
+ ? ` · ${group.active_account_count}/${group.account_count}`
673
  : ""}
674
  </SelectItem>
675
  ))}
web/src/lib/api.ts CHANGED
@@ -233,6 +233,7 @@ export type Sub2APIRemoteGroup = {
233
  id: string;
234
  name: string;
235
  description: string;
 
236
  status: string;
237
  account_count: number;
238
  active_account_count: number;
 
233
  id: string;
234
  name: string;
235
  description: string;
236
+ platform: string;
237
  status: string;
238
  account_count: number;
239
  active_account_count: number;