diff --git a/src/main/configs/SelectionConfig.ts b/src/main/configs/SelectionConfig.ts new file mode 100644 index 0000000000..5d1200d121 --- /dev/null +++ b/src/main/configs/SelectionConfig.ts @@ -0,0 +1,37 @@ +interface IBlacklist { + WINDOWS: string[] + MAC?: string[] +} + +/************************************************************************* + * 注意:请不要修改此配置,除非你非常清楚其含义、影响和行为的目的 + * Note: Do not modify this configuration unless you fully understand its meaning, implications, and intended behavior. + * ----------------------------------------------------------------------- + * A predefined application filter list to include commonly used software + * that does not require text selection but may conflict with it, and disable them in advance. + * + * Specification: must be all lowercase, need to accurately find the actual running program name + *************************************************************************/ +export const SELECTION_PREDEFINED_BLACKLIST: IBlacklist = { + WINDOWS: [ + // Screenshot + 'snipaste.exe', + 'pixpin.exe', + 'sharex.exe', + // Image Editor + 'photoshop.exe', + 'illustrator.exe', + // Video Editor + 'adobe premiere pro.exe', + 'afterfx.exe', + // Audio Editor + 'adobe audition.exe', + // 3D Editor + 'blender.exe', + '3dsmax.exe', + 'maya.exe', + // CAD + 'acad.exe', + 'sldworks.exe' + ] +} diff --git a/src/main/services/SelectionService.ts b/src/main/services/SelectionService.ts index a191e67799..c820c5c526 100644 --- a/src/main/services/SelectionService.ts +++ b/src/main/services/SelectionService.ts @@ -1,3 +1,4 @@ +import { SELECTION_PREDEFINED_BLACKLIST } from '@main/configs/SelectionConfig' import { isDev, isWin } from '@main/constant' import { IpcChannel } from '@shared/IpcChannel' import { BrowserWindow, ipcMain, screen } from 'electron' @@ -196,7 +197,27 @@ export class SelectionService { whitelist: 1, blacklist: 2 } - if (!this.selectionHook.setGlobalFilterMode(modeMap[mode], list)) { + + let combinedList: string[] = [] + let combinedMode = mode + + switch (mode) { + case 'blacklist': + //combine the predefined blacklist with the user-defined blacklist + combinedList = [...new Set([...list, ...SELECTION_PREDEFINED_BLACKLIST.WINDOWS])] + break + case 'whitelist': + combinedList = [...list] + break + case 'default': + default: + //use the predefined blacklist as the default filter list + combinedList = [...SELECTION_PREDEFINED_BLACKLIST.WINDOWS] + combinedMode = 'blacklist' + break + } + + if (!this.selectionHook.setGlobalFilterMode(modeMap[combinedMode], combinedList)) { this.logError(new Error('Failed to set selection-hook global filter mode')) } } diff --git a/src/renderer/src/pages/settings/SelectionAssistantSettings/SelectionFilterListModal.tsx b/src/renderer/src/pages/settings/SelectionAssistantSettings/SelectionFilterListModal.tsx index 8b9ca31fc2..e3076b408b 100644 --- a/src/renderer/src/pages/settings/SelectionAssistantSettings/SelectionFilterListModal.tsx +++ b/src/renderer/src/pages/settings/SelectionAssistantSettings/SelectionFilterListModal.tsx @@ -25,13 +25,13 @@ const SelectionFilterListModal: FC = ({ open, onC const handleSave = async () => { try { const values = await form.validateFields() - const newList = values.filterList + const newList = (values.filterList as string) .trim() .toLowerCase() .split('\n') - .map((line: string) => line.trim()) + .map((line: string) => line.trim().slice(0, 32)) .filter((line: string) => line.length > 0) - onSave(newList) + onSave([...new Set(newList)]) onClose() } catch (error) { // validation failed @@ -57,7 +57,7 @@ const SelectionFilterListModal: FC = ({ open, onC {t('selection.settings.filter_modal.user_tips')}
- +