mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
alert if dotnet not present
This commit is contained in:
@@ -25,6 +25,14 @@ export interface DownloadInfo {
|
||||
stay?: boolean
|
||||
}
|
||||
|
||||
ipcMain.on('is-dotnet-6-installed', async (event, request: IpcRequest<void>) => {
|
||||
const installer = BSInstallerService.getInstance();
|
||||
const utils = UtilsService.getInstance();
|
||||
installer.isDotNet6Installed().then(installed => {
|
||||
utils.ipcSend(request.responceChannel, {success: true, data: installed});
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('bs-download.start', async (event, request: IpcRequest<DownloadInfo>) => {
|
||||
BSInstallerService.getInstance().downloadBsVersion(request.args).then(async res => {
|
||||
await LocalMapsManagerService.getInstance().linkVersionMaps(request.args.bsVersion, true).catch(e => {});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { BS_APP_ID, BS_DEPOT } from "../constants";
|
||||
import path from "path";
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { UtilsService } from "./utils.service";
|
||||
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
|
||||
import { ChildProcessWithoutNullStreams, spawn, spawnSync } from "child_process";
|
||||
import log from "electron-log";
|
||||
import { InstallationLocationService } from "./installation-location.service";
|
||||
import { ctrlc } from "ctrlc-windows";
|
||||
@@ -27,7 +27,7 @@ export class BSInstallerService{
|
||||
this.localVersionService = BSLocalVersionService.getInstance();
|
||||
this.windows = WindowManagerService.getInstance();
|
||||
|
||||
this.windows.getWindows("index.html").on("close", () => {
|
||||
this.windows.getWindows("index.html")?.on("close", () => {
|
||||
this.killDownloadProcess();
|
||||
});
|
||||
}
|
||||
@@ -65,6 +65,18 @@ export class BSInstallerService{
|
||||
});
|
||||
}
|
||||
|
||||
public async isDotNet6Installed(): Promise<boolean>{
|
||||
try{
|
||||
const process = spawnSync(this.getDepotDownloaderExePath());
|
||||
const out = process.output.toString();
|
||||
if(out.includes(".NET runtime can be found at")){ return false; }
|
||||
return true;
|
||||
}
|
||||
catch(e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async downloadBsVersion(downloadInfos: DownloadInfo): Promise<DownloadEvent>{
|
||||
|
||||
if(this.downloadProcess && this.downloadProcess.connected){ throw "AlreadyDownloading"; }
|
||||
|
||||
@@ -11,6 +11,7 @@ import { NotificationService } from './notification.service';
|
||||
import { ProgressBarService } from './progress-bar.service';
|
||||
import { LoginModal } from 'renderer/components/modal/modal-types/login-modal.component';
|
||||
import { GuardModal } from 'renderer/components/modal/modal-types/guard-modal.component';
|
||||
import { LinkOpenerService } from './link-opener.service';
|
||||
|
||||
export class BsDownloaderService{
|
||||
|
||||
@@ -22,6 +23,7 @@ export class BsDownloaderService{
|
||||
private readonly authService: AuthUserService;
|
||||
private readonly progressBarService: ProgressBarService;
|
||||
private readonly notificationService: NotificationService;
|
||||
private readonly linkOpener: LinkOpenerService;
|
||||
|
||||
private _isVerification: boolean = false;
|
||||
|
||||
@@ -41,6 +43,7 @@ export class BsDownloaderService{
|
||||
this.authService = AuthUserService.getInstance();
|
||||
this.progressBarService = ProgressBarService.getInstance();
|
||||
this.notificationService = NotificationService.getInstance();
|
||||
this.linkOpener = LinkOpenerService.getInstance();
|
||||
this.asignListerners();
|
||||
}
|
||||
|
||||
@@ -84,9 +87,29 @@ export class BsDownloaderService{
|
||||
return this.ipcService.send<boolean>("bs-download.kill");
|
||||
}
|
||||
|
||||
public isDotNet6Installed(): Promise<boolean>{
|
||||
return this.ipcService.send<boolean>("is-dotnet-6-installed").then(res => res.success && res.data)
|
||||
}
|
||||
|
||||
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
|
||||
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
|
||||
|
||||
if(isFirstCall && !(await this.isDotNet6Installed())){
|
||||
|
||||
const choice = await this.notificationService.notifyError({
|
||||
duration: 11_000,
|
||||
title: "notifications.bs-download.errors.titles.dotnet-required",
|
||||
desc: "notifications.bs-download.errors.msg.dotnet-required",
|
||||
actions: [{id: "0", title: "notifications.bs-download.errors.actions.download-dotnet"}]
|
||||
});
|
||||
|
||||
if(choice === "0"){
|
||||
this.linkOpener.open("https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-6.0.12-windows-x64-installer");
|
||||
}
|
||||
|
||||
return {success: false};
|
||||
}
|
||||
|
||||
this.progressBarService.show(this.downloadProgress$);
|
||||
this._isVerification = !!isVerification;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user