feat(claude): show proxy hint when switching to OpenAI Chat format provider

Display an info toast when switching to a provider that uses OpenAI Chat
format (apiFormat === "openai_chat"), reminding users to enable the proxy
service. Move toast logic from mutation to useProviderActions for better
control over notification content based on provider properties.
This commit is contained in:
Jason
2026-01-30 16:33:49 +08:00
parent 1ed122a8bd
commit 57713dd336
5 changed files with 42 additions and 16 deletions
+34 -2
View File
@@ -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],
);
// 删除供应商
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -155,7 +155,8 @@
"deleteSuccess": "プロバイダーを削除しました",
"deleteFailed": "プロバイダーの削除に失敗しました: {{error}}",
"settingsSaved": "設定を保存しました",
"settingsSaveFailed": "設定の保存に失敗しました: {{error}}"
"settingsSaveFailed": "設定の保存に失敗しました: {{error}}",
"openAIChatFormatHint": "このプロバイダーは OpenAI Chat フォーマットを使用しており、プロキシサービスの有効化が必要です"
},
"confirm": {
"deleteProvider": "プロバイダーを削除",
+2 -1
View File
@@ -155,7 +155,8 @@
"deleteSuccess": "供应商已删除",
"deleteFailed": "删除供应商失败:{{error}}",
"settingsSaved": "设置已保存",
"settingsSaveFailed": "保存设置失败:{{error}}"
"settingsSaveFailed": "保存设置失败:{{error}}",
"openAIChatFormatHint": "此供应商使用 OpenAI Chat 格式,需要开启代理服务才能正常使用"
},
"confirm": {
"deleteProvider": "删除供应商",
+2 -11
View File
@@ -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");