( list: any[], appPath: string, type: string, featureCode?: string, name?: string )
| 14 | * 其它非插件类型沿用原有 path/name 逻辑。 |
| 15 | */ |
| 16 | export function findCommandIndex( |
| 17 | list: any[], |
| 18 | appPath: string, |
| 19 | type: string, |
| 20 | featureCode?: string, |
| 21 | name?: string |
| 22 | ): number { |
| 23 | return list.findIndex((item) => { |
| 24 | if (item.type === 'plugin' && type === 'plugin') { |
| 25 | if (item.featureCode !== featureCode) { |
| 26 | return false |
| 27 | } |
| 28 | if (name && item.pluginName) { |
| 29 | return item.pluginName === name |
| 30 | } |
| 31 | return item.path === appPath |
| 32 | } |
| 33 | |
| 34 | if (isDirectApp(item, type)) { |
| 35 | if (name) { |
| 36 | return item.path === appPath && item.name === name |
| 37 | } |
| 38 | return item.path === appPath |
| 39 | } |
| 40 | |
| 41 | if (name) { |
| 42 | return item.path === appPath && item.name === name |
| 43 | } |
| 44 | return item.path === appPath |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * 过滤掉匹配项(用于 removeFromHistory / unpinApp) |
no test coverage detected