From 9eb1c01b7b1ded152a2109d71f4147546770935d Mon Sep 17 00:00:00 2001 From: Jidekin Date: Thu, 19 Nov 2026 09:53:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(models):=20=E3=80=8CGo=20=E9=A2=9D=E5=BA=A6?= =?UTF-8?q?=E3=80=8D=E5=88=97=E5=85=A8=E7=A9=BA=20=E2=80=94=E2=80=94=20goM?= =?UTF-8?q?eta=20=E6=8C=82=E9=94=99=E6=95=B0=E7=BB=84=EF=BC=88=E4=B8=BB?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=BB=91=E7=9A=84=E6=98=AF=20modelRows?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现象:列出来了、但每一格都是「—」。 根因:模型页有**两个**行数组—— · `modelRows`(`{...m, key_set}`)—— 第 88 行 `` 真正绑的是它; · `textModelRows` —— 只用来数「全部文本模型」的条数、以及测速按钮的 id 列表。 我把 `goMeta: m.go || null` 只加在了后者,主表格的 row 上根本没有这个字段, 模板 `v-if="row.goMeta"` 永远为假 → 全部走「—」分支。 修复:把 goMeta 挂到 modelRows(并注释说明两个数组的分工,避免再踩)。 后端无需改动 —— 用临时实例(8899,隔离 users 文件)实测真实 HTTP: GET /v1/models → 200 / 28950B / 83 个模型 / 28 个带 go glm-5.3 → {'monthly_usage': {'go': 60, 'go-plus': 180, 'go-teams': 65}, 'training': False, 'zdr': True} 另外给 app/gomodels.py 补了日志(成功 INFO「已载入 N 个模型」/ 失败 WARNING 带异常), 以后这一列再空,看日志就能立刻区分「没拉到」还是「没渲染」。 --- app/gomodels.py | 7 ++++++- frontend/src/views/Models.vue | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/gomodels.py b/app/gomodels.py index 9a68019..ad3a047 100644 --- a/app/gomodels.py +++ b/app/gomodels.py @@ -27,11 +27,13 @@ from __future__ import annotations import json +import logging import threading import time import urllib.request _URL = "https://opencode.ai/inference/go/v1/models" +log = logging.getLogger("api-gateway.gomodels") _TTL = 6 * 3600 _RETRY_AFTER_FAIL = 300 _TIMEOUT = 6 @@ -85,12 +87,15 @@ def get_go_meta(force: bool = False) -> dict[str, dict]: if force or not _cache or time.time() - _at >= _TTL: try: fresh = _fetch() - except Exception: # noqa: BLE001 —— 展示数据,失败不重要 + except Exception as exc: # noqa: BLE001 —— 展示数据,失败不影响主流程 + # 2026-11-19:一定要留痕 —— 前端这一列空了,运维得能一眼看出是"没拉到"还是"没渲染" + log.warning("OpenCode Go 元数据拉取失败(前端额度/训练列会空):%s", exc) fresh = None if fresh: _cache.clear() _cache.update(fresh) _at = time.time() + log.info("OpenCode Go 元数据已载入:%d 个模型", len(fresh)) else: _at = time.time() - _TTL + _RETRY_AFTER_FAIL finally: diff --git a/frontend/src/views/Models.vue b/frontend/src/views/Models.vue index 809a630..be23973 100644 --- a/frontend/src/views/Models.vue +++ b/frontend/src/views/Models.vue @@ -532,7 +532,12 @@ const keySet = computed(() => { for (const p of Object.values(health.value.providers || {}) as any) ks[p.name] = !!p.api_key_set return ks }) -const modelRows = computed(() => models.value.map((m) => ({ ...m, key_set: keySet.value[m.provider_name] }))) +// 主表格的行数据(表格绑的就是 modelRows:`{...m}` 展开原始模型,保留全部接口字段)。 +// 2026-11-19:OpenCode Go 的套餐额度/训练列读 row.goMeta —— 必须在这里挂上, +// 只挂在 textModelRows(另一个只用来数数量/测速的数组)上表格是看不到的。 +const modelRows = computed(() => + models.value.map((m) => ({ ...m, key_set: keySet.value[m.provider_name], goMeta: m.go || null })), +) const providerRows = computed(() => { const p = health.value.providers || {}