UPDATE: System tray setting

This commit is contained in:
2025-10-07 13:14:18 +07:00
parent a6b49bef24
commit edbe04b9fc
15 changed files with 682 additions and 477 deletions

View File

@@ -2,29 +2,17 @@
import { useEffect } from "react";
import { Events } from "@wailsio/runtime";
import { toast } from "react-toastify";
import useSettingStore from "@/stores/settingStore";
import { AppService } from "@bindings/firefly-launcher/internal/app-service";
import useModalStore from "@/stores/modalStore";
import useDiffStore from "@/stores/diffStore";
import useLauncherStore from "@/stores/launcherStore";
export function useGlobalEvents({
setGameRunning,
setServerRunning,
setProxyRunning,
setProgressUpdate,
setMaxProgressUpdate,
setProgressDownload,
setDownloadSpeed,
setMessageUpdate,
setStageType,
export function useGlobalEvents() {
const { setIsOpenCloseModal } = useModalStore()
const { setGameRunning, setServerRunning, setProxyRunning, setProgressDownload, setDownloadSpeed } = useLauncherStore()
const { setProgressUpdate, setMaxProgressUpdate, setMessageUpdate, setStageType } = useDiffStore()
}: {
setGameRunning: (v: boolean) => void;
setServerRunning: (v: boolean) => void;
setProxyRunning: (v: boolean) => void;
setProgressUpdate: (v: number) => void;
setMaxProgressUpdate: (v: number) => void;
setProgressDownload: (v: number) => void;
setDownloadSpeed: (v: string) => void;
setMessageUpdate: (v: string) => void;
setStageType: (v: string) => void,
}) {
useEffect(() => {
const onGameExit = () => setGameRunning(false);
const onServerExit = () => setServerRunning(false);
@@ -64,6 +52,20 @@ export function useGlobalEvents({
const { message } = event.data[0];
toast.error(message);
});
Events.On("window:close", async () => {
const option = useSettingStore.getState().closingOption
if (option.isAsk) {
setIsOpenCloseModal(true);
return
}
if (option.isMinimize) {
const [success, message] = await AppService.MinimizeApp()
if (!success) toast.error(message)
} else {
const [success, message] = await AppService.CloseApp()
if (!success) toast.error(message)
}
});
return () => {
Events.Off("download:server");
@@ -75,6 +77,7 @@ export function useGlobalEvents({
Events.Off("diff:message");
Events.Off("diff:stage");
Events.Off("version:check");
Events.Off("window:close");
};
}, []);
}