| 5 | |
| 6 | //检查该窗口是否在白名单内 |
| 7 | function checkList(windowName: string, identifier: BlackWhiteType): boolean { |
| 8 | const mode = config.get(`${identifier}Mode` as Identifier) as string; |
| 9 | if (mode.indexOf("Global") != -1) { |
| 10 | return true; |
| 11 | } |
| 12 | if (mode.indexOf("WhiteList") != -1) { |
| 13 | const whitelist = config.get( |
| 14 | `${identifier}WhiteList` as Identifier |
| 15 | ) as string[]; |
| 16 | return whitelist.includes(windowName); |
| 17 | } |
| 18 | if (mode.indexOf("BlackList") != -1) { |
| 19 | const blacklist = config.get( |
| 20 | `${identifier}BlackList` as Identifier |
| 21 | ) as string[]; |
| 22 | return !blacklist.includes(windowName); |
| 23 | } |
| 24 | throw "Unknown Mode"; |
| 25 | } |
| 26 | |
| 27 | //注册该窗口,同时检查是否是在白名单内 |
| 28 | export async function isValidWindow( |