auto-vue-manual 0.3.13 → 0.3.15

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 (90) hide show
  1. package/README.md +84 -32
  2. package/dist/auto-vue-manual.es.js +21064 -19484
  3. package/dist/auto-vue-manual.umd.js +73 -73
  4. package/dist/index.css +1 -1
  5. package/dist/types/components/avatar/BasicAvatar.vue.d.ts +5 -5
  6. package/dist/types/components/button/InlineRefreshButton.vue.d.ts +4 -4
  7. package/dist/types/components/button/ModifyButton.vue.d.ts +3 -3
  8. package/dist/types/components/button/OpenButton.vue.d.ts +4 -4
  9. package/dist/types/components/button/RefreshButton.vue.d.ts +4 -4
  10. package/dist/types/components/button/RequestButton.vue.d.ts +4 -4
  11. package/dist/types/components/button/ResetButton.vue.d.ts +4 -4
  12. package/dist/types/components/button/SearchButton.vue.d.ts +4 -4
  13. package/dist/types/components/card/StatisticCard.vue.d.ts +1 -1
  14. package/dist/types/components/error/404.vue.d.ts +51 -2
  15. package/dist/types/components/form/InputNumber.vue.d.ts +40 -5
  16. package/dist/types/components/index.d.ts +1 -1
  17. package/dist/types/components/loading/loading.d.ts +3 -3
  18. package/dist/types/components/modal/BasicDialog.vue.d.ts +36 -15
  19. package/dist/types/components/modal/BasicDrawer.vue.d.ts +37 -16
  20. package/dist/types/components/modal/FormDialog.vue.d.ts +4 -0
  21. package/dist/types/components/modal/TableDialog.vue.d.ts +2 -0
  22. package/dist/types/components/radio/RadioButton.vue.d.ts +15 -9
  23. package/dist/types/components/switch/IconSwitch.vue.d.ts +11 -5
  24. package/dist/types/components/table/ProTable.vue.d.ts +9 -7
  25. package/dist/types/components/table/ProTableList.vue.d.ts +18 -15
  26. package/dist/types/components/table/ProTableSummary.vue.d.ts +10 -9
  27. package/dist/types/components/table/components/Pagination.vue.d.ts +2 -1
  28. package/dist/types/components/table/components/TableColumnV2.d.ts +13 -2
  29. package/dist/types/components/table/hook/useSelection.d.ts +1 -1
  30. package/dist/types/components/table/utils/table.d.ts +0 -6
  31. package/dist/types/components/text/CopyText.vue.d.ts +5 -6
  32. package/dist/types/components/tinymce/index.vue.d.ts +1 -1
  33. package/dist/types/components/upload/UploadAvatar.d.ts +2 -2
  34. package/dist/types/components/upload/UploadFiles.d.ts +3 -4
  35. package/dist/types/components/upload/UploadImage.d.ts +2 -2
  36. package/dist/types/components/upload/UploadImages.d.ts +3 -4
  37. package/dist/types/components/user-drawer/UserDrawer.vue.d.ts +39 -0
  38. package/dist/types/components/waterMark/index.vue.d.ts +5 -4
  39. package/dist/types/config/api.d.ts +8 -0
  40. package/dist/types/directives/index.d.ts +3 -4
  41. package/dist/types/hooks/chartColors.d.ts +20 -0
  42. package/dist/types/hooks/index.d.ts +1 -1
  43. package/dist/types/hooks/useBarChart.d.ts +8 -3
  44. package/dist/types/hooks/useButtonLoading.d.ts +21 -0
  45. package/dist/types/hooks/useChartBase.d.ts +32 -0
  46. package/dist/types/hooks/useChartOption.d.ts +4 -3
  47. package/dist/types/hooks/useCrudPage.d.ts +7 -1
  48. package/dist/types/hooks/useDialog.d.ts +24 -1
  49. package/dist/types/hooks/useLineChart.d.ts +16 -9
  50. package/dist/types/hooks/useLoading.d.ts +2 -2
  51. package/dist/types/hooks/useRadarChart.d.ts +9 -4
  52. package/dist/types/hooks/useSingleDialog.d.ts +15 -1
  53. package/dist/types/hooks/useSingleFormModal.d.ts +8 -1
  54. package/dist/types/hooks/useTheme.d.ts +4 -3
  55. package/dist/types/i18n/index.d.ts +1 -0
  56. package/dist/types/router/dynamicRouter.d.ts +13 -0
  57. package/dist/types/stores/helper/persist.d.ts +15 -1
  58. package/dist/types/stores/index.d.ts +1 -1
  59. package/dist/types/stores/modules/auth.d.ts +1 -42
  60. package/dist/types/stores/modules/cache.d.ts +8 -0
  61. package/dist/types/stores/modules/keepAlive.d.ts +5 -5
  62. package/dist/types/stores/modules/layout.d.ts +0 -1
  63. package/dist/types/stores/modules/loading.d.ts +17 -0
  64. package/dist/types/stores/modules/tabs.d.ts +7 -7
  65. package/dist/types/types/index.d.ts +0 -1
  66. package/dist/types/types/install.d.ts +1 -1
  67. package/dist/types/types/pinia.d.ts +27 -5
  68. package/dist/types/types/request.d.ts +17 -4
  69. package/dist/types/types/table.d.ts +9 -35
  70. package/dist/types/types/util.d.ts +5 -0
  71. package/dist/types/utils/api.d.ts +15 -4
  72. package/dist/types/utils/browser.d.ts +3 -2
  73. package/dist/types/utils/copy.d.ts +6 -1
  74. package/dist/types/utils/greet.d.ts +0 -4
  75. package/dist/types/utils/install.d.ts +65 -9
  76. package/dist/types/utils/menu.d.ts +2 -0
  77. package/dist/types/utils/message.d.ts +4 -0
  78. package/dist/types/utils/mittBus.d.ts +1 -1
  79. package/dist/types/utils/request.d.ts +18 -2
  80. package/dist/types/utils/time.d.ts +3 -2
  81. package/dist/types/utils/verify.d.ts +2 -2
  82. package/dist/version.js +1 -1
  83. package/package.json +6 -1
  84. package/dist/types/components/form/components/FormItem.vue.d.ts +0 -30
  85. package/dist/types/components/form/index.vue.d.ts +0 -51
  86. package/dist/types/components/onLineCodeEditor/index.d.ts +0 -3
  87. package/dist/types/components/table/utils/copy.d.ts +0 -5
  88. package/dist/types/hooks/useAutoForm.d.ts +0 -13
  89. package/dist/types/layouts/components/Tabs/components/MoreButton.vue.d.ts +0 -3
  90. package/dist/types/types/form.d.ts +0 -18
package/README.md CHANGED
@@ -46,6 +46,27 @@ app.mount('#app');
46
46
  [UploadImage](#uploadimage)
47
47
  [UploadImages](#uploadimages)
48
48
 
49
+ ## Storybook
50
+
51
+ ```bash
52
+ npm run storybook # 本地起 Storybook(http://localhost:6006)
53
+ npm run build-storybook # 产出静态站点到 storybook-static/
54
+ ```
55
+
56
+ - **stories**:`package/**/*.stories.@(js|jsx|mjs|ts|tsx)`(如 `package/components/table/table.stories.tsx`,`title: 'Base/Table'`)
57
+ - **配置**:`.storybook/main.ts` / `.storybook/preview.ts`
58
+
59
+ ### 接口全部走本地 mock(离线可用)
60
+
61
+ stories 不依赖任何外部域名,数据由 `.storybook/mocks/*.json` 提供(`requestBaseUrl` 设为 `/api`)。
62
+
63
+ - `.storybook/mock-api.ts` —— `createMockAdapter()` 查表返回 `{ code: 200, data, message: 'ok', status: 'success' }`;未登记的路径 `console.warn` 并返回 `data: null`。
64
+ - 现有 fixture:`/api/menu/search`(分页,`{ list, total }`)、`/api/menu/list`(非分页,直接数组)、`/api/menu/summaries`(`SumResult[]`)、`/api/menu/change_status`。
65
+ - **新增 fixture**:放 `.storybook/mocks/xxx.json` → 在 `MOCK_FIXTURES` 登记 `'/api/xxx'` → story 里写 `url: '/xxx'`。
66
+ - 个别 story 想临时关掉 mock:在请求 config 里显式传 `adapter`(`mergeConfig` 会优先取请求侧)。
67
+
68
+ > ⚠️ **必须在 axios 实例上装 adapter,不能只改 `axios.defaults`**:`axios.create()` 会把创建那一刻的 `axios.defaults.adapter`(默认 `['xhr','http','fetch']` 数组)快照进实例自己的 defaults;且实例是 `bind(Axios.prototype.request, context)` 出来的绑定副本,事后改原型也拦不住。而 `package/utils/request.ts` 的实例是**模块顶层**创建的,静态构建时还会更早求值 —— 所以 `request.ts` 导出该实例(`export { api }`),`preview.ts` 在模块体里 `installMockAdapter(api)`。机制细节与踩坑记录见 `workbench/docs/manual/components/ProTableList.md` 的「Storybook」一节。
69
+
49
70
  ## Button
50
71
 
51
72
  ### 组件列表
@@ -128,7 +149,7 @@ app.mount('#app');
128
149
 
129
150
  | 属性名 | 类型 | 说明 | 默认值 |
130
151
  | ---------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------- | ------ |
131
- | **type** | `string` | 列类型, index / selection/ radio/ expand/ sort/ icon/ tag/ copy | - |
152
+ | **type** | `string` | 列类型, index / selection / radio / expand / switch / status / tooltip / icon / tag / copy | - |
132
153
  | **prop** | `string` | 列数据字段名 | - |
133
154
  | **label** | `string` | 列标题 | - |
134
155
  | **width** | `number` | 列宽 | - |
@@ -158,9 +179,22 @@ app.mount('#app');
158
179
  | **page-size** | `number` | 列表页大小 | 0 |
159
180
  | **row-h** | `number` | 列表行高 | 0 |
160
181
  | **ext-h** | `number` | 列表额外高度 | 0 |
161
- | **sum-url** | `string` | 汇总接口url,仅 ProTableSummary 有效 | |
162
- | **sum-text** | `string` | 汇总文本,仅 ProTableSummary 有效 | Total |
163
- | **sum-text-format** | `string` | 汇总文本格式,仅 ProTableSummary 有效 | \* |
182
+ | **sum-url** | `string` | 汇总接口 url,仅 `ProTableSummary` 有效 | |
183
+
184
+ > **`sumUrl` 的响应结构(`SumResult[]`)**
185
+ >
186
+ > 汇总接口的响应体固定为 `{ data: SumResult[] }`,元素结构为 `{ index: number; text: string }`:
187
+ >
188
+ > - `index` —— 该汇总值落在**第几列**(对应 `columns` 扁平化后的下标,与 `el-table` 的 `summary-method` 对齐);
189
+ > - `text` —— 该单元格显示的文本。
190
+ >
191
+ > ```json
192
+ > { "data": [{ "index": 0, "text": "合计" }, { "index": 3, "text": "128,900" }] }
193
+ > ```
194
+ >
195
+ > 请求参数为 `{ ...initParam, ...totalParam, page: 1, size: 1 }` —— 即当前查询条件,**不随分页变化**(汇总始终是全量口径)。
196
+ >
197
+ > **刷新时机**:随 `getTableList()` 一起刷新,因此首次加载、`search()`、`reset()`、翻页、改每页条数都会重取;请求失败会走 `requestError` 回调,并**保留上一次的汇总值**(不会闪成空白)。宿主也可通过 ref 主动调用 `getSummaries()` 读取当前汇总结果。
164
198
 
165
199
  #### Event 事件说明
166
200
 
@@ -177,6 +211,7 @@ app.mount('#app');
177
211
  | **@search** | 搜索事件 | `(searchParam?: Record<string, any>) => void` |
178
212
  | **@reset** | 重置事件 | `() => void` |
179
213
  | **@getTableList** | 获取表格数据,不更新搜索参数及分页参数 | `() => void` |
214
+ | **@getSummaries** | 读取当前汇总结果(仅 `ProTableSummary`,返回按列 index 索引的文本数组) | `() => string[]` |
180
215
 
181
216
  #### 示例代码
182
217
 
@@ -222,7 +257,6 @@ app.mount('#app');
222
257
  label: '名称',
223
258
  width: 0,
224
259
  align: 'right',
225
- search: { defaultValue: 'League' },
226
260
  headerRender: ({ column }: HeaderRenderScope<any>) => {
227
261
  return <span>headerRender: {column.label}</span>
228
262
  },
@@ -260,18 +294,22 @@ app.mount('#app');
260
294
  | ----------- | -------- | --------------------------------------------------------------------- | ------ |
261
295
  | **row-key** | `string` | 行数据的 Key,用来优化 Table 的渲染,当表格数据多选时,所指定的 id ) | id |
262
296
 
263
- 其余同 [ProTable](#protable--protablesummary)
297
+ 其余同 [ProTable](#protable--protablesummary),但 **`hasPagination` 不在 `ProTableList` 的契约内**(`ProTableListProps extends Omit<BaseTableProps, 'hasPagination'>`)。
298
+
299
+ > ⚠️ **Breaking change**:`ProTableList` 基于 `el-table-v2` 虚拟滚动,模板中不渲染分页器,取数固定为「一次拉全量」(`useTable` 以非分页模式调用,请求不带 `page` / `size`,响应直接读整个 `data` 而非 `data.list`)。历史上 `hasPagination` 会切换请求形态却画不出分页器,还会白扣 44px 高度,故已从契约中移除 —— 传入该 prop 不再生效(且会作为普通 attribute 透传到根元素)。需要分页请改用 `ProTable` / `ProTableSummary`。
264
300
 
265
301
  #### Event 事件说明
266
302
 
267
- | 事件名 | 说明 | 参数 |
268
- | ----------------- | --------------------------------------------------------------------------------- | ------------------------------------- |
269
- | **@row-click** | 行点击事件,未排除 status / operation 列,需添加 e.stopPropagation() 阻止事件冒泡 | `({ row: any, column: any }) => void` |
270
- | **@row-dblclick** | 行双击事件,未排除 status / operation 列,需添加 e.stopPropagation() 阻止事件冒泡 | `({ row: any, column: any }) => void` |
303
+ | 事件名 | 说明 | 参数 |
304
+ | ----------------- | ------------------------------------------------------------- | -------------------------------------------------------- |
305
+ | **@row-click** | 行点击事件,已排除 status / operation 列(与 `ProTable` 一致) | `({ rowKey, rowData, rowIndex, event }: RowEventHandlerParams) => void` |
306
+ | **@row-dblclick** | 行双击事件,已排除 status / operation 列(与 `ProTable` 一致) | `({ rowKey, rowData, rowIndex, event }: RowEventHandlerParams) => void` |
307
+
308
+ > 与 `ProTable` 的 `(row, column, event)` 不同:`el-table-v2` 的行事件包装器只回传 `{ event, rowData, rowIndex, rowKey }`,**没有 `column`**。因此列过滤由组件内部完成 —— 用 `:cell-props` 给每个单元格打上 `data-column-key`,事件里从 `event.target.closest('[role="cell"]')` 反查(取的是列的 `key`,即 `item.key || item.prop`)。**载荷形状不受影响,宿主代码无需改动。**
271
309
 
272
310
  #### Expose 暴露方法说明
273
311
 
274
- 与 ProTable 相同。
312
+ 与 ProTable 相同(含 `radio` —— `type: 'radio'` 单选列的选中值,与 v1 一样**不 emit**,经 `tableRef.value.radio` 读取)。
275
313
 
276
314
  #### 示例代码
277
315
 
@@ -290,7 +328,7 @@ app.mount('#app');
290
328
  import { ref, reactive } from 'vue'
291
329
 
292
330
  import { Plus } from '@element-plus/icons-vue'
293
- import ProTableList from 'auto-vue-manual'
331
+ import { ProTableList } from 'auto-vue-manual'
294
332
 
295
333
  const proTableRef = ref<InstanceType<typeof ProTableList>>()
296
334
  const columns: ColumnProps[] = [
@@ -371,45 +409,59 @@ app.mount('#app');
371
409
 
372
410
  ### 通用 Props
373
411
 
374
- | 属性名 | 类型 | 说明 | 默认值 |
375
- | ----------------- | ------- | ----------------------- | ------ |
376
- | visible | boolean | 是否显示 | false |
377
- | showClose | boolean | 是否显示关闭按钮 | true |
378
- | title | string | 标题 | Title |
379
- | width | string | 宽度 | 520px |
380
- | top | string | 顶部距离 | 15vh |
381
- | dialogProps | object | 透传 Dialog/Drawer 属性 | {} |
382
- | appendToBody | boolean | 是否插入 body | true |
383
- | lockScroll | boolean | 是否锁定滚动 | true |
384
- | closeOnClickModal | boolean | 点击遮罩关闭 | false |
412
+ | 属性名 | 类型 | 说明 | 默认值 |
413
+ | ----------------- | ------- | --------------------------------------------- | ---------------------- |
414
+ | modelValue | boolean | 是否显示(配合 `v-model`) | false |
415
+ | showClose | boolean | 是否显示关闭按钮 | true |
416
+ | title | string | 标题(i18n key,经 `Translate()` 翻译) | '' |
417
+ | width | string | Dialog 宽度;Drawer 映射到 `el-drawer` 的 size | 520px |
418
+ | top | string | 顶部距离(**仅 Dialog**) | 15vh |
419
+ | center | boolean | 头部/底部居中(**仅 Dialog**) | true |
420
+ | divider | boolean | 正文顶部是否渲染 `el-divider` | Dialog `true` / Drawer `false` |
421
+ | appendToBody | boolean | 是否插入 body | true |
422
+ | lockScroll | boolean | 是否锁定滚动 | true |
423
+ | closeOnClickModal | boolean | 点击遮罩关闭 | false |
424
+
425
+ > 除上表外的 Element Plus Dialog / Drawer 原生属性(`fullscreen`、`draggable`、`headerClass`、`beforeClose` 等)均通过 `v-bind` 直接透传。
426
+
427
+ ### 通用事件
428
+
429
+ | 事件名 | 说明 |
430
+ | ----------------- | -------------------------------------------------------- |
431
+ | update:modelValue | `v-model` 回写 |
432
+ | close | 关闭动画**开始**时触发(对应 Element Plus 的 `close`) |
433
+ | closed | 关闭动画**结束**时触发(对应 Element Plus 的 `closed`) |
385
434
 
386
435
  ### BasicDialog
387
436
 
388
437
  - 通用弹窗基类,支持所有通用 props 和事件。
389
- - 事件:`@update:visible`、`@closed`、`@submit`
438
+ - 事件:`update:modelValue`、`close`、`closed`
439
+ - 暴露(`defineExpose`):`close()`、`dialogRef`(内部 `el-dialog` 实例)
390
440
 
391
441
  ### BasicDrawer
392
442
 
393
- - 通用抽屉基类,支持所有通用 props 和事件。
394
- - 事件:`@update:visible`、`@closed`
443
+ - 通用抽屉基类,支持所有通用 props 和事件(无 `top` / `center`)。
444
+ - 事件:`update:modelValue`、`close`、`closed`
445
+ - 暴露(`defineExpose`):`close()`、`drawerRef`(内部 `el-drawer` 实例)
395
446
 
396
447
  ### FormDialog
397
448
 
398
449
  - 基于 BasicDialog 扩展,内置底部按钮,适合表单场景。
399
- - 额外 props:`executing`(是否执行中)、`footer`(是否显示底部)、`btnSize`、`okText`、`cancelText`
400
- - 事件:`@submit`、`@closed`、`@before-close`
450
+ - 额外 props:`executing`(是否执行中)、`btnSize`、`okText`、`okType`、`cancelText`、`cancelType`
451
+ - 事件:`update:modelValue`、`close`、`closed`、`submit`
401
452
 
402
453
  ### TableDialog
403
454
 
404
455
  - 基于 BasicDialog 扩展,适合表格弹窗场景。
405
456
  - 额外 props:`requesting`(是否请求中)
457
+ - 事件:`update:modelValue`、`close`、`closed`
406
458
 
407
459
  ### 示例代码
408
460
 
409
461
  ```vue
410
462
  <template>
411
463
  <OpenButton @open="visible = true" />
412
- <BasicDialog :visible="visible" title="标题" width="520px" @update:visible="visible = $event" @closed="onClosed">
464
+ <BasicDialog v-model="visible" title="base.confirm" width="520px" @closed="onClosed">
413
465
  <template #default>内容区域</template>
414
466
  </BasicDialog>
415
467
  </template>
@@ -418,7 +470,7 @@ app.mount('#app');
418
470
  import { BasicDialog, OpenButton } from 'auto-vue-manual'
419
471
  const visible = ref(false)
420
472
  const onClosed = () => {
421
- visible.value = false
473
+ /* 关闭动画结束后 */
422
474
  }
423
475
  </script>
424
476
  ```
@@ -428,7 +480,7 @@ app.mount('#app');
428
480
  ```vue
429
481
  <template>
430
482
  <OpenButton @open="visible = true" />
431
- <FormDialog :visible="visible" title="表单弹窗" @update:visible="visible = $event" @submit="onSubmit">
483
+ <FormDialog v-model="visible" title="base.confirm" @submit="onSubmit">
432
484
  <template #default>
433
485
  <el-input v-model="form.name" placeholder="请输入名称" />
434
486
  </template>
@@ -457,7 +509,7 @@ app.mount('#app');
457
509
  | **avatar** | `string` | 头像地址 | - |
458
510
  | **text** | `string` | 上传提示 | - |
459
511
  | **path** | `string` | 保存路径 | - |
460
- | **preview** | `boolean` | 是否显示预览 | false |
512
+ | **preview** | `boolean` | 是否显示预览 | true |
461
513
  | **disabled** | `boolean` | 是否禁用 | false |
462
514
  | **size** | `number` | 大小(KB) | 5120 |
463
515