mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Compare commits
8 Commits
v1.0.0-alpha.8
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 571a4f23ea | |||
| 2b9829d57a | |||
| 2f6ea39f79 | |||
| 8e33214fd0 | |||
| 310dfb94c2 | |||
| 39e2a54e1e | |||
| 829cace7b9 | |||
| e82afa7e22 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bs-manager",
|
||||
"version": "1.0.0-alpha.8",
|
||||
"version": "1.0.0",
|
||||
"description": "A foundation for scalable desktop apps",
|
||||
"main": "./dist/main/main.js",
|
||||
"author": {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { BSInstallerService, DownloadEventType } from '../services/bs-installer.service';
|
||||
import { BSInstallerService, DownloadEventType, DownloadInfo } from '../services/bs-installer.service';
|
||||
import { IpcRequest } from 'shared/models/ipc';
|
||||
import { InstallationLocationService } from '../services/installation-location.service';
|
||||
import { UtilsService } from '../services/utils.service';
|
||||
@@ -18,13 +17,6 @@ export interface InitDownloadInfoInterface {
|
||||
stay: boolean
|
||||
}
|
||||
|
||||
export interface DownloadInfo {
|
||||
bsVersion: BSVersion,
|
||||
username: string,
|
||||
password?: string,
|
||||
stay?: boolean
|
||||
}
|
||||
|
||||
ipcMain.on('is-dotnet-6-installed', async (event, request: IpcRequest<void>) => {
|
||||
const installer = BSInstallerService.getInstance();
|
||||
const utils = UtilsService.getInstance();
|
||||
|
||||
@@ -87,7 +87,9 @@ export class BSInstallerService{
|
||||
|
||||
this.utils.createFolderIfNotExist(this.installLocationService.versionsDirectory);
|
||||
|
||||
const dest = this.getPathNotAleardyExist(await this.localVersionService.getVersionPath(bsVersion));
|
||||
const versionPath = await this.localVersionService.getVersionPath(bsVersion)
|
||||
|
||||
const dest = !downloadInfos.isVerification ? this.getPathNotAleardyExist(versionPath) : versionPath;
|
||||
|
||||
const downloadVersion: BSVersion = {...downloadInfos.bsVersion, ...(path.basename(dest) !== downloadInfos.bsVersion.BSVersion && {name: path.basename(dest)})}
|
||||
|
||||
@@ -204,7 +206,8 @@ export interface DownloadInfo {
|
||||
bsVersion: BSVersion,
|
||||
username: string,
|
||||
password?: string,
|
||||
stay?: boolean
|
||||
stay?: boolean,
|
||||
isVerification: boolean
|
||||
}
|
||||
|
||||
export interface DownloadEvent{
|
||||
|
||||
@@ -42,7 +42,7 @@ export const AvailableVersionItem = memo(function AvailableVersionItem(props: {v
|
||||
|
||||
return (
|
||||
<motion.li className="group relative w-72 h-60 transition-transform active:scale-[.98]" onClick={toggleSelect} onHoverStart={() => setHovered(true)} onHoverEnd={() => setHovered(false)}>
|
||||
<GlowEffect visible={hovered} className="absolute"/>
|
||||
<GlowEffect visible={hovered || selected} className="absolute"/>
|
||||
<div className={`relative flex flex-col overflow-hidden rounded-md w-72 h-60 cursor-pointer group-hover:shadow-none duration-300 bg-light-main-color-2 dark:bg-main-color-2 ${!selected && "shadow-lg shadow-gray-900"}`}>
|
||||
<BsmImage image={props.version.ReleaseImg ? props.version.ReleaseImg : defaultImage} errorImage={defaultImage} placeholder={defaultImage} className="absolute top-0 right-0 w-full h-full opacity-40 blur-xl object-cover" loading="lazy"/>
|
||||
<BsmImage image={props.version.ReleaseImg ? props.version.ReleaseImg : defaultImage} errorImage={defaultImage} placeholder={defaultImage} className="bg-black w-full h-3/4 object-cover" loading="lazy"/>
|
||||
|
||||
@@ -43,9 +43,12 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
|
||||
const cancel = () => {
|
||||
const versionDownload = downloaderService.currentBsVersionDownload$.value;
|
||||
const wasVerification = downloaderService.isVerification;
|
||||
downloaderService.cancelDownload().then(async res => {
|
||||
if(!res.success){ return; }
|
||||
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
|
||||
if(!wasVerification){
|
||||
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DownloadEvent } from 'main/services/bs-installer.service';
|
||||
import { DownloadEvent, DownloadInfo } from 'main/services/bs-installer.service';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { distinctUntilChanged, filter, throttleTime } from 'rxjs/operators';
|
||||
import { IpcResponse } from 'shared/models/ipc';
|
||||
@@ -25,6 +25,8 @@ export class BsDownloaderService{
|
||||
private readonly notificationService: NotificationService;
|
||||
private readonly linkOpener: LinkOpenerService;
|
||||
|
||||
private _isVerification: boolean = false;
|
||||
|
||||
public readonly currentBsVersionDownload$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
|
||||
public readonly downloadProgress$: BehaviorSubject<number> = new BehaviorSubject(0);
|
||||
public readonly selectedBsVersion$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
|
||||
@@ -94,7 +96,7 @@ export class BsDownloaderService{
|
||||
return this.ipcService.send<boolean>("is-dotnet-6-installed").then(res => res.success && res.data)
|
||||
}
|
||||
|
||||
public async download(bsVersion: BSVersion, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
|
||||
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())){
|
||||
@@ -114,6 +116,7 @@ export class BsDownloaderService{
|
||||
}
|
||||
|
||||
this.progressBarService.show(this.downloadProgress$);
|
||||
this._isVerification = isVerification;
|
||||
|
||||
let promise;
|
||||
if(!this.authService.sessionExist()){
|
||||
@@ -123,22 +126,22 @@ export class BsDownloaderService{
|
||||
return {success: false};
|
||||
}
|
||||
this.authService.setSteamSession(res.data.username, res.data.stay);
|
||||
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay}});
|
||||
promise = this.ipcService.send<DownloadEvent, DownloadInfo>('bs-download.start', {args: {bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay, isVerification}});
|
||||
}
|
||||
else{
|
||||
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername()}});
|
||||
promise = this.ipcService.send<DownloadEvent, DownloadInfo>('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername(), isVerification}});
|
||||
}
|
||||
|
||||
let res = await promise;
|
||||
|
||||
if(res.data?.type === "[Password]"){
|
||||
this.authService.deleteSteamSession();
|
||||
res = await this.download(bsVersion, false);
|
||||
res = await this.download(bsVersion, isVerification, false);
|
||||
}
|
||||
|
||||
this.progressBarService.hide(true);
|
||||
this.resetDownload();
|
||||
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.download-success", duration: 3000}); }
|
||||
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: `notifications.bs-download.success.titles.${isVerification ? "verification-finished" : "download-success"}`, duration: 3000}); }
|
||||
else if(res.data && isFirstCall){ this.notificationService.notifyError({title: `notifications.types.error`, desc: `notifications.bs-download.errors.msg.${res.data}`, duration: 3000}); }
|
||||
|
||||
return res;
|
||||
@@ -151,6 +154,8 @@ export class BsDownloaderService{
|
||||
return res.success ? res.data : "";
|
||||
}
|
||||
|
||||
public get isVerification(): boolean{ return this._isVerification; }
|
||||
|
||||
public setInstallationFolder(path: string): Promise<IpcResponse<string>>{
|
||||
return this.ipcService.send<string>("bs-download.set-installation-folder", {args: path});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user