优化首次启动体验:自动创建默认供应商且设为选中状态
- 新增 importCurrentConfigAsDefault 函数,创建 ID 为 'default' 的特殊供应商 - 默认供应商不生成独立配置文件,直接使用现有 settings.json - 首次启动时自动导入现有配置为默认供应商,并设为选中状态 - 切换到默认供应商时无需文件操作,直接使用原配置 - 删除默认供应商时保护原配置文件不被误删 - 简化 ImportConfigModal 组件,移除 isEmpty 相关逻辑 - 提升用户体验:无需手动操作,开箱即用
This commit is contained in:
@@ -76,9 +76,9 @@ function App() {
|
||||
setProviders(loadedProviders);
|
||||
setCurrentProviderId(currentId);
|
||||
|
||||
// 如果供应商列表为空,自动弹出导入配置对话框
|
||||
// 如果供应商列表为空,尝试自动导入现有配置为"默认"供应商
|
||||
if (Object.keys(loadedProviders).length === 0) {
|
||||
setIsImportModalOpen(true);
|
||||
await handleAutoImportDefault();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -163,6 +163,22 @@ function App() {
|
||||
}
|
||||
}
|
||||
|
||||
// 自动导入现有配置为"默认"供应商
|
||||
const handleAutoImportDefault = async () => {
|
||||
try {
|
||||
const result = await window.electronAPI.importCurrentConfigAsDefault()
|
||||
|
||||
if (result.success) {
|
||||
await loadProviders()
|
||||
showNotification("已自动导入现有配置为默认供应商", "success", 3000)
|
||||
}
|
||||
// 如果导入失败(比如没有现有配置),静默处理,不显示错误
|
||||
} catch (error) {
|
||||
console.error('自动导入默认配置失败:', error)
|
||||
// 静默处理,不影响用户体验
|
||||
}
|
||||
}
|
||||
|
||||
const handleSelectConfigFile = async () => {
|
||||
const selectedPath = await window.electronAPI.selectConfigFile();
|
||||
if (selectedPath) {
|
||||
@@ -233,7 +249,6 @@ function App() {
|
||||
<ImportConfigModal
|
||||
onImport={handleImportCurrentConfig}
|
||||
onClose={() => setIsImportModalOpen(false)}
|
||||
isEmpty={Object.keys(providers).length === 0}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user