✨ feat(providers): 新增 OpenRouter 内置服务商支持 - #21
Merged
Conversation
新增功能: - 模型列表获取:OpenAI 兼容 GET /models 候选探测(含智谱 /api/paas/v4 特例端点),编辑页"获取模型列表"按钮 + 右侧下拉选择 - 供应商表单新增接口协议展示(Responses 原生)与模型输入框,模型值与编辑器顶层 model 行双向同步 修复: - auth.json 标签页按认证语义显示:第三方档不再显示空的 auth 死标签(resolveAuthSource 修复 ?? 吞 null) - 修复 patchModelValue 在 model_provider 前置的配置上重复插入 model 行(TOML 非法重复键),并自动收敛历史污染 - 修复 AppSelect 翻转判定高估菜单高度导致误向上展开;展开期间菜单滚轮不穿透、背景滚动自动收起 预设修正: - OpenCode 预设对齐 cc-switch:默认 glm-5.2、disable_response_storage、内置 6 模型目录(21 字段全量) - 自定义模板:config 补 base_url/disable_response_storage 行,models.json 模板修正为 Codex 目录格式(slug + 必填字段)
- 新增 `openrouter.toml` 模板,配置 Responses API 接入并禁用响应存储 - 在 Rust 内置模板注册表中添加 OpenRouter 条目及对应单测断言 - 更新 SVG 图标为黑色描边版本,并加入主题反色图标列表 - 前端 `icons.ts` 与 `presets.ts` 补充 OpenRouter 图标标签与默认预设
- 新增 `mimo.toml` 配置模板与 `mimo-models.json` 模型目录,启用 Responses API 并禁用联网搜索。 - 登记 `KIND_MIMO` 常量与内置模板 `小米 MiMo`,使用 `xiaomi-mimo` 图标。 - 在 `builtin.rs` 中嵌入配置/模型字节,并补充单测校验目录形状(拒绝 freeform 工具、推理档位 none/high、上下文窗口与图像输入差异)。 - 前端 `presets.ts` 同步新增 MiMo 预设,包含基础 URL、模型值与配置片段。
- 新增后端 `get_builtin_config` 命令,返回内置供应商 config.toml 原文模板。 - 前端 `ProfileEdit` 通过 IPC 拉取模板,删除前端 `BuiltinPreset.fragment` / `model_values` 字段,移除模板双份维护。 - `presets.ts` 仅保留展示元数据(图标/provider/URL/模型名等),由 `BUILTINS_WITH_CATALOG` 集合替代硬编码的 `model_catalog_json` 判断。 - `web-mock` 新增 `mockBuiltinFragment` 合成前端预览所需的最小模板,保持浏览器调试模式可用。 - 切换预设时改为异步拉取模板并一次性更新所有状态,避免中间态触发 `configText !== liveConfigFragment` 误判。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动概要
为 CGswitch 接入新的内置服务商 OpenRouter,使其在提供商列表中以开箱即用的方式出现,与既有的 OpenAI / Anthropic / DeepSeek 等内置条目拥有相同的注册与图标路径。
改动清单
src-tauri/assets/builtin/openrouter.tomlwire_api = "responses",与现有 Responses 路径一致store = false,避免 OpenRouter 侧留存响应src-tauri/src/builtin.rssrc/assets/providers/openrouter.svgsrc/icons.ts:补充 OpenRouter 图标映射与主题反色标签src/presets.ts:在默认服务商列表中加入 OpenRouter 预设验证
src-tauri/src/builtin.rs内新增的单测覆盖 OpenRouter 解析路径AGENTS.md流程在pnpm dev:tauri窗口内由人工确认(此次改动未触及共享栏位或页面首块几何)备注
src-tauri/assets/builtin/mimo.toml(个人配置,含 API Key 占位符),未纳入本 PRpnpm-lock.yaml/Cargo.lock变更,无需重启 dev 会话