mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: light mode wip (#96)
* 关闭窗口释放UI资源 * windows 还有左键点击事件 * 兼容enhance profile * bug 修复
This commit is contained in:
@@ -30,7 +30,7 @@ const LayoutControl = () => {
|
||||
<Button
|
||||
size="small"
|
||||
sx={{ minWidth, svg: { transform: "scale(1.05)" } }}
|
||||
onClick={() => appWindow.hide()}
|
||||
onClick={() => appWindow.close()}
|
||||
>
|
||||
<CloseRounded fontSize="small" />
|
||||
</Button>
|
||||
|
||||
@@ -35,7 +35,7 @@ const Layout = () => {
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape") appWindow.hide();
|
||||
if (e.key === "Escape") appWindow.close();
|
||||
});
|
||||
|
||||
listen("verge://refresh-clash-config", async () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { emit, listen } from "@tauri-apps/api/event";
|
||||
import { emit, listen, Event } from "@tauri-apps/api/event";
|
||||
import { appWindow } from "@tauri-apps/api/window";
|
||||
import { CmdType } from "./types";
|
||||
import ignoreCase from "../utils/ignore-case";
|
||||
|
||||
@@ -124,21 +125,29 @@ class Enhance {
|
||||
return this.resultMap.get(uid);
|
||||
}
|
||||
|
||||
async enhanceHandler(event: Event<unknown>) {
|
||||
const payload = event.payload as CmdType.EnhancedPayload;
|
||||
|
||||
const result = await this.runner(payload).catch((err: any) => ({
|
||||
data: null,
|
||||
status: "error",
|
||||
error: err.message,
|
||||
}));
|
||||
|
||||
emit(payload.callback, JSON.stringify(result)).catch(console.error);
|
||||
}
|
||||
// setup the handler
|
||||
setup() {
|
||||
if (this.isSetup) return;
|
||||
this.isSetup = true;
|
||||
|
||||
listen("script-handler", async (event) => {
|
||||
const payload = event.payload as CmdType.EnhancedPayload;
|
||||
await this.enhanceHandler(event);
|
||||
});
|
||||
|
||||
const result = await this.runner(payload).catch((err: any) => ({
|
||||
data: null,
|
||||
status: "error",
|
||||
error: err.message,
|
||||
}));
|
||||
|
||||
emit(payload.callback, JSON.stringify(result)).catch(console.error);
|
||||
listen("script-handler-close", async (event) => {
|
||||
await this.enhanceHandler(event);
|
||||
appWindow.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user