Skip to content

Commit dab437c

Browse files
committed
feat(plugin-theme-data): add devtools support
1 parent c7f0c43 commit dab437c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

packages/@vuepress/plugin-theme-data/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"copy": "cpx \"src/**/*.d.ts\" lib"
3030
},
3131
"dependencies": {
32+
"@vue/devtools-api": "^6.0.0-beta.21.1",
3233
"@vuepress/client": "2.0.0-beta.33",
3334
"@vuepress/core": "2.0.0-beta.33",
3435
"@vuepress/shared": "2.0.0-beta.33",

packages/@vuepress/plugin-theme-data/src/client/clientAppEnhance.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setupDevtoolsPlugin } from '@vue/devtools-api'
12
import { defineClientAppEnhance, routeLocaleSymbol } from '@vuepress/client'
23
import { computed } from 'vue'
34
import {
@@ -28,4 +29,37 @@ export default defineClientAppEnhance(({ app }) => {
2829
},
2930
},
3031
})
32+
33+
// setup devtools in dev mode
34+
if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
35+
setupDevtoolsPlugin(
36+
{
37+
app,
38+
id: 'org.vuejs.vuepress.plugin-theme-data',
39+
label: 'VuePress Theme Data Plugin',
40+
packageName: '@vuepress/plugin-theme-data',
41+
homepage: 'https://v2.vuepress.vuejs.org',
42+
logo: 'https://v2.vuepress.vuejs.org/images/hero.png',
43+
componentStateTypes: ['VuePress'],
44+
},
45+
(api) => {
46+
api.on.inspectComponent((payload) => {
47+
payload.instanceData.state.push(
48+
{
49+
type: 'VuePress',
50+
key: 'themeData',
51+
editable: false,
52+
value: themeData.value,
53+
},
54+
{
55+
type: 'VuePress',
56+
key: 'themeLocaleData',
57+
editable: false,
58+
value: themeLocaleData.value,
59+
}
60+
)
61+
})
62+
}
63+
)
64+
}
3165
})

0 commit comments

Comments
 (0)