king-design-analyzer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -0
- package/components/affix.json +178 -0
- package/components/az.json +86 -0
- package/components/badge.json +162 -0
- package/components/billtypes.json +90 -0
- package/components/breadcrumb.json +220 -0
- package/components/button.json +511 -0
- package/components/card.json +334 -0
- package/components/cardcontent.json +144 -0
- package/components/carousel.json +207 -0
- package/components/cascader.json +373 -0
- package/components/checkbox.json +298 -0
- package/components/code.json +318 -0
- package/components/collapse.json +358 -0
- package/components/copy.json +220 -0
- package/components/datepicker.json +529 -0
- package/components/descriptions.json +309 -0
- package/components/dialog.json +460 -0
- package/components/divider.json +287 -0
- package/components/drawer.json +563 -0
- package/components/dropdown.json +407 -0
- package/components/editable.json +331 -0
- package/components/ellipsis.json +218 -0
- package/components/form.json +638 -0
- package/components/grid.json +377 -0
- package/components/icon.json +442 -0
- package/components/input.json +821 -0
- package/components/layoutcontent.json +210 -0
- package/components/menu.json +482 -0
- package/components/message.json +345 -0
- package/components/pagination.json +444 -0
- package/components/paginationplus.json +74 -0
- package/components/popover.json +456 -0
- package/components/progress.json +354 -0
- package/components/protable.json +132 -0
- package/components/radio.json +246 -0
- package/components/region.json +115 -0
- package/components/select.json +676 -0
- package/components/slider.json +422 -0
- package/components/spin.json +232 -0
- package/components/spinner.json +441 -0
- package/components/status.json +75 -0
- package/components/steps.json +292 -0
- package/components/switch.json +357 -0
- package/components/table.json +1057 -0
- package/components/tablecolumnid.json +217 -0
- package/components/tabs.json +363 -0
- package/components/tag.json +504 -0
- package/components/timepicker.json +447 -0
- package/components/tip.json +322 -0
- package/components/tooltip.json +416 -0
- package/components/tour.json +395 -0
- package/components/transfer.json +414 -0
- package/components/tree.json +480 -0
- package/components/treeselect.json +478 -0
- package/components/upload.json +499 -0
- package/components/virtuallist.json +178 -0
- package/dist/ast/index.d.mts +71 -0
- package/dist/ast/index.d.ts +71 -0
- package/dist/ast/index.js +15 -0
- package/dist/ast/index.mjs +2 -0
- package/dist/chunk-4BUGNH4F.mjs +62 -0
- package/dist/chunk-5H7N2A5X.mjs +1 -0
- package/dist/chunk-5IF32MBB.js +603 -0
- package/dist/chunk-ARWRNWDW.js +219 -0
- package/dist/chunk-C3L4IXJC.mjs +577 -0
- package/dist/chunk-GNVCC37B.js +102 -0
- package/dist/chunk-N4UIA6DN.js +68 -0
- package/dist/chunk-RAMIBZAU.mjs +216 -0
- package/dist/chunk-RNQHI7YG.js +64 -0
- package/dist/chunk-TB6BF5TJ.mjs +99 -0
- package/dist/chunk-UX7KGX45.mjs +66 -0
- package/dist/chunk-YTEYDSDW.js +2 -0
- package/dist/full/index.d.mts +29 -0
- package/dist/full/index.d.ts +29 -0
- package/dist/full/index.js +16 -0
- package/dist/full/index.mjs +3 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +43 -0
- package/dist/index.mjs +6 -0
- package/dist/runtime/index.d.mts +14 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.mjs +2 -0
- package/dist/sfcCompiler-m51JOfWs.d.mts +22 -0
- package/dist/sfcCompiler-m51JOfWs.d.ts +22 -0
- package/dist/static/index.d.mts +14 -0
- package/dist/static/index.d.ts +14 -0
- package/dist/static/index.js +19 -0
- package/dist/static/index.mjs +2 -0
- package/package.json +88 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "checkbox",
|
|
3
|
+
"name": "Checkbox",
|
|
4
|
+
"displayName": "复选框",
|
|
5
|
+
"category": "form",
|
|
6
|
+
"description": "复选框组件,用于多选场景。支持单独使用或作为复选框组使用,支持半选中状态(全选/部分选中)、自定义值等功能。",
|
|
7
|
+
"importStatement": "import { Checkbox } from '@king-design/vue';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "value",
|
|
11
|
+
"description": "复选框的取值,可用 v-model 双向绑定。单独使用时为布尔值,组合使用时为数组",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "any",
|
|
14
|
+
"kind": "custom"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"default": "false",
|
|
18
|
+
"usageExample": "<Checkbox v-model=\"checked\">选项</Checkbox>"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "trueValue",
|
|
22
|
+
"description": "选中时的值",
|
|
23
|
+
"type": {
|
|
24
|
+
"raw": "any",
|
|
25
|
+
"kind": "custom"
|
|
26
|
+
},
|
|
27
|
+
"required": false,
|
|
28
|
+
"default": "true",
|
|
29
|
+
"usageExample": "<Checkbox trueValue=\"yes\" falseValue=\"no\">"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "falseValue",
|
|
33
|
+
"description": "未选中时的值",
|
|
34
|
+
"type": {
|
|
35
|
+
"raw": "any",
|
|
36
|
+
"kind": "custom"
|
|
37
|
+
},
|
|
38
|
+
"required": false,
|
|
39
|
+
"default": "false",
|
|
40
|
+
"usageExample": "<Checkbox trueValue=\"active\" falseValue=\"inactive\">"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "disabled",
|
|
44
|
+
"description": "是否禁用",
|
|
45
|
+
"type": {
|
|
46
|
+
"raw": "boolean",
|
|
47
|
+
"kind": "boolean"
|
|
48
|
+
},
|
|
49
|
+
"required": false,
|
|
50
|
+
"default": "false",
|
|
51
|
+
"usageExample": "<Checkbox disabled>禁用</Checkbox>"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "indeterminate",
|
|
55
|
+
"description": "是否半选中状态,用于实现全选功能时表示部分选中",
|
|
56
|
+
"type": {
|
|
57
|
+
"raw": "boolean",
|
|
58
|
+
"kind": "boolean"
|
|
59
|
+
},
|
|
60
|
+
"required": false,
|
|
61
|
+
"default": "false",
|
|
62
|
+
"usageExample": "<Checkbox :indeterminate=\"isPartialChecked\">"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "name",
|
|
66
|
+
"description": "原生 name 属性",
|
|
67
|
+
"type": {
|
|
68
|
+
"raw": "string",
|
|
69
|
+
"kind": "string"
|
|
70
|
+
},
|
|
71
|
+
"required": false,
|
|
72
|
+
"default": "undefined",
|
|
73
|
+
"usageExample": "<Checkbox name=\"agreement\">"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "required",
|
|
77
|
+
"description": "原生 required 属性",
|
|
78
|
+
"type": {
|
|
79
|
+
"raw": "boolean",
|
|
80
|
+
"kind": "boolean"
|
|
81
|
+
},
|
|
82
|
+
"required": false,
|
|
83
|
+
"default": "undefined",
|
|
84
|
+
"usageExample": "<Checkbox required>"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "form",
|
|
88
|
+
"description": "原生 form 属性",
|
|
89
|
+
"type": {
|
|
90
|
+
"raw": "string",
|
|
91
|
+
"kind": "string"
|
|
92
|
+
},
|
|
93
|
+
"required": false,
|
|
94
|
+
"default": "undefined",
|
|
95
|
+
"usageExample": "<Checkbox form=\"myForm\">"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "autofocus",
|
|
99
|
+
"description": "原生 autofocus 属性",
|
|
100
|
+
"type": {
|
|
101
|
+
"raw": "boolean",
|
|
102
|
+
"kind": "boolean"
|
|
103
|
+
},
|
|
104
|
+
"required": false,
|
|
105
|
+
"default": "undefined",
|
|
106
|
+
"usageExample": "<Checkbox autofocus>"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"events": [
|
|
110
|
+
{
|
|
111
|
+
"name": "change",
|
|
112
|
+
"vueEventName": "@change",
|
|
113
|
+
"description": "当点击组件导致值变化时触发",
|
|
114
|
+
"payload": [
|
|
115
|
+
{
|
|
116
|
+
"name": "value",
|
|
117
|
+
"type": "any",
|
|
118
|
+
"description": "变化后的值"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "e",
|
|
122
|
+
"type": "MouseEvent",
|
|
123
|
+
"description": "原生鼠标事件"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"usageExample": "<Checkbox @change=\"handleChange\">",
|
|
127
|
+
"handlerExample": "const handleChange = (value: boolean, e: MouseEvent) => {\n console.log('选中状态:', value);\n};"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"methods": [],
|
|
131
|
+
"examples": [
|
|
132
|
+
{
|
|
133
|
+
"id": "checkbox_basic",
|
|
134
|
+
"title": "基础用法",
|
|
135
|
+
"description": "基本的复选框",
|
|
136
|
+
"difficulty": "easy",
|
|
137
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Checkbox } from '@king-design/vue';\n\nconst checked = ref(false);\n</script>\n<template>\n <Checkbox v-model=\"checked\">同意用户协议</Checkbox>\n <p>当前状态: {{ checked }}</p>\n</template>",
|
|
138
|
+
"tags": [
|
|
139
|
+
"basic"
|
|
140
|
+
],
|
|
141
|
+
"usedProps": [
|
|
142
|
+
"value"
|
|
143
|
+
],
|
|
144
|
+
"usedEvents": [],
|
|
145
|
+
"usedMethods": [],
|
|
146
|
+
"scenario": "创建一个基本的复选框"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"id": "checkbox_group",
|
|
150
|
+
"title": "复选框组",
|
|
151
|
+
"description": "多个复选框组合使用",
|
|
152
|
+
"difficulty": "medium",
|
|
153
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Checkbox } from '@king-design/vue';\n\nconst checkedList = ref<string[]>([]);\n</script>\n<template>\n <Checkbox v-model=\"checkedList\" trueValue=\"apple\">苹果</Checkbox>\n <Checkbox v-model=\"checkedList\" trueValue=\"banana\">香蕉</Checkbox>\n <Checkbox v-model=\"checkedList\" trueValue=\"orange\">橙子</Checkbox>\n <p>已选择: {{ checkedList.join(', ') }}</p>\n</template>",
|
|
154
|
+
"tags": [
|
|
155
|
+
"group",
|
|
156
|
+
"multiple"
|
|
157
|
+
],
|
|
158
|
+
"usedProps": [
|
|
159
|
+
"value",
|
|
160
|
+
"trueValue"
|
|
161
|
+
],
|
|
162
|
+
"usedEvents": [],
|
|
163
|
+
"usedMethods": [],
|
|
164
|
+
"scenario": "创建复选框组实现多选"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"id": "checkbox_disabled",
|
|
168
|
+
"title": "禁用状态",
|
|
169
|
+
"description": "禁用的复选框",
|
|
170
|
+
"difficulty": "easy",
|
|
171
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Checkbox } from '@king-design/vue';\n\nconst checked = ref(true);\n</script>\n<template>\n <Checkbox disabled>未选中禁用</Checkbox>\n <Checkbox v-model=\"checked\" disabled>选中禁用</Checkbox>\n</template>",
|
|
172
|
+
"tags": [
|
|
173
|
+
"disabled"
|
|
174
|
+
],
|
|
175
|
+
"usedProps": [
|
|
176
|
+
"value",
|
|
177
|
+
"disabled"
|
|
178
|
+
],
|
|
179
|
+
"usedEvents": [],
|
|
180
|
+
"usedMethods": [],
|
|
181
|
+
"scenario": "禁用复选框"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"id": "checkbox_indeterminate",
|
|
185
|
+
"title": "全选/半选",
|
|
186
|
+
"description": "实现全选功能",
|
|
187
|
+
"difficulty": "hard",
|
|
188
|
+
"code": "<script setup lang=\"ts\">\nimport { ref, computed } from 'vue';\nimport { Checkbox } from '@king-design/vue';\n\nconst options = ['选项1', '选项2', '选项3'];\nconst checkedList = ref<string[]>([]);\n\nconst checkAll = computed({\n get: () => checkedList.value.length === options.length,\n set: (val) => {\n checkedList.value = val ? [...options] : [];\n }\n});\n\nconst indeterminate = computed(() => \n checkedList.value.length > 0 && checkedList.value.length < options.length\n);\n</script>\n<template>\n <Checkbox v-model=\"checkAll\" :indeterminate=\"indeterminate\">全选</Checkbox>\n <hr />\n <Checkbox v-for=\"opt in options\" :key=\"opt\" v-model=\"checkedList\" :trueValue=\"opt\">\n {{ opt }}\n </Checkbox>\n</template>",
|
|
189
|
+
"tags": [
|
|
190
|
+
"indeterminate",
|
|
191
|
+
"checkAll",
|
|
192
|
+
"selectAll"
|
|
193
|
+
],
|
|
194
|
+
"usedProps": [
|
|
195
|
+
"value",
|
|
196
|
+
"indeterminate",
|
|
197
|
+
"trueValue"
|
|
198
|
+
],
|
|
199
|
+
"usedEvents": [],
|
|
200
|
+
"usedMethods": [],
|
|
201
|
+
"scenario": "实现全选/部分选中功能"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "checkbox_custom_value",
|
|
205
|
+
"title": "自定义值",
|
|
206
|
+
"description": "使用自定义的选中/未选中值",
|
|
207
|
+
"difficulty": "easy",
|
|
208
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Checkbox } from '@king-design/vue';\n\nconst status = ref('inactive');\n</script>\n<template>\n <Checkbox v-model=\"status\" trueValue=\"active\" falseValue=\"inactive\">\n 激活状态\n </Checkbox>\n <p>当前状态: {{ status }}</p>\n</template>",
|
|
209
|
+
"tags": [
|
|
210
|
+
"trueValue",
|
|
211
|
+
"falseValue",
|
|
212
|
+
"custom"
|
|
213
|
+
],
|
|
214
|
+
"usedProps": [
|
|
215
|
+
"value",
|
|
216
|
+
"trueValue",
|
|
217
|
+
"falseValue"
|
|
218
|
+
],
|
|
219
|
+
"usedEvents": [],
|
|
220
|
+
"usedMethods": [],
|
|
221
|
+
"scenario": "使用自定义的字符串值作为选中状态"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"id": "checkbox_change_event",
|
|
225
|
+
"title": "监听变化",
|
|
226
|
+
"description": "监听复选框状态变化",
|
|
227
|
+
"difficulty": "easy",
|
|
228
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Checkbox, Message } from '@king-design/vue';\n\nconst checked = ref(false);\n\nconst handleChange = (value: boolean) => {\n Message.info(`状态变更为: ${value}`);\n};\n</script>\n<template>\n <Checkbox v-model=\"checked\" @change=\"handleChange\">\n 点击我\n </Checkbox>\n</template>",
|
|
229
|
+
"tags": [
|
|
230
|
+
"change",
|
|
231
|
+
"event"
|
|
232
|
+
],
|
|
233
|
+
"usedProps": [
|
|
234
|
+
"value"
|
|
235
|
+
],
|
|
236
|
+
"usedEvents": [
|
|
237
|
+
"change"
|
|
238
|
+
],
|
|
239
|
+
"usedMethods": [],
|
|
240
|
+
"scenario": "监听复选框的状态变化"
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"commonMistakes": [
|
|
244
|
+
{
|
|
245
|
+
"id": "checkbox_group_value_type",
|
|
246
|
+
"description": "复选框组使用错误的 value 类型",
|
|
247
|
+
"wrongCode": "const checked = ref(false);\n<Checkbox v-model=\"checked\" trueValue=\"apple\">苹果</Checkbox>\n<Checkbox v-model=\"checked\" trueValue=\"banana\">香蕉</Checkbox>",
|
|
248
|
+
"correctCode": "const checkedList = ref<string[]>([]);\n<Checkbox v-model=\"checkedList\" trueValue=\"apple\">苹果</Checkbox>\n<Checkbox v-model=\"checkedList\" trueValue=\"banana\">香蕉</Checkbox>",
|
|
249
|
+
"explanation": "复选框组需要使用数组类型的 value",
|
|
250
|
+
"relatedProps": [
|
|
251
|
+
"value",
|
|
252
|
+
"trueValue"
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"id": "checkbox_indeterminate_without_handler",
|
|
257
|
+
"description": "使用 indeterminate 但未正确处理全选逻辑",
|
|
258
|
+
"wrongCode": "<Checkbox :indeterminate=\"true\">全选</Checkbox>",
|
|
259
|
+
"correctCode": "<Checkbox v-model=\"checkAll\" :indeterminate=\"indeterminate\">全选</Checkbox>",
|
|
260
|
+
"explanation": "indeterminate 只控制视觉样式,需要配合 v-model 和计算属性实现全选逻辑",
|
|
261
|
+
"relatedProps": [
|
|
262
|
+
"indeterminate",
|
|
263
|
+
"value"
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"id": "checkbox_custom_value_mismatch",
|
|
268
|
+
"description": "自定义值类型与初始值不匹配",
|
|
269
|
+
"wrongCode": "const value = ref(false);\n<Checkbox v-model=\"value\" trueValue=\"yes\" falseValue=\"no\">",
|
|
270
|
+
"correctCode": "const value = ref('no');\n<Checkbox v-model=\"value\" trueValue=\"yes\" falseValue=\"no\">",
|
|
271
|
+
"explanation": "使用自定义值时,初始值应与 trueValue 或 falseValue 类型匹配",
|
|
272
|
+
"relatedProps": [
|
|
273
|
+
"value",
|
|
274
|
+
"trueValue",
|
|
275
|
+
"falseValue"
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
"searchKeywords": [
|
|
280
|
+
"复选框",
|
|
281
|
+
"checkbox",
|
|
282
|
+
"多选",
|
|
283
|
+
"勾选",
|
|
284
|
+
"全选",
|
|
285
|
+
"半选"
|
|
286
|
+
],
|
|
287
|
+
"useCases": [
|
|
288
|
+
"多选列表",
|
|
289
|
+
"协议同意",
|
|
290
|
+
"表单多选项",
|
|
291
|
+
"批量选择",
|
|
292
|
+
"权限勾选"
|
|
293
|
+
],
|
|
294
|
+
"relatedComponents": [
|
|
295
|
+
"Radio",
|
|
296
|
+
"Switch"
|
|
297
|
+
]
|
|
298
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "code",
|
|
3
|
+
"name": "Code",
|
|
4
|
+
"displayName": "代码编辑器",
|
|
5
|
+
"category": "data-display",
|
|
6
|
+
"description": "代码编辑器组件,基于 Monaco Editor 实现。支持多种编程语言、多种主题、只读模式等功能。注意:由于 Monaco Editor 较大,该组件不会默认加入 index.js。",
|
|
7
|
+
"importStatement": "import { Code } from '@king-design/vue';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "value",
|
|
11
|
+
"description": "编辑器的代码内容,可用 v-model 双向绑定",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "string",
|
|
14
|
+
"kind": "string"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"default": "\"\"",
|
|
18
|
+
"usageExample": "<Code v-model=\"code\" />"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "language",
|
|
22
|
+
"description": "指定编程语言",
|
|
23
|
+
"type": {
|
|
24
|
+
"raw": "string",
|
|
25
|
+
"kind": "string"
|
|
26
|
+
},
|
|
27
|
+
"required": false,
|
|
28
|
+
"default": "\"javascript\"",
|
|
29
|
+
"usageExample": "<Code language=\"typescript\" />"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "theme",
|
|
33
|
+
"description": "指定主题",
|
|
34
|
+
"type": {
|
|
35
|
+
"raw": "\"vs\" | \"vs-dark\" | \"hc-black\"",
|
|
36
|
+
"kind": "union",
|
|
37
|
+
"unionTypes": [
|
|
38
|
+
"vs",
|
|
39
|
+
"vs-dark",
|
|
40
|
+
"hc-black"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"required": false,
|
|
44
|
+
"default": "\"vs\"",
|
|
45
|
+
"allowedValues": [
|
|
46
|
+
{
|
|
47
|
+
"value": "vs",
|
|
48
|
+
"label": "亮色主题",
|
|
49
|
+
"isDefault": true
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"value": "vs-dark",
|
|
53
|
+
"label": "暗色主题"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"value": "hc-black",
|
|
57
|
+
"label": "高对比度黑色主题"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"usageExample": "<Code theme=\"vs-dark\" />"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "readOnly",
|
|
64
|
+
"description": "是否只读",
|
|
65
|
+
"type": {
|
|
66
|
+
"raw": "boolean",
|
|
67
|
+
"kind": "boolean"
|
|
68
|
+
},
|
|
69
|
+
"required": false,
|
|
70
|
+
"default": "false",
|
|
71
|
+
"usageExample": "<Code readOnly />"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "width",
|
|
75
|
+
"description": "指定宽度,需要带单位",
|
|
76
|
+
"type": {
|
|
77
|
+
"raw": "string",
|
|
78
|
+
"kind": "string"
|
|
79
|
+
},
|
|
80
|
+
"required": false,
|
|
81
|
+
"default": "\"100%\"",
|
|
82
|
+
"usageExample": "<Code width=\"800px\" />"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "height",
|
|
86
|
+
"description": "指定高度,需要带单位",
|
|
87
|
+
"type": {
|
|
88
|
+
"raw": "string",
|
|
89
|
+
"kind": "string"
|
|
90
|
+
},
|
|
91
|
+
"required": false,
|
|
92
|
+
"default": "\"100%\"",
|
|
93
|
+
"usageExample": "<Code height=\"400px\" />"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "options",
|
|
97
|
+
"description": "其它 Monaco Editor 配置,会传给 monaco.editor.create() 方法",
|
|
98
|
+
"type": {
|
|
99
|
+
"raw": "editor.IStandaloneEditorConstructionOptions",
|
|
100
|
+
"kind": "object"
|
|
101
|
+
},
|
|
102
|
+
"required": false,
|
|
103
|
+
"default": "{}",
|
|
104
|
+
"usageExample": "<Code :options=\"{minimap: {enabled: false}}\" />"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"events": [
|
|
108
|
+
{
|
|
109
|
+
"name": "ready",
|
|
110
|
+
"vueEventName": "@ready",
|
|
111
|
+
"description": "编辑器加载并实例化完成时触发",
|
|
112
|
+
"payload": [
|
|
113
|
+
{
|
|
114
|
+
"name": "editor",
|
|
115
|
+
"type": "editor.IStandaloneCodeEditor",
|
|
116
|
+
"description": "编辑器实例"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "Editor",
|
|
120
|
+
"type": "typeof editor",
|
|
121
|
+
"description": "Editor 模块"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "Monaco",
|
|
125
|
+
"type": "typeof monaco",
|
|
126
|
+
"description": "Monaco 模块"
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"usageExample": "<Code @ready=\"handleReady\" />",
|
|
130
|
+
"handlerExample": "const handleReady = (editor, Editor, Monaco) => {\n console.log('编辑器已加载', editor);\n // 可以通过 editor 实例进行更多操作\n};"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"methods": [],
|
|
134
|
+
"examples": [
|
|
135
|
+
{
|
|
136
|
+
"id": "code_basic",
|
|
137
|
+
"title": "基础用法",
|
|
138
|
+
"description": "基本的代码编辑器",
|
|
139
|
+
"difficulty": "easy",
|
|
140
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst code = ref(`function hello() {\n console.log('Hello World');\n}`);\n</script>\n<template>\n <Code v-model=\"code\" language=\"javascript\" height=\"200px\" />\n</template>",
|
|
141
|
+
"tags": [
|
|
142
|
+
"basic"
|
|
143
|
+
],
|
|
144
|
+
"usedProps": [
|
|
145
|
+
"value",
|
|
146
|
+
"language",
|
|
147
|
+
"height"
|
|
148
|
+
],
|
|
149
|
+
"usedEvents": [],
|
|
150
|
+
"usedMethods": [],
|
|
151
|
+
"scenario": "创建一个基本的 JavaScript 代码编辑器"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"id": "code_dark_theme",
|
|
155
|
+
"title": "暗色主题",
|
|
156
|
+
"description": "使用暗色主题的编辑器",
|
|
157
|
+
"difficulty": "easy",
|
|
158
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst code = ref('const name = \"World\";');\n</script>\n<template>\n <Code v-model=\"code\" language=\"javascript\" theme=\"vs-dark\" height=\"200px\" />\n</template>",
|
|
159
|
+
"tags": [
|
|
160
|
+
"theme",
|
|
161
|
+
"dark"
|
|
162
|
+
],
|
|
163
|
+
"usedProps": [
|
|
164
|
+
"value",
|
|
165
|
+
"language",
|
|
166
|
+
"theme",
|
|
167
|
+
"height"
|
|
168
|
+
],
|
|
169
|
+
"usedEvents": [],
|
|
170
|
+
"usedMethods": [],
|
|
171
|
+
"scenario": "使用暗色主题的代码编辑器"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "code_readonly",
|
|
175
|
+
"title": "只读模式",
|
|
176
|
+
"description": "只读的代码展示",
|
|
177
|
+
"difficulty": "easy",
|
|
178
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst code = ref('// 这是只读代码\\nconst x = 1;');\n</script>\n<template>\n <Code v-model=\"code\" language=\"javascript\" readOnly height=\"200px\" />\n</template>",
|
|
179
|
+
"tags": [
|
|
180
|
+
"readOnly",
|
|
181
|
+
"display"
|
|
182
|
+
],
|
|
183
|
+
"usedProps": [
|
|
184
|
+
"value",
|
|
185
|
+
"language",
|
|
186
|
+
"readOnly",
|
|
187
|
+
"height"
|
|
188
|
+
],
|
|
189
|
+
"usedEvents": [],
|
|
190
|
+
"usedMethods": [],
|
|
191
|
+
"scenario": "只读模式的代码展示"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"id": "code_no_minimap",
|
|
195
|
+
"title": "隐藏缩略图",
|
|
196
|
+
"description": "隐藏右侧的代码缩略图",
|
|
197
|
+
"difficulty": "easy",
|
|
198
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst code = ref('const a = 1;');\nconst options = {\n minimap: { enabled: false }\n};\n</script>\n<template>\n <Code v-model=\"code\" language=\"javascript\" :options=\"options\" height=\"200px\" />\n</template>",
|
|
199
|
+
"tags": [
|
|
200
|
+
"options",
|
|
201
|
+
"minimap"
|
|
202
|
+
],
|
|
203
|
+
"usedProps": [
|
|
204
|
+
"value",
|
|
205
|
+
"language",
|
|
206
|
+
"options",
|
|
207
|
+
"height"
|
|
208
|
+
],
|
|
209
|
+
"usedEvents": [],
|
|
210
|
+
"usedMethods": [],
|
|
211
|
+
"scenario": "隐藏代码编辑器的缩略图"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "code_typescript",
|
|
215
|
+
"title": "TypeScript 编辑器",
|
|
216
|
+
"description": "TypeScript 代码编辑",
|
|
217
|
+
"difficulty": "easy",
|
|
218
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst code = ref(`interface User {\n name: string;\n age: number;\n}\n\nconst user: User = { name: 'Alice', age: 20 };`);\n</script>\n<template>\n <Code v-model=\"code\" language=\"typescript\" height=\"200px\" />\n</template>",
|
|
219
|
+
"tags": [
|
|
220
|
+
"typescript"
|
|
221
|
+
],
|
|
222
|
+
"usedProps": [
|
|
223
|
+
"value",
|
|
224
|
+
"language",
|
|
225
|
+
"height"
|
|
226
|
+
],
|
|
227
|
+
"usedEvents": [],
|
|
228
|
+
"usedMethods": [],
|
|
229
|
+
"scenario": "TypeScript 代码编辑"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"id": "code_json",
|
|
233
|
+
"title": "JSON 编辑器",
|
|
234
|
+
"description": "JSON 数据编辑",
|
|
235
|
+
"difficulty": "easy",
|
|
236
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst json = ref(JSON.stringify({ name: 'test', value: 123 }, null, 2));\n</script>\n<template>\n <Code v-model=\"json\" language=\"json\" height=\"200px\" />\n</template>",
|
|
237
|
+
"tags": [
|
|
238
|
+
"json"
|
|
239
|
+
],
|
|
240
|
+
"usedProps": [
|
|
241
|
+
"value",
|
|
242
|
+
"language",
|
|
243
|
+
"height"
|
|
244
|
+
],
|
|
245
|
+
"usedEvents": [],
|
|
246
|
+
"usedMethods": [],
|
|
247
|
+
"scenario": "JSON 数据编辑器"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"id": "code_ready_event",
|
|
251
|
+
"title": "监听加载完成",
|
|
252
|
+
"description": "监听编辑器加载完成事件",
|
|
253
|
+
"difficulty": "medium",
|
|
254
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Code } from '@king-design/vue';\n\nconst code = ref('');\n\nconst handleReady = (editor: any, Editor: any, Monaco: any) => {\n console.log('编辑器已加载', editor);\n // 可以通过 editor 实例进行更多操作\n};\n</script>\n<template>\n <Code v-model=\"code\" language=\"javascript\" @ready=\"handleReady\" height=\"200px\" />\n</template>",
|
|
255
|
+
"tags": [
|
|
256
|
+
"ready",
|
|
257
|
+
"event"
|
|
258
|
+
],
|
|
259
|
+
"usedProps": [
|
|
260
|
+
"value",
|
|
261
|
+
"language",
|
|
262
|
+
"height"
|
|
263
|
+
],
|
|
264
|
+
"usedEvents": [
|
|
265
|
+
"ready"
|
|
266
|
+
],
|
|
267
|
+
"usedMethods": [],
|
|
268
|
+
"scenario": "监听编辑器加载完成,获取编辑器实例"
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"commonMistakes": [
|
|
272
|
+
{
|
|
273
|
+
"id": "code_height_no_unit",
|
|
274
|
+
"description": "height/width 未带单位",
|
|
275
|
+
"wrongCode": "<Code height=\"200\" /> <!-- 无单位 -->",
|
|
276
|
+
"correctCode": "<Code height=\"200px\" />",
|
|
277
|
+
"explanation": "height 和 width 需要带单位,如 px、%、vh 等",
|
|
278
|
+
"relatedProps": [
|
|
279
|
+
"height",
|
|
280
|
+
"width"
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"id": "code_language_typo",
|
|
285
|
+
"description": "language 拼写错误",
|
|
286
|
+
"wrongCode": "<Code language=\"Javascript\" /> <!-- 大写错误 -->",
|
|
287
|
+
"correctCode": "<Code language=\"javascript\" />",
|
|
288
|
+
"explanation": "language 应使用小写,如 javascript、typescript",
|
|
289
|
+
"relatedProps": [
|
|
290
|
+
"language"
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"id": "code_import_bundle",
|
|
295
|
+
"description": "未正确导入 Code 组件",
|
|
296
|
+
"wrongCode": "import { Code } from '@king-design/vue'; // 可能未包含在默认 bundle 中",
|
|
297
|
+
"correctCode": "// 确保项目配置了 Monaco Editor\nimport { Code } from '@king-design/vue';",
|
|
298
|
+
"explanation": "Code 组件由于依赖 Monaco Editor,不会默认加入 index.js,需要确保正确配置",
|
|
299
|
+
"relatedProps": []
|
|
300
|
+
}
|
|
301
|
+
],
|
|
302
|
+
"searchKeywords": [
|
|
303
|
+
"代码",
|
|
304
|
+
"code",
|
|
305
|
+
"编辑器",
|
|
306
|
+
"monaco",
|
|
307
|
+
"语法高亮",
|
|
308
|
+
"IDE"
|
|
309
|
+
],
|
|
310
|
+
"useCases": [
|
|
311
|
+
"代码编辑器",
|
|
312
|
+
"在线 IDE",
|
|
313
|
+
"代码展示",
|
|
314
|
+
"配置文件编辑",
|
|
315
|
+
"JSON 编辑器"
|
|
316
|
+
],
|
|
317
|
+
"relatedComponents": []
|
|
318
|
+
}
|