From 275424033977465d9be5330a4ce2b7b3d0f59576 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 5 Jan 2025 12:25:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E4=BE=9D=E8=B5=96=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 2 ++ back/services/dependence.ts | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index db240b339ba..6325bc6b014 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -581,6 +581,8 @@ export async function detectOS(): Promise< Logger.error(`Unknown Linux Distribution: ${osReleaseInfo}`); console.error(`Unknown Linux Distribution: ${osReleaseInfo}`); } + } else if (platform === 'darwin') { + osType = undefined; } else { Logger.error(`Unsupported platform: ${platform}`); console.error(`Unsupported platform: ${platform}`); diff --git a/back/services/dependence.ts b/back/services/dependence.ts index 1ff72cbe78a..59119faeccc 100644 --- a/back/services/dependence.ts +++ b/back/services/dependence.ts @@ -226,6 +226,12 @@ export default class DependenceService { if (taskLimit.firstDependencyId !== dependency.id) { return resolve(null); } + const depIds = [dependency.id!]; + let depName = dependency.name.trim(); + const actionText = isInstall ? '安装' : '删除'; + const socketMessageType = isInstall + ? 'installDependence' + : 'uninstallDependence'; const isNodeDependence = dependency.type === DependenceTypes.nodejs; const isLinuxDependence = dependency.type === DependenceTypes.linux; const isPythonDependence = dependency.type === DependenceTypes.python3; @@ -234,21 +240,32 @@ export default class DependenceService { taskLimit.removeQueuedDependency(dependency); if (isLinuxDependence) { if (!osType) { + await DependenceModel.update( + { status: DependenceStatus.installFailed }, + { where: { id: depIds } }, + ); + const startTime = dayjs(); + const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format( + 'YYYY-MM-DD HH:mm:ss', + )}\n\n当前系统不支持\n\n依赖${actionText}失败,结束时间 ${startTime.format( + 'YYYY-MM-DD HH:mm:ss', + )},耗时 ${startTime.diff(startTime, 'second')} 秒`; + this.sockService.sendMessage({ + type: socketMessageType, + message, + references: depIds, + }); + this.updateLog(depIds, message); return resolve(null); } linuxCommand = LINUX_DEPENDENCE_COMMAND[osType]; } - const depIds = [dependency.id!]; const status = isInstall ? DependenceStatus.installing : DependenceStatus.removing; await DependenceModel.update({ status }, { where: { id: depIds } }); - const socketMessageType = isInstall - ? 'installDependence' - : 'uninstallDependence'; - let depName = dependency.name.trim(); let depRunCommand = ( isInstall ? InstallDependenceCommandTypes @@ -259,7 +276,6 @@ export default class DependenceService { ? linuxCommand.install : linuxCommand.uninstall; } - const actionText = isInstall ? '安装' : '删除'; const startTime = dayjs(); const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format(