feat: 优化初始化逻辑,仅在自动模式下出现环境缺失页面

This commit is contained in:
Alirea
2025-09-15 10:17:27 +08:00
parent 804c3ed62c
commit 7ca0dcc918

View File

@@ -213,15 +213,22 @@ async function checkEnvironment() {
console.log(' - git.exe缺失:', !criticalFiles.gitExists) console.log(' - git.exe缺失:', !criticalFiles.gitExists)
console.log(' - main.py缺失:', !criticalFiles.mainPyExists) console.log(' - main.py缺失:', !criticalFiles.mainPyExists)
// 显示环境不完整页面 // 检查是否应该显示环境不完整页面(仅在自动模式下)
const missing = [] // 如果不是第一次启动且关键文件缺失,说明之前是自动模式但现在环境有问题
if (!criticalFiles.pythonExists) missing.push('Python 环境') if (!isFirst) {
if (!criticalFiles.gitExists) missing.push('Git 工具') const missing = []
if (!criticalFiles.mainPyExists) missing.push('后端代码') if (!criticalFiles.pythonExists) missing.push('Python 环境')
if (!criticalFiles.gitExists) missing.push('Git 工具')
missingComponents.value = missing if (!criticalFiles.mainPyExists) missing.push('后端代码')
showEnvironmentIncomplete.value = true
autoMode.value = false missingComponents.value = missing
showEnvironmentIncomplete.value = true
autoMode.value = false
} else {
// 第一次启动时,即使文件缺失也直接进入手动模式
autoMode.value = false
showEnvironmentIncomplete.value = false
}
} else { } else {
// 其他情况直接进入手动模式 // 其他情况直接进入手动模式
autoMode.value = false autoMode.value = false
@@ -236,7 +243,7 @@ async function checkEnvironment() {
} }
} catch (error) { } catch (error) {
const errorMsg = `环境检查失败: ${error instanceof Error ? error.message : String(error)}` const errorMsg = `环境检查失败: ${error instanceof Error ? error.message : String(error)}`
console.error('环境检查失败:', error) console.error(errorMsg)
// 检查失败时强制进入手动模式 // 检查失败时强制进入手动模式
autoMode.value = false autoMode.value = false