mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 00:35:32 +08:00
fix: add import button for OpenCode/OpenClaw empty state and remove auto-import on startup
Previously OpenCode and OpenClaw auto-imported providers from live config on app startup, which could confuse users. Now they follow the same pattern as Claude/Codex/Gemini: manual import via the empty state button.
This commit is contained in:
@@ -179,7 +179,17 @@ export function ProviderList({
|
||||
// Import current live config as default provider
|
||||
const queryClient = useQueryClient();
|
||||
const importMutation = useMutation({
|
||||
mutationFn: () => providersApi.importDefault(appId),
|
||||
mutationFn: async (): Promise<boolean> => {
|
||||
if (appId === "opencode") {
|
||||
const count = await providersApi.importOpenCodeFromLive();
|
||||
return count > 0;
|
||||
}
|
||||
if (appId === "openclaw") {
|
||||
const count = await providersApi.importOpenClawFromLive();
|
||||
return count > 0;
|
||||
}
|
||||
return providersApi.importDefault(appId);
|
||||
},
|
||||
onSuccess: (imported) => {
|
||||
if (imported) {
|
||||
queryClient.invalidateQueries({ queryKey: ["providers", appId] });
|
||||
@@ -245,15 +255,11 @@ export function ProviderList({
|
||||
);
|
||||
}
|
||||
|
||||
// Only show import button for standard apps (not additive-mode apps like OpenCode/OpenClaw)
|
||||
const showImportButton =
|
||||
appId === "claude" || appId === "codex" || appId === "gemini";
|
||||
|
||||
if (sortedProviders.length === 0) {
|
||||
return (
|
||||
<ProviderEmptyState
|
||||
onCreate={onCreate}
|
||||
onImport={showImportButton ? () => importMutation.mutate() : undefined}
|
||||
onImport={() => importMutation.mutate()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,14 @@ export const providersApi = {
|
||||
async getOpenClawLiveProviderIds(): Promise<string[]> {
|
||||
return await invoke("get_openclaw_live_provider_ids");
|
||||
},
|
||||
|
||||
/**
|
||||
* 从 OpenClaw live 配置导入供应商到数据库
|
||||
* OpenClaw 特有功能:由于累加模式,用户可能已在 openclaw.json 中配置供应商
|
||||
*/
|
||||
async importOpenClawFromLive(): Promise<number> {
|
||||
return await invoke("import_openclaw_providers_from_live");
|
||||
},
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user