feat(usage): add automatic models.dev pricing sync (#5734)

* feat(usage): persist model pricing in local config

* feat(usage): sync selected models.dev pricing on startup

* fix(usage): address models.dev sync review feedback

* fix(usage): harden local pricing synchronization
This commit is contained in:
Thefool
2026-07-28 23:37:55 +08:00
committed by GitHub
parent ff3bc242cc
commit 12b972a66e
20 changed files with 2672 additions and 195 deletions
+34
View File
@@ -1633,6 +1633,40 @@
"modelsDevNoResults": "No matching models",
"modelsDevTruncated": "Showing first {{shown}} of {{total}} results — refine your search",
"modelsDevDefaultHint": "Showing the {{shown}} most recently released models (of {{total}}) — type to search all",
"modelsDevAutoSync": {
"title": "Automatic models.dev pricing sync",
"description": "When enabled, periodically fetch selected prices when CC Switch launches and keep them in your local pricing file.",
"enabled": "Enabled",
"disabled": "Disabled",
"enableConfirmTitle": "Enable automatic pricing sync?",
"enableConfirmMessage": "After enabling, CC Switch will periodically update prices for the selected models from models.dev when it launches (at most once every 6 hours). Built-in and manually configured prices with the same model ID will be overwritten.",
"enableConfirmAction": "Enable automatic sync",
"configure": "Choose models",
"configureTitle": "Choose models for automatic pricing sync",
"configureDescription": "Search and filter models to update automatically. Your choices are stored locally.",
"commonModels": "Automatically include common models",
"commonModelsDescription": "Selects {{count}} recent Claude, GPT, Gemini, Grok, DeepSeek, Qwen, MiMo, LongCat, Kimi, MiniMax, and GLM models.",
"selectFiltered": "Select filtered ({{count}})",
"clearFiltered": "Clear filtered",
"selectedCount": "{{count}} models selected",
"selectionHint": "Selections with the same normalized model ID are imported once.",
"commonBadge": "Common",
"selectionSaved": "Automatic pricing selection saved",
"syncSuccess": "Pricing sync complete: {{imported}} models checked, {{changed}} updated",
"syncFailed": "Pricing sync failed: {{error}}",
"configLoadFailed": "Failed to load local pricing configuration: {{error}}",
"neverSynced": "Never",
"lastSync": "Last sync",
"commonStatus": "Common models",
"lastError": "Last automatic sync failed: {{error}}",
"localFile": "Local pricing file",
"openFolder": "Open folder",
"openFolderFailed": "Failed to open the local pricing folder: {{error}}",
"reloadLocalFile": "Reload file",
"localFileReloaded": "Local pricing file reloaded",
"localFileReloadFailed": "Failed to reload local pricing file: {{error}}",
"syncNow": "Sync now"
},
"cacheReadCostPerMillion": "Cache Read Cost (per million tokens, USD)",
"cacheCreationCostPerMillion": "Cache Write Cost (per million tokens, USD)"
},
+34
View File
@@ -1633,6 +1633,40 @@
"modelsDevNoResults": "一致するモデルがありません",
"modelsDevTruncated": "{{total}} 件中、先頭 {{shown}} 件のみ表示しています。検索条件を絞り込んでください",
"modelsDevDefaultHint": "最新リリース順に {{shown}} 件を表示しています(全 {{total}} 件)。キーワード入力で全件検索できます",
"modelsDevAutoSync": {
"title": "models.dev 料金の自動同期",
"description": "有効にすると、CC Switch の起動時に選択したモデルの最新料金を定期的に取得し、ローカル料金ファイルに保存します。",
"enabled": "有効",
"disabled": "無効",
"enableConfirmTitle": "料金の自動同期を有効にしますか?",
"enableConfirmMessage": "有効にすると、CC Switch の起動時に models.dev から選択したモデルの料金を定期的に更新します(最大 6 時間に 1 回)。同じモデル ID の内蔵料金と手動設定した料金は上書きされます。",
"enableConfirmAction": "自動同期を有効にする",
"configure": "モデルを選択",
"configureTitle": "料金を自動同期するモデルを選択",
"configureDescription": "検索とプロバイダーの絞り込みで自動更新するモデルを選択します。選択内容はローカルに保存されます。",
"commonModels": "よく使うモデルを自動的に含める",
"commonModelsDescription": "最近の Claude、GPT、Gemini、Grok、DeepSeek、Qwen、MiMo、LongCat、Kimi、MiniMax、GLM から {{count}} モデルを選択します。",
"selectFiltered": "絞り込み結果を選択({{count}}",
"clearFiltered": "絞り込み結果を解除",
"selectedCount": "{{count}} モデルを選択中",
"selectionHint": "正規化後のモデル ID が同じ項目は一度だけインポートされます。",
"commonBadge": "よく使う",
"selectionSaved": "自動料金同期の選択を保存しました",
"syncSuccess": "料金同期が完了しました:{{imported}} モデルを確認、{{changed}} モデルを更新",
"syncFailed": "料金同期に失敗しました:{{error}}",
"configLoadFailed": "ローカル料金設定の読み込みに失敗しました:{{error}}",
"neverSynced": "未同期",
"lastSync": "最終同期",
"commonStatus": "よく使うモデル",
"lastError": "前回の自動同期に失敗しました:{{error}}",
"localFile": "ローカル料金ファイル",
"openFolder": "フォルダーを開く",
"openFolderFailed": "ローカル料金フォルダーを開けませんでした: {{error}}",
"reloadLocalFile": "ファイルを再読み込み",
"localFileReloaded": "ローカル料金ファイルを再読み込みしました",
"localFileReloadFailed": "ローカル料金ファイルの再読み込みに失敗しました:{{error}}",
"syncNow": "今すぐ同期"
},
"cacheReadCostPerMillion": "キャッシュ読み取りコスト(100万トークンあたり、USD)",
"cacheCreationCostPerMillion": "キャッシュ書き込みコスト(100万トークンあたり、USD)"
},
+34
View File
@@ -1604,6 +1604,40 @@
"modelsDevNoResults": "沒有符合的模型",
"modelsDevTruncated": "僅顯示前 {{shown}} 條,共 {{total}} 條結果,請縮小搜尋範圍",
"modelsDevDefaultHint": "預設展示最新發布的 {{shown}} 個模型(共 {{total}} 個),輸入關鍵字可全量搜尋",
"modelsDevAutoSync": {
"title": "自動同步 models.dev 定價",
"description": "開啟後,CC Switch 會在啟動時定期擷取所選模型的最新價格,並儲存到本機定價檔案。",
"enabled": "已開啟",
"disabled": "已關閉",
"enableConfirmTitle": "開啟自動同步定價?",
"enableConfirmMessage": "開啟後,CC Switch 會在啟動時定期從 models.dev 更新所選模型的價格(最多每 6 小時一次)。相同模型 ID 的軟體內建價格和手動設定價格都會被覆寫。",
"enableConfirmAction": "開啟自動同步",
"configure": "選擇模型",
"configureTitle": "選擇自動同步定價的模型",
"configureDescription": "透過搜尋和供應商篩選選擇需要自動更新的模型,選擇結果儲存在本機。",
"commonModels": "自動包含常用模型",
"commonModelsDescription": "自動選擇 {{count}} 個近期 Claude、GPT、Gemini、Grok、DeepSeek、Qwen、MiMo、LongCat、Kimi、MiniMax 和 GLM 模型。",
"selectFiltered": "全選篩選結果({{count}}",
"clearFiltered": "清除篩選結果",
"selectedCount": "已選擇 {{count}} 個模型",
"selectionHint": "標準化模型 ID 相同的選項只會匯入一次。",
"commonBadge": "常用",
"selectionSaved": "自動定價同步選擇已儲存",
"syncSuccess": "定價同步完成:檢查 {{imported}} 個模型,更新 {{changed}} 個",
"syncFailed": "定價同步失敗:{{error}}",
"configLoadFailed": "載入本機定價設定失敗:{{error}}",
"neverSynced": "從未同步",
"lastSync": "上次同步",
"commonStatus": "常用模型",
"lastError": "上次自動同步失敗:{{error}}",
"localFile": "本機定價檔案",
"openFolder": "開啟資料夾",
"openFolderFailed": "開啟本機定價檔案資料夾失敗:{{error}}",
"reloadLocalFile": "重新載入檔案",
"localFileReloaded": "本機定價檔案已重新載入",
"localFileReloadFailed": "重新載入本機定價檔案失敗:{{error}}",
"syncNow": "立即同步"
},
"cacheReadCostPerMillion": "快取讀取成本 (每百萬 tokens, USD)",
"cacheCreationCostPerMillion": "快取寫入成本 (每百萬 tokens, USD)"
},
+34
View File
@@ -1633,6 +1633,40 @@
"modelsDevNoResults": "没有匹配的模型",
"modelsDevTruncated": "仅显示前 {{shown}} 条,共 {{total}} 条结果,请缩小搜索范围",
"modelsDevDefaultHint": "默认展示最新发布的 {{shown}} 个模型(共 {{total}} 个),输入关键字可全量搜索",
"modelsDevAutoSync": {
"title": "自动同步 models.dev 定价",
"description": "开启后,CC Switch 会在启动时定期拉取所选模型的最新价格,并保存到本地定价文件。",
"enabled": "已开启",
"disabled": "已关闭",
"enableConfirmTitle": "开启自动同步定价?",
"enableConfirmMessage": "开启后,CC Switch 会在启动时定期从 models.dev 更新所选模型的价格(最多每 6 小时一次)。同一模型 ID 的软件内置价格和手动设置价格都会被覆盖。",
"enableConfirmAction": "开启自动同步",
"configure": "选择模型",
"configureTitle": "选择自动同步定价的模型",
"configureDescription": "通过搜索和供应商筛选选择需要自动更新的模型,选择结果保存在本地。",
"commonModels": "自动包含常用模型",
"commonModelsDescription": "自动选择 {{count}} 个近期 Claude、GPT、Gemini、Grok、DeepSeek、Qwen、MiMo、LongCat、Kimi、MiniMax 和 GLM 模型。",
"selectFiltered": "全选筛选结果({{count}}",
"clearFiltered": "清空筛选结果",
"selectedCount": "已选择 {{count}} 个模型",
"selectionHint": "归一化模型 ID 相同的选项只会导入一次。",
"commonBadge": "常用",
"selectionSaved": "自动定价同步选择已保存",
"syncSuccess": "定价同步完成:检查 {{imported}} 个模型,更新 {{changed}} 个",
"syncFailed": "定价同步失败:{{error}}",
"configLoadFailed": "加载本地定价配置失败:{{error}}",
"neverSynced": "从未同步",
"lastSync": "上次同步",
"commonStatus": "常用模型",
"lastError": "上次自动同步失败:{{error}}",
"localFile": "本地定价文件",
"openFolder": "打开目录",
"openFolderFailed": "打开本地定价文件目录失败:{{error}}",
"reloadLocalFile": "重新加载文件",
"localFileReloaded": "本地定价文件已重新加载",
"localFileReloadFailed": "重新加载本地定价文件失败:{{error}}",
"syncNow": "立即同步"
},
"cacheReadCostPerMillion": "缓存读取成本 (每百万 tokens, USD)",
"cacheCreationCostPerMillion": "缓存写入成本 (每百万 tokens, USD)"
},