feat(deeplink): add Claude model fields support and enhance import dialog

- Add Claude-specific model field support in deeplink import:
  * Support model (ANTHROPIC_MODEL) - general default model
  * Support haikuModel (ANTHROPIC_DEFAULT_HAIKU_MODEL)
  * Support sonnetModel (ANTHROPIC_DEFAULT_SONNET_MODEL)
  * Support opusModel (ANTHROPIC_DEFAULT_OPUS_MODEL)
  * Backend: Update DeepLinkImportRequest struct to include optional model fields
  * Frontend: Add TypeScript type definitions for new model parameters

- Enhance deeplink demo page (deplink.html):
  * Add 5 new Claude configuration examples showcasing different model setups
  * Add parameter documentation with required/optional tags
  * Include basic config (no models), single model, complete 4-model, partial models, and third-party provider examples
  * Improve visual design with param-list component and color-coded badges
  * Add detailed descriptions for each configuration scenario

- Redesign DeepLinkImportDialog layout:
  * Switch from 3-column to compact 2-column grid layout
  * Reduce dialog width from 500px to 650px for better content display
  * Add dedicated section for Claude model configurations with blue highlight box
  * Use uppercase labels and smaller text for more information density
  * Add truncation and tooltips for long URLs
  * Improve visual hierarchy with spacing and grouping
  * Increase z-index to 9999 to ensure dialog appears on top

- Minor UI refinements:
  * Update App.tsx layout adjustments
  * Optimize McpFormModal styling
  * Refine ProviderCard and BasicFormFields components

This enables users to import Claude providers with precise model configurations via deeplink.
This commit is contained in:
YoVinchen
2025-11-22 03:26:28 +08:00
parent 127fa5bf9d
commit 1a89267986
8 changed files with 402 additions and 76 deletions

View File

@@ -263,6 +263,34 @@
color: #e91e63; color: #e91e63;
} }
.param-list {
background: #f8f9fa;
border-left: 3px solid #3498db;
padding: 12px;
border-radius: 6px;
margin: 12px 0;
font-size: 13px;
line-height: 1.8;
color: #495057;
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}
.param-tag {
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
margin-right: 6px;
background: #3498db;
color: white;
}
.param-tag.optional {
background: #95a5a6;
}
@media (max-width: 768px) { @media (max-width: 768px) {
.header h1 { .header h1 {
font-size: 24px; font-size: 24px;
@@ -293,28 +321,90 @@
<div class="link-card"> <div class="link-card">
<h3> <h3>
<span class="app-badge badge-claude">Claude</span> <span class="app-badge badge-claude">Claude</span>
Claude Official (官方) 基础配置(无模型)
</h3> </h3>
<p class="description"> <p class="description">
导入 Claude 官方 API 配置。使用官方端点 api.anthropic.com默认模型 claude-haiku-4.1 最简单的 Claude 配置仅包含必需参数API Key、端点等不指定任何模型使用 Claude Code 默认值
</p> </p>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=Claude%20Official&homepage=https%3A%2F%2Fclaude.ai&endpoint=https%3A%2F%2Fapi.anthropic.com%2Fv1&apiKey=sk-ant-test-demo-key-12345&model=claude-haiku-4.1&notes=%E5%AE%98%E6%96%B9%E6%B5%8B%E8%AF%95%E9%85%8D%E7%BD%AE" <div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=claude, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=Claude%20Basic&homepage=https%3A%2F%2Fclaude.ai&endpoint=https%3A%2F%2Fapi.anthropic.com%2Fv1&apiKey=sk-ant-test-basic-key&notes=%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%EF%BC%8C%E6%97%A0%E6%A8%A1%E5%9E%8B%E6%8C%87%E5%AE%9A"
class="deep-link"> class="deep-link">
📥 导入 Claude Official 📥 导入基础配置
</a> </a>
</div> </div>
<div class="link-card"> <div class="link-card">
<h3> <h3>
<span class="app-badge badge-claude">Claude</span> <span class="app-badge badge-claude">Claude</span>
Claude 测试环境 带默认模型
</h3> </h3>
<p class="description"> <p class="description">
公司内部测试环境配置示例。包含备注信息,方便区分不同环境。默认模型 claude-haiku-4.1 设置通用默认模型ANTHROPIC_MODEL适用于只需要一个固定模型的场景
</p> </p>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=%E5%85%AC%E5%8F%B8%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83&homepage=https%3A%2F%2Ftest.company.com&endpoint=https%3A%2F%2Fapi-test.company.com%2Fv1&apiKey=sk-ant-test-company-key&model=claude-haiku-4.1&notes=%E5%85%AC%E5%8F%B8%E5%86%85%E9%83%A8%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83%EF%BC%8C%E4%BB%85%E4%BE%9B%E5%BC%80%E5%8F%91%E4%BD%BF%E7%94%A8" <div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=claude, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=claude-haiku-4.1</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=Claude%20with%20Model&homepage=https%3A%2F%2Fclaude.ai&endpoint=https%3A%2F%2Fapi.anthropic.com%2Fv1&apiKey=sk-ant-test-model-key&model=claude-haiku-4.1&notes=%E5%B8%A6%E9%BB%98%E8%AE%A4%E6%A8%A1%E5%9E%8B"
class="deep-link"> class="deep-link">
📥 导入测试环境 📥 导入带默认模型
</a>
</div>
<div class="link-card">
<h3>
<span class="app-badge badge-claude">Claude</span>
完整配置(四种模型)
</h3>
<p class="description">
设置所有四种模型字段默认模型、Haiku 模型、Sonnet 模型、Opus 模型。适用于需要精细控制不同模型系列的场景。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=claude, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=claude-sonnet-4.5</strong>, <strong>haikuModel=claude-haiku-4.1</strong>, <strong>sonnetModel=claude-sonnet-4.5</strong>, <strong>opusModel=claude-opus-4</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=Claude%20Complete&homepage=https%3A%2F%2Fclaude.ai&endpoint=https%3A%2F%2Fapi.anthropic.com%2Fv1&apiKey=sk-ant-test-complete-key&model=claude-sonnet-4.5&haikuModel=claude-haiku-4.1&sonnetModel=claude-sonnet-4.5&opusModel=claude-opus-4&notes=%E5%AE%8C%E6%95%B4%E6%A8%A1%E5%9E%8B%E9%85%8D%E7%BD%AE"
class="deep-link">
📥 导入完整配置
</a>
</div>
<div class="link-card">
<h3>
<span class="app-badge badge-claude">Claude</span>
部分模型配置
</h3>
<p class="description">
仅设置特定的模型字段(例如只设置 Haiku 和 Sonnet其他模型使用默认值。演示参数灵活性。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=claude, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>haikuModel=claude-haiku-4.1</strong>, <strong>sonnetModel=claude-sonnet-4.5</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=Claude%20Partial&homepage=https%3A%2F%2Fclaude.ai&endpoint=https%3A%2F%2Fapi.anthropic.com%2Fv1&apiKey=sk-ant-test-partial-key&haikuModel=claude-haiku-4.1&sonnetModel=claude-sonnet-4.5&notes=%E9%83%A8%E5%88%86%E6%A8%A1%E5%9E%8B%E9%85%8D%E7%BD%AE"
class="deep-link">
📥 导入部分模型配置
</a>
</div>
<div class="link-card">
<h3>
<span class="app-badge badge-claude">Claude</span>
第三方供应商示例
</h3>
<p class="description">
使用第三方供应商的 API 端点和自定义模型名称,演示兼容性。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=claude, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=custom-claude-v1</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=claude&name=Third-Party%20Claude&homepage=https%3A%2F%2Fthirdparty.com&endpoint=https%3A%2F%2Fapi.thirdparty.com%2Fv1&apiKey=sk-third-party-key&model=custom-claude-v1&notes=%E7%AC%AC%E4%B8%89%E6%96%B9%E4%BE%9B%E5%BA%94%E5%95%86%E7%A4%BA%E4%BE%8B"
class="deep-link">
📥 导入第三方供应商
</a> </a>
</div> </div>
</div> </div>
@@ -326,11 +416,33 @@
<div class="link-card"> <div class="link-card">
<h3> <h3>
<span class="app-badge badge-codex">Codex</span> <span class="app-badge badge-codex">Codex</span>
OpenAI Official (官方) 基础配置
</h3> </h3>
<p class="description"> <p class="description">
导入 OpenAI 官方 API 配置。使用官方端点 api.openai.com默认模型 gpt-5.1 OpenAI 官方 API 基础配置,仅包含必需参数
</p> </p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=codex, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=codex&name=OpenAI%20Basic&homepage=https%3A%2F%2Fopenai.com&endpoint=https%3A%2F%2Fapi.openai.com%2Fv1&apiKey=sk-test-basic-openai-key&notes=%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE"
class="deep-link">
📥 导入基础配置
</a>
</div>
<div class="link-card">
<h3>
<span class="app-badge badge-codex">Codex</span>
带默认模型
</h3>
<p class="description">
OpenAI API 配置,指定默认模型为 gpt-5.1。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=codex, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=gpt-5.1</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=codex&name=OpenAI%20Official&homepage=https%3A%2F%2Fopenai.com&endpoint=https%3A%2F%2Fapi.openai.com%2Fv1&apiKey=sk-test-demo-openai-key-67890&model=gpt-5.1&notes=OpenAI%20%E5%AE%98%E6%96%B9%E6%9C%8D%E5%8A%A1" <a href="ccswitch://v1/import?resource=provider&app=codex&name=OpenAI%20Official&homepage=https%3A%2F%2Fopenai.com&endpoint=https%3A%2F%2Fapi.openai.com%2Fv1&apiKey=sk-test-demo-openai-key-67890&model=gpt-5.1&notes=OpenAI%20%E5%AE%98%E6%96%B9%E6%9C%8D%E5%8A%A1"
class="deep-link"> class="deep-link">
📥 导入 OpenAI Official 📥 导入 OpenAI Official
@@ -345,17 +457,57 @@
<p class="description"> <p class="description">
Azure 部署的 OpenAI 服务示例。适合企业用户使用 Azure 云服务。默认模型 gpt-5.1。 Azure 部署的 OpenAI 服务示例。适合企业用户使用 Azure 云服务。默认模型 gpt-5.1。
</p> </p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=codex, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=gpt-5.1</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=codex&name=Azure%20OpenAI&homepage=https%3A%2F%2Fazure.microsoft.com%2Fopenai&endpoint=https%3A%2F%2Fyour-resource.openai.azure.com%2F&apiKey=azure-test-api-key-xyz&model=gpt-5.1&notes=Azure%20%E4%BC%81%E4%B8%9A%E7%89%88%E6%9C%AC" <a href="ccswitch://v1/import?resource=provider&app=codex&name=Azure%20OpenAI&homepage=https%3A%2F%2Fazure.microsoft.com%2Fopenai&endpoint=https%3A%2F%2Fyour-resource.openai.azure.com%2F&apiKey=azure-test-api-key-xyz&model=gpt-5.1&notes=Azure%20%E4%BC%81%E4%B8%9A%E7%89%88%E6%9C%AC"
class="deep-link"> class="deep-link">
📥 导入 Azure OpenAI 📥 导入 Azure OpenAI
</a> </a>
</div> </div>
<div class="link-card">
<h3>
<span class="app-badge badge-codex">Codex</span>
第三方兼容 API
</h3>
<p class="description">
使用兼容 OpenAI API 格式的第三方服务(如 Together AI、Groq 等)。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=codex, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=mixtral-8x7b</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=codex&name=Third-Party%20API&homepage=https%3A%2F%2Fthirdparty.com&endpoint=https%3A%2F%2Fapi.thirdparty.com%2Fv1&apiKey=sk-third-party-key&model=mixtral-8x7b&notes=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%85%BC%E5%AE%B9%E6%9C%8D%E5%8A%A1"
class="deep-link">
📥 导入第三方 API
</a>
</div>
</div> </div>
<!-- Gemini 示例 --> <!-- Gemini 示例 -->
<div class="section"> <div class="section">
<h2>Gemini 供应商</h2> <h2>Gemini 供应商</h2>
<div class="link-card">
<h3>
<span class="app-badge badge-gemini">Gemini</span>
基础配置
</h3>
<p class="description">
Google Gemini 官方 API 基础配置,仅包含必需参数。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=gemini, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=gemini&name=Google%20Gemini%20Basic&homepage=https%3A%2F%2Fai.google.dev&endpoint=https%3A%2F%2Fgenerativelanguage.googleapis.com%2Fv1beta&apiKey=AIzaSy-test-basic-key&notes=%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE"
class="deep-link">
📥 导入基础配置
</a>
</div>
<div class="link-card"> <div class="link-card">
<h3> <h3>
<span class="app-badge badge-gemini">Gemini</span> <span class="app-badge badge-gemini">Gemini</span>
@@ -364,6 +516,10 @@
<p class="description"> <p class="description">
导入 Google Gemini 官方 API 配置。默认模型 gemini-3-pro-preview。 导入 Google Gemini 官方 API 配置。默认模型 gemini-3-pro-preview。
</p> </p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=gemini, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=gemini-3-pro-preview</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=gemini&name=Google%20Gemini&homepage=https%3A%2F%2Fai.google.dev&endpoint=https%3A%2F%2Fgenerativelanguage.googleapis.com%2Fv1beta&apiKey=AIzaSy-test-demo-key-abc123&model=gemini-3-pro-preview&notes=Google%20AI%20%E5%AE%98%E6%96%B9%E6%9C%8D%E5%8A%A1" <a href="ccswitch://v1/import?resource=provider&app=gemini&name=Google%20Gemini&homepage=https%3A%2F%2Fai.google.dev&endpoint=https%3A%2F%2Fgenerativelanguage.googleapis.com%2Fv1beta&apiKey=AIzaSy-test-demo-key-abc123&model=gemini-3-pro-preview&notes=Google%20AI%20%E5%AE%98%E6%96%B9%E6%9C%8D%E5%8A%A1"
class="deep-link"> class="deep-link">
📥 导入 Google Gemini 📥 导入 Google Gemini
@@ -376,13 +532,35 @@
Gemini 测试环境 Gemini 测试环境
</h3> </h3>
<p class="description"> <p class="description">
公司内部 Gemini 测试环境配置示例。用于验证 Gemini 相关深链接导入流程请求地址为https://api-gemini-test.company.com/v1beta。默认模型 gemini-3-pro-preview。 公司内部 Gemini 测试环境配置示例。用于验证 Gemini 相关深链接导入流程。默认模型 gemini-3-pro-preview。
</p> </p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=gemini, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=gemini-3-pro-preview</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=gemini&name=%E5%85%AC%E5%8F%B8%20Gemini%20%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83&homepage=https%3A%2F%2Fgemini-test.company.com&endpoint=https%3A%2F%2Fapi-gemini-test.company.com%2Fv1beta&apiKey=sk-gemini-test-company-key&model=gemini-3-pro-preview&notes=%E5%85%AC%E5%8F%B8%E5%86%85%E9%83%A8%20Gemini%20%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83%EF%BC%8C%E4%BB%85%E4%BE%9B%E5%BC%80%E5%8F%91%E4%BD%BF%E7%94%A8" <a href="ccswitch://v1/import?resource=provider&app=gemini&name=%E5%85%AC%E5%8F%B8%20Gemini%20%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83&homepage=https%3A%2F%2Fgemini-test.company.com&endpoint=https%3A%2F%2Fapi-gemini-test.company.com%2Fv1beta&apiKey=sk-gemini-test-company-key&model=gemini-3-pro-preview&notes=%E5%85%AC%E5%8F%B8%E5%86%85%E9%83%A8%20Gemini%20%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83%EF%BC%8C%E4%BB%85%E4%BE%9B%E5%BC%80%E5%8F%91%E4%BD%BF%E7%94%A8"
class="deep-link"> class="deep-link">
📥 导入 Gemini 测试环境 📥 导入 Gemini 测试环境
</a> </a>
</div> </div>
<div class="link-card">
<h3>
<span class="app-badge badge-gemini">Gemini</span>
第三方兼容服务
</h3>
<p class="description">
使用第三方提供的 Gemini API 兼容服务,支持自定义模型名称。
</p>
<div class="param-list">
<span class="param-tag">必需</span> resource=provider, app=gemini, name, homepage, endpoint, apiKey<br>
<span class="param-tag optional">可选</span> <strong>model=gemini-custom-v2</strong>, notes
</div>
<a href="ccswitch://v1/import?resource=provider&app=gemini&name=Third-Party%20Gemini&homepage=https%3A%2F%2Fthirdparty-gemini.com&endpoint=https%3A%2F%2Fapi.thirdparty-gemini.com%2Fv1&apiKey=tpg-test-key-xyz&model=gemini-custom-v2&notes=%E7%AC%AC%E4%B8%89%E6%96%B9%20Gemini%20%E5%85%BC%E5%AE%B9%E6%9C%8D%E5%8A%A1"
class="deep-link">
📥 导入第三方服务
</a>
</div>
</div> </div>
<!-- 注意事项 --> <!-- 注意事项 -->
@@ -404,7 +582,7 @@
<div class="form-group"> <div class="form-group">
<label>应用类型 *</label> <label>应用类型 *</label>
<select id="app"> <select id="app" onchange="updateModelFields()">
<option value="claude">Claude Code</option> <option value="claude">Claude Code</option>
<option value="codex">Codex</option> <option value="codex">Codex</option>
<option value="gemini">Gemini</option> <option value="gemini">Gemini</option>
@@ -432,8 +610,47 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>模型(可选)</label> <label>默认模型(可选)</label>
<input type="text" id="model" placeholder="例如: claude-haiku-4.1, gpt-5.1, gemini-3-pro-preview"> <input type="text" id="model" placeholder="例如: claude-haiku-4.1, gpt-5.1, gemini-3-pro-preview">
<small style="color: #7f8c8d; font-size: 12px; display: block; margin-top: 4px;">
通用模型字段,适用于所有应用类型
</small>
</div>
<!-- Claude 专用字段 -->
<div id="claudeFields" style="display: block;">
<div style="background: #e8f4f8; padding: 16px; border-radius: 8px; margin: 16px 0;">
<h4 style="color: #2c3e50; margin-bottom: 12px; font-size: 14px;">
📋 Claude 专用模型字段(可选)
</h4>
<p style="color: #7f8c8d; font-size: 12px; margin-bottom: 12px;">
可以根据需要设置特定的模型字段,这些字段仅在 Claude 应用中生效
</p>
<div class="form-group">
<label>Haiku 模型</label>
<input type="text" id="haikuModel" placeholder="claude-haiku-4.1">
<small style="color: #7f8c8d; font-size: 11px; display: block; margin-top: 4px;">
对应环境变量ANTHROPIC_DEFAULT_HAIKU_MODEL
</small>
</div>
<div class="form-group">
<label>Sonnet 模型</label>
<input type="text" id="sonnetModel" placeholder="claude-sonnet-4.5">
<small style="color: #7f8c8d; font-size: 11px; display: block; margin-top: 4px;">
对应环境变量ANTHROPIC_DEFAULT_SONNET_MODEL
</small>
</div>
<div class="form-group">
<label>Opus 模型</label>
<input type="text" id="opusModel" placeholder="claude-opus-4">
<small style="color: #7f8c8d; font-size: 11px; display: block; margin-top: 4px;">
对应环境变量ANTHROPIC_DEFAULT_OPUS_MODEL
</small>
</div>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -458,6 +675,18 @@
</div> </div>
<script> <script>
// 更新模型字段显示
function updateModelFields() {
const app = document.getElementById('app').value;
const claudeFields = document.getElementById('claudeFields');
if (app === 'claude') {
claudeFields.style.display = 'block';
} else {
claudeFields.style.display = 'none';
}
}
function generateLink() { function generateLink() {
const app = document.getElementById('app').value; const app = document.getElementById('app').value;
const name = document.getElementById('name').value.trim(); const name = document.getElementById('name').value.trim();
@@ -467,6 +696,11 @@
const model = document.getElementById('model').value.trim(); const model = document.getElementById('model').value.trim();
const notes = document.getElementById('notes').value.trim(); const notes = document.getElementById('notes').value.trim();
// Claude 专用字段
const haikuModel = document.getElementById('haikuModel').value.trim();
const sonnetModel = document.getElementById('sonnetModel').value.trim();
const opusModel = document.getElementById('opusModel').value.trim();
// 验证必填字段 // 验证必填字段
if (!name || !homepage || !endpoint || !apiKey) { if (!name || !homepage || !endpoint || !apiKey) {
alert('❌ 请填写所有必填字段(标记 * 的字段)!'); alert('❌ 请填写所有必填字段(标记 * 的字段)!');
@@ -492,10 +726,25 @@
apiKey: apiKey apiKey: apiKey
}); });
// 添加通用模型
if (model) { if (model) {
params.append('model', model); params.append('model', model);
} }
// 添加 Claude 专用模型字段
if (app === 'claude') {
if (haikuModel) {
params.append('haikuModel', haikuModel);
}
if (sonnetModel) {
params.append('sonnetModel', sonnetModel);
}
if (opusModel) {
params.append('opusModel', opusModel);
}
}
// 添加备注
if (notes) { if (notes) {
params.append('notes', notes); params.append('notes', notes);
} }
@@ -544,6 +793,9 @@
} }
}); });
}); });
// 初始化显示 Claude 字段
updateModelFields();
}); });
</script> </script>
</body> </body>

View File

@@ -37,6 +37,15 @@ pub struct DeepLinkImportRequest {
/// Optional notes/description /// Optional notes/description
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub notes: Option<String>, pub notes: Option<String>,
/// Optional Haiku model (Claude only, v3.7.1+)
#[serde(skip_serializing_if = "Option::is_none")]
pub haiku_model: Option<String>,
/// Optional Sonnet model (Claude only, v3.7.1+)
#[serde(skip_serializing_if = "Option::is_none")]
pub sonnet_model: Option<String>,
/// Optional Opus model (Claude only, v3.7.1+)
#[serde(skip_serializing_if = "Option::is_none")]
pub opus_model: Option<String>,
} }
/// Parse a ccswitch:// URL into a DeepLinkImportRequest /// Parse a ccswitch:// URL into a DeepLinkImportRequest
@@ -133,6 +142,11 @@ pub fn parse_deeplink_url(url_str: &str) -> Result<DeepLinkImportRequest, AppErr
let model = params.get("model").cloned(); let model = params.get("model").cloned();
let notes = params.get("notes").cloned(); let notes = params.get("notes").cloned();
// Extract Claude-specific optional model fields (v3.7.1+)
let haiku_model = params.get("haikuModel").cloned();
let sonnet_model = params.get("sonnetModel").cloned();
let opus_model = params.get("opusModel").cloned();
Ok(DeepLinkImportRequest { Ok(DeepLinkImportRequest {
version, version,
resource, resource,
@@ -143,6 +157,9 @@ pub fn parse_deeplink_url(url_str: &str) -> Result<DeepLinkImportRequest, AppErr
api_key, api_key,
model, model,
notes, notes,
haiku_model,
sonnet_model,
opus_model,
}) })
} }
@@ -211,11 +228,22 @@ fn build_provider_from_request(
env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), json!(request.api_key)); env.insert("ANTHROPIC_AUTH_TOKEN".to_string(), json!(request.api_key));
env.insert("ANTHROPIC_BASE_URL".to_string(), json!(request.endpoint)); env.insert("ANTHROPIC_BASE_URL".to_string(), json!(request.endpoint));
// Add model if provided (use as default model) // Add default model if provided
if let Some(model) = &request.model { if let Some(model) = &request.model {
env.insert("ANTHROPIC_MODEL".to_string(), json!(model)); env.insert("ANTHROPIC_MODEL".to_string(), json!(model));
} }
// Add Claude-specific model fields (v3.7.1+)
if let Some(haiku_model) = &request.haiku_model {
env.insert("ANTHROPIC_DEFAULT_HAIKU_MODEL".to_string(), json!(haiku_model));
}
if let Some(sonnet_model) = &request.sonnet_model {
env.insert("ANTHROPIC_DEFAULT_SONNET_MODEL".to_string(), json!(sonnet_model));
}
if let Some(opus_model) = &request.opus_model {
env.insert("ANTHROPIC_DEFAULT_OPUS_MODEL".to_string(), json!(opus_model));
}
json!({ "env": env }) json!({ "env": env })
} }
AppType::Codex => { AppType::Codex => {

View File

@@ -509,8 +509,9 @@ function App() {
</header> </header>
<main <main
className={`flex-1 overflow-y-auto pb-12 animate-fade-in scroll-overlay ${currentView === "providers" ? "pt-24" : "pt-20" className={`flex-1 overflow-y-auto pb-12 animate-fade-in scroll-overlay ${
}`} currentView === "providers" ? "pt-24" : "pt-20"
}`}
style={{ overflowX: "hidden" }} style={{ overflowX: "hidden" }}
> >
{renderContent()} {renderContent()}
@@ -553,8 +554,8 @@ function App() {
message={ message={
confirmDelete confirmDelete
? t("confirm.deleteProviderMessage", { ? t("confirm.deleteProviderMessage", {
name: confirmDelete.name, name: confirmDelete.name,
}) })
: "" : ""
} }
onConfirm={() => void handleConfirmDelete()} onConfirm={() => void handleConfirmDelete()}

View File

@@ -96,8 +96,8 @@ export function DeepLinkImportDialog() {
: "****"; : "****";
return ( return (
<Dialog open={isOpen} onOpenChange={setIsOpen}> <Dialog open={isOpen} onOpenChange={setIsOpen} modal={true}>
<DialogContent className="sm:max-w-[500px]"> <DialogContent className="sm:max-w-[650px] z-[9999]">
{/* 标题显式左对齐,避免默认居中样式影响 */} {/* 标题显式左对齐,避免默认居中样式影响 */}
<DialogHeader className="text-left sm:text-left"> <DialogHeader className="text-left sm:text-left">
<DialogTitle>{t("deeplink.confirmImport")}</DialogTitle> <DialogTitle>{t("deeplink.confirmImport")}</DialogTitle>
@@ -106,82 +106,120 @@ export function DeepLinkImportDialog() {
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
{/* 主体内容整体右移,略大于标题内边距,让内容看起来不贴边 */} {/* 使用两列布局压缩内容 */}
<div className="space-y-4 px-8 py-4"> <div className="space-y-4 px-4 py-3">
{/* App Type */} {/* 第一行:应用类型 + 供应商名称 */}
<div className="grid grid-cols-3 items-center gap-4"> <div className="grid grid-cols-2 gap-4">
<div className="font-medium text-sm text-muted-foreground"> <div className="space-y-1">
{t("deeplink.app")} <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.app")}
</div>
<div className="text-sm font-medium capitalize">
{request.app}
</div>
</div> </div>
<div className="col-span-2 text-sm font-medium capitalize"> <div className="space-y-1">
{request.app} <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.providerName")}
</div>
<div className="text-sm font-medium truncate" title={request.name}>
{request.name}
</div>
</div> </div>
</div> </div>
{/* Provider Name */} {/* 第二行:官网 + 端点 */}
<div className="grid grid-cols-3 items-center gap-4"> <div className="grid grid-cols-2 gap-4">
<div className="font-medium text-sm text-muted-foreground"> <div className="space-y-1">
{t("deeplink.providerName")} <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.homepage")}
</div>
<div className="text-xs break-all text-blue-600 dark:text-blue-400 line-clamp-2" title={request.homepage}>
{request.homepage}
</div>
</div> </div>
<div className="col-span-2 text-sm font-medium">{request.name}</div> <div className="space-y-1">
</div> <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.endpoint")}
{/* Homepage */} </div>
<div className="grid grid-cols-3 items-center gap-4"> <div className="text-xs break-all line-clamp-2" title={request.endpoint}>
<div className="font-medium text-sm text-muted-foreground"> {request.endpoint}
{t("deeplink.homepage")} </div>
</div>
<div className="col-span-2 text-sm break-all text-blue-600 dark:text-blue-400">
{request.homepage}
</div> </div>
</div> </div>
{/* API Endpoint */} {/* 第三行API Key */}
<div className="grid grid-cols-3 items-center gap-4"> <div className="space-y-1">
<div className="font-medium text-sm text-muted-foreground"> <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.endpoint")}
</div>
<div className="col-span-2 text-sm break-all">
{request.endpoint}
</div>
</div>
{/* API Key (masked) */}
<div className="grid grid-cols-3 items-center gap-4">
<div className="font-medium text-sm text-muted-foreground">
{t("deeplink.apiKey")} {t("deeplink.apiKey")}
</div> </div>
<div className="col-span-2 text-sm font-mono text-muted-foreground"> <div className="text-sm font-mono text-muted-foreground">
{maskedApiKey} {maskedApiKey}
</div> </div>
</div> </div>
{/* Model (if present) */} {/* 第四行:默认模型(如果有) */}
{request.model && ( {request.model && (
<div className="grid grid-cols-3 items-center gap-4"> <div className="space-y-1">
<div className="font-medium text-sm text-muted-foreground"> <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.model")} {t("deeplink.model")}
</div> </div>
<div className="col-span-2 text-sm font-mono"> <div className="text-sm font-mono">{request.model}</div>
{request.model} </div>
)}
{/* Claude 专用模型字段(紧凑布局) */}
{request.app === "claude" && (request.haikuModel || request.sonnetModel || request.opusModel) && (
<div className="rounded-lg bg-blue-50 dark:bg-blue-900/20 p-3 space-y-2">
<div className="font-medium text-xs text-blue-900 dark:text-blue-100 uppercase">
{t("deeplink.claudeModels", "Claude 模型配置")}
</div>
<div className="grid grid-cols-3 gap-2 text-xs">
{request.haikuModel && (
<div>
<span className="text-muted-foreground">Haiku:</span>
<div className="font-mono truncate" title={request.haikuModel}>
{request.haikuModel}
</div>
</div>
)}
{request.sonnetModel && (
<div>
<span className="text-muted-foreground">Sonnet:</span>
<div className="font-mono truncate" title={request.sonnetModel}>
{request.sonnetModel}
</div>
</div>
)}
{request.opusModel && (
<div>
<span className="text-muted-foreground">Opus:</span>
<div className="font-mono truncate" title={request.opusModel}>
{request.opusModel}
</div>
</div>
)}
</div> </div>
</div> </div>
)} )}
{/* Notes (if present) */} {/* 备注(如果有) */}
{request.notes && ( {request.notes && (
<div className="grid grid-cols-3 items-start gap-4"> <div className="space-y-1">
<div className="font-medium text-sm text-muted-foreground"> <div className="font-medium text-xs text-muted-foreground uppercase">
{t("deeplink.notes")} {t("deeplink.notes")}
</div> </div>
<div className="col-span-2 text-sm text-muted-foreground"> <div className="text-sm text-muted-foreground line-clamp-2" title={request.notes}>
{request.notes} {request.notes}
</div> </div>
</div> </div>
)} )}
{/* Warning */} {/* 警告提示(紧凑版) */}
<div className="rounded-lg bg-yellow-50 dark:bg-yellow-900/20 p-3 text-sm text-yellow-800 dark:text-yellow-200"> <div className="rounded-lg bg-yellow-50 dark:bg-yellow-900/20 p-2 text-xs text-yellow-800 dark:text-yellow-200">
{t("deeplink.warning")} {t("deeplink.warning")}
</div> </div>
</div> </div>

View File

@@ -440,10 +440,11 @@ const McpFormModal: React.FC<McpFormModalProps> = ({
<button <button
type="button" type="button"
onClick={applyCustom} onClick={applyCustom}
className={`inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${selectedPreset === -1 className={`inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${
selectedPreset === -1
? "bg-emerald-500 text-white dark:bg-emerald-600" ? "bg-emerald-500 text-white dark:bg-emerald-600"
: "bg-accent text-muted-foreground hover:bg-accent/80" : "bg-accent text-muted-foreground hover:bg-accent/80"
}`} }`}
> >
{t("presetSelector.custom")} {t("presetSelector.custom")}
</button> </button>
@@ -454,10 +455,11 @@ const McpFormModal: React.FC<McpFormModalProps> = ({
key={preset.id} key={preset.id}
type="button" type="button"
onClick={() => applyPreset(idx)} onClick={() => applyPreset(idx)}
className={`inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${selectedPreset === idx className={`inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${
selectedPreset === idx
? "bg-emerald-500 text-white dark:bg-emerald-600" ? "bg-emerald-500 text-white dark:bg-emerald-600"
: "bg-accent text-muted-foreground hover:bg-accent/80" : "bg-accent text-muted-foreground hover:bg-accent/80"
}`} }`}
title={t(descriptionKey)} title={t(descriptionKey)}
> >
{preset.id} {preset.id}
@@ -631,9 +633,7 @@ const McpFormModal: React.FC<McpFormModalProps> = ({
<div> <div>
<div className="flex items-center justify-between mb-2"> <div className="flex items-center justify-between mb-2">
<label className="text-sm font-medium text-foreground"> <label className="text-sm font-medium text-foreground">
{useToml {useToml ? t("mcp.form.tomlConfig") : t("mcp.form.jsonConfig")}
? t("mcp.form.tomlConfig")
: t("mcp.form.jsonConfig")}
</label> </label>
{(isEditing || selectedPreset === -1) && ( {(isEditing || selectedPreset === -1) && (
<button <button

View File

@@ -120,7 +120,7 @@ export function ProviderCard({
? "border-primary/50 bg-primary/5 shadow-[0_0_20px_rgba(59,130,246,0.15)]" ? "border-primary/50 bg-primary/5 shadow-[0_0_20px_rgba(59,130,246,0.15)]"
: "hover:scale-[1.01]", : "hover:scale-[1.01]",
dragHandleProps?.isDragging && dragHandleProps?.isDragging &&
"cursor-grabbing border-primary shadow-lg scale-105 z-10", "cursor-grabbing border-primary shadow-lg scale-105 z-10",
)} )}
> >
<div className="absolute inset-0 bg-gradient-to-r from-primary/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none" /> <div className="absolute inset-0 bg-gradient-to-r from-primary/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none" />

View File

@@ -130,7 +130,10 @@ export function BasicFormFields({ form }: BasicFormFieldsProps) {
<FormItem> <FormItem>
<FormLabel>{t("provider.notes")}</FormLabel> <FormLabel>{t("provider.notes")}</FormLabel>
<FormControl> <FormControl>
<Input {...field} placeholder={t("provider.notesPlaceholder")} /> <Input
{...field}
placeholder={t("provider.notesPlaceholder")}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

View File

@@ -10,6 +10,10 @@ export interface DeepLinkImportRequest {
apiKey: string; apiKey: string;
model?: string; model?: string;
notes?: string; notes?: string;
// Claude 专用模型字段 (v3.7.1+)
haikuModel?: string;
sonnetModel?: string;
opusModel?: string;
} }
export const deeplinkApi = { export const deeplinkApi = {