fix: resolve from lightweight cause crash (#4682)

* refactor: streamline lightweight mode handling and improve window management

* refactor: replace mutex-based window creation lock with atomic operations for improved performance

* refactor: remove startup completed event handling and simplify initialization logic

* refactor: remove conditional compilation for emit_update_event function

* refactor: simplify return statements and clean up commented code in lightweight and window manager modules

* refactor: streamline lightweight mode handling by consolidating window management calls

* refactor: prevent unnecessary window toggle when exiting lightweight mode

* refactor: reorder imports for consistency in lightweight module

* refactor: move macOS specific logging_error import for clarity
This commit is contained in:
Tunglies
2025-09-09 18:50:24 +08:00
committed by GitHub
Unverified
parent c54d89a465
commit dfc1f736af
10 changed files with 209 additions and 256 deletions

View File

@@ -379,14 +379,6 @@ const Layout = () => {
const setupEventListener = async () => {
try {
console.log("[Layout] 开始监听启动完成事件");
const unlisten = await listen("verge://startup-completed", () => {
if (!hasEventTriggered) {
console.log("[Layout] 收到启动完成事件,开始初始化");
hasEventTriggered = true;
performInitialization();
}
});
return unlisten;
} catch (err) {
console.error("[Layout] 监听启动完成事件失败:", err);
return () => {};
@@ -425,14 +417,11 @@ const Layout = () => {
}
}, 5000);
const unlistenPromise = setupEventListener();
setTimeout(checkImmediateInitialization, 100);
return () => {
clearTimeout(backupInitialization);
clearTimeout(emergencyInitialization);
unlistenPromise.then((unlisten) => unlisten());
};
}, []);