feat: add lightweight mode

This commit is contained in:
wonfen
2025-02-13 02:18:17 +08:00
parent f5760784bf
commit 3b0635e8a1
5 changed files with 57 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import { getPortableFlag } from "@/services/cmds";
import React from "react";
import { TransitionGroup, CSSTransition } from "react-transition-group";
import { useListen } from "@/hooks/use-listen";
import { listen } from "@tauri-apps/api/event";
const appWindow = getCurrentWebviewWindow();
export let portableFlag = false;
@@ -91,6 +92,24 @@ const Layout = () => {
await appWindow.show();
await appWindow.setFocus();
}, 50);
// 监听窗口显示/隐藏事件
const setupListeners = async () => {
const unlisten1 = await listen("verge://hide-window", () => {
appWindow.hide();
});
const unlisten2 = await listen("verge://show-window", () => {
appWindow.show();
});
return () => {
unlisten1();
unlisten2();
};
};
setupListeners();
}, []);
useEffect(() => {