MCPcopy
hub / github.com/ZToolsCenter/ZTools / findCommandIndex

Function findCommandIndex

src/main/api/renderer/commandMatchers.ts:16–46  ·  view source on GitHub ↗
(
  list: any[],
  appPath: string,
  type: string,
  featureCode?: string,
  name?: string
)

Source from the content-addressed store, hash-verified

14 * 其它非插件类型沿用原有 path/name 逻辑。
15 */
16export 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)

Callers 3

addToHistoryMethod · 0.90
updateUsageStatsMethod · 0.90

Calls 1

isDirectAppFunction · 0.85

Tested by

no test coverage detected