winupdate-neo/lib/windowFilters.ts
feie9454 520cfd96c7 feat: 别名/屏蔽移到 .env
Co-authored-by: Copilot <copilot@github.com>
2026-04-25 18:17:58 +08:00

19 lines
636 B
TypeScript

import { IGNORED_WINDOW_KEYWORDS } from './config'
export { IGNORED_WINDOW_KEYWORDS }
const normalizedIgnoredWindowKeywords = IGNORED_WINDOW_KEYWORDS.map(keyword => keyword.toLowerCase())
interface WindowLike {
title?: string | null
path?: string | null
}
export const isIgnoredWindow = ({ title, path }: WindowLike) => {
const normalizedValue = `${title ?? ''}\n${path ?? ''}`.toLowerCase()
return normalizedIgnoredWindowKeywords.some(keyword => normalizedValue.includes(keyword))
}
export const filterIgnoredWindows = <T extends WindowLike>(windows: T[]) => {
return windows.filter(window => !isIgnoredWindow(window))
}