优化首次启动体验:自动创建默认供应商且设为选中状态
- 新增 importCurrentConfigAsDefault 函数,创建 ID 为 'default' 的特殊供应商 - 默认供应商不生成独立配置文件,直接使用现有 settings.json - 首次启动时自动导入现有配置为默认供应商,并设为选中状态 - 切换到默认供应商时无需文件操作,直接使用原配置 - 删除默认供应商时保护原配置文件不被误删 - 简化 ImportConfigModal 组件,移除 isEmpty 相关逻辑 - 提升用户体验:无需手动操作,开箱即用
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
deleteProviderConfig,
|
||||
sanitizeProviderName,
|
||||
importCurrentConfig,
|
||||
importCurrentConfigAsDefault,
|
||||
getProviderConfigPath,
|
||||
fileExists,
|
||||
} from "./services";
|
||||
@@ -234,6 +235,29 @@ ipcMain.handle("importCurrentConfig", async (_, name: string) => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("importCurrentConfigAsDefault", async () => {
|
||||
try {
|
||||
const result = await importCurrentConfigAsDefault();
|
||||
|
||||
if (result.success && result.provider) {
|
||||
// 将默认供应商添加到store中
|
||||
const providers = store.get("providers", {} as Record<string, Provider>);
|
||||
providers[result.provider.id] = result.provider;
|
||||
await store.set("providers", providers);
|
||||
|
||||
// 设置为当前选中的供应商
|
||||
await store.set("current", result.provider.id);
|
||||
|
||||
return { success: true, providerId: result.provider.id };
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
console.error("导入默认配置失败:", error);
|
||||
return { success: false };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("getClaudeCodeConfigPath", () => {
|
||||
return getClaudeCodeConfig().path;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user