feat: add lightweight mode

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

View File

@@ -60,6 +60,7 @@ const SettingVerge = ({ onError }: Props) => {
env_type,
startup_script,
start_page,
enable_lite_mode,
} = verge ?? {};
const configRef = useRef<DialogRef>(null);
const hotkeyRef = useRef<DialogRef>(null);
@@ -69,7 +70,7 @@ const SettingVerge = ({ onError }: Props) => {
const updateRef = useRef<DialogRef>(null);
const backupRef = useRef<DialogRef>(null);
const onChangeData = (patch: Partial<IVergeConfig>) => {
const onChangeData = (patch: any) => {
mutateVerge({ ...verge, ...patch }, false);
};
@@ -292,6 +293,14 @@ const SettingVerge = ({ onError }: Props) => {
<SettingItem onClick={openDevTools} label={t("Open Dev Tools")} />
<SettingItem
label={t("Lite Mode")}
extra={
<TooltipIcon title={t("Lite Mode Info")} sx={{ opacity: "0.7" }} />
}
onClick={() => patchVerge({ enable_lite_mode: true })}
/>
<SettingItem
onClick={() => {
exitApp();

View File

@@ -433,5 +433,7 @@
"Rule Mode": "规则模式",
"Global Mode": "全局模式",
"Direct Mode": "直连模式",
"Enable Tray Speed": "启用托盘速率"
"Enable Tray Speed": "启用托盘速率",
"Lite Mode": "轻量模式",
"Lite Mode Info": "开启后将关闭GUI界面仅保留内核运行"
}

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(() => {