jianghu-ui 1.0.1

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 (112) hide show
  1. package/README.md +376 -0
  2. package/dist/jianghu-ui.css +2318 -0
  3. package/dist/jianghu-ui.js +2 -0
  4. package/dist/jianghu-ui.js.LICENSE.txt +1 -0
  5. package/package.json +56 -0
  6. package/src/Design.stories.mdx +195 -0
  7. package/src/Introduction.stories.mdx +148 -0
  8. package/src/components/JhAddressSelect/JhAddressSelect.md +250 -0
  9. package/src/components/JhAddressSelect/JhAddressSelect.stories.js +282 -0
  10. package/src/components/JhAddressSelect/JhAddressSelect.vue +261 -0
  11. package/src/components/JhCard/JhCard.md +246 -0
  12. package/src/components/JhCard/JhCard.stories.js +688 -0
  13. package/src/components/JhCard/JhCard.vue +604 -0
  14. package/src/components/JhCheckCard/JhCheckCard.md +245 -0
  15. package/src/components/JhCheckCard/JhCheckCard.stories.js +750 -0
  16. package/src/components/JhCheckCard/JhCheckCard.vue +476 -0
  17. package/src/components/JhConfirmDialog/JhConfirmDialog.md +70 -0
  18. package/src/components/JhConfirmDialog/JhConfirmDialog.stories.js +550 -0
  19. package/src/components/JhConfirmDialog/JhConfirmDialog.vue +181 -0
  20. package/src/components/JhDateRangePicker/JhDateRangePicker.md +56 -0
  21. package/src/components/JhDateRangePicker/JhDateRangePicker.stories.js +320 -0
  22. package/src/components/JhDateRangePicker/JhDateRangePicker.vue +307 -0
  23. package/src/components/JhDescriptions/JhDescriptions.md +724 -0
  24. package/src/components/JhDescriptions/JhDescriptions.stories.js +858 -0
  25. package/src/components/JhDescriptions/JhDescriptions.vue +933 -0
  26. package/src/components/JhDraggable/JhDraggable.md +66 -0
  27. package/src/components/JhDraggable/JhDraggable.stories.js +161 -0
  28. package/src/components/JhDraggable/JhDraggable.vue +254 -0
  29. package/src/components/JhDrawer/JhDrawer.md +68 -0
  30. package/src/components/JhDrawer/JhDrawer.stories.js +478 -0
  31. package/src/components/JhDrawer/JhDrawer.vue +281 -0
  32. package/src/components/JhDrawerForm/JhDrawerForm.md +69 -0
  33. package/src/components/JhDrawerForm/JhDrawerForm.stories.js +492 -0
  34. package/src/components/JhDrawerForm/JhDrawerForm.vue +297 -0
  35. package/src/components/JhEditableTable/JhEditableTable.md +507 -0
  36. package/src/components/JhEditableTable/JhEditableTable.stories.js +615 -0
  37. package/src/components/JhEditableTable/JhEditableTable.vue +685 -0
  38. package/src/components/JhFileInput/JhFileInput.md +56 -0
  39. package/src/components/JhFileInput/JhFileInput.stories.js +103 -0
  40. package/src/components/JhFileInput/JhFileInput.vue +253 -0
  41. package/src/components/JhForm/JhForm.md +676 -0
  42. package/src/components/JhForm/JhForm.stories.js +1375 -0
  43. package/src/components/JhForm/JhForm.vue +657 -0
  44. package/src/components/JhFormField/JhFormField.stories.js +217 -0
  45. package/src/components/JhFormField/JhFormField.vue +439 -0
  46. package/src/components/JhFormFields/JhFormFields.md +647 -0
  47. package/src/components/JhFormFields/JhFormFields.stories.js +922 -0
  48. package/src/components/JhFormFields/JhFormFields.vue +998 -0
  49. package/src/components/JhFormList/JhFormList.md +303 -0
  50. package/src/components/JhFormList/JhFormList.stories.js +661 -0
  51. package/src/components/JhFormList/JhFormList.vue +1127 -0
  52. package/src/components/JhJsonEditor/JhJsonEditor.md +54 -0
  53. package/src/components/JhJsonEditor/JhJsonEditor.stories.js +157 -0
  54. package/src/components/JhJsonEditor/JhJsonEditor.vue +178 -0
  55. package/src/components/JhLayout/JhLayout.md +580 -0
  56. package/src/components/JhLayout/JhLayout.stories.js +414 -0
  57. package/src/components/JhLayout/JhLayout.vue +387 -0
  58. package/src/components/JhList/JhList.md +441 -0
  59. package/src/components/JhList/JhList.stories.js +524 -0
  60. package/src/components/JhList/JhList.vue +571 -0
  61. package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +56 -0
  62. package/src/components/JhMarkdownEditor/JhMarkdownEditor.stories.js +191 -0
  63. package/src/components/JhMarkdownEditor/JhMarkdownEditor.vue +188 -0
  64. package/src/components/JhMask/JhMask.md +62 -0
  65. package/src/components/JhMask/JhMask.stories.js +270 -0
  66. package/src/components/JhMask/JhMask.vue +123 -0
  67. package/src/components/JhMenu/JhMenu.md +85 -0
  68. package/src/components/JhMenu/JhMenu.stories.js +384 -0
  69. package/src/components/JhMenu/JhMenu.vue +545 -0
  70. package/src/components/JhModal/JhModal.md +68 -0
  71. package/src/components/JhModal/JhModal.stories.js +562 -0
  72. package/src/components/JhModal/JhModal.vue +235 -0
  73. package/src/components/JhModalForm/JhModalForm.md +69 -0
  74. package/src/components/JhModalForm/JhModalForm.stories.js +592 -0
  75. package/src/components/JhModalForm/JhModalForm.vue +298 -0
  76. package/src/components/JhPageContainer/JhPageContainer.md +409 -0
  77. package/src/components/JhPageContainer/JhPageContainer.stories.js +209 -0
  78. package/src/components/JhPageContainer/JhPageContainer.vue +72 -0
  79. package/src/components/JhQueryFilter/JhQueryFilter.md +77 -0
  80. package/src/components/JhQueryFilter/JhQueryFilter.stories.js +684 -0
  81. package/src/components/JhQueryFilter/JhQueryFilter.vue +429 -0
  82. package/src/components/JhScene/JhScene.md +64 -0
  83. package/src/components/JhScene/JhScene.stories.js +317 -0
  84. package/src/components/JhScene/JhScene.vue +376 -0
  85. package/src/components/JhStatisticCard/JhStatisticCard.md +363 -0
  86. package/src/components/JhStatisticCard/JhStatisticCard.stories.js +847 -0
  87. package/src/components/JhStatisticCard/JhStatisticCard.vue +459 -0
  88. package/src/components/JhStepsForm/JhStepsForm.md +666 -0
  89. package/src/components/JhStepsForm/JhStepsForm.stories.js +1224 -0
  90. package/src/components/JhStepsForm/JhStepsForm.vue +749 -0
  91. package/src/components/JhTable/JhTable.md +730 -0
  92. package/src/components/JhTable/JhTable.stories.js +1444 -0
  93. package/src/components/JhTable/JhTable.vue +2298 -0
  94. package/src/components/JhTableAttachment/JhTableAttachment.md +70 -0
  95. package/src/components/JhTableAttachment/JhTableAttachment.stories.js +198 -0
  96. package/src/components/JhTableAttachment/JhTableAttachment.vue +264 -0
  97. package/src/components/JhToast/JhToast.md +67 -0
  98. package/src/components/JhToast/JhToast.stories.js +386 -0
  99. package/src/components/JhToast/JhToast.vue +239 -0
  100. package/src/components/JhTreeSelect/JhTreeSelect.md +82 -0
  101. package/src/components/JhTreeSelect/JhTreeSelect.stories.js +391 -0
  102. package/src/components/JhTreeSelect/JhTreeSelect.vue +727 -0
  103. package/src/components/JhWaterMark/JhWaterMark.md +190 -0
  104. package/src/components/JhWaterMark/JhWaterMark.stories.js +675 -0
  105. package/src/components/JhWaterMark/JhWaterMark.vue +351 -0
  106. package/src/components/README.md +52 -0
  107. package/src/index.js +135 -0
  108. package/src/style/globalCSSJHV4.css +348 -0
  109. package/src/style/globalCSSVuetifyV4.css +637 -0
  110. package/src/style/storybook.css +4 -0
  111. package/src/tailwind.css +3 -0
  112. package/src/utils/vuetify.js +31 -0
@@ -0,0 +1,858 @@
1
+ import JhDescriptions from './JhDescriptions.vue';
2
+
3
+ export default {
4
+ title: '数据展示/JhDescriptions - 定义列表',
5
+ component: JhDescriptions,
6
+ tags: ['autodocs'],
7
+ argTypes: {
8
+ title: {
9
+ control: 'text',
10
+ description: '描述列表标题',
11
+ },
12
+ layout: {
13
+ control: { type: 'select' },
14
+ options: ['horizontal', 'vertical'],
15
+ description: '布局方式',
16
+ },
17
+ column: {
18
+ control: 'number',
19
+ description: '列数',
20
+ },
21
+ size: {
22
+ control: { type: 'select' },
23
+ options: ['small', 'default'],
24
+ description: '尺寸',
25
+ },
26
+ bordered: {
27
+ control: 'boolean',
28
+ description: '是否显示边框',
29
+ },
30
+ colon: {
31
+ control: 'boolean',
32
+ description: '是否显示冒号',
33
+ },
34
+ editable: {
35
+ control: 'boolean',
36
+ description: '是否可编辑',
37
+ },
38
+ },
39
+ };
40
+
41
+ // 基础用法
42
+ export const Basic = {
43
+ render: (args) => ({
44
+ components: { JhDescriptions },
45
+ setup() {
46
+ const columns = [
47
+ {
48
+ title: '用户名',
49
+ dataIndex: 'username',
50
+ key: 'username',
51
+ },
52
+ {
53
+ title: '手机号',
54
+ dataIndex: 'phone',
55
+ key: 'phone',
56
+ },
57
+ {
58
+ title: '邮箱',
59
+ dataIndex: 'email',
60
+ key: 'email',
61
+ },
62
+ {
63
+ title: '地址',
64
+ dataIndex: 'address',
65
+ key: 'address',
66
+ span: 2,
67
+ },
68
+ {
69
+ title: '备注',
70
+ dataIndex: 'remark',
71
+ key: 'remark',
72
+ span: 3,
73
+ },
74
+ ];
75
+
76
+ const dataSource = {
77
+ username: '张三',
78
+ phone: '13800138000',
79
+ email: 'zhangsan@example.com',
80
+ address: '浙江省杭州市西湖区某某街道某某号',
81
+ remark: '这是一段备注信息',
82
+ };
83
+
84
+ return { args, columns, dataSource };
85
+ },
86
+ template: `
87
+ <jh-descriptions
88
+ v-bind="args"
89
+ :columns="columns"
90
+ :data-source="dataSource"
91
+ />
92
+ `,
93
+ }),
94
+ args: {
95
+ title: '用户信息',
96
+ column: 3,
97
+ bordered: true,
98
+ },
99
+ };
100
+
101
+ // 垂直布局
102
+ export const VerticalLayout = {
103
+ render: (args) => ({
104
+ components: { JhDescriptions },
105
+ setup() {
106
+ const columns = [
107
+ {
108
+ title: '产品名称',
109
+ dataIndex: 'productName',
110
+ key: 'productName',
111
+ },
112
+ {
113
+ title: '产品价格',
114
+ dataIndex: 'price',
115
+ key: 'price',
116
+ valueType: 'money',
117
+ },
118
+ {
119
+ title: '库存数量',
120
+ dataIndex: 'stock',
121
+ key: 'stock',
122
+ valueType: 'digit',
123
+ },
124
+ {
125
+ title: '产品状态',
126
+ dataIndex: 'status',
127
+ key: 'status',
128
+ valueType: 'option',
129
+ valueEnum: {
130
+ online: '在线',
131
+ offline: '离线',
132
+ pending: '待审核',
133
+ },
134
+ },
135
+ {
136
+ title: '创建时间',
137
+ dataIndex: 'createTime',
138
+ key: 'createTime',
139
+ valueType: 'dateTime',
140
+ },
141
+ {
142
+ title: '产品描述',
143
+ dataIndex: 'description',
144
+ key: 'description',
145
+ },
146
+ ];
147
+
148
+ const dataSource = {
149
+ productName: 'iPhone 15 Pro',
150
+ price: 7999,
151
+ stock: 1234,
152
+ status: 'online',
153
+ createTime: '2024-01-15 10:30:00',
154
+ description: '这是一款高端智能手机,配备最新的A17芯片和钛金属边框。',
155
+ };
156
+
157
+ return { args, columns, dataSource };
158
+ },
159
+ template: `
160
+ <jh-descriptions
161
+ v-bind="args"
162
+ :columns="columns"
163
+ :data-source="dataSource"
164
+ />
165
+ `,
166
+ }),
167
+ args: {
168
+ title: '产品详情',
169
+ layout: 'vertical',
170
+ column: 3,
171
+ bordered: true,
172
+ },
173
+ };
174
+
175
+ // 可编辑
176
+ export const Editable = {
177
+ render: (args) => ({
178
+ components: { JhDescriptions },
179
+ setup() {
180
+ const columns = [
181
+ {
182
+ title: '姓名',
183
+ dataIndex: 'name',
184
+ key: 'name',
185
+ editable: true,
186
+ },
187
+ {
188
+ title: '年龄',
189
+ dataIndex: 'age',
190
+ key: 'age',
191
+ valueType: 'digit',
192
+ editable: true,
193
+ },
194
+ {
195
+ title: '性别',
196
+ dataIndex: 'gender',
197
+ key: 'gender',
198
+ valueType: 'select',
199
+ editable: true,
200
+ valueEnum: {
201
+ male: '男',
202
+ female: '女',
203
+ },
204
+ },
205
+ {
206
+ title: '出生日期',
207
+ dataIndex: 'birthday',
208
+ key: 'birthday',
209
+ valueType: 'date',
210
+ editable: true,
211
+ },
212
+ {
213
+ title: '手机号',
214
+ dataIndex: 'phone',
215
+ key: 'phone',
216
+ editable: true,
217
+ },
218
+ {
219
+ title: '邮箱',
220
+ dataIndex: 'email',
221
+ key: 'email',
222
+ editable: true,
223
+ },
224
+ {
225
+ title: '个人简介',
226
+ dataIndex: 'bio',
227
+ key: 'bio',
228
+ valueType: 'textarea',
229
+ editable: true,
230
+ span: 3,
231
+ },
232
+ ];
233
+
234
+ const dataSource = {
235
+ name: '李四',
236
+ age: 28,
237
+ gender: 'male',
238
+ birthday: '1996-05-20',
239
+ phone: '13900139000',
240
+ email: 'lisi@example.com',
241
+ bio: '热爱编程,喜欢开源技术。',
242
+ };
243
+
244
+ const handleSave = (data) => {
245
+ console.log('保存数据:', data);
246
+ alert('保存成功!');
247
+ };
248
+
249
+ return { args, columns, dataSource, handleSave };
250
+ },
251
+ template: `
252
+ <jh-descriptions
253
+ v-bind="args"
254
+ :columns="columns"
255
+ :data-source="dataSource"
256
+ @save="handleSave"
257
+ />
258
+ `,
259
+ }),
260
+ args: {
261
+ title: '个人信息',
262
+ column: 3,
263
+ bordered: true,
264
+ editable: true,
265
+ },
266
+ };
267
+
268
+ // 不同的 ValueType
269
+ export const ValueTypes = {
270
+ render: (args) => ({
271
+ components: { JhDescriptions },
272
+ setup() {
273
+ const columns = [
274
+ {
275
+ title: '文本',
276
+ dataIndex: 'text',
277
+ key: 'text',
278
+ valueType: 'text',
279
+ },
280
+ {
281
+ title: '金额',
282
+ dataIndex: 'money',
283
+ key: 'money',
284
+ valueType: 'money',
285
+ },
286
+ {
287
+ title: '百分比',
288
+ dataIndex: 'percent',
289
+ key: 'percent',
290
+ valueType: 'percent',
291
+ },
292
+ {
293
+ title: '数字',
294
+ dataIndex: 'digit',
295
+ key: 'digit',
296
+ valueType: 'digit',
297
+ },
298
+ {
299
+ title: '日期',
300
+ dataIndex: 'date',
301
+ key: 'date',
302
+ valueType: 'date',
303
+ },
304
+ {
305
+ title: '日期时间',
306
+ dataIndex: 'dateTime',
307
+ key: 'dateTime',
308
+ valueType: 'dateTime',
309
+ },
310
+ {
311
+ title: '时间',
312
+ dataIndex: 'time',
313
+ key: 'time',
314
+ valueType: 'time',
315
+ },
316
+ {
317
+ title: '选项',
318
+ dataIndex: 'option',
319
+ key: 'option',
320
+ valueType: 'option',
321
+ valueEnum: {
322
+ success: '成功',
323
+ error: '失败',
324
+ warning: '警告',
325
+ },
326
+ },
327
+ ];
328
+
329
+ const dataSource = {
330
+ text: '这是一段文本',
331
+ money: 12345.67,
332
+ percent: 85,
333
+ digit: 1234567,
334
+ date: '2024-01-15',
335
+ dateTime: '2024-01-15 14:30:00',
336
+ time: '14:30:00',
337
+ option: 'success',
338
+ };
339
+
340
+ return { args, columns, dataSource };
341
+ },
342
+ template: `
343
+ <jh-descriptions
344
+ v-bind="args"
345
+ :columns="columns"
346
+ :data-source="dataSource"
347
+ />
348
+ `,
349
+ }),
350
+ args: {
351
+ title: 'ValueType 示例',
352
+ column: 2,
353
+ bordered: true,
354
+ },
355
+ };
356
+
357
+ // 自定义渲染
358
+ export const CustomRender = {
359
+ render: (args) => ({
360
+ components: { JhDescriptions },
361
+ setup() {
362
+ const columns = [
363
+ {
364
+ title: '用户名',
365
+ dataIndex: 'username',
366
+ key: 'username',
367
+ },
368
+ {
369
+ title: '状态',
370
+ dataIndex: 'status',
371
+ key: 'status',
372
+ render: (value) => {
373
+ const statusMap = {
374
+ active: '<span style="color: #52c41a;">● 活跃</span>',
375
+ inactive: '<span style="color: #ff4d4f;">● 未激活</span>',
376
+ pending: '<span style="color: #faad14;">● 待审核</span>',
377
+ };
378
+ return statusMap[value] || value;
379
+ },
380
+ },
381
+ {
382
+ title: '等级',
383
+ dataIndex: 'level',
384
+ key: 'level',
385
+ render: (value) => {
386
+ const stars = '★'.repeat(value) + '☆'.repeat(5 - value);
387
+ return `<span style="color: #faad14;">${stars}</span>`;
388
+ },
389
+ },
390
+ {
391
+ title: '进度',
392
+ dataIndex: 'progress',
393
+ key: 'progress',
394
+ render: (value) => {
395
+ const color = value >= 80 ? '#52c41a' : value >= 50 ? '#faad14' : '#ff4d4f';
396
+ return `
397
+ <div style="display: flex; align-items: center; gap: 8px;">
398
+ <div style="flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden;">
399
+ <div style="width: ${value}%; height: 100%; background: ${color}; transition: width 0.3s;"></div>
400
+ </div>
401
+ <span>${value}%</span>
402
+ </div>
403
+ `;
404
+ },
405
+ span: 2,
406
+ },
407
+ ];
408
+
409
+ const dataSource = {
410
+ username: '王五',
411
+ status: 'active',
412
+ level: 4,
413
+ progress: 75,
414
+ };
415
+
416
+ return { args, columns, dataSource };
417
+ },
418
+ template: `
419
+ <jh-descriptions
420
+ v-bind="args"
421
+ :columns="columns"
422
+ :data-source="dataSource"
423
+ />
424
+ `,
425
+ }),
426
+ args: {
427
+ title: '自定义渲染',
428
+ column: 2,
429
+ bordered: true,
430
+ },
431
+ };
432
+
433
+ // 可复制
434
+ export const Copyable = {
435
+ render: (args) => ({
436
+ components: { JhDescriptions },
437
+ setup() {
438
+ const columns = [
439
+ {
440
+ title: 'API Key',
441
+ dataIndex: 'apiKey',
442
+ key: 'apiKey',
443
+ copyable: true,
444
+ },
445
+ {
446
+ title: 'Secret Key',
447
+ dataIndex: 'secretKey',
448
+ key: 'secretKey',
449
+ copyable: true,
450
+ },
451
+ {
452
+ title: '访问令牌',
453
+ dataIndex: 'token',
454
+ key: 'token',
455
+ copyable: true,
456
+ span: 2,
457
+ },
458
+ {
459
+ title: 'Webhook URL',
460
+ dataIndex: 'webhookUrl',
461
+ key: 'webhookUrl',
462
+ copyable: true,
463
+ span: 3,
464
+ },
465
+ ];
466
+
467
+ const dataSource = {
468
+ apiKey: 'sk_test_1234567890abcdef',
469
+ secretKey: 'sk_live_abcdef1234567890',
470
+ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ',
471
+ webhookUrl: 'https://api.example.com/webhook/callback',
472
+ };
473
+
474
+ const handleCopy = ({ text }) => {
475
+ console.log('已复制:', text);
476
+ };
477
+
478
+ return { args, columns, dataSource, handleCopy };
479
+ },
480
+ template: `
481
+ <jh-descriptions
482
+ v-bind="args"
483
+ :columns="columns"
484
+ :data-source="dataSource"
485
+ @copy="handleCopy"
486
+ />
487
+ `,
488
+ }),
489
+ args: {
490
+ title: 'API 配置',
491
+ tooltip: '点击复制按钮可以复制内容到剪贴板',
492
+ column: 3,
493
+ bordered: true,
494
+ },
495
+ };
496
+
497
+ // 响应式列数
498
+ export const ResponsiveColumns = {
499
+ render: (args) => ({
500
+ components: { JhDescriptions },
501
+ setup() {
502
+ const columns = [
503
+ {
504
+ title: '订单号',
505
+ dataIndex: 'orderNo',
506
+ key: 'orderNo',
507
+ },
508
+ {
509
+ title: '订单状态',
510
+ dataIndex: 'status',
511
+ key: 'status',
512
+ valueType: 'option',
513
+ valueEnum: {
514
+ pending: '待支付',
515
+ paid: '已支付',
516
+ shipped: '已发货',
517
+ completed: '已完成',
518
+ },
519
+ },
520
+ {
521
+ title: '订单金额',
522
+ dataIndex: 'amount',
523
+ key: 'amount',
524
+ valueType: 'money',
525
+ },
526
+ {
527
+ title: '下单时间',
528
+ dataIndex: 'createTime',
529
+ key: 'createTime',
530
+ valueType: 'dateTime',
531
+ },
532
+ {
533
+ title: '收货地址',
534
+ dataIndex: 'address',
535
+ key: 'address',
536
+ span: 2,
537
+ },
538
+ {
539
+ title: '订单备注',
540
+ dataIndex: 'remark',
541
+ key: 'remark',
542
+ span: 3,
543
+ },
544
+ ];
545
+
546
+ const dataSource = {
547
+ orderNo: 'ORD20240115001',
548
+ status: 'paid',
549
+ amount: 299.99,
550
+ createTime: '2024-01-15 10:30:00',
551
+ address: '浙江省杭州市西湖区某某街道某某号',
552
+ remark: '请尽快发货,谢谢!',
553
+ };
554
+
555
+ return { args, columns, dataSource };
556
+ },
557
+ template: `
558
+ <jh-descriptions
559
+ v-bind="args"
560
+ :columns="columns"
561
+ :data-source="dataSource"
562
+ />
563
+ `,
564
+ }),
565
+ args: {
566
+ title: '订单详情',
567
+ column: {
568
+ xs: 1,
569
+ sm: 2,
570
+ md: 3,
571
+ lg: 3,
572
+ xl: 3,
573
+ xxl: 4,
574
+ },
575
+ bordered: true,
576
+ },
577
+ };
578
+
579
+ // 小尺寸
580
+ export const SmallSize = {
581
+ render: (args) => ({
582
+ components: { JhDescriptions },
583
+ setup() {
584
+ const columns = [
585
+ {
586
+ title: '名称',
587
+ dataIndex: 'name',
588
+ key: 'name',
589
+ },
590
+ {
591
+ title: '类型',
592
+ dataIndex: 'type',
593
+ key: 'type',
594
+ },
595
+ {
596
+ title: '大小',
597
+ dataIndex: 'size',
598
+ key: 'size',
599
+ },
600
+ {
601
+ title: '修改时间',
602
+ dataIndex: 'modifyTime',
603
+ key: 'modifyTime',
604
+ valueType: 'dateTime',
605
+ },
606
+ ];
607
+
608
+ const dataSource = {
609
+ name: 'document.pdf',
610
+ type: 'PDF 文档',
611
+ size: '2.5 MB',
612
+ modifyTime: '2024-01-15 14:30:00',
613
+ };
614
+
615
+ return { args, columns, dataSource };
616
+ },
617
+ template: `
618
+ <jh-descriptions
619
+ v-bind="args"
620
+ :columns="columns"
621
+ :data-source="dataSource"
622
+ />
623
+ `,
624
+ }),
625
+ args: {
626
+ title: '文件信息',
627
+ column: 2,
628
+ size: 'small',
629
+ bordered: true,
630
+ },
631
+ };
632
+
633
+ // 使用 Request 加载数据
634
+ export const WithRequest = {
635
+ render: (args) => ({
636
+ components: { JhDescriptions },
637
+ setup() {
638
+ const columns = [
639
+ {
640
+ title: 'ID',
641
+ dataIndex: 'id',
642
+ key: 'id',
643
+ },
644
+ {
645
+ title: '标题',
646
+ dataIndex: 'title',
647
+ key: 'title',
648
+ },
649
+ {
650
+ title: '作者',
651
+ dataIndex: 'author',
652
+ key: 'author',
653
+ },
654
+ {
655
+ title: '发布时间',
656
+ dataIndex: 'publishTime',
657
+ key: 'publishTime',
658
+ valueType: 'dateTime',
659
+ },
660
+ {
661
+ title: '阅读量',
662
+ dataIndex: 'views',
663
+ key: 'views',
664
+ valueType: 'digit',
665
+ },
666
+ {
667
+ title: '点赞数',
668
+ dataIndex: 'likes',
669
+ key: 'likes',
670
+ valueType: 'digit',
671
+ },
672
+ {
673
+ title: '摘要',
674
+ dataIndex: 'summary',
675
+ key: 'summary',
676
+ span: 3,
677
+ },
678
+ ];
679
+
680
+ const request = async (params) => {
681
+ // 模拟 API 请求
682
+ return new Promise((resolve) => {
683
+ setTimeout(() => {
684
+ resolve({
685
+ id: params.id || 1,
686
+ title: '如何使用 JhDescriptions 组件',
687
+ author: '张三',
688
+ publishTime: '2024-01-15 10:00:00',
689
+ views: 12345,
690
+ likes: 567,
691
+ summary: '这是一篇关于如何使用 JhDescriptions 组件的详细教程,包含了各种使用场景和示例代码。',
692
+ });
693
+ }, 1000);
694
+ });
695
+ };
696
+
697
+ return { args, columns, request };
698
+ },
699
+ template: `
700
+ <jh-descriptions
701
+ v-bind="args"
702
+ :columns="columns"
703
+ :request="request"
704
+ :params="{ id: 1 }"
705
+ />
706
+ `,
707
+ }),
708
+ args: {
709
+ title: '文章详情',
710
+ column: 3,
711
+ bordered: true,
712
+ },
713
+ };
714
+
715
+ // 自定义插槽
716
+ export const CustomSlots = {
717
+ render: (args) => ({
718
+ components: { JhDescriptions },
719
+ setup() {
720
+ const columns = [
721
+ {
722
+ title: '用户头像',
723
+ dataIndex: 'avatar',
724
+ key: 'avatar',
725
+ },
726
+ {
727
+ title: '用户名',
728
+ dataIndex: 'username',
729
+ key: 'username',
730
+ },
731
+ {
732
+ title: '会员等级',
733
+ dataIndex: 'vipLevel',
734
+ key: 'vipLevel',
735
+ },
736
+ {
737
+ title: '标签',
738
+ dataIndex: 'tags',
739
+ key: 'tags',
740
+ span: 2,
741
+ },
742
+ ];
743
+
744
+ const dataSource = {
745
+ avatar: 'https://i.pravatar.cc/150?img=1',
746
+ username: '赵六',
747
+ vipLevel: 3,
748
+ tags: ['前端开发', 'Vue.js', 'React'],
749
+ };
750
+
751
+ return { args, columns, dataSource };
752
+ },
753
+ template: `
754
+ <jh-descriptions
755
+ v-bind="args"
756
+ :columns="columns"
757
+ :data-source="dataSource"
758
+ >
759
+ <template #item-avatar="{ value }">
760
+ <img :src="value" alt="avatar" style="width: 48px; height: 48px; border-radius: 50%;" />
761
+ </template>
762
+
763
+ <template #item-vipLevel="{ value }">
764
+ <span style="display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 12px; font-size: 12px;">
765
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
766
+ <path d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"/>
767
+ </svg>
768
+ VIP {{ value }}
769
+ </span>
770
+ </template>
771
+
772
+ <template #item-tags="{ value }">
773
+ <div style="display: flex; gap: 8px; flex-wrap: wrap;">
774
+ <span
775
+ v-for="tag in value"
776
+ :key="tag"
777
+ style="padding: 2px 8px; background: #f0f0f0; border-radius: 4px; font-size: 12px;"
778
+ >
779
+ {{ tag }}
780
+ </span>
781
+ </div>
782
+ </template>
783
+ </jh-descriptions>
784
+ `,
785
+ }),
786
+ args: {
787
+ title: '用户资料',
788
+ column: 2,
789
+ bordered: true,
790
+ },
791
+ };
792
+
793
+ // 无边框
794
+ export const NoBorder = {
795
+ render: (args) => ({
796
+ components: { JhDescriptions },
797
+ setup() {
798
+ const columns = [
799
+ {
800
+ title: '项目名称',
801
+ dataIndex: 'projectName',
802
+ key: 'projectName',
803
+ },
804
+ {
805
+ title: '负责人',
806
+ dataIndex: 'owner',
807
+ key: 'owner',
808
+ },
809
+ {
810
+ title: '项目状态',
811
+ dataIndex: 'status',
812
+ key: 'status',
813
+ valueType: 'option',
814
+ valueEnum: {
815
+ planning: '规划中',
816
+ developing: '开发中',
817
+ testing: '测试中',
818
+ online: '已上线',
819
+ },
820
+ },
821
+ {
822
+ title: '开始时间',
823
+ dataIndex: 'startTime',
824
+ key: 'startTime',
825
+ valueType: 'date',
826
+ },
827
+ {
828
+ title: '项目描述',
829
+ dataIndex: 'description',
830
+ key: 'description',
831
+ span: 2,
832
+ },
833
+ ];
834
+
835
+ const dataSource = {
836
+ projectName: 'JiangHu UI',
837
+ owner: '开发团队',
838
+ status: 'developing',
839
+ startTime: '2024-01-01',
840
+ description: '一个基于 Vue 和 Vuetify 的企业级 UI 组件库',
841
+ };
842
+
843
+ return { args, columns, dataSource };
844
+ },
845
+ template: `
846
+ <jh-descriptions
847
+ v-bind="args"
848
+ :columns="columns"
849
+ :data-source="dataSource"
850
+ />
851
+ `,
852
+ }),
853
+ args: {
854
+ title: '项目信息',
855
+ column: 2,
856
+ bordered: false,
857
+ },
858
+ };