MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / buildAppCommandItems

Function buildAppCommandItems

src/renderer/src/stores/commandDataStore.ts:875–913  ·  view source on GitHub ↗
(rawApps: any[], commandAliases: CommandAliasStore)

Source from the content-addressed store, hash-verified

873 }
874
875 function buildAppCommandItems(rawApps: any[], commandAliases: CommandAliasStore): Command[] {
876 return rawApps.flatMap((app) => {
877 const extendedApp = app as any
878 const baseApp: Command = {
879 ...app,
880 type: extendedApp.type || ('direct' as const),
881 subType: extendedApp.subType || ('app' as const),
882 cmdType: 'text',
883 originalName: app.name,
884 pinyin: pinyin(app.name, { toneType: 'none', type: 'string' })
885 .replace(/\s+/g, '')
886 .toLowerCase(),
887 pinyinAbbr: pinyin(app.name, { pattern: 'first', toneType: 'none', type: 'string' })
888 .replace(/\s+/g, '')
889 .toLowerCase()
890 }
891 const result: Command[] = [baseApp]
892 if (extendedApp.aliases && Array.isArray(extendedApp.aliases)) {
893 for (const alias of extendedApp.aliases) {
894 if (alias && alias !== extendedApp.name) {
895 result.push({
896 ...baseApp,
897 name: alias,
898 pinyin: pinyin(alias, { toneType: 'none', type: 'string' })
899 .replace(/\s+/g, '')
900 .toLowerCase(),
901 pinyinAbbr: pinyin(alias, { pattern: 'first', toneType: 'none', type: 'string' })
902 .replace(/\s+/g, '')
903 .toLowerCase()
904 })
905 }
906 }
907 }
908
909 result.push(...expandDirectAppAliases(baseApp, commandAliases))
910
911 return result
912 })
913 }
914
915 function rebuildCommandCollections(commandAliases: CommandAliasStore): void {
916 const appItems = buildAppCommandItems(rawAppsCache.value, commandAliases)

Callers 1

Calls 1

expandDirectAppAliasesFunction · 0.85

Tested by

no test coverage detected