Skip to content

Commit

Permalink
feat(devtools): support select node to bind $vm with console (#2682)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzi1996 authored Dec 27, 2021
1 parent 589e74b commit 80ef079
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions devtools/chrome-extension/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export default styled(({ className, dataSource }) => {
dataSource={dataSource}
onSelect={(info) => {
select(info)
if (chrome && chrome.devtools && chrome.devtools.inspectedWindow) {
chrome.devtools.inspectedWindow.eval(
`window.__FORMILY_DEV_TOOLS_HOOK__.setVm("${info.key}","${
dataSource[info.current][''].id
}")`
)
}
}}
/>
<RightPanel
Expand Down
7 changes: 7 additions & 0 deletions devtools/chrome-extension/src/extension/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ const HOOK = {
closeDevtools() {
this.hasOpenDevtools = false
},
setVm(fieldId: string, formId: string) {
if (fieldId) {
globalThis.$vm = this.store[formId].fields[fieldId]
} else {
globalThis.$vm = this.store[formId]
}
},
inject(id: number, form: any) {
this.hasFormilyInstance = true
this.store[id] = form
Expand Down

0 comments on commit 80ef079

Please sign in to comment.