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

Function loadCommands

src/renderer/src/stores/commandDataStore.ts:939–1017  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

937
938 // 加载指令列表
939 async function loadCommands(): Promise<void> {
940 const requestId = ++loadCommandsRequestId
941 loading.value = true
942 try {
943 const [rawApps, plugins, disabledPlugins, disabledMainPushPlugins, commandAliases] =
944 await Promise.all([
945 window.ztools.getApps(),
946 window.ztools.getAllPlugins(),
947 window.ztools.getDisabledPlugins(),
948 window.ztools.dbGet(DISABLED_MAIN_PUSH_PLUGINS_KEY),
949 loadCommandAliases()
950 ])
951
952 let settingCommands: Command[] = []
953 try {
954 const isWindows = window.ztools.getPlatform() === 'win32'
955 if (isWindows) {
956 const settings = await window.ztools.getSystemSettings()
957 settingCommands = settings.map((s: any) => ({
958 name: s.name,
959 path: s.uri,
960 icon: settingsFillIcon,
961 type: 'direct' as const,
962 subType: 'system-setting' as const,
963 settingUri: s.uri,
964 category: s.category,
965 confirmDialog: s.confirmDialog,
966 pinyin: pinyin(s.name, { toneType: 'none', type: 'string' })
967 .replace(/\s+/g, '')
968 .toLowerCase(),
969 pinyinAbbr: pinyin(s.name, { pattern: 'first', toneType: 'none', type: 'string' })
970 .replace(/\s+/g, '')
971 .toLowerCase()
972 }))
973 }
974 } catch (error) {
975 console.error('加载系统设置失败:', error)
976 }
977
978 let localShortcuts: Command[] = []
979 try {
980 const shortcuts = await window.ztools.localShortcuts.getAll()
981 localShortcuts = shortcuts.map((s: any) => ({
982 name: s.alias || s.name,
983 path: s.path,
984 icon: s.icon,
985 type: 'direct' as const,
986 subType: 'local-shortcut' as const,
987 pinyin: s.pinyin || '',
988 pinyinAbbr: s.pinyinAbbr || '',
989 cmdType: 'text' as const
990 }))
991 } catch (error) {
992 console.error('加载本地启动项失败:', error)
993 }
994
995 if (requestId !== loadCommandsRequestId) {
996 return

Callers 1

initializeDataFunction · 0.85

Calls 11

normalizeConfigListFunction · 0.90
loadCommandAliasesFunction · 0.85
setDisabledPluginPathsFunction · 0.85
getEnabledPluginPathsFunction · 0.85
getAppsMethod · 0.80
getAllPluginsMethod · 0.80
getDisabledPluginsMethod · 0.80
getPlatformMethod · 0.80
getSystemSettingsMethod · 0.80
dbGetMethod · 0.45

Tested by

no test coverage detected