Skip to content

Commit

Permalink
修复系统安装依赖提示
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Jan 5, 2025
1 parent c865828 commit 2754240
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions back/config/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
28 changes: 22 additions & 6 deletions back/services/dependence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -259,7 +276,6 @@ export default class DependenceService {
? linuxCommand.install
: linuxCommand.uninstall;
}
const actionText = isInstall ? '安装' : '删除';
const startTime = dayjs();

const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format(
Expand Down

0 comments on commit 2754240

Please sign in to comment.