mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
fix object desctory when oneClick window close
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
import { useState } from 'react';
|
||||
import { IpcService } from 'renderer/services/ipc.service';
|
||||
import { WindowManagerService } from 'renderer/services/window-manager.service';
|
||||
import { AppWindow } from 'shared/models/window-manager/app-window.model';
|
||||
import './title-bar.component.css'
|
||||
|
||||
export default function TitleBar({template = "main"} : {template?: "update"|"main"|"oneclick"}) {
|
||||
export default function TitleBar({template = "index.html"} : {template: AppWindow}) {
|
||||
|
||||
const ipcService = IpcService.getInstance();
|
||||
const windows = WindowManagerService.getInstance();
|
||||
|
||||
const [maximized, setMaximized] = useState(false);
|
||||
|
||||
const closeWindow = () => {
|
||||
ipcService.sendLazy('window.close');
|
||||
}
|
||||
const closeWindow = () => {
|
||||
return windows.close(template);
|
||||
}
|
||||
|
||||
const maximizeWindow = () => {
|
||||
ipcService.sendLazy('window.maximize');
|
||||
@@ -30,7 +33,7 @@ export default function TitleBar({template = "main"} : {template?: "update"|"mai
|
||||
setMaximized(!maximized);
|
||||
}
|
||||
|
||||
if(template === "main"){
|
||||
if(template === "index.html"){
|
||||
|
||||
return (
|
||||
<header id="titlebar" className="min-h-[22px] bg-light-main-color-1 shrink-0 dark:bg-main-color-1 w-screen h-[22px] flex content-center items-center justify-start z-10">
|
||||
@@ -54,14 +57,14 @@ export default function TitleBar({template = "main"} : {template?: "update"|"mai
|
||||
);
|
||||
|
||||
}
|
||||
if(template === "update"){
|
||||
if(template === "launcher.html"){
|
||||
return (
|
||||
<header id="titlebar" className="min-h-[22px] bg-transparent w-screen h-[22px] z-10">
|
||||
<div id="drag-region" className='grow basis-0 h-full'></div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
if(template === "oneclick"){
|
||||
if(template === "oneclick-download-map.html"){
|
||||
return (
|
||||
<header id="titlebar" className="min-h-[22px] bg-transparent w-screen h-[22px] flex content-center items-center justify-start z-10">
|
||||
<div id="drag-region" className='grow h-full'>
|
||||
|
||||
@@ -22,6 +22,10 @@ export class WindowManagerService{
|
||||
|
||||
public closeAll(except?: AppWindow){
|
||||
this.ipcService.sendLazy<AppWindow>("close-all-windows", {args: except});
|
||||
}
|
||||
}
|
||||
|
||||
public close(...win: AppWindow[]){
|
||||
this.ipcService.sendLazy<AppWindow[]>("close-windows", {args: win});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export default function App() {
|
||||
<NotificationOverlay/>
|
||||
<BsmIframeView/>
|
||||
<div className="relative flex flex-col grow max-w-full min-w-0">
|
||||
<TitleBar/>
|
||||
<TitleBar template="index.html"/>
|
||||
<div className="bg-light-main-color-2 dark:bg-main-color-2 relative rounded-tl-lg grow overflow-hidden max-w-full">
|
||||
<Routes>
|
||||
<Route path="/bs-version/:versionNumber" element={<VersionViewer/>}/>
|
||||
|
||||
@@ -42,7 +42,7 @@ export default function Launcher() {
|
||||
|
||||
return (
|
||||
<div className="w-full h-full">
|
||||
<TitleBar template="update"/>
|
||||
<TitleBar template="launcher.html"/>
|
||||
<div className="relative flex flex-col items-center justify-center pt-10">
|
||||
<motion.div ref={constraintsRef}>
|
||||
<motion.div drag dragConstraints={constraintsRef} animate={{rotate: [0, 10, 0]}} transition={{ duration: .6, repeat: Infinity, repeatDelay: 1.6 }}>
|
||||
|
||||
@@ -59,7 +59,7 @@ export default function OneClickDownloadMap() {
|
||||
|
||||
});
|
||||
|
||||
promise.finally(() => windows.closeAll("index.html"));
|
||||
promise.finally(() =>{});
|
||||
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
@@ -71,7 +71,7 @@ export default function OneClickDownloadMap() {
|
||||
<div className="relative w-screen h-screen overflow-hidden">
|
||||
{cover && <BsmImage className="absolute top-0 left-0 w-full h-full object-cover" image={cover}/>}
|
||||
<div className="w-full h-full backdrop-brightness-50 backdrop-blur-md flex flex-col justify-start items-center gap-10">
|
||||
<TitleBar template="oneclick"/>
|
||||
<TitleBar template="oneclick-download-map.html"/>
|
||||
<BsmImage className="aspect-square w-1/2 object-cover rounded-md shadow-black shadow-lg" placeholder={defaultImage} image={cover} errorImage={defaultImage}/>
|
||||
<h1 className="overflow-hidden font-bold italic text-xl text-gray-200 tracking-wide w-full text-center whitespace-nowrap text-ellipsis px-2">{mapInfo?.name ?? "Chargement de la map..."}</h1>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user