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,292 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "steps",
|
|
3
|
+
"name": "Steps",
|
|
4
|
+
"displayName": "步骤条",
|
|
5
|
+
"category": "navigation",
|
|
6
|
+
"description": "步骤条组件,用于引导用户按照流程完成任务。支持多种样式、垂直布局、可点击切换、错误状态等功能。配合 Step 子组件使用。",
|
|
7
|
+
"importStatement": "import { Steps, Step } from '@king-design/vue';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "value",
|
|
11
|
+
"description": "当前第几步,从 0 开始,可用 v-model 双向绑定",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "number",
|
|
14
|
+
"kind": "number"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"default": "undefined",
|
|
18
|
+
"usageExample": "<Steps :value=\"current\">"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "status",
|
|
22
|
+
"description": "步骤条的状态",
|
|
23
|
+
"type": {
|
|
24
|
+
"raw": "\"normal\" | \"error\"",
|
|
25
|
+
"kind": "union",
|
|
26
|
+
"unionTypes": [
|
|
27
|
+
"normal",
|
|
28
|
+
"error"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"required": false,
|
|
32
|
+
"default": "\"normal\"",
|
|
33
|
+
"allowedValues": [
|
|
34
|
+
{
|
|
35
|
+
"value": "normal",
|
|
36
|
+
"label": "正常状态",
|
|
37
|
+
"isDefault": true
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"value": "error",
|
|
41
|
+
"label": "错误状态"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"usageExample": "<Steps status=\"error\">"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "type",
|
|
48
|
+
"description": "步骤条样式",
|
|
49
|
+
"type": {
|
|
50
|
+
"raw": "\"default\" | \"line\" | \"simple\" | \"line-compact\"",
|
|
51
|
+
"kind": "union",
|
|
52
|
+
"unionTypes": [
|
|
53
|
+
"default",
|
|
54
|
+
"line",
|
|
55
|
+
"simple",
|
|
56
|
+
"line-compact"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"required": false,
|
|
60
|
+
"default": "\"default\"",
|
|
61
|
+
"allowedValues": [
|
|
62
|
+
{
|
|
63
|
+
"value": "default",
|
|
64
|
+
"label": "默认样式",
|
|
65
|
+
"isDefault": true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"value": "line",
|
|
69
|
+
"label": "线条样式"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"value": "simple",
|
|
73
|
+
"label": "简洁样式"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"value": "line-compact",
|
|
77
|
+
"label": "紧凑线条样式"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"usageExample": "<Steps type=\"line\">"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "clickable",
|
|
84
|
+
"description": "是否支持快速切换已完成的步骤",
|
|
85
|
+
"type": {
|
|
86
|
+
"raw": "boolean",
|
|
87
|
+
"kind": "boolean"
|
|
88
|
+
},
|
|
89
|
+
"required": false,
|
|
90
|
+
"default": "false",
|
|
91
|
+
"usageExample": "<Steps v-model=\"current\" clickable>"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "vertical",
|
|
95
|
+
"description": "是否垂直排列",
|
|
96
|
+
"type": {
|
|
97
|
+
"raw": "boolean",
|
|
98
|
+
"kind": "boolean"
|
|
99
|
+
},
|
|
100
|
+
"required": false,
|
|
101
|
+
"default": "false",
|
|
102
|
+
"usageExample": "<Steps vertical>"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"events": [],
|
|
106
|
+
"methods": [],
|
|
107
|
+
"subComponents": [
|
|
108
|
+
{
|
|
109
|
+
"name": "Step",
|
|
110
|
+
"description": "步骤项组件,用于定义每个步骤的标题和内容",
|
|
111
|
+
"props": [
|
|
112
|
+
{
|
|
113
|
+
"name": "title",
|
|
114
|
+
"description": "步骤标题",
|
|
115
|
+
"type": {
|
|
116
|
+
"raw": "string",
|
|
117
|
+
"kind": "string"
|
|
118
|
+
},
|
|
119
|
+
"required": false,
|
|
120
|
+
"default": "undefined",
|
|
121
|
+
"usageExample": "<Step title=\"步骤1\" />"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"examples": [
|
|
127
|
+
{
|
|
128
|
+
"id": "steps_basic",
|
|
129
|
+
"title": "基础用法",
|
|
130
|
+
"description": "基本的步骤条",
|
|
131
|
+
"difficulty": "easy",
|
|
132
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Steps, Step } from '@king-design/vue';\n\nconst current = ref(1);\n</script>\n<template>\n <Steps :value=\"current\">\n <Step title=\"步骤1\" />\n <Step title=\"步骤2\" />\n <Step title=\"步骤3\" />\n </Steps>\n</template>",
|
|
133
|
+
"tags": [
|
|
134
|
+
"basic"
|
|
135
|
+
],
|
|
136
|
+
"usedProps": [
|
|
137
|
+
"value",
|
|
138
|
+
"title"
|
|
139
|
+
],
|
|
140
|
+
"usedEvents": [],
|
|
141
|
+
"usedMethods": [],
|
|
142
|
+
"scenario": "创建一个基本的步骤条"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "steps_clickable",
|
|
146
|
+
"title": "可点击切换",
|
|
147
|
+
"description": "支持点击切换已完成的步骤",
|
|
148
|
+
"difficulty": "easy",
|
|
149
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Steps, Step } from '@king-design/vue';\n\nconst current = ref(0);\n</script>\n<template>\n <Steps v-model=\"current\" clickable>\n <Step title=\"填写信息\" />\n <Step title=\"确认信息\" />\n <Step title=\"完成\" />\n </Steps>\n</template>",
|
|
150
|
+
"tags": [
|
|
151
|
+
"clickable",
|
|
152
|
+
"interactive"
|
|
153
|
+
],
|
|
154
|
+
"usedProps": [
|
|
155
|
+
"value",
|
|
156
|
+
"clickable",
|
|
157
|
+
"title"
|
|
158
|
+
],
|
|
159
|
+
"usedEvents": [],
|
|
160
|
+
"usedMethods": [],
|
|
161
|
+
"scenario": "可以点击已完成的步骤进行切换"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "steps_vertical",
|
|
165
|
+
"title": "垂直步骤条",
|
|
166
|
+
"description": "垂直排列的步骤条",
|
|
167
|
+
"difficulty": "easy",
|
|
168
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Steps, Step } from '@king-design/vue';\n\nconst current = ref(1);\n</script>\n<template>\n <Steps :value=\"current\" vertical>\n <Step title=\"步骤1\" />\n <Step title=\"步骤2\" />\n <Step title=\"步骤3\" />\n </Steps>\n</template>",
|
|
169
|
+
"tags": [
|
|
170
|
+
"vertical"
|
|
171
|
+
],
|
|
172
|
+
"usedProps": [
|
|
173
|
+
"value",
|
|
174
|
+
"vertical",
|
|
175
|
+
"title"
|
|
176
|
+
],
|
|
177
|
+
"usedEvents": [],
|
|
178
|
+
"usedMethods": [],
|
|
179
|
+
"scenario": "创建垂直排列的步骤条"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"id": "steps_error",
|
|
183
|
+
"title": "错误状态",
|
|
184
|
+
"description": "显示当前步骤为错误状态",
|
|
185
|
+
"difficulty": "easy",
|
|
186
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Steps, Step } from '@king-design/vue';\n\nconst current = ref(1);\n</script>\n<template>\n <Steps :value=\"current\" status=\"error\">\n <Step title=\"步骤1\" />\n <Step title=\"步骤2(错误)\" />\n <Step title=\"步骤3\" />\n </Steps>\n</template>",
|
|
187
|
+
"tags": [
|
|
188
|
+
"error",
|
|
189
|
+
"status"
|
|
190
|
+
],
|
|
191
|
+
"usedProps": [
|
|
192
|
+
"value",
|
|
193
|
+
"status",
|
|
194
|
+
"title"
|
|
195
|
+
],
|
|
196
|
+
"usedEvents": [],
|
|
197
|
+
"usedMethods": [],
|
|
198
|
+
"scenario": "显示当前步骤为错误状态"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"id": "steps_types",
|
|
202
|
+
"title": "不同类型",
|
|
203
|
+
"description": "不同样式的步骤条",
|
|
204
|
+
"difficulty": "easy",
|
|
205
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Steps, Step } from '@king-design/vue';\n\nconst current = ref(1);\n</script>\n<template>\n <Steps :value=\"current\" type=\"line\">\n <Step title=\"步骤1\" />\n <Step title=\"步骤2\" />\n <Step title=\"步骤3\" />\n </Steps>\n</template>",
|
|
206
|
+
"tags": [
|
|
207
|
+
"type",
|
|
208
|
+
"line",
|
|
209
|
+
"simple"
|
|
210
|
+
],
|
|
211
|
+
"usedProps": [
|
|
212
|
+
"value",
|
|
213
|
+
"type",
|
|
214
|
+
"title"
|
|
215
|
+
],
|
|
216
|
+
"usedEvents": [],
|
|
217
|
+
"usedMethods": [],
|
|
218
|
+
"scenario": "使用线条样式的步骤条"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"id": "steps_wizard",
|
|
222
|
+
"title": "向导流程",
|
|
223
|
+
"description": "完整的向导流程示例",
|
|
224
|
+
"difficulty": "medium",
|
|
225
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Steps, Step, Button, Card } from '@king-design/vue';\n\nconst current = ref(0);\n\nconst next = () => {\n if (current.value < 2) current.value++;\n};\n\nconst prev = () => {\n if (current.value > 0) current.value--;\n};\n</script>\n<template>\n <Steps :value=\"current\">\n <Step title=\"填写信息\" />\n <Step title=\"确认信息\" />\n <Step title=\"完成\" />\n </Steps>\n <Card style=\"margin-top: 16px;\">\n <div v-if=\"current === 0\">步骤1: 填写信息的内容</div>\n <div v-if=\"current === 1\">步骤2: 确认信息的内容</div>\n <div v-if=\"current === 2\">步骤3: 完成!</div>\n <div style=\"margin-top: 16px;\">\n <Button v-if=\"current > 0\" @click=\"prev\">上一步</Button>\n <Button v-if=\"current < 2\" type=\"primary\" @click=\"next\">下一步</Button>\n </div>\n </Card>\n</template>",
|
|
226
|
+
"tags": [
|
|
227
|
+
"wizard",
|
|
228
|
+
"flow",
|
|
229
|
+
"complete"
|
|
230
|
+
],
|
|
231
|
+
"usedProps": [
|
|
232
|
+
"value",
|
|
233
|
+
"title"
|
|
234
|
+
],
|
|
235
|
+
"usedEvents": [],
|
|
236
|
+
"usedMethods": [],
|
|
237
|
+
"scenario": "完整的向导流程示例"
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"commonMistakes": [
|
|
241
|
+
{
|
|
242
|
+
"id": "steps_value_start",
|
|
243
|
+
"description": "value 从 1 开始而非 0",
|
|
244
|
+
"wrongCode": "const current = ref(1); // 期望第一步\n<Steps :value=\"current\">",
|
|
245
|
+
"correctCode": "const current = ref(0); // 第一步\n<Steps :value=\"current\">",
|
|
246
|
+
"explanation": "Steps 的 value 从 0 开始,0 表示第一步",
|
|
247
|
+
"relatedProps": [
|
|
248
|
+
"value"
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"id": "steps_clickable_vmodel",
|
|
253
|
+
"description": "使用 clickable 但未用 v-model",
|
|
254
|
+
"wrongCode": "<Steps :value=\"current\" clickable> <!-- 点击不会改变值 -->",
|
|
255
|
+
"correctCode": "<Steps v-model=\"current\" clickable>",
|
|
256
|
+
"explanation": "使用 clickable 时需要用 v-model 进行双向绑定才能响应点击",
|
|
257
|
+
"relatedProps": [
|
|
258
|
+
"value",
|
|
259
|
+
"clickable"
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"id": "steps_type_typo",
|
|
264
|
+
"description": "type 值拼写错误",
|
|
265
|
+
"wrongCode": "<Steps type=\"compact\">",
|
|
266
|
+
"correctCode": "<Steps type=\"line-compact\">",
|
|
267
|
+
"explanation": "type 只支持 default, line, simple, line-compact",
|
|
268
|
+
"relatedProps": [
|
|
269
|
+
"type"
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
"searchKeywords": [
|
|
274
|
+
"步骤条",
|
|
275
|
+
"steps",
|
|
276
|
+
"向导",
|
|
277
|
+
"wizard",
|
|
278
|
+
"流程",
|
|
279
|
+
"进度"
|
|
280
|
+
],
|
|
281
|
+
"useCases": [
|
|
282
|
+
"注册流程",
|
|
283
|
+
"订单流程",
|
|
284
|
+
"表单向导",
|
|
285
|
+
"任务进度展示",
|
|
286
|
+
"安装向导"
|
|
287
|
+
],
|
|
288
|
+
"relatedComponents": [
|
|
289
|
+
"Step",
|
|
290
|
+
"Progress"
|
|
291
|
+
]
|
|
292
|
+
}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "switch",
|
|
3
|
+
"name": "Switch",
|
|
4
|
+
"displayName": "开关",
|
|
5
|
+
"category": "form",
|
|
6
|
+
"description": "开关组件,用于切换两种状态。支持自定义开关文案、自定义值、切换前拦截、加载状态等功能。在 Vue 中使用时可能需要重命名为 KSwitch。",
|
|
7
|
+
"importStatement": "import { Switch } 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": "<Switch v-model=\"value\" />"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "trueValue",
|
|
22
|
+
"description": "开启时的值",
|
|
23
|
+
"type": {
|
|
24
|
+
"raw": "any",
|
|
25
|
+
"kind": "custom"
|
|
26
|
+
},
|
|
27
|
+
"required": false,
|
|
28
|
+
"default": "true",
|
|
29
|
+
"usageExample": "<Switch trueValue=\"on\" falseValue=\"off\" />"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "falseValue",
|
|
33
|
+
"description": "关闭时的值",
|
|
34
|
+
"type": {
|
|
35
|
+
"raw": "any",
|
|
36
|
+
"kind": "custom"
|
|
37
|
+
},
|
|
38
|
+
"required": false,
|
|
39
|
+
"default": "false",
|
|
40
|
+
"usageExample": "<Switch trueValue=\"1\" falseValue=\"0\" />"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "on",
|
|
44
|
+
"description": "开启时显示的文案",
|
|
45
|
+
"type": {
|
|
46
|
+
"raw": "string",
|
|
47
|
+
"kind": "string"
|
|
48
|
+
},
|
|
49
|
+
"required": false,
|
|
50
|
+
"default": "undefined",
|
|
51
|
+
"usageExample": "<Switch on=\"开\" off=\"关\" />"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "off",
|
|
55
|
+
"description": "关闭时显示的文案",
|
|
56
|
+
"type": {
|
|
57
|
+
"raw": "string",
|
|
58
|
+
"kind": "string"
|
|
59
|
+
},
|
|
60
|
+
"required": false,
|
|
61
|
+
"default": "undefined",
|
|
62
|
+
"usageExample": "<Switch on=\"ON\" off=\"OFF\" />"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "disabled",
|
|
66
|
+
"description": "是否禁用",
|
|
67
|
+
"type": {
|
|
68
|
+
"raw": "boolean",
|
|
69
|
+
"kind": "boolean"
|
|
70
|
+
},
|
|
71
|
+
"required": false,
|
|
72
|
+
"default": "false",
|
|
73
|
+
"usageExample": "<Switch disabled />"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "loading",
|
|
77
|
+
"description": "是否显示加载状态",
|
|
78
|
+
"type": {
|
|
79
|
+
"raw": "boolean",
|
|
80
|
+
"kind": "boolean"
|
|
81
|
+
},
|
|
82
|
+
"required": false,
|
|
83
|
+
"default": "false",
|
|
84
|
+
"usageExample": "<Switch :loading=\"isLoading\" />"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "size",
|
|
88
|
+
"description": "尺寸",
|
|
89
|
+
"type": {
|
|
90
|
+
"raw": "\"large\" | \"default\" | \"small\" | \"mini\"",
|
|
91
|
+
"kind": "union",
|
|
92
|
+
"unionTypes": [
|
|
93
|
+
"large",
|
|
94
|
+
"default",
|
|
95
|
+
"small",
|
|
96
|
+
"mini"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"required": false,
|
|
100
|
+
"default": "\"default\"",
|
|
101
|
+
"allowedValues": [
|
|
102
|
+
{
|
|
103
|
+
"value": "large",
|
|
104
|
+
"label": "大尺寸"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"value": "default",
|
|
108
|
+
"label": "默认尺寸",
|
|
109
|
+
"isDefault": true
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"value": "small",
|
|
113
|
+
"label": "小尺寸"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"value": "mini",
|
|
117
|
+
"label": "迷你尺寸"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"usageExample": "<Switch size=\"small\" />"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "width",
|
|
124
|
+
"description": "开关的宽度",
|
|
125
|
+
"type": {
|
|
126
|
+
"raw": "number | string",
|
|
127
|
+
"kind": "union"
|
|
128
|
+
},
|
|
129
|
+
"required": false,
|
|
130
|
+
"default": "undefined",
|
|
131
|
+
"usageExample": "<Switch :width=\"60\" />"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "height",
|
|
135
|
+
"description": "开关的高度",
|
|
136
|
+
"type": {
|
|
137
|
+
"raw": "number | string",
|
|
138
|
+
"kind": "union"
|
|
139
|
+
},
|
|
140
|
+
"required": false,
|
|
141
|
+
"default": "undefined",
|
|
142
|
+
"usageExample": "<Switch :height=\"24\" />"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "name",
|
|
146
|
+
"description": "开关的名称,用于表单提交",
|
|
147
|
+
"type": {
|
|
148
|
+
"raw": "string",
|
|
149
|
+
"kind": "string"
|
|
150
|
+
},
|
|
151
|
+
"required": false,
|
|
152
|
+
"default": "undefined",
|
|
153
|
+
"usageExample": "<Switch name=\"enable\" />"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "beforeChange",
|
|
157
|
+
"description": "切换前的拦截函数,返回 false 阻止切换,支持异步",
|
|
158
|
+
"type": {
|
|
159
|
+
"raw": "(from: any, to: any) => boolean | Promise<boolean>",
|
|
160
|
+
"kind": "function",
|
|
161
|
+
"functionSignature": "(from: any, to: any) => boolean | Promise<boolean>"
|
|
162
|
+
},
|
|
163
|
+
"required": false,
|
|
164
|
+
"default": "undefined",
|
|
165
|
+
"usageExample": "<Switch :beforeChange=\"handleBeforeChange\" />"
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"slots": [
|
|
169
|
+
{
|
|
170
|
+
"name": "on",
|
|
171
|
+
"description": "扩展开启时的文案"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "off",
|
|
175
|
+
"description": "扩展关闭时的文案"
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"events": [],
|
|
179
|
+
"methods": [],
|
|
180
|
+
"examples": [
|
|
181
|
+
{
|
|
182
|
+
"id": "switch_basic",
|
|
183
|
+
"title": "基础用法",
|
|
184
|
+
"description": "基本的开关",
|
|
185
|
+
"difficulty": "easy",
|
|
186
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch } from '@king-design/vue';\n\nconst value = ref(false);\n</script>\n<template>\n <Switch v-model=\"value\" />\n</template>",
|
|
187
|
+
"tags": [
|
|
188
|
+
"basic"
|
|
189
|
+
],
|
|
190
|
+
"usedProps": [
|
|
191
|
+
"value"
|
|
192
|
+
],
|
|
193
|
+
"usedEvents": [],
|
|
194
|
+
"usedMethods": [],
|
|
195
|
+
"scenario": "创建一个基本的开关"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "switch_text",
|
|
199
|
+
"title": "显示文案",
|
|
200
|
+
"description": "显示开启/关闭文案",
|
|
201
|
+
"difficulty": "easy",
|
|
202
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch } from '@king-design/vue';\n\nconst value = ref(true);\n</script>\n<template>\n <Switch v-model=\"value\" on=\"开\" off=\"关\" />\n</template>",
|
|
203
|
+
"tags": [
|
|
204
|
+
"on",
|
|
205
|
+
"off",
|
|
206
|
+
"text"
|
|
207
|
+
],
|
|
208
|
+
"usedProps": [
|
|
209
|
+
"value",
|
|
210
|
+
"on",
|
|
211
|
+
"off"
|
|
212
|
+
],
|
|
213
|
+
"usedEvents": [],
|
|
214
|
+
"usedMethods": [],
|
|
215
|
+
"scenario": "在开关上显示开启/关闭文案"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"id": "switch_disabled",
|
|
219
|
+
"title": "禁用状态",
|
|
220
|
+
"description": "禁用开关",
|
|
221
|
+
"difficulty": "easy",
|
|
222
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch } from '@king-design/vue';\n\nconst value = ref(true);\n</script>\n<template>\n <Switch v-model=\"value\" disabled />\n</template>",
|
|
223
|
+
"tags": [
|
|
224
|
+
"disabled"
|
|
225
|
+
],
|
|
226
|
+
"usedProps": [
|
|
227
|
+
"value",
|
|
228
|
+
"disabled"
|
|
229
|
+
],
|
|
230
|
+
"usedEvents": [],
|
|
231
|
+
"usedMethods": [],
|
|
232
|
+
"scenario": "禁用开关"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"id": "switch_loading",
|
|
236
|
+
"title": "加载状态",
|
|
237
|
+
"description": "显示加载状态的开关",
|
|
238
|
+
"difficulty": "easy",
|
|
239
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch } from '@king-design/vue';\n\nconst value = ref(false);\nconst loading = ref(false);\n</script>\n<template>\n <Switch v-model=\"value\" :loading=\"loading\" />\n</template>",
|
|
240
|
+
"tags": [
|
|
241
|
+
"loading"
|
|
242
|
+
],
|
|
243
|
+
"usedProps": [
|
|
244
|
+
"value",
|
|
245
|
+
"loading"
|
|
246
|
+
],
|
|
247
|
+
"usedEvents": [],
|
|
248
|
+
"usedMethods": [],
|
|
249
|
+
"scenario": "显示加载状态的开关"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"id": "switch_before_change",
|
|
253
|
+
"title": "切换前确认",
|
|
254
|
+
"description": "切换前弹出确认对话框",
|
|
255
|
+
"difficulty": "medium",
|
|
256
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch, Dialog } from '@king-design/vue';\n\nconst value = ref(false);\n\nconst beforeChange = async () => {\n try {\n await Dialog.confirm({ content: '确定要切换吗?' });\n return true;\n } catch {\n return false;\n }\n};\n</script>\n<template>\n <Switch v-model=\"value\" :beforeChange=\"beforeChange\" />\n</template>",
|
|
257
|
+
"tags": [
|
|
258
|
+
"beforeChange",
|
|
259
|
+
"confirm"
|
|
260
|
+
],
|
|
261
|
+
"usedProps": [
|
|
262
|
+
"value",
|
|
263
|
+
"beforeChange"
|
|
264
|
+
],
|
|
265
|
+
"usedEvents": [],
|
|
266
|
+
"usedMethods": [],
|
|
267
|
+
"scenario": "切换前弹出确认对话框"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"id": "switch_custom_value",
|
|
271
|
+
"title": "自定义值",
|
|
272
|
+
"description": "使用自定义的开关值",
|
|
273
|
+
"difficulty": "easy",
|
|
274
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch } from '@king-design/vue';\n\nconst status = ref('inactive');\n</script>\n<template>\n <Switch v-model=\"status\" trueValue=\"active\" falseValue=\"inactive\" />\n <p>当前状态: {{ status }}</p>\n</template>",
|
|
275
|
+
"tags": [
|
|
276
|
+
"trueValue",
|
|
277
|
+
"falseValue",
|
|
278
|
+
"custom"
|
|
279
|
+
],
|
|
280
|
+
"usedProps": [
|
|
281
|
+
"value",
|
|
282
|
+
"trueValue",
|
|
283
|
+
"falseValue"
|
|
284
|
+
],
|
|
285
|
+
"usedEvents": [],
|
|
286
|
+
"usedMethods": [],
|
|
287
|
+
"scenario": "使用自定义的字符串值作为开关状态"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "switch_sizes",
|
|
291
|
+
"title": "不同尺寸",
|
|
292
|
+
"description": "不同尺寸的开关",
|
|
293
|
+
"difficulty": "easy",
|
|
294
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { Switch } from '@king-design/vue';\n\nconst value = ref(true);\n</script>\n<template>\n <Switch v-model=\"value\" size=\"mini\" />\n <Switch v-model=\"value\" size=\"small\" />\n <Switch v-model=\"value\" size=\"default\" />\n <Switch v-model=\"value\" size=\"large\" />\n</template>",
|
|
295
|
+
"tags": [
|
|
296
|
+
"size"
|
|
297
|
+
],
|
|
298
|
+
"usedProps": [
|
|
299
|
+
"value",
|
|
300
|
+
"size"
|
|
301
|
+
],
|
|
302
|
+
"usedEvents": [],
|
|
303
|
+
"usedMethods": [],
|
|
304
|
+
"scenario": "展示不同尺寸的开关"
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
"commonMistakes": [
|
|
308
|
+
{
|
|
309
|
+
"id": "switch_vue_name",
|
|
310
|
+
"description": "在 Vue 中使用保留字 Switch",
|
|
311
|
+
"wrongCode": "import { Switch } from '@king-design/vue';\n// 可能在某些情况下与 Vue 保留字冲突",
|
|
312
|
+
"correctCode": "import { Switch as KSwitch } from '@king-design/vue';\n// 或直接使用 Switch,现代 Vue 3 通常没问题",
|
|
313
|
+
"explanation": "在某些 Vue 版本中,Switch 可能是保留字,可以重命名为 KSwitch",
|
|
314
|
+
"relatedProps": []
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"id": "switch_beforechange_return",
|
|
318
|
+
"description": "beforeChange 函数未正确返回布尔值",
|
|
319
|
+
"wrongCode": "const beforeChange = async () => {\n await Dialog.confirm({});\n // 忘记返回 true\n}",
|
|
320
|
+
"correctCode": "const beforeChange = async () => {\n try {\n await Dialog.confirm({});\n return true;\n } catch {\n return false;\n }\n}",
|
|
321
|
+
"explanation": "beforeChange 必须返回布尔值,true 允许切换,false 阻止切换",
|
|
322
|
+
"relatedProps": [
|
|
323
|
+
"beforeChange"
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": "switch_custom_value_type",
|
|
328
|
+
"description": "自定义值类型与初始值不匹配",
|
|
329
|
+
"wrongCode": "const value = ref(false);\n<Switch v-model=\"value\" trueValue=\"yes\" falseValue=\"no\" />",
|
|
330
|
+
"correctCode": "const value = ref('no');\n<Switch v-model=\"value\" trueValue=\"yes\" falseValue=\"no\" />",
|
|
331
|
+
"explanation": "使用自定义值时,初始值应该与 trueValue 或 falseValue 类型和值匹配",
|
|
332
|
+
"relatedProps": [
|
|
333
|
+
"value",
|
|
334
|
+
"trueValue",
|
|
335
|
+
"falseValue"
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"searchKeywords": [
|
|
340
|
+
"开关",
|
|
341
|
+
"switch",
|
|
342
|
+
"切换",
|
|
343
|
+
"toggle",
|
|
344
|
+
"布尔",
|
|
345
|
+
"状态切换"
|
|
346
|
+
],
|
|
347
|
+
"useCases": [
|
|
348
|
+
"功能开关",
|
|
349
|
+
"设置项切换",
|
|
350
|
+
"状态启用/禁用",
|
|
351
|
+
"表单布尔输入",
|
|
352
|
+
"偏好设置"
|
|
353
|
+
],
|
|
354
|
+
"relatedComponents": [
|
|
355
|
+
"Checkbox"
|
|
356
|
+
]
|
|
357
|
+
}
|