From 917b447a39785a1f255aa37f6505c16784abfebd Mon Sep 17 00:00:00 2001 From: flippedround <734243792@qq.com> Date: Thu, 28 Nov 2024 17:18:50 +0800 Subject: [PATCH] feat: use treeviewer.vue --- packages/client/auto-imports.d.ts | 322 +----------------- packages/client/components.d.ts | 2 + .../client/src/components/basic/NodeTag.vue | 28 ++ .../src/components/basic/ToggleExpanded.vue | 14 + .../client/src/components/tree/TreeViewer.vue | 73 ++++ packages/client/src/composables/select.ts | 27 ++ .../client/src/composables/toggle-expanded.ts | 32 ++ packages/client/src/pages/components.vue | 20 +- packages/client/src/stores/init.ts | 10 +- packages/plugin/inspect/initMPClient.js | 9 +- packages/types/index.d.ts | 1 + 11 files changed, 205 insertions(+), 333 deletions(-) create mode 100644 packages/client/src/components/basic/NodeTag.vue create mode 100644 packages/client/src/components/basic/ToggleExpanded.vue create mode 100644 packages/client/src/components/tree/TreeViewer.vue create mode 100644 packages/client/src/composables/select.ts create mode 100644 packages/client/src/composables/toggle-expanded.ts diff --git a/packages/client/auto-imports.d.ts b/packages/client/auto-imports.d.ts index 42f0384..5c483a2 100644 --- a/packages/client/auto-imports.d.ts +++ b/packages/client/auto-imports.d.ts @@ -19,10 +19,12 @@ declare global { const controlledRef: typeof import('@vueuse/core')['controlledRef'] const createApp: typeof import('vue')['createApp'] const createEventHook: typeof import('@vueuse/core')['createEventHook'] + const createExpandedContext: typeof import('./src/composables/toggle-expanded')['createExpandedContext'] const createGlobalState: typeof import('@vueuse/core')['createGlobalState'] const createInjectionState: typeof import('@vueuse/core')['createInjectionState'] const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn'] const createReusableTemplate: typeof import('@vueuse/core')['createReusableTemplate'] + const createSelectedContext: typeof import('./src/composables/select')['createSelectedContext'] const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable'] const createTemplatePromise: typeof import('@vueuse/core')['createTemplatePromise'] const createUnrefFn: typeof import('@vueuse/core')['createUnrefFn'] @@ -259,6 +261,7 @@ declare global { const useScriptTag: typeof import('@vueuse/core')['useScriptTag'] const useScroll: typeof import('@vueuse/core')['useScroll'] const useScrollLock: typeof import('@vueuse/core')['useScrollLock'] + const useSelect: typeof import('./src/composables/select')['useSelect'] const useSessionStorage: typeof import('@vueuse/core')['useSessionStorage'] const useShare: typeof import('@vueuse/core')['useShare'] const useSlots: typeof import('vue')['useSlots'] @@ -289,6 +292,7 @@ declare global { const useToNumber: typeof import('@vueuse/core')['useToNumber'] const useToString: typeof import('@vueuse/core')['useToString'] const useToggle: typeof import('@vueuse/core')['useToggle'] + const useToggleExpanded: typeof import('./src/composables/toggle-expanded')['useToggleExpanded'] const useTransition: typeof import('@vueuse/core')['useTransition'] const useUrlSearchParams: typeof import('@vueuse/core')['useUrlSearchParams'] const useUserMedia: typeof import('@vueuse/core')['useUserMedia'] @@ -324,7 +328,7 @@ declare global { // for type re-export declare global { // @ts-ignore - export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' + export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' import('vue') } // for vue template auto import @@ -346,10 +350,12 @@ declare module 'vue' { readonly controlledRef: UnwrapRef readonly createApp: UnwrapRef readonly createEventHook: UnwrapRef + readonly createExpandedContext: UnwrapRef readonly createGlobalState: UnwrapRef readonly createInjectionState: UnwrapRef readonly createReactiveFn: UnwrapRef readonly createReusableTemplate: UnwrapRef + readonly createSelectedContext: UnwrapRef readonly createSharedComposable: UnwrapRef readonly createTemplatePromise: UnwrapRef readonly createUnrefFn: UnwrapRef @@ -406,6 +412,7 @@ declare module 'vue' { readonly onStartTyping: UnwrapRef readonly onUnmounted: UnwrapRef readonly onUpdated: UnwrapRef + readonly onWatcherCleanup: UnwrapRef readonly openInEditor: UnwrapRef readonly pausableWatch: UnwrapRef readonly provide: UnwrapRef @@ -523,6 +530,7 @@ declare module 'vue' { readonly useFullscreen: UnwrapRef readonly useGamepad: UnwrapRef readonly useGeolocation: UnwrapRef + readonly useId: UnwrapRef readonly useIdle: UnwrapRef readonly useImage: UnwrapRef readonly useInfiniteScroll: UnwrapRef @@ -540,6 +548,7 @@ declare module 'vue' { readonly useMediaQuery: UnwrapRef readonly useMemoize: UnwrapRef readonly useMemory: UnwrapRef + readonly useModel: UnwrapRef readonly useMounted: UnwrapRef readonly useMouse: UnwrapRef readonly useMouseInElement: UnwrapRef @@ -576,6 +585,7 @@ declare module 'vue' { readonly useScriptTag: UnwrapRef readonly useScroll: UnwrapRef readonly useScrollLock: UnwrapRef + readonly useSelect: UnwrapRef readonly useSessionStorage: UnwrapRef readonly useShare: UnwrapRef readonly useSlots: UnwrapRef @@ -588,6 +598,7 @@ declare module 'vue' { readonly useStyleTag: UnwrapRef readonly useSupported: UnwrapRef readonly useSwipe: UnwrapRef + readonly useTemplateRef: UnwrapRef readonly useTemplateRefsList: UnwrapRef readonly useTextDirection: UnwrapRef readonly useTextSelection: UnwrapRef @@ -604,314 +615,7 @@ declare module 'vue' { readonly useToNumber: UnwrapRef readonly useToString: UnwrapRef readonly useToggle: UnwrapRef - readonly useTransition: UnwrapRef - readonly useUrlSearchParams: UnwrapRef - readonly useUserMedia: UnwrapRef - readonly useVModel: UnwrapRef - readonly useVModels: UnwrapRef - readonly useVibrate: UnwrapRef - readonly useVirtualList: UnwrapRef - readonly useWakeLock: UnwrapRef - readonly useWebNotification: UnwrapRef - readonly useWebSocket: UnwrapRef - readonly useWebWorker: UnwrapRef - readonly useWebWorkerFn: UnwrapRef - readonly useWindowFocus: UnwrapRef - readonly useWindowScroll: UnwrapRef - readonly useWindowSize: UnwrapRef - readonly watch: UnwrapRef - readonly watchArray: UnwrapRef - readonly watchAtMost: UnwrapRef - readonly watchDebounced: UnwrapRef - readonly watchDeep: UnwrapRef - readonly watchEffect: UnwrapRef - readonly watchIgnorable: UnwrapRef - readonly watchImmediate: UnwrapRef - readonly watchOnce: UnwrapRef - readonly watchPausable: UnwrapRef - readonly watchPostEffect: UnwrapRef - readonly watchSyncEffect: UnwrapRef - readonly watchThrottled: UnwrapRef - readonly watchTriggerable: UnwrapRef - readonly watchWithFilter: UnwrapRef - readonly whenever: UnwrapRef - } -} -declare module '@vue/runtime-core' { - interface GlobalComponents {} - interface ComponentCustomProperties { - readonly EffectScope: UnwrapRef - readonly asyncComputed: UnwrapRef - readonly autoResetRef: UnwrapRef - readonly builtinTab: UnwrapRef - readonly computed: UnwrapRef - readonly computedAsync: UnwrapRef - readonly computedEager: UnwrapRef - readonly computedInject: UnwrapRef - readonly computedWithControl: UnwrapRef - readonly consoleTypeColorMap: UnwrapRef - readonly controlledComputed: UnwrapRef - readonly controlledRef: UnwrapRef - readonly createApp: UnwrapRef - readonly createEventHook: UnwrapRef - readonly createGlobalState: UnwrapRef - readonly createInjectionState: UnwrapRef - readonly createReactiveFn: UnwrapRef - readonly createReusableTemplate: UnwrapRef - readonly createSharedComposable: UnwrapRef - readonly createTemplatePromise: UnwrapRef - readonly createUnrefFn: UnwrapRef - readonly customRef: UnwrapRef - readonly debouncedRef: UnwrapRef - readonly debouncedWatch: UnwrapRef - readonly defineAsyncComponent: UnwrapRef - readonly defineComponent: UnwrapRef - readonly definePage: UnwrapRef - readonly devtoolsClientState: UnwrapRef - readonly downloadBase64File: UnwrapRef - readonly eagerComputed: UnwrapRef - readonly effectScope: UnwrapRef - readonly extendRef: UnwrapRef - readonly formatStateType: UnwrapRef - readonly formatStateValue: UnwrapRef - readonly getCurrentInstance: UnwrapRef - readonly getCurrentScope: UnwrapRef - readonly getStateValueType: UnwrapRef - readonly h: UnwrapRef - readonly ignorableWatch: UnwrapRef - readonly inject: UnwrapRef - readonly injectLocal: UnwrapRef - readonly isArray: UnwrapRef - readonly isDefined: UnwrapRef - readonly isMap: UnwrapRef - readonly isPlainObject: UnwrapRef - readonly isProxy: UnwrapRef - readonly isReactive: UnwrapRef - readonly isReadonly: UnwrapRef - readonly isRef: UnwrapRef - readonly isRegExp: UnwrapRef - readonly isSet: UnwrapRef - readonly makeDestructurable: UnwrapRef - readonly markRaw: UnwrapRef - readonly nextTick: UnwrapRef - readonly objectToString: UnwrapRef - readonly onActivated: UnwrapRef - readonly onBeforeMount: UnwrapRef - readonly onBeforeRouteLeave: UnwrapRef - readonly onBeforeRouteUpdate: UnwrapRef - readonly onBeforeUnmount: UnwrapRef - readonly onBeforeUpdate: UnwrapRef - readonly onClickOutside: UnwrapRef - readonly onDeactivated: UnwrapRef - readonly onErrorCaptured: UnwrapRef - readonly onKeyStroke: UnwrapRef - readonly onLongPress: UnwrapRef - readonly onMounted: UnwrapRef - readonly onRenderTracked: UnwrapRef - readonly onRenderTriggered: UnwrapRef - readonly onScopeDispose: UnwrapRef - readonly onServerPrefetch: UnwrapRef - readonly onStartTyping: UnwrapRef - readonly onUnmounted: UnwrapRef - readonly onUpdated: UnwrapRef - readonly openInEditor: UnwrapRef - readonly pausableWatch: UnwrapRef - readonly provide: UnwrapRef - readonly provideLocal: UnwrapRef - readonly reactify: UnwrapRef - readonly reactifyObject: UnwrapRef - readonly reactive: UnwrapRef - readonly reactiveComputed: UnwrapRef - readonly reactiveOmit: UnwrapRef - readonly reactivePick: UnwrapRef - readonly readonly: UnwrapRef - readonly ref: UnwrapRef - readonly refAutoReset: UnwrapRef - readonly refDebounced: UnwrapRef - readonly refDefault: UnwrapRef - readonly refThrottled: UnwrapRef - readonly refWithControl: UnwrapRef - readonly renderCodeHighlight: UnwrapRef - readonly resetDevtoolsClientState: UnwrapRef - readonly resolveComponent: UnwrapRef - readonly resolveRef: UnwrapRef - readonly resolveUnref: UnwrapRef - readonly shallowReactive: UnwrapRef - readonly shallowReadonly: UnwrapRef - readonly shallowRef: UnwrapRef - readonly shiki: UnwrapRef - readonly stateTypeColorMap: UnwrapRef - readonly syncRef: UnwrapRef - readonly syncRefs: UnwrapRef - readonly templateRef: UnwrapRef - readonly throttledRef: UnwrapRef - readonly throttledWatch: UnwrapRef - readonly toRaw: UnwrapRef - readonly toRawType: UnwrapRef - readonly toReactive: UnwrapRef - readonly toRef: UnwrapRef - readonly toRefs: UnwrapRef - readonly toTypeString: UnwrapRef - readonly toValue: UnwrapRef - readonly triggerRef: UnwrapRef - readonly trpc: UnwrapRef - readonly tryOnBeforeMount: UnwrapRef - readonly tryOnBeforeUnmount: UnwrapRef - readonly tryOnMounted: UnwrapRef - readonly tryOnScopeDispose: UnwrapRef - readonly tryOnUnmounted: UnwrapRef - readonly unref: UnwrapRef - readonly unrefElement: UnwrapRef - readonly until: UnwrapRef - readonly useActiveElement: UnwrapRef - readonly useAnimate: UnwrapRef - readonly useArrayDifference: UnwrapRef - readonly useArrayEvery: UnwrapRef - readonly useArrayFilter: UnwrapRef - readonly useArrayFind: UnwrapRef - readonly useArrayFindIndex: UnwrapRef - readonly useArrayFindLast: UnwrapRef - readonly useArrayIncludes: UnwrapRef - readonly useArrayJoin: UnwrapRef - readonly useArrayMap: UnwrapRef - readonly useArrayReduce: UnwrapRef - readonly useArraySome: UnwrapRef - readonly useArrayUnique: UnwrapRef - readonly useAsyncQueue: UnwrapRef - readonly useAsyncState: UnwrapRef - readonly useAttrs: UnwrapRef - readonly useBase64: UnwrapRef - readonly useBattery: UnwrapRef - readonly useBluetooth: UnwrapRef - readonly useBreakpoints: UnwrapRef - readonly useBroadcastChannel: UnwrapRef - readonly useBrowserLocation: UnwrapRef - readonly useCached: UnwrapRef - readonly useClipboard: UnwrapRef - readonly useClipboardItems: UnwrapRef - readonly useCloned: UnwrapRef - readonly useColorMode: UnwrapRef - readonly useConfirmDialog: UnwrapRef - readonly useCopy: UnwrapRef - readonly useCounter: UnwrapRef - readonly useCssModule: UnwrapRef - readonly useCssVar: UnwrapRef - readonly useCssVars: UnwrapRef - readonly useCurrentElement: UnwrapRef - readonly useCycleList: UnwrapRef - readonly useDark: UnwrapRef - readonly useDateFormat: UnwrapRef - readonly useDebounce: UnwrapRef - readonly useDebounceFn: UnwrapRef - readonly useDebouncedRefHistory: UnwrapRef - readonly useDeviceMotion: UnwrapRef - readonly useDeviceOrientation: UnwrapRef - readonly useDevicePixelRatio: UnwrapRef - readonly useDevicesList: UnwrapRef - readonly useDisplayMedia: UnwrapRef - readonly useDocumentVisibility: UnwrapRef - readonly useDraggable: UnwrapRef - readonly useDropZone: UnwrapRef - readonly useElementBounding: UnwrapRef - readonly useElementByPoint: UnwrapRef - readonly useElementHover: UnwrapRef - readonly useElementSize: UnwrapRef - readonly useElementVisibility: UnwrapRef - readonly useEventBus: UnwrapRef - readonly useEventListener: UnwrapRef - readonly useEventSource: UnwrapRef - readonly useEyeDropper: UnwrapRef - readonly useFavicon: UnwrapRef - readonly useFetch: UnwrapRef - readonly useFileDialog: UnwrapRef - readonly useFileSystemAccess: UnwrapRef - readonly useFocus: UnwrapRef - readonly useFocusWithin: UnwrapRef - readonly useFps: UnwrapRef - readonly useFullscreen: UnwrapRef - readonly useGamepad: UnwrapRef - readonly useGeolocation: UnwrapRef - readonly useIdle: UnwrapRef - readonly useImage: UnwrapRef - readonly useInfiniteScroll: UnwrapRef - readonly useInitState: UnwrapRef - readonly useIntersectionObserver: UnwrapRef - readonly useInterval: UnwrapRef - readonly useIntervalFn: UnwrapRef - readonly useKeyModifier: UnwrapRef - readonly useLastChanged: UnwrapRef - readonly useLink: UnwrapRef - readonly useLocalStorage: UnwrapRef - readonly useMagicKeys: UnwrapRef - readonly useManualRefHistory: UnwrapRef - readonly useMediaControls: UnwrapRef - readonly useMediaQuery: UnwrapRef - readonly useMemoize: UnwrapRef - readonly useMemory: UnwrapRef - readonly useMounted: UnwrapRef - readonly useMouse: UnwrapRef - readonly useMouseInElement: UnwrapRef - readonly useMousePressed: UnwrapRef - readonly useMutationObserver: UnwrapRef - readonly useNavigatorLanguage: UnwrapRef - readonly useNetwork: UnwrapRef - readonly useNow: UnwrapRef - readonly useObjectUrl: UnwrapRef - readonly useOffsetPagination: UnwrapRef - readonly useOnline: UnwrapRef - readonly usePageLeave: UnwrapRef - readonly usePagesState: UnwrapRef - readonly useParallax: UnwrapRef - readonly useParentElement: UnwrapRef - readonly usePerformanceObserver: UnwrapRef - readonly usePermission: UnwrapRef - readonly usePointer: UnwrapRef - readonly usePointerLock: UnwrapRef - readonly usePointerSwipe: UnwrapRef - readonly usePreferredColorScheme: UnwrapRef - readonly usePreferredContrast: UnwrapRef - readonly usePreferredDark: UnwrapRef - readonly usePreferredLanguages: UnwrapRef - readonly usePreferredReducedMotion: UnwrapRef - readonly usePrevious: UnwrapRef - readonly useRafFn: UnwrapRef - readonly useRefHistory: UnwrapRef - readonly useResizeObserver: UnwrapRef - readonly useRoute: UnwrapRef - readonly useRouter: UnwrapRef - readonly useScreenOrientation: UnwrapRef - readonly useScreenSafeArea: UnwrapRef - readonly useScriptTag: UnwrapRef - readonly useScroll: UnwrapRef - readonly useScrollLock: UnwrapRef - readonly useSessionStorage: UnwrapRef - readonly useShare: UnwrapRef - readonly useSlots: UnwrapRef - readonly useSorted: UnwrapRef - readonly useSpeechRecognition: UnwrapRef - readonly useSpeechSynthesis: UnwrapRef - readonly useStepper: UnwrapRef - readonly useStorage: UnwrapRef - readonly useStorageAsync: UnwrapRef - readonly useStyleTag: UnwrapRef - readonly useSupported: UnwrapRef - readonly useSwipe: UnwrapRef - readonly useTemplateRefsList: UnwrapRef - readonly useTextDirection: UnwrapRef - readonly useTextSelection: UnwrapRef - readonly useTextareaAutosize: UnwrapRef - readonly useThrottle: UnwrapRef - readonly useThrottleFn: UnwrapRef - readonly useThrottledRefHistory: UnwrapRef - readonly useTimeAgo: UnwrapRef - readonly useTimeout: UnwrapRef - readonly useTimeoutFn: UnwrapRef - readonly useTimeoutPoll: UnwrapRef - readonly useTimestamp: UnwrapRef - readonly useTitle: UnwrapRef - readonly useToNumber: UnwrapRef - readonly useToString: UnwrapRef - readonly useToggle: UnwrapRef + readonly useToggleExpanded: UnwrapRef readonly useTransition: UnwrapRef readonly useUrlSearchParams: UnwrapRef readonly useUserMedia: UnwrapRef diff --git a/packages/client/components.d.ts b/packages/client/components.d.ts index e857682..4af0c39 100644 --- a/packages/client/components.d.ts +++ b/packages/client/components.d.ts @@ -22,6 +22,7 @@ declare module 'vue' { IconTitle: typeof import('./src/components/common/IconTitle.vue')['default'] IframeView: typeof import('./src/components/common/IframeView.vue')['default'] Navbar: typeof import('./src/components/common/Navbar.vue')['default'] + NodeTag: typeof import('./src/components/basic/NodeTag.vue')['default'] PanelGrids: typeof import('./src/components/common/PanelGrids.vue')['default'] RootStateViewer: typeof import('./src/components/state/RootStateViewer.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] @@ -34,5 +35,6 @@ declare module 'vue' { StateFieldsTree: typeof import('./src/components/state/StateFieldsTree.vue')['default'] TabIcon: typeof import('./src/components/TabIcon.vue')['default'] ToggleExpanded: typeof import('./src/components/common/ToggleExpanded.vue')['default'] + TreeViewer: typeof import('./src/components/tree/TreeViewer.vue')['default'] } } diff --git a/packages/client/src/components/basic/NodeTag.vue b/packages/client/src/components/basic/NodeTag.vue new file mode 100644 index 0000000..02a7a95 --- /dev/null +++ b/packages/client/src/components/basic/NodeTag.vue @@ -0,0 +1,28 @@ + + + diff --git a/packages/client/src/components/basic/ToggleExpanded.vue b/packages/client/src/components/basic/ToggleExpanded.vue new file mode 100644 index 0000000..d813f4e --- /dev/null +++ b/packages/client/src/components/basic/ToggleExpanded.vue @@ -0,0 +1,14 @@ + + + diff --git a/packages/client/src/components/tree/TreeViewer.vue b/packages/client/src/components/tree/TreeViewer.vue new file mode 100644 index 0000000..a02c798 --- /dev/null +++ b/packages/client/src/components/tree/TreeViewer.vue @@ -0,0 +1,73 @@ + + + diff --git a/packages/client/src/composables/select.ts b/packages/client/src/composables/select.ts new file mode 100644 index 0000000..2d6356d --- /dev/null +++ b/packages/client/src/composables/select.ts @@ -0,0 +1,27 @@ +import type { InjectionKey, Ref } from 'vue' +import { inject, provide, ref } from 'vue' + +const SelectedSymbolKey: InjectionKey> = Symbol('SelectedSymbolKey') + +export function createSelectedContext() { + const selected = ref('') + + provide>(SelectedSymbolKey, selected) + + return { + selected, + } +} + +export function useSelect() { + const selected = inject>(SelectedSymbolKey, ref(''))! + + function select(value: string) { + selected.value = value + } + + return { + selected, + select, + } +} diff --git a/packages/client/src/composables/toggle-expanded.ts b/packages/client/src/composables/toggle-expanded.ts new file mode 100644 index 0000000..36f1d2b --- /dev/null +++ b/packages/client/src/composables/toggle-expanded.ts @@ -0,0 +1,32 @@ +import type { Ref } from 'vue' +import { inject, provide, ref } from 'vue' + +const expandedKey = 'expanded-state' + +export function createExpandedContext(id = '') { + const expanded = ref([]) + + provide>(`${expandedKey}-${id}`, expanded) + + return { + expanded, + } +} + +export function useToggleExpanded(id = '') { + const expanded = inject>(`${expandedKey}-${id}`, ref([]))! + + function toggleExpanded(key: string) { + const index = expanded.value.indexOf(key) + if (index === -1) + expanded.value.push(key) + + else + expanded.value.splice(index, 1) + } + + return { + expanded, + toggleExpanded, + } +} diff --git a/packages/client/src/pages/components.vue b/packages/client/src/pages/components.vue index 9f4e685..111d858 100644 --- a/packages/client/src/pages/components.vue +++ b/packages/client/src/pages/components.vue @@ -1,25 +1,21 @@ diff --git a/packages/client/src/stores/init.ts b/packages/client/src/stores/init.ts index cc8eeb4..d901039 100644 --- a/packages/client/src/stores/init.ts +++ b/packages/client/src/stores/init.ts @@ -1,8 +1,7 @@ -import type { InitState, VersionState } from '@uni-helper/devtools-types' +import type { VersionState } from '@uni-helper/devtools-types' export const useInitState = createGlobalState( () => { - const initState = ref({}) const versionState = ref() const currentPage = ref('') const loading = ref(false) @@ -18,18 +17,11 @@ export const useInitState = createGlobalState( console.log('currentPage', data) }, }) - trpc.onComponentTree.subscribe(undefined, { - onData: (data) => { - console.log(data) - initState.value.components = data - }, - }) } return { init, loading, - initState, currentPage, versionState, } diff --git a/packages/plugin/inspect/initMPClient.js b/packages/plugin/inspect/initMPClient.js index 42c21e4..067ff0e 100644 --- a/packages/plugin/inspect/initMPClient.js +++ b/packages/plugin/inspect/initMPClient.js @@ -34,7 +34,11 @@ function extractComponentInfo(component) { if (name === 'UniDevTools') return null const file = type.filePath - const componentInfo = { name, file } + const componentInfo = { + name, + file, + id: component.$.uid, + } if (component.$children?.length > 0) { componentInfo.children = component.$children.map(extractComponentInfo).filter(c => c !== null) @@ -44,6 +48,7 @@ function extractComponentInfo(component) { } export function setCurrentPage() { + console.log('initMPClient') onShow(() => { // eslint-disable-next-line no-undef const pages = getCurrentPages() @@ -60,8 +65,6 @@ export function setCurrentPage() { trpc.setComponentTree.subscribe(componentTree, { onComplete: () => {}, }) - console.log('setCurrentPage', currentPage.route) - console.log('setComponentTree', componentTree) trpc.onChangeCurrentPage.subscribe(undefined, { onData: (data) => { diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index a1ab06c..84d2807 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -8,6 +8,7 @@ export interface ModuleInfo { export interface ComponentTreeNode { name: string file: string + id: string children?: ComponentTreeNode[] }