优化事件处理

This commit is contained in:
xintaofei
2026-03-08 17:08:31 +08:00
parent 7a4cbcb73e
commit c1220e1a8f
12 changed files with 178 additions and 64 deletions

View File

@@ -20,6 +20,7 @@ import {
terminalKill,
terminalList,
} from "@/lib/tauri"
import { disposeTauriListener } from "@/lib/tauri-listener"
import type { FolderCommand, TerminalEvent } from "@/lib/types"
import { CommandManageDialog } from "./command-manage-dialog"
@@ -66,7 +67,7 @@ export function CommandDropdown() {
const clearRunningByTerminalId = useCallback((terminalId: string) => {
const unlisten = exitUnlistenersRef.current.get(terminalId)
if (unlisten) {
unlisten()
disposeTauriListener(unlisten, "CommandDropdown.terminalExit")
exitUnlistenersRef.current.delete(terminalId)
}
@@ -85,7 +86,7 @@ export function CommandDropdown() {
const clearAllRunningStates = useCallback(() => {
for (const unlisten of exitUnlistenersRef.current.values()) {
unlisten()
disposeTauriListener(unlisten, "CommandDropdown.terminalExit")
}
exitUnlistenersRef.current.clear()
setRunningCommandTerminals({})