From 4d8d71f294b1c144094e8fc2f86d83c561be5d0e Mon Sep 17 00:00:00 2001 From: AoXuan Date: Sun, 14 Sep 2025 02:04:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=8E=AF=E5=A2=83=E4=B8=8D=E5=AE=8C=E6=95=B4=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/electron/main.ts | 52 +++++ frontend/electron/preload.ts | 2 + .../components/initialization/AutoMode.vue | 14 +- .../initialization/EnvironmentIncomplete.vue | 185 ++++++++++++++++++ .../components/initialization/ManualMode.vue | 16 +- frontend/src/views/Initialization.vue | 61 ++++-- 6 files changed, 296 insertions(+), 34 deletions(-) create mode 100644 frontend/src/components/initialization/EnvironmentIncomplete.vue diff --git a/frontend/electron/main.ts b/frontend/electron/main.ts index 72bcb66..184fca2 100644 --- a/frontend/electron/main.ts +++ b/frontend/electron/main.ts @@ -516,6 +516,47 @@ ipcMain.handle('check-environment', async () => { return checkEnvironment(appRoot) }) +// 关键文件检查 - 每次都重新检查exe文件是否存在 +ipcMain.handle('check-critical-files', async () => { + try { + const appRoot = getAppRoot() + + // 检查Python可执行文件 + const pythonPath = path.join(appRoot, 'environment', 'python', 'python.exe') + const pythonExists = fs.existsSync(pythonPath) + + // 检查pip(通常与Python一起安装) + const pipPath = path.join(appRoot, 'environment', 'python', 'Scripts', 'pip.exe') + const pipExists = fs.existsSync(pipPath) + + // 检查Git可执行文件 + const gitPath = path.join(appRoot, 'environment', 'git', 'bin', 'git.exe') + const gitExists = fs.existsSync(gitPath) + + // 检查后端主文件 + const mainPyPath = path.join(appRoot, 'main.py') + const mainPyExists = fs.existsSync(mainPyPath) + + const result = { + pythonExists, + pipExists, + gitExists, + mainPyExists + } + + log.info('关键文件检查结果:', result) + return result + } catch (error) { + log.error('检查关键文件失败:', error) + return { + pythonExists: false, + pipExists: false, + gitExists: false, + mainPyExists: false + } + } +}) + // Python相关 ipcMain.handle('download-python', async (_event, mirror = 'tsinghua') => { const appRoot = getAppRoot() @@ -547,6 +588,17 @@ ipcMain.handle('download-git', async () => { return downloadGit(appRoot) }) +ipcMain.handle('check-git-update', async () => { + try { + // 这里可以实现检查Git仓库更新的逻辑 + // 暂时返回false,表示没有更新 + return { hasUpdate: false } + } catch (error) { + log.error('检查Git更新失败:', error) + return { hasUpdate: false, error: error instanceof Error ? error.message : String(error) } + } +}) + ipcMain.handle( 'clone-backend', async (_event, repoUrl = 'https://github.com/AUTO-MAS-Project/AUTO-MAS.git') => { diff --git a/frontend/electron/preload.ts b/frontend/electron/preload.ts index 3866a77..c7331ed 100644 --- a/frontend/electron/preload.ts +++ b/frontend/electron/preload.ts @@ -19,9 +19,11 @@ contextBridge.exposeInMainWorld('electronAPI', { // 初始化相关API checkEnvironment: () => ipcRenderer.invoke('check-environment'), + checkCriticalFiles: () => ipcRenderer.invoke('check-critical-files'), downloadPython: (mirror?: string) => ipcRenderer.invoke('download-python', mirror), installPip: () => ipcRenderer.invoke('install-pip'), downloadGit: () => ipcRenderer.invoke('download-git'), + checkGitUpdate: () => ipcRenderer.invoke('check-git-update'), installDependencies: (mirror?: string) => ipcRenderer.invoke('install-dependencies', mirror), cloneBackend: (repoUrl?: string) => ipcRenderer.invoke('clone-backend', repoUrl), updateBackend: (repoUrl?: string) => ipcRenderer.invoke('update-backend', repoUrl), diff --git a/frontend/src/components/initialization/AutoMode.vue b/frontend/src/components/initialization/AutoMode.vue index 0f61829..55e4e9a 100644 --- a/frontend/src/components/initialization/AutoMode.vue +++ b/frontend/src/components/initialization/AutoMode.vue @@ -32,7 +32,7 @@ - + + + + + \ No newline at end of file diff --git a/frontend/src/components/initialization/ManualMode.vue b/frontend/src/components/initialization/ManualMode.vue index 020240c..8147af0 100644 --- a/frontend/src/components/initialization/ManualMode.vue +++ b/frontend/src/components/initialization/ManualMode.vue @@ -48,7 +48,7 @@ - + @@ -136,7 +136,7 @@