king-design-analyzer 2.2.0 → 2.2.2

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.
Files changed (154) hide show
  1. package/components/actions.json +8 -0
  2. package/components/advancedset.json +1 -0
  3. package/components/affix.json +1 -0
  4. package/components/anchor.json +220 -0
  5. package/components/anchorlink.json +111 -0
  6. package/components/badge.json +1 -0
  7. package/components/breadcrumb.json +2 -1
  8. package/components/button.json +1 -0
  9. package/components/buttonlink.json +1 -0
  10. package/components/card.json +6 -3
  11. package/components/cardcontent.json +5 -0
  12. package/components/cascader.json +56 -0
  13. package/components/collapse.json +335 -348
  14. package/components/configprovider.json +96 -0
  15. package/components/copyrow.json +1 -0
  16. package/components/descriptions.json +10 -3
  17. package/components/diagram.json +295 -0
  18. package/components/dialog.json +4 -0
  19. package/components/divider.json +1 -0
  20. package/components/drawer.json +32 -0
  21. package/components/dropdown.json +13 -4
  22. package/components/flex.json +1 -0
  23. package/components/form.json +12 -3
  24. package/components/header.json +4 -0
  25. package/components/input.json +8 -4
  26. package/components/layoutcontent.json +9 -0
  27. package/components/layoutlistcontent.json +9 -0
  28. package/components/layoutpermissioncontent.json +1 -0
  29. package/components/layoutstandardlist.json +1 -0
  30. package/components/lazymount.json +1 -0
  31. package/components/lazyteleport.json +1 -0
  32. package/components/menu.json +4 -3
  33. package/components/notification.json +351 -0
  34. package/components/popover.json +23 -0
  35. package/components/protable.json +2 -0
  36. package/components/rate.json +1 -0
  37. package/components/scrollselect.json +140 -0
  38. package/components/select.json +72 -0
  39. package/components/skeleton.json +1 -0
  40. package/components/slider.json +12 -2
  41. package/components/spin.json +2 -1
  42. package/components/spinner.json +422 -428
  43. package/components/split.json +3 -0
  44. package/components/switch.json +4 -2
  45. package/components/table.json +6 -1
  46. package/components/tabs.json +2 -2
  47. package/components/tag.json +8 -5
  48. package/components/timeline.json +3 -1
  49. package/components/tip.json +20 -0
  50. package/components/tooltip.json +8 -0
  51. package/components/tour.json +16 -0
  52. package/components/transfer.json +52 -5
  53. package/components/tree.json +22 -1
  54. package/components/treeselect.json +56 -0
  55. package/components/upload.json +16 -0
  56. package/components/vdialog.json +1 -0
  57. package/components/vdrawer.json +4 -0
  58. package/components/virtuallist.json +9 -0
  59. package/dist/ast/index.d.mts +30 -1
  60. package/dist/ast/index.d.ts +30 -1
  61. package/dist/ast/index.js +3 -3
  62. package/dist/ast/index.mjs +1 -1
  63. package/dist/{chunk-BI5TIQID.mjs → chunk-4OTQAQ6J.mjs} +13 -2
  64. package/dist/chunk-6HOIRUQB.mjs +409 -0
  65. package/dist/{chunk-XGPHQHLR.mjs → chunk-BSCASJTV.mjs} +27 -4
  66. package/dist/{chunk-CR3GC4H3.js → chunk-DHLWNT53.js} +13 -2
  67. package/dist/{chunk-CJGGFVQJ.js → chunk-HARQRI4F.js} +31 -8
  68. package/dist/{chunk-TA3SV4SP.js → chunk-JJ6AB4ZH.js} +2 -2
  69. package/dist/{chunk-3LYQ5XFM.mjs → chunk-NZL6T22V.mjs} +1 -1
  70. package/dist/chunk-V5N65MRP.js +411 -0
  71. package/dist/{chunk-SZYVGYKK.js → chunk-XPHDD6XR.js} +113 -35
  72. package/dist/{chunk-KMIDURUR.mjs → chunk-YRGYDK2I.mjs} +113 -35
  73. package/dist/full/index.d.mts +2 -0
  74. package/dist/full/index.d.ts +2 -0
  75. package/dist/full/index.js +6 -6
  76. package/dist/full/index.mjs +4 -4
  77. package/dist/index.js +13 -13
  78. package/dist/index.mjs +5 -5
  79. package/dist/metadata/index.d.mts +17 -2
  80. package/dist/metadata/index.d.ts +17 -2
  81. package/dist/runtime/index.d.mts +2 -0
  82. package/dist/runtime/index.d.ts +2 -0
  83. package/dist/runtime/index.js +4 -4
  84. package/dist/runtime/index.mjs +2 -2
  85. package/dist/static/index.js +5 -5
  86. package/dist/static/index.mjs +2 -2
  87. package/docs_for_llm/actions.doc.md +11 -1
  88. package/docs_for_llm/advancedset.doc.md +10 -1
  89. package/docs_for_llm/affix.doc.md +5 -0
  90. package/docs_for_llm/anchor.doc.md +155 -0
  91. package/docs_for_llm/anchorlink.doc.md +75 -0
  92. package/docs_for_llm/badge.doc.md +5 -0
  93. package/docs_for_llm/breadcrumb.doc.md +74 -1
  94. package/docs_for_llm/button.doc.md +57 -0
  95. package/docs_for_llm/buttonlink.doc.md +10 -1
  96. package/docs_for_llm/card.doc.md +50 -3
  97. package/docs_for_llm/cardcontent.doc.md +21 -0
  98. package/docs_for_llm/carousel.doc.md +71 -0
  99. package/docs_for_llm/cascader.doc.md +62 -0
  100. package/docs_for_llm/collapse.doc.md +138 -8
  101. package/docs_for_llm/configprovider.doc.md +77 -0
  102. package/docs_for_llm/copyrow.doc.md +10 -1
  103. package/docs_for_llm/datepicker.doc.md +19 -0
  104. package/docs_for_llm/descriptions.doc.md +113 -4
  105. package/docs_for_llm/diagram.doc.md +343 -0
  106. package/docs_for_llm/dialog.doc.md +49 -0
  107. package/docs_for_llm/divider.doc.md +5 -0
  108. package/docs_for_llm/drawer.doc.md +86 -0
  109. package/docs_for_llm/dropdown.doc.md +257 -3
  110. package/docs_for_llm/flex.doc.md +10 -1
  111. package/docs_for_llm/form.doc.md +163 -4
  112. package/docs_for_llm/formitemspinner.doc.md +1 -1
  113. package/docs_for_llm/grid.doc.md +71 -0
  114. package/docs_for_llm/header.doc.md +33 -4
  115. package/docs_for_llm/input.doc.md +109 -2
  116. package/docs_for_llm/layoutcontent.doc.md +37 -0
  117. package/docs_for_llm/layoutlistcontent.doc.md +82 -9
  118. package/docs_for_llm/layoutpermissioncontent.doc.md +10 -1
  119. package/docs_for_llm/layoutstandardlist.doc.md +10 -1
  120. package/docs_for_llm/lazymount.doc.md +10 -1
  121. package/docs_for_llm/lazyteleport.doc.md +10 -1
  122. package/docs_for_llm/menu.doc.md +125 -3
  123. package/docs_for_llm/message.doc.md +45 -0
  124. package/docs_for_llm/notification.doc.md +214 -0
  125. package/docs_for_llm/popover.doc.md +34 -0
  126. package/docs_for_llm/protable.doc.md +9 -0
  127. package/docs_for_llm/rate.doc.md +5 -0
  128. package/docs_for_llm/scrollselect.doc.md +90 -0
  129. package/docs_for_llm/select.doc.md +189 -0
  130. package/docs_for_llm/skeleton.doc.md +35 -0
  131. package/docs_for_llm/slider.doc.md +11 -1
  132. package/docs_for_llm/spin.doc.md +10 -1
  133. package/docs_for_llm/spinner.doc.md +1 -1
  134. package/docs_for_llm/split.doc.md +13 -0
  135. package/docs_for_llm/steps.doc.md +71 -0
  136. package/docs_for_llm/switch.doc.md +15 -2
  137. package/docs_for_llm/table.doc.md +199 -4
  138. package/docs_for_llm/tabs.doc.md +98 -2
  139. package/docs_for_llm/tag.doc.md +148 -5
  140. package/docs_for_llm/timeline.doc.md +80 -2
  141. package/docs_for_llm/timepicker.doc.md +19 -0
  142. package/docs_for_llm/tip.doc.md +30 -0
  143. package/docs_for_llm/tooltip.doc.md +46 -0
  144. package/docs_for_llm/tour.doc.md +102 -0
  145. package/docs_for_llm/transfer.doc.md +59 -4
  146. package/docs_for_llm/tree.doc.md +64 -1
  147. package/docs_for_llm/treeselect.doc.md +68 -0
  148. package/docs_for_llm/upload.doc.md +28 -0
  149. package/docs_for_llm/vdialog.doc.md +26 -1
  150. package/docs_for_llm/vdrawer.doc.md +33 -4
  151. package/docs_for_llm/virtuallist.doc.md +165 -0
  152. package/package.json +3 -3
  153. package/dist/chunk-D2SXGGTX.mjs +0 -162
  154. package/dist/chunk-EYKZY2F3.js +0 -164
@@ -44,6 +44,23 @@ const handlePositioned = (feedback: Feedback) => {
44
44
  };
45
45
  ```
46
46
 
47
+ ## 插槽 (Slots)
48
+ | 插槽名 | 说明 | 模板写法 | 示例 |
49
+ | --- | --- | --- | --- |
50
+ | menu | 自定义下拉菜单内容,通常放置 DropdownMenu 和 DropdownItem。 | `<template #menu>...</template>` | `<Dropdown>
51
+ <Button>更多操作</Button>
52
+ <template #menu>
53
+ <DropdownMenu>
54
+ <DropdownItem>查看详情</DropdownItem>
55
+ </DropdownMenu>
56
+ </template>
57
+ </Dropdown>` |
58
+
59
+ ### 插槽参数说明
60
+ **menu**
61
+
62
+ - 参数结构: 无参数
63
+
47
64
  ## 方法 (Methods)
48
65
  | 方法名 | 说明 | 参数 | 返回值 |
49
66
  | --- | --- | --- | --- |
@@ -59,33 +76,270 @@ const handlePositioned = (feedback: Feedback) => {
59
76
  | --- | --- | --- | --- | --- |
60
77
  | shouldFocus | `boolean` | 否 | - | 展开后是否尝试把焦点移动到菜单内容,用于键盘可访问性场景。 |
61
78
 
79
+ 调用示例:
80
+ ```typescript
81
+ dropdownRef.value?.show(true);
82
+ ```
83
+
62
84
  **hide**
63
85
 
64
86
  | 参数 | 类型 | 必填 | 默认值 | 说明 |
65
87
  | --- | --- | --- | --- | --- |
66
88
  | immediately | `boolean` | 否 | - | 是否立即隐藏并跳过延迟关闭逻辑。 |
67
89
 
90
+ 调用示例:
91
+ ```typescript
92
+ dropdownRef.value?.hide(true);
93
+ ```
94
+
68
95
  **position**
69
96
 
70
97
  | 参数 | 类型 | 必填 | 默认值 | 说明 |
71
98
  | --- | --- | --- | --- | --- |
72
99
  | callback | `(feedback: Feedback) => void` | 否 | - | 定位完成后的回调,可读取最终 placement 和坐标。 |
73
100
 
101
+ 调用示例:
102
+ ```typescript
103
+ dropdownRef.value?.position((feedback) => console.log(feedback.placement));
104
+ ```
105
+
106
+ ### 方法调用示例
107
+ **show**
108
+
109
+ ```typescript
110
+ dropdownRef.value?.show(true);
111
+ ```
112
+
113
+ **hide**
114
+
115
+ ```typescript
116
+ dropdownRef.value?.hide(true);
117
+ ```
118
+
119
+ **focusFirst**
120
+
121
+ ```typescript
122
+ dropdownRef.value?.focusFirst();
123
+ ```
124
+
125
+ **position**
126
+
127
+ ```typescript
128
+ dropdownRef.value?.position((feedback) => console.log(feedback.placement));
129
+ ```
130
+
74
131
  ## 子组件 (Sub-Components)
75
132
  ### DropdownMenu
76
133
  下拉菜单容器,用于包裹菜单项
77
134
 
135
+ #### 组合示例
136
+ ##### 嵌套菜单
137
+ **场景**: 创建多级嵌套的下拉菜单
138
+
139
+ 多级嵌套的下拉菜单
140
+
141
+ ```vue
142
+ <script setup lang="ts">
143
+ import { Dropdown, DropdownMenu, DropdownItem, Button } from '@king-design/vue';
144
+ </script>
145
+ <template>
146
+ <Dropdown>
147
+ <Button>嵌套菜单</Button>
148
+ <template #menu>
149
+ <DropdownMenu>
150
+ <DropdownItem>菜单项1</DropdownItem>
151
+ <Dropdown position="right">
152
+ <DropdownItem>更多 ></DropdownItem>
153
+ <template #menu>
154
+ <DropdownMenu>
155
+ <DropdownItem>子菜单1</DropdownItem>
156
+ <DropdownItem>子菜单2</DropdownItem>
157
+ </DropdownMenu>
158
+ </template>
159
+ </Dropdown>
160
+ </DropdownMenu>
161
+ </template>
162
+ </Dropdown>
163
+ </template>
164
+ ```
165
+
166
+ ##### 基础用法
167
+ **场景**: 创建一个悬停触发的下拉菜单
168
+
169
+ 基本的下拉菜单,悬停触发
170
+
171
+ ```vue
172
+ <script setup lang="ts">
173
+ import { Dropdown, DropdownMenu, DropdownItem, Button } from '@king-design/vue';
174
+ </script>
175
+ <template>
176
+ <Dropdown>
177
+ <Button>下拉菜单</Button>
178
+ <template #menu>
179
+ <DropdownMenu>
180
+ <DropdownItem>菜单项1</DropdownItem>
181
+ <DropdownItem>菜单项2</DropdownItem>
182
+ <DropdownItem>菜单项3</DropdownItem>
183
+ </DropdownMenu>
184
+ </template>
185
+ </Dropdown>
186
+ </template>
187
+ ```
188
+
189
+ ##### 点击触发
190
+ **场景**: 创建点击触发的下拉菜单
191
+
192
+ 点击触发的下拉菜单
193
+
194
+ ```vue
195
+ <script setup lang="ts">
196
+ import { Dropdown, DropdownMenu, DropdownItem, Button } from '@king-design/vue';
197
+ </script>
198
+ <template>
199
+ <Dropdown trigger="click">
200
+ <Button>点击展开</Button>
201
+ <template #menu>
202
+ <DropdownMenu>
203
+ <DropdownItem>菜单项1</DropdownItem>
204
+ <DropdownItem>菜单项2</DropdownItem>
205
+ </DropdownMenu>
206
+ </template>
207
+ </Dropdown>
208
+ </template>
209
+ ```
210
+
78
211
  ### DropdownItem
79
212
  下拉菜单项组件
80
213
 
214
+ #### 属性 (Props)
81
215
  | 属性名 | 类型 | 说明 | 示例 |
82
216
  | --- | --- | --- | --- |
83
217
  | disabled | `boolean` | 是否禁用该菜单项 | `<DropdownItem disabled>禁用项</DropdownItem>` |
84
218
  | hideOnSelect | `boolean` | 选中该菜单后是否隐藏整个菜单 | `<DropdownItem :hideOnSelect="false">选中不关闭</DropdownItem>` |
85
219
 
86
- **事件**:
87
- - `@select`: 菜单项被选中时触发(点击或键盘操作)
88
- - `@click`: 菜单项被点击时触发
220
+ #### 事件 (Events)
221
+ | 事件名 | Vue事件名 | 说明 | 回调参数 | 示例 |
222
+ | --- | --- | --- | --- | --- |
223
+ | select | `@select` | 菜单项被选中时触发(点击或键盘操作) | `item: DropdownItem` | `<DropdownItem @select="handleActionSelect">查看详情</DropdownItem>` |
224
+ | click | `@click` | 菜单项被点击时触发 | `e: MouseEvent` | `<DropdownItem @click="recordMenuClick">下载日志</DropdownItem>` |
225
+
226
+ ##### DropdownItem 事件参数说明
227
+ **select**
228
+
229
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
230
+ | --- | --- | --- | --- | --- |
231
+ | item | `DropdownItem` | 是 | - | 被选中的菜单项实例 |
232
+
233
+ 事件处理示例:
234
+ ```typescript
235
+ const selectedAction = ref('');
236
+ const selectedItem = ref(null);
237
+
238
+ const handleActionSelect = (item) => {
239
+ selectedAction.value = 'detail';
240
+ selectedItem.value = item;
241
+ };
242
+ ```
243
+
244
+ **click**
245
+
246
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
247
+ | --- | --- | --- | --- | --- |
248
+ | e | `MouseEvent` | 是 | - | 原生鼠标事件 |
249
+
250
+ 事件处理示例:
251
+ ```typescript
252
+ const lastPointer = ref({ x: 0, y: 0 });
253
+
254
+ const recordMenuClick = (e: MouseEvent) => {
255
+ lastPointer.value = { x: e.clientX, y: e.clientY };
256
+ };
257
+ ```
258
+
259
+ #### 组合示例
260
+ ##### 禁用菜单项
261
+ **场景**: 禁用特定的菜单项
262
+
263
+ 禁用特定的菜单项
264
+
265
+ **命中的子组件 API**: 属性: disabled
266
+
267
+ ```vue
268
+ <script setup lang="ts">
269
+ import { Dropdown, DropdownMenu, DropdownItem, Button } from '@king-design/vue';
270
+ </script>
271
+ <template>
272
+ <Dropdown>
273
+ <Button>下拉菜单</Button>
274
+ <template #menu>
275
+ <DropdownMenu>
276
+ <DropdownItem>可用项</DropdownItem>
277
+ <DropdownItem disabled>禁用项</DropdownItem>
278
+ <DropdownItem>可用项</DropdownItem>
279
+ </DropdownMenu>
280
+ </template>
281
+ </Dropdown>
282
+ </template>
283
+ ```
284
+
285
+ ##### 监听选择事件
286
+ **场景**: 监听菜单项点击并执行操作
287
+
288
+ 监听菜单项的选择
289
+
290
+ **命中的子组件 API**: 事件: click
291
+
292
+ ```vue
293
+ <script setup lang="ts">
294
+ import { Dropdown, DropdownMenu, DropdownItem, Button, Message } from '@king-design/vue';
295
+
296
+ const handleClick = (action: string) => {
297
+ Message.info(`选择了: ${action}`);
298
+ };
299
+ </script>
300
+ <template>
301
+ <Dropdown>
302
+ <Button>操作</Button>
303
+ <template #menu>
304
+ <DropdownMenu>
305
+ <DropdownItem @click="handleClick('编辑')">编辑</DropdownItem>
306
+ <DropdownItem @click="handleClick('复制')">复制</DropdownItem>
307
+ <DropdownItem @click="handleClick('删除')">删除</DropdownItem>
308
+ </DropdownMenu>
309
+ </template>
310
+ </Dropdown>
311
+ </template>
312
+ ```
313
+
314
+ ##### 表格操作列
315
+ **场景**: 在表格操作列中使用下拉菜单
316
+
317
+ 在表格中使用下拉菜单作为操作列
318
+
319
+ **命中的子组件 API**: 事件: click
320
+
321
+ ```vue
322
+ <script setup lang="ts">
323
+ import { Dropdown, DropdownMenu, DropdownItem, Button, Message } from '@king-design/vue';
324
+
325
+ const handleAction = (action: string, id: number) => {
326
+ Message.info(`对 ID=${id} 执行 ${action}`);
327
+ };
328
+ </script>
329
+ <template>
330
+ <!-- 假设在表格的操作列中 -->
331
+ <Dropdown trigger="click">
332
+ <Button type="link" size="small">操作</Button>
333
+ <template #menu>
334
+ <DropdownMenu>
335
+ <DropdownItem @click="handleAction('查看', 1)">查看</DropdownItem>
336
+ <DropdownItem @click="handleAction('编辑', 1)">编辑</DropdownItem>
337
+ <DropdownItem @click="handleAction('删除', 1)">删除</DropdownItem>
338
+ </DropdownMenu>
339
+ </template>
340
+ </Dropdown>
341
+ </template>
342
+ ```
89
343
 
90
344
  ## 常见错误与正确用法 (Anti-Hallucination)
91
345
  ### 未使用 #menu 插槽
@@ -25,7 +25,16 @@ import { Flex } from '@ksyun-internal/versatile';
25
25
  ## 插槽 (Slots)
26
26
  | 插槽名 | 说明 | 模板写法 | 示例 |
27
27
  | --- | --- | --- | --- |
28
- | default | Flex 容器内容 | `<Flex>...</Flex>` | - |
28
+ | default | Flex 容器内容 | `<Flex>...</Flex>` | `<Flex>
29
+ <template <Flex>...</Flex>>
30
+ 自定义default内容
31
+ </template>
32
+ </Flex>` |
33
+
34
+ ### 插槽参数说明
35
+ **default**
36
+
37
+ - 参数结构: 无参数
29
38
 
30
39
  ## 使用示例
31
40
  ### 工具栏左右分布布局
@@ -55,10 +55,43 @@ const handleSubmit = (e: Event) => {
55
55
  | getFirstInvalidFormItem | 获取第一条出错的 FormItem | `-` | `FormItem` |
56
56
  | getAllInvalidFormItems | 获取所有校验失败的 FormItem | `-` | `FormItem[]` |
57
57
 
58
+ ### 方法调用示例
59
+ **validate**
60
+
61
+ ```typescript
62
+ const formRef = ref<InstanceType<typeof Form>>();
63
+
64
+ const handleSubmit = async () => {
65
+ const valid = await formRef.value?.validate();
66
+ if (valid) {
67
+ console.log('验证通过');
68
+ }
69
+ };</InstanceType>
70
+ ```
71
+
72
+ **reset**
73
+
74
+ ```typescript
75
+ formRef.value?.reset();
76
+ ```
77
+
78
+ **getFirstInvalidFormItem**
79
+
80
+ ```typescript
81
+ const firstError = formRef.value?.getFirstInvalidFormItem();
82
+ ```
83
+
84
+ **getAllInvalidFormItems**
85
+
86
+ ```typescript
87
+ const allErrors = formRef.value?.getAllInvalidFormItems();
88
+ ```
89
+
58
90
  ## 子组件 (Sub-Components)
59
91
  ### FormItem
60
92
  表单项组件,用于包裹表单控件并提供验证功能
61
93
 
94
+ #### 属性 (Props)
62
95
  | 属性名 | 类型 | 说明 | 示例 |
63
96
  | --- | --- | --- | --- |
64
97
  | value | `any` | 指定需要验证的数据 | `<FormItem :value="model.username" :rules="{required: true}"></FormItem>` |
@@ -72,10 +105,136 @@ const handleSubmit = (e: Event) => {
72
105
  | fluid | `boolean` | FormItem 的宽度默认是被子元素撑开的,添加该属性可以渲染 100% 的宽度 | `<FormItem fluid></FormItem>` |
73
106
  | validateOnStart | `boolean` | 是否组件一渲染就开始验证,而不是等用户输入完成再验证 | `<FormItem validateOnStart></FormItem>` |
74
107
 
75
- **插槽**:
76
- - `undefined`: 扩展前面的标题label
77
- - `undefined`: 扩展后面的内容,也可以使用children代替
78
- - `undefined`: 往后面追加的内容
108
+ #### 插槽 (Slots)
109
+ | 插槽名 | 说明 | 模板写法 | 示例 |
110
+ | --- | --- | --- | --- |
111
+ | label | 扩展前面的标题label | `#label` | `<FormItem>
112
+ <template #label>
113
+ 用户名
114
+ </template>
115
+ <Input />
116
+ </FormItem>` |
117
+ | content | 扩展后面的内容,也可以使用children代替 | `#content` | `<FormItem label="用户名">
118
+ <template #content>
119
+ <Input />
120
+ </template>
121
+ </FormItem>` |
122
+ | append | 往后面追加的内容 | `#append` | `<FormItem label="验证码">
123
+ <Input />
124
+ <template #append>
125
+ <Button type="primary">发送验证码</Button>
126
+ </template>
127
+ </FormItem>` |
128
+
129
+ ##### 插槽参数说明
130
+ **label**
131
+
132
+ - 参数结构: 无参数
133
+
134
+ **content**
135
+
136
+ - 参数结构: 无参数
137
+
138
+ **append**
139
+
140
+ - 参数结构: 无参数
141
+
142
+ #### 组合示例
143
+ ##### 自定义错误提示
144
+ **场景**: 自定义表单验证失败时显示的错误提示文案
145
+
146
+ 自定义验证失败时的错误提示文案
147
+
148
+ **命中的子组件 API**: 属性: value, rules, messages, label
149
+
150
+ ```vue
151
+ <script setup lang="ts">
152
+ import { reactive } from 'vue';
153
+ import { Form, FormItem, Input } from '@king-design/vue';
154
+
155
+ const model = reactive({
156
+ email: ''
157
+ });
158
+ </script>
159
+ <template>
160
+ <Form>
161
+ <FormItem label="邮箱" :value="model.email"
162
+ :rules="{required: true, email: true}"
163
+ :messages="{required: '邮箱不能为空', email: '邮箱格式不正确'}">
164
+ <Input v-model="model.email" />
165
+ </FormItem>
166
+ </Form>
167
+ </template>
168
+ ```
169
+
170
+ ##### 基础表单验证
171
+ **场景**: 创建一个带有用户名和邮箱验证的基础表单
172
+
173
+ 基本的表单验证用法
174
+
175
+ **命中的子组件 API**: 属性: value, rules, label
176
+
177
+ ```vue
178
+ <script setup lang="ts">
179
+ import { ref, reactive } from 'vue';
180
+ import { Form, FormItem, Input, Button, Message } from '@king-design/vue';
181
+
182
+ const form = ref<InstanceType<typeof Form>>();
183
+ const model = reactive({
184
+ username: '',
185
+ email: ''
186
+ });
187
+
188
+ const handleSubmit = async () => {
189
+ if (await form.value?.validate()) {
190
+ Message.success('验证通过');
191
+ }
192
+ };
193
+ </script>
194
+ <template>
195
+ <Form ref="form" @submit="handleSubmit">
196
+ <FormItem label="用户名" :value="model.username" :rules="{required: true}">
197
+ <Input v-model="model.username" />
198
+ </FormItem>
199
+ <FormItem label="邮箱" :value="model.email" :rules="{required: true, email: true}">
200
+ <Input v-model="model.email" />
201
+ </FormItem>
202
+ <FormItem>
203
+ <Button type="primary" htmlType="submit">提交</Button>
204
+ </FormItem>
205
+ </Form>
206
+ </template>
207
+ ```
208
+
209
+ ##### 密码确认验证
210
+ **场景**: 创建密码和确认密码字段,验证两次输入是否一致
211
+
212
+ 使用 equal 规则实现密码确认
213
+
214
+ **命中的子组件 API**: 属性: value, rules, label
215
+
216
+ ```vue
217
+ <script setup lang="ts">
218
+ import { reactive } from 'vue';
219
+ import { Form, FormItem, Input } from '@king-design/vue';
220
+
221
+ const model = reactive({
222
+ password: '',
223
+ confirmPassword: ''
224
+ });
225
+ </script>
226
+ <template>
227
+ <Form>
228
+ <FormItem label="密码" :value="model.password" :rules="{required: true}">
229
+ <Input type="password" v-model="model.password" />
230
+ </FormItem>
231
+ <FormItem label="确认密码" :value="model.confirmPassword"
232
+ :rules="{required: true, equal: model.password}">
233
+ <Input type="password" v-model="model.confirmPassword" />
234
+ </FormItem>
235
+ </Form>
236
+ </template>
237
+ ```
79
238
 
80
239
  ## 常见错误与正确用法 (Anti-Hallucination)
81
240
  ### FormItem 配置了 rules 但未绑定 value
@@ -18,7 +18,7 @@ import { FormItemSpinner } from '@ksyun-internal/versatile';
18
18
  | max | `number` | `Infinity` | 否 | 最大值 | - | - |
19
19
  | min | `number` | `0` | 否 | 最小值 | - | - |
20
20
  | step | `number` | `1` | 否 | 步长 | - | - |
21
- | size | `"default" | "small" | "mini"` | `"default"` | 否 | 尺寸 | `inherited:Spinner` | `<Spinner size="small" />` |
21
+ | size | `"large" | "default" | "small" | "mini"` | `"default"` | 否 | 尺寸 | `inherited:Spinner` | `<Spinner size="small" />` |
22
22
  | vertical | `boolean` | `false` | 否 | 控制按钮是否竖直排列 | `inherited:Spinner` | `<Spinner vertical />` |
23
23
  | precision | `number` | `0` | 否 | 保留小数位数 | - | - |
24
24
  | formatter | `(value: number) => string` | `undefined` | 否 | 定义格式化展示值的函数 | `inherited:Spinner` | `<Spinner :formatter="(val) => `${val}%`" :parser="(val) => parseFloat(val)" /></Spinner>` |
@@ -22,6 +22,7 @@ import { Row, Col } from '@king-design/vue';
22
22
  ### Col
23
23
  栅格列组件
24
24
 
25
+ #### 属性 (Props)
25
26
  | 属性名 | 类型 | 说明 | 示例 |
26
27
  | --- | --- | --- | --- |
27
28
  | span | `number | string` | 栅格占位格数,为 0 时相当于 display: none | `<Col :span="12"></Col>` |
@@ -36,6 +37,76 @@ import { Row, Col } from '@king-design/vue';
36
37
  | xl | `number | string | object` | ≥1200px 响应式栅格 | - |
37
38
  | xxl | `number | string | object` | ≥1600px 响应式栅格 | - |
38
39
 
40
+ #### 组合示例
41
+ ##### 响应式布局
42
+ **场景**: 适配不同屏幕尺寸的布局
43
+
44
+ 预设六个响应尺寸:xs sm md lg xl xxl
45
+
46
+ **命中的子组件 API**: 属性: xs, sm, md, lg, xl
47
+
48
+ ```vue
49
+ <script setup lang="ts">
50
+ import { Row, Col } from '@king-design/vue';
51
+ </script>
52
+ <template>
53
+ <Row :gutter="10">
54
+ <Col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
55
+ <div>Responsive</div>
56
+ </Col>
57
+ <Col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
58
+ <div>Responsive</div>
59
+ </Col>
60
+ <Col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
61
+ <div>Responsive</div>
62
+ </Col>
63
+ </Row>
64
+ </template>
65
+ ```
66
+
67
+ ##### 左右偏移
68
+ **场景**: 创建中间有空隙的布局
69
+
70
+ 使用 offset 属性将列向右侧偏移
71
+
72
+ **命中的子组件 API**: 属性: span, offset
73
+
74
+ ```vue
75
+ <script setup lang="ts">
76
+ import { Row, Col } from '@king-design/vue';
77
+ </script>
78
+ <template>
79
+ <Row>
80
+ <Col :span="8"><div>col-8</div></Col>
81
+ <Col :span="8" :offset="8"><div>col-8 offset-8</div></Col>
82
+ </Row>
83
+ </template>
84
+ ```
85
+
86
+ ##### 基础栅格
87
+ **场景**: 基本的等分列布局
88
+
89
+ 简单的行列布局
90
+
91
+ **命中的子组件 API**: 属性: span
92
+
93
+ ```vue
94
+ <script setup lang="ts">
95
+ import { Row, Col } from '@king-design/vue';
96
+ </script>
97
+ <template>
98
+ <Row>
99
+ <Col :span="12"><div>50%</div></Col>
100
+ <Col :span="12"><div>50%</div></Col>
101
+ </Row>
102
+ <Row>
103
+ <Col :span="8"><div>33.3%</div></Col>
104
+ <Col :span="8"><div>33.3%</div></Col>
105
+ <Col :span="8"><div>33.3%</div></Col>
106
+ </Row>
107
+ </template>
108
+ ```
109
+
39
110
  ## 常见错误与正确用法 (Anti-Hallucination)
40
111
  ### span 总和超过 24
41
112
  > **错误用法**: `<Row>
@@ -24,10 +24,39 @@ import { Header } from '@ksyun-internal/versatile';
24
24
  ## 插槽 (Slots)
25
25
  | 插槽名 | 说明 | 模板写法 | 示例 |
26
26
  | --- | --- | --- | --- |
27
- | title | 扩展顶部栏左侧标题处内容 | `<template #title>...</template>` | - |
28
- | titleAppend | 扩展顶部栏左侧标题后的追加内容 | `<template #titleAppend>...</template>` | - |
29
- | docPrepend | 扩展右侧文档入口前的内容 | `<template #docPrepend>...</template>` | - |
30
- | doc | 自定义右侧文档区域 | `<template #doc>...</template>` | - |
27
+ | title | 扩展顶部栏左侧标题处内容 | `<template #title>...</template>` | `<Header>
28
+ <template <template #title>...</template>>自定义标题</template>
29
+ </Header>` |
30
+ | titleAppend | 扩展顶部栏左侧标题后的追加内容 | `<template #titleAppend>...</template>` | `<Header>
31
+ <template <template #titleAppend>...</template>>
32
+ 自定义titleAppend内容
33
+ </template>
34
+ </Header>` |
35
+ | docPrepend | 扩展右侧文档入口前的内容 | `<template #docPrepend>...</template>` | `<Header>
36
+ <template <template #docPrepend>...</template>>
37
+ 自定义docPrepend内容
38
+ </template>
39
+ </Header>` |
40
+ | doc | 自定义右侧文档区域 | `<template #doc>...</template>` | `<Header>
41
+ <template <template #doc>...</template>>自定义doc内容</template>
42
+ </Header>` |
43
+
44
+ ### 插槽参数说明
45
+ **title**
46
+
47
+ - 参数结构: 无参数
48
+
49
+ **titleAppend**
50
+
51
+ - 参数结构: 无参数
52
+
53
+ **docPrepend**
54
+
55
+ - 参数结构: 无参数
56
+
57
+ **doc**
58
+
59
+ - 参数结构: 无参数
31
60
 
32
61
  ## 使用示例
33
62
  ### 详情页头部信息