diff --git a/internal-plugins/system/public/plugin.json b/internal-plugins/system/public/plugin.json index f51c087b..3e4c15bb 100644 --- a/internal-plugins/system/public/plugin.json +++ b/internal-plugins/system/public/plugin.json @@ -90,7 +90,8 @@ "type": "window", "label": "复制路径", "match": { - "app": ["Finder.app", "explorer.exe"] + "app": ["Finder.app", "explorer.exe"], + "className": ["", "CabinetWClass"] } }, { @@ -110,7 +111,8 @@ "type": "window", "label": "在终端打开", "match": { - "app": ["Finder.app", "explorer.exe"] + "app": ["Finder.app", "explorer.exe"], + "className": ["", "CabinetWClass"] } }, { diff --git a/src/main/managers/clipboardManager.ts b/src/main/managers/clipboardManager.ts index cabd05fc..52de6a69 100644 --- a/src/main/managers/clipboardManager.ts +++ b/src/main/managers/clipboardManager.ts @@ -155,6 +155,10 @@ class ClipboardManager { className?: string hwnd?: number }): void { + //Windows下任务栏成为前台窗口时,阻止当前窗口数据的切换 + if (data.app === 'explorer.exe' && data.className === 'Shell_TrayWnd') { + return + } // 直接使用原生数据,保留所有字段 this.currentWindow = { app: data.app, @@ -841,7 +845,7 @@ class ClipboardManager { resolve(null) }, timeoutMs) - const wrappedResolve = (content: LastCopiedContent) => { + const wrappedResolve = (content: LastCopiedContent): void => { if (timer) { clearTimeout(timer) timer = null diff --git a/src/renderer/src/components/search/SearchResults.vue b/src/renderer/src/components/search/SearchResults.vue index d565b16f..ca51a6cd 100644 --- a/src/renderer/src/components/search/SearchResults.vue +++ b/src/renderer/src/components/search/SearchResults.vue @@ -168,7 +168,8 @@ const windowMatchedActions = computed(() => { // 使用 commandDataStore 的 searchWindowCommands 进行匹配 const matched = commandDataStore.searchWindowCommands({ app: currentWindow.app, - title: currentWindow.title + title: currentWindow.title, + className: currentWindow.className }) // 如果有搜索内容,在匹配的窗口指令中进一步搜索 diff --git a/src/renderer/src/stores/commandDataStore.ts b/src/renderer/src/stores/commandDataStore.ts index 09af971e..90f3f133 100644 --- a/src/renderer/src/stores/commandDataStore.ts +++ b/src/renderer/src/stores/commandDataStore.ts @@ -57,6 +57,7 @@ interface WindowCmd { match: { app?: string[] // 匹配应用名称列表(如 ["Finder.app"]) title?: string // 匹配窗口标题的正则表达式字符串 + className?: string[] } } @@ -1350,7 +1351,7 @@ export const useCommandDataStore = defineStore('commandData', () => { function matchesWindowCommand( command: Command, - windowInfo?: { app?: string; title?: string } | null + windowInfo?: { app?: string; title?: string; className?: string } | null ): boolean { if ( !windowInfo || @@ -1368,7 +1369,10 @@ export const useCommandDataStore = defineStore('commandData', () => { // 直接字符串匹配 return windowInfo.app === appPattern }) - if (appMatches) { + const classNameMatches = windowCmd.match.className?.some( + (classNamePattern) => classNamePattern === (windowInfo.className || '') + ) + if (appMatches && (!windowCmd.match.className || classNameMatches)) { return true } } @@ -1385,7 +1389,11 @@ export const useCommandDataStore = defineStore('commandData', () => { } // 搜索支持窗口的指令(根据当前激活窗口进行匹配) - function searchWindowCommands(windowInfo?: { app?: string; title?: string }): SearchResult[] { + function searchWindowCommands(windowInfo?: { + app?: string + title?: string + className?: string + }): SearchResult[] { if (!windowInfo || (!windowInfo.app && !windowInfo.title)) { return [] }