♻️ refactor(channels): rebuild channel create/edit drawer with modular sections and improved form UX

Restructure the default-theme channel create/edit experience to align with
classic frontend behavior, modern form UX patterns, and the project's Base UI
design system.

Channel editor architecture:
- Split the monolithic channel mutate drawer into focused section components
  (basic, API access, auth, models, advanced) with shared drawer layout
  primitives
- Extract submission, toast handling, and react-query cache invalidation into
  `useChannelMutateForm`
- Add a dedicated loading skeleton for channel detail fetch during edit mode
- Remove the top-level configuration summary block per UX feedback

Form validation and data handling:
- Strengthen `channel-form` Zod schema with JSON, model mapping, status code
  mapping, Codex credential, and Vertex AI key refinements
- Move type-specific conditional validation into `superRefine`
- Normalize base URL formatting and tighten model mapping value validation

Model mapping editor:
- Add Visual/JSON tabbed editing with inline JSON and duplicate-key feedback
- Improve accessibility for icon-only actions and add model suggestion datalists

MultiSelect component:
- Replace the custom cmdk-based implementation with Base UI Combobox chips
- Align focus, border, ring, disabled, and invalid states with standard Input
  styling via `ComboboxChips`
- Preserve existing API (`options`, `selected`, `onChange`, `allowCreate`,
  `createLabel`) for all current callers
- Support inline custom value creation, comma/newline batch input, searchable
  options, portal-based dropdown positioning, and chip removal

Models & groups UX:
- Integrate manual custom model entry directly into the model MultiSelect
- Remove the separate manual model input/button block
- Keep selected-model count and existing model-mapping guardrail behavior

i18n:
- Add and sync translation keys for new editor sections, validation messages,
  model mapping UI, and MultiSelect empty/create labels across en, zh, fr, ja,
  ru, and vi
- Remove obsolete keys tied to the deprecated summary and manual model entry UI

Affected areas:
- `web/default/src/features/channels/components/drawers/`
- `web/default/src/features/channels/hooks/use-channel-mutate-form.ts`
- `web/default/src/features/channels/lib/channel-form.ts`
- `web/default/src/features/channels/lib/model-mapping-validation.ts`
- `web/default/src/features/channels/components/model-mapping-editor.tsx`
- `web/default/src/components/multi-select.tsx`
- `web/default/src/i18n/locales/*.json`
This commit is contained in:
t0ng7u
2026-05-26 01:22:49 +08:00
parent 583da45296
commit 3d850d38b6
19 changed files with 3465 additions and 2478 deletions
+35 -14
View File
@@ -37,7 +37,6 @@
"{{count}} IP(s)": "{{count}} 个 IP",
"{{count}} log entries removed.": "已删除 {{count}} 条日志。",
"{{count}} minutes ago": "{{count}} 分钟前",
"{{count}} model(s)": "{{count}} 个模型",
"{{count}} models": "{{count}} 个模型",
"{{count}} months ago": "{{count}} 个月前",
"{{count}} override": "{{count}} 个覆盖",
@@ -135,6 +134,7 @@
"Actual Model": "实际模型",
"Actual Model:": "实际模型:",
"Add": "添加",
"Add \"{{value}}\"": "添加 \"{{value}}\"",
"Add {{title}}": "添加{{title}}",
"Add a group identifier to the auto assignment list.": "将分组标识符添加到自动分配列表。",
"Add a new API key by providing necessary info.": "通过提供必要信息添加新的 API 密钥。",
@@ -152,7 +152,7 @@
"Add condition": "新增条件",
"Add Condition": "添加条件",
"Add credits": "添加额度",
"Add custom model(s), comma-separated": "添加自定义模型(多个以逗号分隔)",
"Add custom model \"{{value}}\"": "添加自定义模型“{{value}}”",
"Add discount tier": "添加折扣等级",
"Add each model or tag you want to include.": "添加您想要包含的每个模型或标签。",
"Add FAQ": "添加问答",
@@ -164,6 +164,7 @@
"Add group rules": "添加分组规则",
"Add Mapping": "添加映射",
"Add method": "添加方法",
"Add missing models": "添加缺失模型",
"Add Mode": "添加模式",
"Add model": "添加模型",
"Add Model": "添加模型",
@@ -192,7 +193,6 @@
"Add User": "添加用户",
"Add user group": "添加用户分组",
"Add your API keys, set up channels and configure access permissions": "添加 API 密钥,设置渠道并配置访问权限",
"Added {{count}} custom model(s)": "已添加 {{count}} 个自定义模型",
"Added {{count}} model(s)": "已添加 {{count}} 个模型",
"Added successfully": "新增成功",
"Additional Conditions": "附加条件",
@@ -201,8 +201,8 @@
"Additional Limit": "附加额度",
"Additional Limits": "附加额度",
"Additional metered capability": "附加计费能力",
"Adjust Quota": "调整额度",
"Adjust filters, then search to refresh the logs.": "调整筛选条件,然后搜索以刷新日志。",
"Adjust Quota": "调整额度",
"Adjust response formatting, prompt behavior, proxy, and upstream automation.": "调整响应格式、提示词行为、代理和上游自动化。",
"Adjust the appearance and layout to suit your preferences.": "调整外观和布局以适应您的偏好。",
"Admin": "管理员",
@@ -424,6 +424,11 @@
"Audio Tokens": "语音 Token",
"Auth configured": "认证已配置",
"Auth Style": "认证方式",
"auth.resetPasswordConfirm.backToLogin": "返回登录",
"auth.resetPasswordConfirm.confirm": "确认重置密码",
"auth.resetPasswordConfirm.description": "确认重置请求以生成新密码。",
"auth.resetPasswordConfirm.retry": "重试 ({{seconds}}s)",
"auth.resetPasswordConfirm.success": "您的密码已成功重置",
"Authentication": "身份验证",
"Authenticator code": "身份验证器代码",
"Authorization Endpoint": "授权端点",
@@ -502,6 +507,7 @@
"Base Price": "基础价格",
"Base rate limit windows for this account.": "当前账号的基础额度窗口。",
"Base URL": "API 地址",
"Base URL is required for this channel type": "此渠道类型需要填写 Base URL",
"Base URL of your Uptime Kuma instance": "您的 Uptime Kuma 实例的基础 URL",
"Basic Authentication": "基本身份验证",
"Basic Configuration": "基本配置",
@@ -759,8 +765,10 @@
"Codex": "Codex",
"Codex Account & Usage": "Codex 账户和用量",
"Codex Authorization": "Codex 授权",
"Codex channels do not support batch creation": "Codex 渠道不支持批量创建",
"Codex channels use an OAuth JSON credential as the key.": "Codex 频道使用 OAuth JSON 凭据作为密钥。",
"Codex CLI Header Passthrough": "Codex CLI 请求头透传",
"Codex credential must be a JSON object with access_token and account_id": "Codex 凭据必须是包含 access_token 和 account_id 的 JSON 对象",
"Cohere": "Cohere",
"Collapse": "收起",
"Collapse All": "全部收起",
@@ -867,8 +875,6 @@
"Confirm New Password": "确认新密码",
"Confirm password": "确认密码",
"Confirm Payment": "确认付款",
"auth.resetPasswordConfirm.confirm": "确认重置密码",
"auth.resetPasswordConfirm.description": "确认重置请求以生成新密码。",
"Confirm Selection": "确认选择",
"Confirm settings and finish setup": "确认设置并完成安装",
"confirm that I bear legal responsibility arising from deployment": "确认我承担因部署产生的法律责任",
@@ -999,6 +1005,7 @@
"Create, revoke, and audit API tokens.": "创建、撤销和审计 API 令牌。",
"Created": "创建时间",
"Created At": "创建时间",
"Creates a Pancake product in the saved store using this plans title and price. Requires Waffo Pancake to be fully configured in Payment settings first.": "使用此套餐的标题和价格,在已保存的店铺中创建 Pancake 产品。需要先在支付设置中完整配置 Waffo Pancake。",
"Creating...": "创建中...",
"Creation failed": "创建失败",
"Credential generated": "凭据已生成",
@@ -1122,6 +1129,7 @@
"Delete invalid redemption codes": "删除无效兑换码",
"Delete Invalid Redemption Codes?": "删除无效的兑换码?",
"Delete logs": "删除日志",
"Delete mapping": "删除映射",
"Delete Model": "删除模型",
"Delete Models?": "删除模型?",
"Delete Provider": "删除提供商",
@@ -1249,6 +1257,8 @@
"Drawing task records": "绘图任务记录",
"Duplicate": "重复",
"Duplicate group names: {{names}}": "存在重复的分组名称:{{names}}",
"Duplicate source model mappings are not allowed": "不允许重复的源模型映射",
"Duplicate source model(s): {{models}}": "重复的源模型:{{models}}",
"Duration": "耗时",
"Duration (hours)": "时长 (小时)",
"Duration Settings": "有效期设置",
@@ -1935,7 +1945,7 @@
"How client credentials are sent to the token endpoint": "客户端凭据如何发送至令牌端点",
"How frequently the system tests all channels": "系统测试所有渠道的频率",
"How It Works": "工作流程",
"How model mapping works": "模型映射的工作原理",
"How model mapping works": "模型映射如何工作",
"How much to charge for each US dollar of balance (Epay)": "每美元余额(Epay)的收费金额",
"How this model name should match requests": "此模型名称应如何匹配请求",
"How to deliver the resulting image": "图像结果的返回方式",
@@ -2177,6 +2187,7 @@
"Load template...": "加载模板...",
"Loader": "加载器",
"Loading": "加载中",
"Loading channel details": "正在加载渠道详情",
"Loading configuration": "正在加载配置",
"Loading content settings...": "正在加载内容设置...",
"Loading current models...": "正在加载当前模型...",
@@ -2293,7 +2304,6 @@
"Minimum:": "最低:",
"Minor blips in the last 30 days": "近 30 天内有轻微抖动",
"Mint a fresh pair below — or pick an existing one further down. Click Save when ready.": "在下方创建新的配对,或继续向下选择已有配对。准备好后点击保存。",
"Creates a Pancake product in the saved store using this plans title and price. Requires Waffo Pancake to be fully configured in Payment settings first.": "使用此套餐的标题和价格,在已保存的店铺中创建 Pancake 产品。需要先在支付设置中完整配置 Waffo Pancake。",
"Minute": "分钟",
"minutes": "分钟",
"Missing code": "缺少代码",
@@ -2324,7 +2334,9 @@
"Model Mapping": "模型映射",
"Model Mapping (JSON)": "模型映射 (JSON)",
"Model Mapping must be a JSON object like": "模型映射必须是如下所示的 JSON 对象",
"Model mapping must be a JSON object with string values": "模型映射必须是值为字符串的 JSON 对象",
"Model mapping must be valid JSON": "模型映射必须是有效的 JSON",
"Model mapping values must be strings": "模型映射的值必须是字符串",
"Model name": "模型名称",
"Model Name": "模型名称",
"Model Name *": "模型名称 *",
@@ -2333,8 +2345,8 @@
"Model not found": "模型未找到",
"Model performance metrics": "模型性能指标",
"Model Price": "模型价格",
"Model Price Not Configured": "模型价格未配置",
"Model price is not configured. Please complete model pricing in settings.": "模型价格未配置,请前往设置补充模型价格。",
"Model Price Not Configured": "模型价格未配置",
"Model prices": "模型价格",
"Model prices reset successfully": "模型价格重置成功",
"Model Pricing": "模型定价",
@@ -2532,6 +2544,7 @@
"No Logs Found": "未找到日志",
"No mappings configured. Click \"Add Row\" to get started.": "未配置映射。点击 \"添加行\" 开始。",
"No matches found": "未找到匹配项",
"No matching items": "没有匹配项",
"No matching results": "无匹配结果",
"No matching rules": "没有匹配的规则",
"No messages yet": "暂无消息",
@@ -2950,6 +2963,7 @@
"Please upload key file(s)": "请上传密钥文件",
"Please wait a moment before trying again.": "请稍候再试。",
"Please wait a moment, human check is initializing...": "请稍等,人机验证正在初始化...",
"Please wait before editing to avoid overwriting saved values.": "请等待加载完成后再编辑,以免覆盖已保存的值。",
"Policy JSON": "策略 JSON",
"Polling": "轮询",
"Polling mode requires Redis and memory cache, otherwise performance will be significantly degraded": "轮询模式需要 Redis 和内存缓存,否则性能将显著下降",
@@ -2983,6 +2997,7 @@
"Prepend to Start": "追加到开头",
"Prepend value to array / string / object start": "把值追加到数组/字符串/对象开头",
"Preserve the original field when applying this rule": "应用此规则时保留原始字段",
"Preset groups": "预设分组",
"Preset recharge amounts (JSON array)": "预设充值金额(JSON 数组)",
"Preset recharge amounts displayed to users": "向用户显示的预设充值金额",
"Preset Template": "预设模板",
@@ -3098,6 +3113,7 @@
"Querying...": "正在查询...",
"Question": "问题",
"Queued": "排队中",
"Quick actions": "快捷操作",
"Quick insert common payment methods": "快速插入常用支付方式",
"Quick Range": "快速范围",
"Quick Setup from Preset": "从预设快速设置",
@@ -3219,6 +3235,7 @@
"Remaining:": "剩余:",
"Remark": "备注",
"Remove": "移除",
"Remove {{value}}": "移除 {{value}}",
"Remove ${{amount}}": "移除 ${{amount}}",
"Remove all log entries created before the selected timestamp.": "移除所选时间戳之前创建的所有日志条目。",
"Remove attachment": "移除附件",
@@ -3226,6 +3243,7 @@
"Remove Duplicates": "移除重复项",
"Remove filter": "移除筛选",
"Remove functionResponse.id field": "移除 functionResponse.id 字段",
"Remove mapped targets": "移除映射目标",
"Remove Models": "删除模型",
"Remove Passkey": "解绑 Passkey",
"Remove Passkey?": "移除通行密钥?",
@@ -3329,7 +3347,6 @@
"Retain last N files": "保留最近 N 个文件",
"Retention days": "保留天数",
"Retry": "重试",
"auth.resetPasswordConfirm.retry": "重试 ({{seconds}}s)",
"Retry Chain": "重试链路",
"Retry Suggestion": "重试建议",
"Retry Times": "重试次数",
@@ -3339,7 +3356,6 @@
"Return Error": "返回错误",
"Return per-token log probabilities": "返回每个 token 的对数概率",
"Return to dashboard": "返回仪表盘",
"auth.resetPasswordConfirm.backToLogin": "返回登录",
"Return vector embeddings for inputs": "为输入返回向量嵌入",
"Reveal API key": "显示 API 密钥",
"Reveal key": "显示密钥",
@@ -3491,7 +3507,6 @@
"Select all (filtered)": "全选(筛选结果)",
"Select all models": "选择所有模型",
"Select All Visible": "全选当前",
"Select model {{model}}": "选择模型 {{model}}",
"Select an operation mode and enter the amount": "选择操作模式并输入金额",
"Select announcement type": "选择公告类型",
"Select at least one field to overwrite.": "请选择至少一个要覆盖的字段。",
@@ -3518,6 +3533,7 @@
"Select layout style": "选择布局样式",
"Select locations": "选择位置",
"Select Model": "选择模型",
"Select model {{model}}": "选择模型 {{model}}",
"Select models (empty for allow all)": "选择模型(留空表示允许所有)",
"Select models and apply to channel models list.": "选择模型并应用到渠道模型列表。",
"Select models or add custom ones": "选择模型或添加自定义模型",
@@ -3547,6 +3563,7 @@
"Select vendor": "选择供应商",
"Selectable groups": "可选分组",
"selected": "已选择",
"Selected {{count}}": "已选 {{count}} 个",
"selected channel(s). Leave empty to remove tag.": "选定的渠道。留空以移除标签。",
"Selected conflicts were overwritten successfully.": "选中的冲突已成功覆盖。",
"Selected when creating a token and used as the default billing group for API calls.": "创建令牌时选择,用作 API 调用的默认计费分组。",
@@ -3690,6 +3707,7 @@
"Status & Sync": "状态与同步",
"Status Code": "状态码",
"Status Code Mapping": "状态码映射",
"Status code mapping must use valid HTTP status codes": "状态码映射必须使用有效的 HTTP 状态码",
"Status Page Slug": "状态页面 Slug",
"Status short": "状态",
"Status:": "状态:",
@@ -3897,6 +3915,7 @@
"This action will permanently remove 2FA protection from your account.": "此操作将永久移除您账户的 2FA 保护。",
"This channel is not an Ollama channel.": "该渠道不是 Ollama 渠道。",
"This channel type does not support fetching models": "此通道类型不支持获取模型",
"This channel type requires additional configuration": "此渠道类型需要填写额外配置",
"This confirmation unlocks payment, redemption code, subscription plan, and invitation reward features. Please read the statements carefully.": "此确认会解锁支付、兑换码、订阅套餐和邀请奖励功能。请仔细阅读相关声明。",
"This controls model request rate limiting. Web/API route throttling is configured by environment variables and may still return 429.": "此处仅控制模型请求速率限制。Web/API 路由限流由环境变量配置,仍可能返回 429。",
"This data may be unreliable, use with caution": "此数据可能不可靠,请谨慎使用",
@@ -4215,6 +4234,7 @@
"Use external tools to extend capabilities": "通过外部工具扩展能力",
"Use our unified OpenAI-compatible endpoint in your applications": "在应用中使用我们兼容 OpenAI 的统一接口",
"Use Passkey to sign in without entering your password.": "使用通行密钥登录,无需输入密码。",
"Use presets or upstream discovery to populate the model list faster.": "使用预设或上游发现来更快填充模型列表。",
"Use secure connection when sending emails": "发送电子邮件时使用安全连接",
"Use sidebar shortcut": "使用侧边栏快捷方式",
"Use the full-width table to scan prices, then select a row to edit it here.": "先在表格中快速浏览价格,然后选择一行在这里编辑。",
@@ -4302,8 +4322,10 @@
"Verifying credentials and pulling stores from your Pancake account...": "正在验证凭证并从你的 Pancake 账户拉取店铺...",
"Version Overrides": "版本覆盖",
"Vertex AI": "Vertex AI",
"Vertex AI API Key mode does not support batch creation": "Vertex AI API Key 模式不支持批量创建",
"Vertex AI does not support functionResponse.id. Enable this to remove the field automatically.": "Vertex AI 不支持 functionResponse.id 字段,开启后将自动移除该字段",
"Vertex AI Key Format": "Vertex AI 密钥格式",
"Vertex AI service account key must be valid JSON": "Vertex AI 服务账号密钥必须是有效 JSON",
"Video": "视频",
"Video length in seconds": "视频时长(秒)",
"Video Remix": "视频 Remix",
@@ -4334,7 +4356,7 @@
"Visit Settings → General and adjust quota options...": "访问设置 → 通用并调整配额选项...",
"Visitors must authenticate before accessing the pricing directory.": "访客必须先进行身份验证才能访问定价目录。",
"Visitors must authenticate before accessing the rankings page.": "访客必须先进行身份验证才能访问排行榜页面。",
"Visual": "可视",
"Visual": "可视",
"Visual edit": "可视化编辑",
"Visual editor": "可视化编辑器",
"Visual Editor": "可视编辑器",
@@ -4466,7 +4488,6 @@
"Your GitHub OAuth Client ID": "您的 GitHub OAuth 客户端 ID",
"Your GitHub OAuth Client Secret": "您的 GitHub OAuth 客户端密钥",
"Your new backup codes are ready": "您的新备份代码已准备就绪",
"auth.resetPasswordConfirm.success": "您的密码已成功重置",
"Your Referral Link": "您的推荐链接",
"Your setup guide is collapsed so usage stays in focus.": "设置引导已收起,让用量信息保持在焦点位置。",
"Your system access token for API authentication. Keep it secure and don't share it with others.": "您的系统访问令牌,用于 API 认证。请妥善保管,不要与他人分享。",