mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore] add routes for IPCs + migrate all old ipc.send to sendV2 + remove some dead code
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { useConstant } from "./use-constant.hook";
|
||||
|
||||
export function useWindowArgs<Key extends string>(...keys: Key[]): Record<Key, string|undefined> {
|
||||
|
||||
const getArgs = (...keys: Key[]) => {
|
||||
const url = new URLSearchParams(window.location.search);
|
||||
const result = {} as Record<Key, string>;
|
||||
keys.forEach(key => {
|
||||
result[key] = url.get(key) || undefined;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return useConstant(() => getArgs(...keys));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { IpcService } from "renderer/services/ipc.service";
|
||||
import { useService } from "./use-service.hook";
|
||||
import { useConstant } from "./use-constant.hook";
|
||||
import { lastValueFrom } from "rxjs";
|
||||
|
||||
export function useWindowControls() {
|
||||
const ipc = useService(IpcService);
|
||||
|
||||
const { close, maximise, minimise, unmaximise } = useConstant(() => ({
|
||||
close: () => lastValueFrom(ipc.sendV2("close-window")),
|
||||
maximise: () => lastValueFrom(ipc.sendV2("maximise-window")),
|
||||
minimise: () => lastValueFrom(ipc.sendV2("minimise-window")),
|
||||
unmaximise: () => lastValueFrom(ipc.sendV2("unmaximise-window"))
|
||||
}));
|
||||
|
||||
return { close, maximise, minimise, unmaximise };
|
||||
}
|
||||
Reference in New Issue
Block a user