Skip to content

Commit 1a6ee16

Browse files
committed
完善 ui 选项的读写
1 parent 3400625 commit 1a6ee16

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

ui.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
11
module.exports = api => {
22
api.describeConfig({
3-
// 唯一的配置 ID
43
id: 'vueconf.demo',
5-
// 展示名称
64
name: 'vueconf',
7-
// 该配置所有可能的文件
85
files: {
96
vue: {
107
js: ['vue.config.js']
118
}
9+
},
10+
onRead: ({
11+
data
12+
}) => {
13+
return {
14+
prompts: [{
15+
name: 'themeColor',
16+
type: 'color',
17+
message: '选择一种配置的颜色',
18+
default: '#4DBA87',
19+
value: data.vue.pluginOptions && data.vue.pluginOptions.vueconf && data.vue.pluginOptions.vueconf.themeColor
20+
},
21+
{
22+
name: 'welcome',
23+
type: 'input',
24+
message: '项目介绍',
25+
description: '请输入这个项目的介绍',
26+
default: 'Learn React',
27+
value: data.vue.pluginOptions && data.vue.pluginOptions.vueconf && data.vue.pluginOptions.vueconf.welcome
28+
}
29+
]
30+
}
31+
},
32+
onWrite: async ({
33+
api,
34+
prompts
35+
}) => {
36+
const result = {}
37+
for (const prompt of prompts) {
38+
result[`pluginOptions.vueconf.${prompt.id}`] = await api.getAnswer(prompt.id)
39+
}
40+
api.setData('vue', result)
1241
}
1342
})
1443
}

0 commit comments

Comments
 (0)