diff --git a/src/hooks/useProviderActions.ts b/src/hooks/useProviderActions.ts index cc46cca8..ede55f8a 100644 --- a/src/hooks/useProviderActions.ts +++ b/src/hooks/useProviderActions.ts @@ -84,11 +84,43 @@ export function useProviderActions(activeApp: AppId) { try { await switchProviderMutation.mutateAsync(provider.id); await syncClaudePlugin(provider); + + // 根据供应商类型显示不同的成功提示 + if ( + activeApp === "claude" && + provider.category !== "official" && + provider.meta?.apiFormat === "openai_chat" + ) { + // OpenAI Chat 格式供应商:显示代理提示 + toast.info( + t("notifications.openAIChatFormatHint", { + defaultValue: + "此供应商使用 OpenAI Chat 格式,需要开启代理服务才能正常使用", + }), + { + duration: 5000, + closeButton: true, + }, + ); + } else { + // 普通供应商:显示切换成功 + // OpenCode: show "added to config" message instead of "switched" + const messageKey = + activeApp === "opencode" + ? "notifications.addToConfigSuccess" + : "notifications.switchSuccess"; + const defaultMessage = + activeApp === "opencode" ? "已添加到配置" : "切换成功!"; + + toast.success(t(messageKey, { defaultValue: defaultMessage }), { + closeButton: true, + }); + } } catch { - // 错误提示由 mutation 与同步函数处理 + // 错误提示由 mutation 处理 } }, - [switchProviderMutation, syncClaudePlugin], + [switchProviderMutation, syncClaudePlugin, activeApp, t], ); // 删除供应商 diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index b0d10c98..d3df05da 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -155,7 +155,8 @@ "deleteSuccess": "Provider deleted", "deleteFailed": "Failed to delete provider: {{error}}", "settingsSaved": "Settings saved", - "settingsSaveFailed": "Failed to save settings: {{error}}" + "settingsSaveFailed": "Failed to save settings: {{error}}", + "openAIChatFormatHint": "This provider uses OpenAI Chat format and requires the proxy service to be enabled" }, "confirm": { "deleteProvider": "Delete Provider", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 5f028a8c..ca053f2d 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -155,7 +155,8 @@ "deleteSuccess": "プロバイダーを削除しました", "deleteFailed": "プロバイダーの削除に失敗しました: {{error}}", "settingsSaved": "設定を保存しました", - "settingsSaveFailed": "設定の保存に失敗しました: {{error}}" + "settingsSaveFailed": "設定の保存に失敗しました: {{error}}", + "openAIChatFormatHint": "このプロバイダーは OpenAI Chat フォーマットを使用しており、プロキシサービスの有効化が必要です" }, "confirm": { "deleteProvider": "プロバイダーを削除", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 5126f582..cb16c0f0 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -155,7 +155,8 @@ "deleteSuccess": "供应商已删除", "deleteFailed": "删除供应商失败:{{error}}", "settingsSaved": "设置已保存", - "settingsSaveFailed": "保存设置失败:{{error}}" + "settingsSaveFailed": "保存设置失败:{{error}}", + "openAIChatFormatHint": "此供应商使用 OpenAI Chat 格式,需要开启代理服务才能正常使用" }, "confirm": { "deleteProvider": "删除供应商", diff --git a/src/lib/query/mutations.ts b/src/lib/query/mutations.ts index 0aa84356..454dd54d 100644 --- a/src/lib/query/mutations.ts +++ b/src/lib/query/mutations.ts @@ -171,17 +171,8 @@ export const useSwitchProviderMutation = (appId: AppId) => { ); } - // OpenCode: show "added to config" message instead of "switched" - const messageKey = - appId === "opencode" - ? "notifications.addToConfigSuccess" - : "notifications.switchSuccess"; - const defaultMessage = - appId === "opencode" ? "已添加到配置" : "切换供应商成功"; - - toast.success(t(messageKey, { defaultValue: defaultMessage }), { - closeButton: true, - }); + // Note: Success toast is handled by useProviderActions.switchProvider + // to allow customization based on provider properties (e.g., apiFormat) }, onError: (error: Error) => { const detail = extractErrorMessage(error) || t("common.unknown");