Skip to content

Commit 5639e70

Browse files
committed
chore(dev): delayed devtools plugin
1 parent 918df59 commit 5639e70

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

packages/shell-dev-vue3/public/target.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<div id="app"></div>
1414
<div id="app2"></div>
1515
<div id="app3"></div>
16+
<div id="delay-app"></div>
1617
<div id="ghost-app"></div>
1718
<div id="shadow"></div>
1819
<iframe src="/target-iframe.html" width="100%"></iframe>

packages/shell-dev-vue3/src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Mixins from './Mixins.vue'
1818
import Animation from './Animation.vue'
1919
2020
import { h, createApp } from 'vue'
21+
import SimplePlugin from './devtools-plugin/simple'
2122
2223
export default {
2324
name: 'MyApp',
@@ -54,7 +55,9 @@ export default {
5455
5556
methods: {
5657
createApp () {
57-
createApp(Child).mount('#nested-app')
58+
const app = createApp(Child)
59+
app.use(SimplePlugin)
60+
app.mount('#nested-app')
5861
}
5962
}
6063
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { setupDevtoolsPlugin } from '@vue/devtools-api'
2+
3+
export default {
4+
install: (app) => {
5+
setupDevtoolsPlugin({
6+
id: 'simple-plugin',
7+
label: 'Simple devtools plugin',
8+
app
9+
}, (api) => {
10+
api.on.visitComponentTree((payload, ctx) => {
11+
payload.treeNode.tags.push({
12+
label: 'simple plugin',
13+
textColor: 0xFFAAAA,
14+
backgroundColor: 0xFFEEEE
15+
})
16+
})
17+
})
18+
}
19+
}

packages/shell-dev-vue3/src/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createRouter, createWebHashHistory } from 'vue-router'
33
import App from './App.vue'
44
import App3 from './App3.vue'
55
import TestPlugin from './devtools-plugin'
6+
import SimplePlugin from './devtools-plugin/simple'
67
import store from './store'
78

89
// eslint-disable-next-line no-extend-native
@@ -33,6 +34,7 @@ app.use(TestPlugin)
3334
app.mount('#app')
3435

3536
const app2 = createApp({
37+
name: 'App2',
3638
render: () => h('h1', 'App 2')
3739
})
3840
app2.mount('#app2')
@@ -47,3 +49,12 @@ createApp({
4749
hide: true
4850
}
4951
}).mount('#ghost-app')
52+
53+
setTimeout(() => {
54+
const app = createApp({
55+
name: 'DelayedApp',
56+
render: () => h('h1', 'Delayed app')
57+
})
58+
app.use(SimplePlugin)
59+
app.mount('#delay-app')
60+
}, 1000)

0 commit comments

Comments
 (0)