feat: complete T-530 cmhub URL normalization

This commit is contained in:
chengma
2026-07-06 10:31:36 +08:00
parent 42dd8a993f
commit b99019e954
14 changed files with 142 additions and 31 deletions
+9 -1
View File
@@ -1142,4 +1142,12 @@
- 代码:`DEFAULT_CONFIG.ai.backend` 改为 `cmhub`,`ai_backend()` 缺省跟随默认 backend;⑤设置页隐藏「AI 后端」下拉、direct 模型选择、模型详情和标题/图片角色下拉,普通 UI 直接展示 cmhub 网关配置;保存设置固定写 `ai.backend=cmhub`,允许先保存不完整 cmhub 配置,真正生成时仍由 `app/ai.py` 提示补齐 Base URL/API Key/别名。
- 兼容:direct 代码、`config/ai_models.json`、AI 模型测试 worker 和 direct 单测保留为内部兼容/手工回滚路径;未改 AI HTTP 协议、DB schema、Excel、Shopee/CDP 流程。
- 测试:更新 appconfig/GUI/AI 单测,direct 分支测试显式设置 `backend=direct`;②AI生成页默认显示 cmhub 余额标签。
- 验证:`python -m py_compile app\appconfig.py app\gui\tabs\settings.py app\gui\tabs\generate.py tests\test_appconfig.py tests\test_gui.py tests\test_ai.py` 通过;`python -m unittest discover -s tests -p test_appconfig.py` 通过(8 tests);`python -m unittest discover -s tests -p test_gui.py` 通过(80 tests);`python -m unittest discover -s tests -p test_ai.py` 通过(17 tests);`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(187 tests);`git diff --check` 通过,仅有本机 LF/CRLF 提示。全量 GUI 测试仍有本机 PySide6 字体目录提示,不影响结果。
- 验证:`python -m py_compile app\appconfig.py app\gui\tabs\settings.py app\gui\tabs\generate.py tests\test_appconfig.py tests\test_gui.py tests\test_ai.py` 通过;`python -m unittest discover -s tests -p test_appconfig.py` 通过(8 tests);`python -m unittest discover -s tests -p test_gui.py` 通过(80 tests);`python -m unittest discover -s tests -p test_ai.py` 通过(17 tests);`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(187 tests);`git diff --check` 通过,仅有本机 LF/CRLF 提示。全量 GUI 测试仍有本机 PySide6 字体目录提示,不影响结果。
## 【2026-07-06】T-530 完成 · cmhub Base URL 规整 + 404 明确提示
- 状态:DONE
- 代码:新增 `appconfig.normalize_cmhub_base_url()`,并让 `cmhub_request_url()`、`save_config()`、`load_config()`、`cmhub_config()` 使用规整后的网关根;⑤设置页新增 Base URL 网关根提示,保存/刷新别名前会把输入同步规整;`app/ai.py` 将 HTTP 404 / `notfound` 统一映射为 `CMHubError(code="not_found")`,显示中文排障提示。
- 边界:未改 AI HTTP 协议、DB schema、Excel、Shopee/CDP 流程;direct 兼容路径不变。
- 测试:新增 appconfig URL 规整测试、ai 404 `not_found` 测试、GUI Base URL 提示/保存归一断言。
- 验证:`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(189 tests)。全量 GUI 测试仍有本机 PySide6 字体目录提示,不影响结果。
- 下一步:T-525「引入 ruff(lint + format)+ 可选 pre-commit」。