Skip to content

Commit 3444a07

Browse files
committed
feat: update for vue3
1 parent 2d170a0 commit 3444a07

4 files changed

Lines changed: 29 additions & 20 deletions

File tree

packages/core/src/load.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// import * as Vue from 'vue'
2-
import Vue from 'vue'
3-
import App from 'virtual:vue-inspector-path:Overlay.vue'
41
import inspectorOptions from 'virtual:vue-inspector-options'
2+
import App from 'virtual:vue-inspector-path:Overlay.vue'
53

64
const CONTAINER_ID = 'vue-inspector-container'
75

@@ -15,29 +13,21 @@ function createInspectorContainer() {
1513
return el
1614
}
1715

18-
function load() {
16+
async function load() {
1917
const isClient = typeof window !== 'undefined'
2018
if (!isClient)
2119
return
2220
createInspectorContainer()
2321
const { vue } = inspectorOptions
22+
// console.log('load inspectorOptions', vue, `loadVue${vue}`)
2423

25-
console.log('load inspectorOptions', inspectorOptions)
24+
let res = {}
25+
if (vue === 3)
26+
res = await import('./loadVue3.js')
27+
else
28+
res = await import('./loadVue2.js')
2629

27-
// vue 2/3 compatibility
28-
vue === 3
29-
? Vue.createApp({
30-
render: () => Vue.h(App),
31-
devtools: {
32-
hide: true,
33-
},
34-
}).mount(`#${CONTAINER_ID}`)
35-
: new Vue({
36-
render: h => h(App),
37-
devtools: {
38-
hide: true,
39-
},
40-
}).$mount(`#${CONTAINER_ID}`)
30+
res.loadVue(CONTAINER_ID, App)
4131
}
4232

4333
if (inspectorOptions.lazyLoad)

packages/core/src/loadVue2.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Vue from 'vue'
2+
3+
export function loadVue(CONTAINER_ID, App) {
4+
new Vue({
5+
render: h => h(App),
6+
devtools: {
7+
hide: true,
8+
},
9+
}).$mount(`#${CONTAINER_ID}`)
10+
}

packages/core/src/loadVue3.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Vue from 'vue'
2+
3+
export function loadVue(CONTAINER_ID, App) {
4+
Vue.createApp({
5+
render: () => Vue.h(App),
6+
devtools: {
7+
hide: true,
8+
},
9+
}).mount(`#${CONTAINER_ID}`)
10+
}

packages/playground/vue3/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export default defineConfig({
99
Vue(),
1010
VueJsx(),
1111
Inspector({
12-
enabled: true,
1312
toggleButtonVisibility: 'always',
1413
launchEditor: 'code',
1514
}),

0 commit comments

Comments
 (0)