@zl-ui-kit/components 0.5.1 → 0.6.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 (75) hide show
  1. package/README.md +3031 -148
  2. package/dist/components/ZlAction/types.d.ts +7 -0
  3. package/dist/components/ZlAddSub/index.css +1 -1
  4. package/dist/components/ZlAddSub/index.vue.mjs +1 -1
  5. package/dist/components/ZlAutoTooltip/index.css +1 -1
  6. package/dist/components/ZlAutoTooltip/index.vue.mjs +1 -1
  7. package/dist/components/ZlAutoTooltip/index2.vue.mjs +7 -3
  8. package/dist/components/ZlAvatar/Group.css +1 -1
  9. package/dist/components/ZlAvatar/Group.vue.mjs +2 -2
  10. package/dist/components/ZlAvatar/index.css +1 -1
  11. package/dist/components/ZlAvatar/index.vue.mjs +2 -2
  12. package/dist/components/ZlCardPage/index.vue.d.ts +6 -12
  13. package/dist/components/ZlCardPage/index.vue.mjs +24 -10
  14. package/dist/components/ZlChart/index.vue.mjs +11 -5
  15. package/dist/components/ZlCheckAll/index.css +1 -1
  16. package/dist/components/ZlCheckAll/index.vue.mjs +2 -2
  17. package/dist/components/ZlCheckboxTag/index.vue.mjs +1 -2
  18. package/dist/components/ZlCopy/index.css +1 -1
  19. package/dist/components/ZlCopy/index.vue.mjs +2 -2
  20. package/dist/components/ZlDictTag/index.vue.mjs +10 -6
  21. package/dist/components/ZlDynamicComponent/index.vue.mjs +1 -2
  22. package/dist/components/ZlEditor/ZlSqlEditor.vue.mjs +13 -8
  23. package/dist/components/ZlEditor/index.vue.mjs +28 -19
  24. package/dist/components/ZlEmpty/index.css +1 -1
  25. package/dist/components/ZlEmpty/index.vue.mjs +2 -2
  26. package/dist/components/ZlFileViewer/index.css +1 -1
  27. package/dist/components/ZlFileViewer/index.vue.mjs +2 -2
  28. package/dist/components/ZlForm/index.vue.mjs +15 -12
  29. package/dist/components/ZlGrid/index.vue.mjs +1 -2
  30. package/dist/components/ZlGrid/types.d.ts +5 -0
  31. package/dist/components/ZlHorizontalTable/index.css +1 -1
  32. package/dist/components/ZlHorizontalTable/index.vue.mjs +1 -1
  33. package/dist/components/ZlLayoutSwitch/index.css +1 -1
  34. package/dist/components/ZlLayoutSwitch/index.vue.mjs +2 -2
  35. package/dist/components/ZlLogin/components/LoginForm.css +1 -1
  36. package/dist/components/ZlLogin/components/LoginForm.vue.mjs +2 -2
  37. package/dist/components/ZlLogin/components/LoginForm2.vue.mjs +4 -3
  38. package/dist/components/ZlLogin/components/SlideChecker.css +1 -1
  39. package/dist/components/ZlLogin/components/SlideChecker.vue.mjs +2 -2
  40. package/dist/components/ZlLogin/components/SlideChecker2.vue.mjs +2 -8
  41. package/dist/components/ZlLogin/index.vue.mjs +2 -3
  42. package/dist/components/ZlPagination/index.css +1 -1
  43. package/dist/components/ZlPagination/index.vue.mjs +1 -1
  44. package/dist/components/ZlPagination/index2.vue.mjs +17 -8
  45. package/dist/components/ZlPermission/usePermission.mjs +9 -5
  46. package/dist/components/ZlSearch/index.css +1 -1
  47. package/dist/components/ZlSearch/index.vue.d.ts +9 -3
  48. package/dist/components/ZlSearch/index.vue.mjs +129 -114
  49. package/dist/components/ZlSearch/useSearchFormOverflow.d.ts +17 -0
  50. package/dist/components/ZlSearch/useSearchFormOverflow.mjs +50 -0
  51. package/dist/components/ZlSearchTable/index.vue.d.ts +6 -12
  52. package/dist/components/ZlSearchTable/index.vue.mjs +28 -17
  53. package/dist/components/ZlSorter/ZlSorterList.css +1 -1
  54. package/dist/components/ZlSorter/ZlSorterList.vue.mjs +2 -2
  55. package/dist/components/ZlSorter/index.css +1 -1
  56. package/dist/components/ZlSorter/index.vue.mjs +2 -2
  57. package/dist/components/ZlTable/index.vue.mjs +14 -8
  58. package/dist/components/ZlTable/useTablePagination.mjs +16 -10
  59. package/dist/components/ZlTabs/index.vue.d.ts +4 -0
  60. package/dist/components/ZlTabs/index.vue.mjs +31 -19
  61. package/dist/components/ZlText/index.css +1 -1
  62. package/dist/components/ZlText/index.vue.mjs +1 -1
  63. package/dist/components/ZlTitle/index.css +1 -1
  64. package/dist/components/ZlTitle/index.vue.mjs +2 -2
  65. package/dist/components/ZlTree/index.vue.mjs +13 -8
  66. package/dist/components/ZlTreeSelect/index.css +1 -1
  67. package/dist/components/ZlTreeSelect/index.vue.mjs +1 -1
  68. package/dist/components/ZlUpload/index.css +1 -1
  69. package/dist/components/ZlUpload/index.vue.mjs +2 -2
  70. package/dist/index.d.ts +1 -1
  71. package/dist/locales/en.mjs +2 -0
  72. package/dist/locales/messages.mjs +2 -2
  73. package/dist/locales/zh-cn.mjs +2 -0
  74. package/dist/types.d.ts +8 -0
  75. package/package.json +7 -7
package/README.md CHANGED
@@ -12,13 +12,13 @@ ZL UI 业务组件库 —— Element Plus 体系,`Zl` 前缀,47 个业务组
12
12
 
13
13
  `zl-ui` 是一套基于 **Element Plus(EP)** 的企业级 Vue 3 组件库,以 EP 为底座,封装了 47 个 `Zl` 前缀业务组件,并提供请求、主题、图标、工具四套配套能力。
14
14
 
15
- | 包 | 职责 |
16
- | --- | --- |
17
- | [`@zl-ui-kit/components`](https://www.npmjs.com/package/@zl-ui-kit/components) | EP 化业务组件库(`Zl` 前缀,47 个组件) |
15
+ | 包 | 职责 |
16
+ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
17
+ | [`@zl-ui-kit/components`](https://www.npmjs.com/package/@zl-ui-kit/components) | EP 化业务组件库(`Zl` 前缀,47 个组件) |
18
18
  | [`@zl-ui-kit/composables`](https://www.npmjs.com/package/@zl-ui-kit/composables) | `useRequest` 请求体系、`useDict`、`useGlobalData` 全局数据、国际化 |
19
- | [`@zl-ui-kit/icons`](https://www.npmjs.com/package/@zl-ui-kit/icons) | 444 个离线 SVG 图标(prefix `zl`,开源图标库) |
20
- | [`@zl-ui-kit/theme`](https://www.npmjs.com/package/@zl-ui-kit/theme) | 5 套主题 + `defineTheme` 运行时定制(内置 OFL 开源中文字体) |
21
- | [`@zl-ui-kit/utils`](https://www.npmjs.com/package/@zl-ui-kit/utils) | TS 工具函数库 + Axios 请求封装 |
19
+ | [`@zl-ui-kit/icons`](https://www.npmjs.com/package/@zl-ui-kit/icons) | 444 个离线 SVG 图标(prefix `zl`,开源图标库) |
20
+ | [`@zl-ui-kit/theme`](https://www.npmjs.com/package/@zl-ui-kit/theme) | 5 套主题 + `defineTheme` 运行时定制(内置 OFL 开源中文字体) |
21
+ | [`@zl-ui-kit/utils`](https://www.npmjs.com/package/@zl-ui-kit/utils) | TS 工具函数库 + Axios 请求封装 |
22
22
 
23
23
  **三个关键约定(使用组件前必读)**
24
24
 
@@ -41,11 +41,11 @@ npm i vue element-plus @vueuse/core
41
41
 
42
42
  以下组件**不在主入口**,走独立子路径,依赖按需安装(`peerDependenciesMeta.optional`,没装也不会导致主入口编译失败):
43
43
 
44
- | 子入口 | 组件 | 需安装 |
45
- | --- | --- | --- |
46
- | `@zl-ui-kit/components/chart` | `ZlChart` | `echarts` |
47
- | `@zl-ui-kit/components/editor` | `ZlEditor` / `ZlSqlEditor` / `useSqlCompletion` | `monaco-editor` |
48
- | `@zl-ui-kit/components/file-preview` | `ZlFilePreview` / `ZlFileViewer` | `@vue-office/docx` `@vue-office/excel` `@vue-office/pdf` `@vue-office/pptx` |
44
+ | 子入口 | 组件 | 需安装 |
45
+ | ------------------------------------ | ----------------------------------------------- | --------------------------------------------------------------------------- |
46
+ | `@zl-ui-kit/components/chart` | `ZlChart` | `echarts` |
47
+ | `@zl-ui-kit/components/editor` | `ZlEditor` / `ZlSqlEditor` / `useSqlCompletion` | `monaco-editor` |
48
+ | `@zl-ui-kit/components/file-preview` | `ZlFilePreview` / `ZlFileViewer` | `@vue-office/docx` `@vue-office/excel` `@vue-office/pdf` `@vue-office/pptx` |
49
49
 
50
50
  ```ts
51
51
  import { ZlChart } from '@zl-ui-kit/components/chart'
@@ -71,7 +71,7 @@ import { ZlFilePreview, ZlFileViewer } from '@zl-ui-kit/components/file-preview'
71
71
  import { createApp } from 'vue'
72
72
  import ElementPlus from 'element-plus'
73
73
  import 'element-plus/dist/index.css'
74
- import '@zl-ui-kit/theme/themes.css' // 主题变量(--zl-* / --el-*)
74
+ import '@zl-ui-kit/theme/themes.css' // 主题变量(--zl-* / --el-*)
75
75
  import ZlUI from '@zl-ui-kit/components'
76
76
 
77
77
  createApp(App).use(ElementPlus).use(ZlUI).mount('#app')
@@ -141,41 +141,60 @@ pnpm --filter @zl-ui-kit/playground dev # http://localhost:3100
141
141
 
142
142
  playground 以 **源码模式** 运行,vite alias 将 `@zl-ui-kit/*` 五包精确指向各自 `src/`:
143
143
 
144
- | 别名 | 指向 |
145
- | --- | --- |
146
- | `@zl-ui-kit/utils` | `packages/utils/src/index.ts` |
147
- | `@zl-ui-kit/composables` | `packages/composables/src/index.ts` |
148
- | `@zl-ui-kit/components` | `packages/components/src/index.ts` |
149
- | `@zl-ui-kit/theme`(JS API) | `packages/theme/src/index.ts` |
150
- | `@zl-ui-kit/icons` | `packages/icons/src/index.mjs` |
144
+ | 别名 | 指向 |
145
+ | ---------------------------- | ----------------------------------- |
146
+ | `@zl-ui-kit/utils` | `packages/utils/src/index.ts` |
147
+ | `@zl-ui-kit/composables` | `packages/composables/src/index.ts` |
148
+ | `@zl-ui-kit/components` | `packages/components/src/index.ts` |
149
+ | `@zl-ui-kit/theme`(JS API) | `packages/theme/src/index.ts` |
150
+ | `@zl-ui-kit/icons` | `packages/icons/src/index.mjs` |
151
151
 
152
152
  **效果:直接改任意包的 `src` 源码,playground 即时热更,无需先构建。**
153
153
 
154
+ playground 的界面按 **Element Plus 官网的信息架构**组织(顶栏 + 左侧分组目录 + 右侧内容):
155
+
156
+ | 位置 | 内容 |
157
+ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
158
+ | 顶栏 | Logo、一级导航(组件/主题/图标/示例/手册)、组件搜索(`Ctrl K` 聚焦,↑↓ 选择、Enter 跳转)、语言与主题切换 |
159
+ | 左侧栏 | 「指南」「综合示例」+ 按功能分 7 组(基础/布局/表单/数据展示/反馈/文件与编辑器/其他)的全部组件,分组可折叠 |
160
+ | 组件总览 | `/#/`,每个组件一张卡片(图标 + 中文名 + 导出符号),点击进入组件页 |
161
+ | 组件页 | `/#/component/ZlTable`,依次是「基础用法」实时示例 → 用法示例 / 插槽用法代码块 → props/事件/插槽/暴露方法表(props 与插槽表各带一列「示例」) |
162
+ | 接口手册 | `/#/manual`,跨组件检索(按 props 名 / 事件名反查组件),支持 `?name=ZlTable` 直接定位 |
163
+
164
+ > 组件页的示例来自 `apps/playground/src/pages/gallery-demos.ts`(与冒烟测试同一份渲染函数),
165
+ > 接口表来自 `pnpm docs:api` 产物 —— 与本文件第 14 章同源:改完组件源码记得重跑,否则 `pnpm check` 会报产物过期。
166
+ > 两处的 **用法示例 / 插槽用法** 代码块也是同一份字符串,页面里可一键复制;
167
+ > 每个 prop / 插槽的「示例」列同样是同一份字符串(可直接粘贴的属性写法 / `<template #name>` 片段)。
168
+
154
169
  > 注意:`@zl-ui-kit/theme/light`、`@zl-ui-kit/theme/themes.css` 等 CSS 子路径不走别名,读取 `src/generated/` 生成物——改主题 token 后需先 `pnpm --filter @zl-ui-kit/theme gen`。
155
170
 
156
171
  ### 2.3 主题快速接入(宿主项目)
157
172
 
158
173
  ```ts
159
174
  // main.ts
160
- import '@zl-ui-kit/theme/themes.css' // 全部内置主题(或按需 '@zl-ui-kit/theme/light' 等)
175
+ import '@zl-ui-kit/theme/themes.css' // 全部内置主题(或按需 '@zl-ui-kit/theme/light' 等)
161
176
  import { setTheme } from '@zl-ui-kit/theme'
162
177
 
163
- setTheme('dark') // 切换主题(light/dark/red-light/red-dark/blue)
178
+ setTheme('dark') // 切换主题(light/dark/red-light/red-dark/blue)
164
179
  ```
165
180
 
166
181
  ### 2.4 示例页面索引
167
182
 
168
- | 路由 | 页面 | 覆盖内容 |
169
- | --- | --- | --- |
170
- | `/` | 首页 | 说明与导航 |
171
- | `/icons` | 图标集 | 全量图标浏览/搜索,`zl:` 前缀渲染 |
172
- | `/theme` | 主题工场 | 5 套主题切换 + `defineTheme` 运行时自定义 |
173
- | `/components` | 组件示例 | ZlTitle/ZlTag/ZlCornerTag/ZlIcon/ZlText/ZlCopy/ZlAutoTooltip/ZlPagination/ZlEmpty |
174
- | `/table-form` | 表格/表单示例 | ZlTable/ZlSearchTable/ZlForm/ZlDrawer/ZlPopconfirm/ZlSwitch/ZlDescription/ZlAction/ZlIconLabel/ZlIconHover/ZlSearch |
175
- | `/general` | 通用/布局示例 | ZlAvatar/ZlCheckAll/ZlRadioTag/ZlCheckboxTag/ZlAddSub/ZlSorter/ZlLayoutSwitch/ZlSection/ZlCard/ZlAppSlogan/ZlPermission/ZlHorizontalTable/ZlUpload/ZlTabs/ZlGrid/ZlDynamicComponent/ZlCardPage |
176
- | `/use-request` | useRequest 联调 | 用 Mock 模块驱动各数据型组件(见第 6 章) |
177
- | `/search-table` | ZlSearchTable 专项 | 基础用法 / `{ service, options }` 用法 / 暴露方法 / 无查询项 immediate,含分页与查询验证 |
178
- | `/gallery` | 组件陈列 | 55 个组件逐个渲染(用于批量截图与冒烟) |
183
+ | 路由 | 页面 | 覆盖内容 |
184
+ | ------------------------ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
185
+ | `/` | 组件总览 | 按功能分组的组件卡片,点击进入组件页(Element Plus 官网 overview 的组织方式) |
186
+ | `/component/:name` | 组件页 | 基础用法实时示例 + 用法示例 / 插槽用法代码块 + props / 事件 / 插槽 / 暴露方法表 + 上/下一页 |
187
+ | `/manual` | 接口手册 | 全量 API 检索,支持按 props 名 / 事件名反查组件,`?name=ZlTable` 直接定位 |
188
+ | `/icons` | 图标集 | 全量图标浏览/搜索,`zl:` 前缀渲染 |
189
+ | `/theme` | 主题工场 | 5 套主题切换 + `defineTheme` 运行时自定义 |
190
+ | `/gallery` | 组件陈列 | 55 个组件逐个渲染(用于批量截图与冒烟) |
191
+ | `/use-request` | useRequest 联调 | 用 Mock 模块驱动各数据型组件(见第 6 章) |
192
+ | `/examples/basic` | 通用展示示例 | ZlTitle/ZlTag/ZlCornerTag/ZlIcon/ZlText/ZlCopy/ZlAutoTooltip/ZlPagination/ZlEmpty |
193
+ | `/examples/table-form` | 表格/表单示例 | ZlTable/ZlSearchTable/ZlForm/ZlDrawer/ZlPopconfirm/ZlSwitch/ZlDescription/ZlAction/ZlIconLabel/ZlIconHover/ZlSearch |
194
+ | `/examples/general` | 布局与交互示例 | ZlAvatar/ZlCheckAll/ZlRadioTag/ZlCheckboxTag/ZlAddSub/ZlSorter/ZlLayoutSwitch/ZlSection/ZlCard/ZlAppSlogan/ZlPermission/ZlHorizontalTable/ZlUpload/ZlTabs/ZlGrid/ZlDynamicComponent/ZlCardPage |
195
+ | `/examples/search-table` | ZlSearchTable 专项 | 基础用法 / `{ service, options }` 用法 / 暴露方法 / 无查询项 immediate,含分页与查询验证 |
196
+
197
+ > 改造前的扁平路由(`/components`、`/general`、`/table-form`、`/search-table`)保留 **redirect**,历史链接与自动化脚本不会失效。
179
198
 
180
199
  ---
181
200
 
@@ -183,24 +202,32 @@ setTheme('dark') // 切换主题(light/dark/red-light/red-dark/b
183
202
 
184
203
  > 下面按功能分组,列出的是**导出符号**(含同目录变体,如 `ZlCornerTag` / `ZlIconHover` / `ZlActionList`),所以条目数略多于 47;组件目录共 48 个(47 个业务组件 + `ZlI18nProvider`)。
185
204
 
205
+ > **要查精确的 props / 事件 / 插槽 / 暴露方法 / schema 类型?** 直接看 **[§14 组件 API 参考](#14-组件-api-参考自动生成)**——逐个组件给出 `import`、可直接照抄的 **用法示例**(props 怎么写)与 **插槽用法**(`<template #name>` 怎么写),再用表格列出 TS 类型表达式、默认值、是否必填,**且每个 prop / 每个插槽都带一列「示例」**(能直接粘到标签上的写法),以及 `TableColumn` / `FormItem` / `SearchItem` / `ActionItem` 等 schema 类型的字段表。本章及 §4~§9 讲的是**场景化用法**,§14 是**逐字段的契约 + 可粘贴代码**。
206
+
186
207
  ### 3.1 通用展示组件
208
+
187
209
  `ZlIcon` · `ZlTitle` · `ZlTag` · `ZlCornerTag` · `ZlText` · `ZlCopy` · `ZlAutoTooltip` · `ZlEmpty` · `ZlDictTag` · `ZlDescription` · `ZlSection` · `ZlCard` · `ZlAvatar` · `ZlAppSlogan` · `ZlIconLabel` · `ZlIconHover`
188
210
 
189
211
  ### 3.2 数据型组件
212
+
190
213
  `ZlTable` · `ZlSearchTable` · `ZlCardPage` · `ZlPagination` · `ZlTree` · `ZlTreeSelect` · `ZlChart` · `ZlUpload`
191
214
 
192
215
  ### 3.3 表单与交互组件
216
+
193
217
  `ZlForm` · `ZlSearch` · `ZlDrawer` · `ZlPopconfirm` · `ZlSwitch` · `ZlAction` · `ZlActionList` · `ZlRadioTag` · `ZlCheckboxTag` · `ZlCheckAll` · `ZlSorter` · `ZlAddSub` · `ZlLayoutSwitch` · `ZlTabs` · `ZlDynamicComponent` · `ZlGrid`
194
218
 
195
219
  ### 3.4 布局与权限
220
+
196
221
  `ZlAppLayout` · `ZlAppMenu` · `ZlPermission` · `ZlHorizontalTable`
197
222
 
198
223
  ### 3.5 文件与编辑
224
+
199
225
  `ZlFilePreview` · `ZlFileViewer` · `ZlPdfViewer` · `ZlEditor` · `ZlSqlEditor` · `ZlLogin`
200
226
 
201
227
  > 页签/微前端类组件(`ZlMicroPage`/`ZlAppTabs`/`ZlPageTabs`/`ZlDevMenu`)与配套 composables(`usePageTabs` 等)均已移除,`0.5.0` 起组件库不含任何微前端能力。
202
228
 
203
229
  ### 3.6 国际化基础设施(独立于 47 个业务组件)
230
+
204
231
  `ZlI18nProvider` —— 国际化根容器,将 Element Plus 语言包经 `<el-config-provider>` 挂载到 Element Plus(详见第 13 章)。
205
232
 
206
233
  ---
@@ -214,11 +241,33 @@ setTheme('dark') // 切换主题(light/dark/red-light/red-dark/b
214
241
  <ZlIcon icon="zl:database-color" :size="20" />
215
242
  ```
216
243
 
217
- | prop | 说明 |
218
- | --- | --- |
219
- | `icon` | 图标名,支持 `zl:xxx`(内置)、`https://...`(外链)、普通名(iconify 在线集,需联网) |
220
- | `size` | 字号/尺寸,默认 `14px` |
221
- | `color` / `spin` 等 | 透传至底层 iconify-icon |
244
+ | prop | 说明 |
245
+ | ------------------- | -------------------------------------------------------------------------------------- |
246
+ | `icon` | 图标名,支持 `zl:xxx`(内置)、`https://...`(外链)、普通名(iconify 在线集,需联网) |
247
+ | `size` | 字号/尺寸,默认 `14px` |
248
+ | `color` / `spin` 等 | 透传至底层 iconify-icon |
249
+
250
+ ### 4.1 必须先注册图标集(否则一个图标都不显示)
251
+
252
+ `ZlIcon` 走 `@iconify/vue/offline`,**库不会自动把 444 个图标塞进打包结果**(否则不用图标的宿主也会白扛 ~150KB)。
253
+ 消费方需要在应用启动时把内置图标集注册进 offline 集合,只需一次:
254
+
255
+ ```ts
256
+ // main.ts(或你的 kit 接入入口)
257
+ import { presetIconifyIcon } from '@zl-ui-kit/components'
258
+ import { icons } from '@zl-ui-kit/icons'
259
+
260
+ presetIconifyIcon(icons)
261
+ ```
262
+
263
+ > **漏掉这一步的表现**:`ZlIcon` 只渲染出一个空的 `<div class="zl-icon">`,不报错、不告警,
264
+ > 组件内部(查询条的「查询/重置/展开」按钮、表单 label 后的问号、空态插画等)的图标同样全部空白——
265
+ > 排查时容易误判成图标名写错或样式问题。
266
+ >
267
+ > `@zl-ui-kit/icons` 需要作为**直接依赖**安装(`pnpm add @zl-ui-kit/icons`),不要依赖它被 `components` 间接带进 `node_modules`:
268
+ > 幽灵依赖在提升规则变化或切换包管理器后会直接解析失败。
269
+
270
+ `presetIconifyIcon(...collections)` 接受多个集合,可叠加自建图标:`presetIconifyIcon(icons, myIcons)`。
222
271
 
223
272
  > 图标名须真实存在于 `packages/icons/src/icons.json`,否则不显示。可用 `Object.keys(require('@zl-ui-kit/icons').icons).includes('database-color')` 校验。
224
273
 
@@ -227,52 +276,69 @@ setTheme('dark') // 切换主题(light/dark/red-light/red-dark/b
227
276
  ## 5. 通用展示组件
228
277
 
229
278
  ### ZlTitle — 区块标题
279
+
230
280
  ```vue
231
281
  <ZlTitle size="medium" text="资源列表" />
232
282
  ```
283
+
233
284
  `size`: `small`(12px) / `medium`(14px) / `large`;自带左侧竖条与可选图标(`zl:help-color`)。
234
285
 
235
286
  ### ZlTag — 标签
287
+
236
288
  ```vue
237
289
  <ZlTag type="primary" :closable="true" icon="zl:star-color">标签</ZlTag>
238
290
  ```
239
- | prop | 取值 |
240
- | --- | --- |
241
- | `type` | `primary` / `success` / `warning` / `info` / `danger` |
242
- | `size` | `mini` / `small` / `medium` |
243
- | `color` | 自定义色(覆盖 type) |
244
- | `icon` / `iconColor` | 前置图标 |
245
- | `closable` / `rounded` | 可关闭 / 圆角 |
291
+
292
+ | prop | 取值 |
293
+ | ---------------------- | ----------------------------------------------------- |
294
+ | `type` | `primary` / `success` / `warning` / `info` / `danger` |
295
+ | `size` | `mini` / `small` / `medium` |
296
+ | `color` | 自定义色(覆盖 type) |
297
+ | `icon` / `iconColor` | 前置图标 |
298
+ | `closable` / `rounded` | 可关闭 / 圆角 |
246
299
 
247
300
  `ZlCornerTag` 为四角定位标签,语义一致、定位展开为显式四类。
248
301
 
249
302
  ### ZlCopy — 一键复制
303
+
250
304
  ```vue
251
305
  <ZlCopy :text="row.id" />
252
306
  ```
307
+
253
308
  `text`(或插槽文本)经 `copy()` 写入剪贴板,按钮 `size="small" text`。
254
309
 
255
310
  ### ZlEmpty — 空状态
311
+
256
312
  ```vue
257
313
  <ZlEmpty description="暂无数据" />
258
- <ZlEmpty :image="customImg" /> <!-- 传入自定义图,缺省为内置轻量 SVG 线稿 -->
314
+ <ZlEmpty :image="customImg" />
315
+ <!-- 传入自定义图,缺省为内置轻量 SVG 线稿 -->
259
316
  ```
260
317
 
261
318
  ### ZlDictTag — 字典标签
319
+
262
320
  经 `useDict(dictKey)` 解析独立字典 store(`useDictStore`,Vue3 状态管理缓存,不依赖全局数据)。**支持三种数据注入方式**(详见第 12.1.3 节与第 6.3 节 ⑤):
263
321
 
264
322
  ```vue
265
323
  <!-- 1. 组件级直传(最轻量,无需任何全局配置即可翻译) -->
266
- <ZlDictTag dict-key="resourceType" :value="row.type"
267
- :dict="[{ label: '图片', value: '1', icon: 'zl:image' }, { label: '视频', value: '2' }]" />
324
+ <ZlDictTag
325
+ dict-key="resourceType"
326
+ :value="row.type"
327
+ :dict="[
328
+ { label: '图片', value: '1', icon: 'zl:image' },
329
+ { label: '视频', value: '2' },
330
+ ]"
331
+ />
268
332
 
269
333
  <!-- 2. 全局/局部数据源(应用入口注册一次,全项目共享) -->
270
334
  <ZlDictTag dict-key="resourceType" :value="row.type" />
271
335
  <ZlDictTag dict-key="resourceType" :value="row.type" simple />
272
336
  ```
337
+
273
338
  详见第 6.3 节 ⑤。
274
339
 
275
340
  ### 其余
341
+
276
342
  `ZlText`(文本省略)、`ZlAutoTooltip`(超长省略 + tooltip)、`ZlDescription`(描述列表)、`ZlSection`(分区容器)、`ZlCard`(卡片,背景图已改为纯 CSS)、`ZlAvatar`(+Group)、`ZlAppSlogan`(品牌标语,字体走 `--zl-slogan-font-family`)、`ZlIconLabel`/`ZlIconHover`(图标 + 文字组合)。
277
343
 
278
344
  ---
@@ -286,30 +352,36 @@ setTheme('dark') // 切换主题(light/dark/red-light/red-dark/b
286
352
  来源:`@zl-ui-kit/composables`。`service` 统一签名:`(...args) => Promise<R>`。
287
353
 
288
354
  #### `useRequest(service, options?, plugins?)` —— 基础形态
355
+
289
356
  ```ts
290
- const { loading, data, error, status, run, runAsync, refresh, refreshAsync, cancel, mutate } =
291
- useRequest(service, { manual: false, defaultParams: [], initialData, onSuccess, onError })
292
- ```
293
- | 返回/选项 | 说明 |
294
- | --- | --- |
295
- | `loading` / `data` / `error` / `status` | 响应式状态(`status`: `''`/`pending`/`finished`/`error`) |
296
- | `run(...args)` | 同步触发,错误被吞(除非传 `onError`) |
297
- | `runAsync(...args)` | 返回 Promise,可 await 捕获 |
298
- | `refresh()` / `refreshAsync()` | 用上次参数重跑 |
299
- | `cancel()` | 取消进行中请求(结果丢弃) |
300
- | `mutate(data | prev => R)` | 本地立即改 `data`,不触网 |
301
- | `options.manual` | `true` 时不自动执行 |
302
- | `options.defaultParams` / `initialData` | 首参 / 初始占位 |
303
- | `options.onBefore/onSuccess/onError/onFinally` | 生命周期回调 |
304
- | `options.loadingDelay` / `refreshDeps` | 延迟 loading / 依赖变更刷新 |
357
+ const { loading, data, error, status, run, runAsync, refresh, refreshAsync, cancel, mutate } = useRequest(
358
+ service,
359
+ { manual: false, defaultParams: [], initialData, onSuccess, onError },
360
+ )
361
+ ```
362
+
363
+ | 返回/选项 | 说明 |
364
+ | ---------------------------------------------- | --------------------------------------------------------- |
365
+ | `loading` / `data` / `error` / `status` | 响应式状态(`status`: `''`/`pending`/`finished`/`error`) |
366
+ | `run(...args)` | 同步触发,错误被吞(除非传 `onError`) |
367
+ | `runAsync(...args)` | 返回 Promise,可 await 捕获 |
368
+ | `refresh()` / `refreshAsync()` | 用上次参数重跑 |
369
+ | `cancel()` | 取消进行中请求(结果丢弃) |
370
+ | `mutate(data \| prev => R)` | 本地立即改 `data`,不触网 |
371
+ | `options.manual` | `true` 时不自动执行 |
372
+ | `options.defaultParams` / `initialData` | 首参 / 初始占位 |
373
+ | `options.onBefore/onSuccess/onError/onFinally` | 生命周期回调 |
374
+ | `options.loadingDelay` / `refreshDeps` | 延迟 loading / 依赖变更刷新 |
305
375
 
306
376
  #### `useDataRequest(service, { dataKey = 'data' })` —— 自动解包信封
377
+
307
378
  ```ts
308
379
  const { data } = useDataRequest(getChartDataApi, { dataKey: 'data' })
309
380
  // data.value === 响应里的 data 字段
310
381
  ```
311
382
 
312
383
  #### `usePaginationRequest(service, { pagination })` —— 分页专用
384
+
313
385
  额外返回 `data`(行数组) / `total` / `current` / `pageSize` / `changeCurrent` / `changePageSize` / `changePagination`,分页键名(`pageNum/pageSize/total/rows`)可配置,与后端契约对齐时通过 `pagination` 选项或 `setGlobalOptions` 调整。
314
386
 
315
387
  > `ZlSearchTable` / `ZlCardPage` 内部已用 `usePageableRequest`,**直接传 service 即可**,无需在外层再包。
@@ -318,26 +390,27 @@ const { data } = useDataRequest(getChartDataApi, { dataKey: 'data' })
318
390
 
319
391
  位置 `apps/playground/src/mock/`:
320
392
 
321
- | 文件 | 内容 |
322
- | --- | --- |
323
- | `data.ts` | 内存假数据:`genResources(count=137)`、`dicts`(resourceType/resourceStatus/region)、`treeData`、`chartData` |
393
+ | 文件 | 内容 |
394
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
395
+ | `data.ts` | 内存假数据:`genResources(count=137)`、`dicts`(resourceType/resourceStatus/region)、`treeData`、`chartData` |
324
396
  | `services.ts` | Promise service(300~600ms 延迟):`getResourcePage` / `getResourceDetail` / `getTreeData` / `getChartDataApi` / `getDictMap` / `uploadFile` / `submitResourceForm` / `getResourcePageMaybeFail` |
325
- | `index.ts` | 统一出口 |
326
-
327
- | service | 返回结构 | 用途 |
328
- | --- | --- | --- |
329
- | `getResourcePage(params)` | `{ rows, total, pageNum, pageSize }` | 分页列表,喂 `ZlSearchTable`/`ZlCardPage`/`usePaginationRequest` |
330
- | `getResourceDetail(id)` | `ResourceItem` | 详情 |
331
- | `getTreeData()` | `TreeNode[]` | 组织树 |
332
- | `getChartDataApi()` | `{ code:200, msg, data }` 信封 | 演示 `useDataRequest` 解包 |
333
- | `getDictMap()` | `Record<string, DictItem[]>` | 经 `setDictSource()` 注册为全局字典数据源 |
334
- | `uploadFile(formData)` | `{ url }` | 演示 `ZlUpload` |
335
- | `submitResourceForm(data)` | `{ code:200, msg, data }` | 表单提交 |
336
- | `getResourcePageMaybeFail(params)` | `fail:true` 时 reject | 演示错误态 |
397
+ | `index.ts` | 统一出口 |
398
+
399
+ | service | 返回结构 | 用途 |
400
+ | ---------------------------------- | ------------------------------------ | ---------------------------------------------------------------- |
401
+ | `getResourcePage(params)` | `{ rows, total, pageNum, pageSize }` | 分页列表,喂 `ZlSearchTable`/`ZlCardPage`/`usePaginationRequest` |
402
+ | `getResourceDetail(id)` | `ResourceItem` | 详情 |
403
+ | `getTreeData()` | `TreeNode[]` | 组织树 |
404
+ | `getChartDataApi()` | `{ code:200, msg, data }` 信封 | 演示 `useDataRequest` 解包 |
405
+ | `getDictMap()` | `Record<string, DictItem[]>` | 经 `setDictSource()` 注册为全局字典数据源 |
406
+ | `uploadFile(formData)` | `{ url }` | 演示 `ZlUpload` |
407
+ | `submitResourceForm(data)` | `{ code:200, msg, data }` | 表单提交 |
408
+ | `getResourcePageMaybeFail(params)` | `fail:true` 时 reject | 演示错误态 |
337
409
 
338
410
  ### 6.3 组件对接实战(对应 `/use-request` 页面)
339
411
 
340
412
  #### ① `ZlSearchTable` —— 直接传 service
413
+
341
414
  ```vue
342
415
  <ZlSearchTable
343
416
  :request="getResourcePage"
@@ -347,9 +420,11 @@ const { data } = useDataRequest(getChartDataApi, { dataKey: 'data' })
347
420
  height="380"
348
421
  />
349
422
  ```
423
+
350
424
  内部用 `usePageableRequest` 驱动分页与查询;`columns` 为 `TableColumn[]`,`queryItems` 为 `SearchItem[]`。
351
425
 
352
426
  #### ② `ZlCardPage` —— 直接传 service
427
+
353
428
  ```vue
354
429
  <ZlCardPage :request="getResourcePage" card-min-width="200px">
355
430
  <template #default="{ data }">
@@ -357,30 +432,42 @@ const { data } = useDataRequest(getChartDataApi, { dataKey: 'data' })
357
432
  </template>
358
433
  </ZlCardPage>
359
434
  ```
435
+
360
436
  内部组合 `usePageableRequest + ZlSearch + ZlPagination + ZlEmpty`。
361
437
 
362
438
  #### ③ `ZlTable` + `ZlPagination` —— 自行 `usePaginationRequest`
439
+
363
440
  ```ts
364
441
  const req = usePaginationRequest(getResourcePage, { manual: true })
365
442
  onMounted(() => req.run({ pageNum: 1, pageSize: 8 }))
366
443
  ```
444
+
367
445
  ```vue
368
446
  <ZlTable :columns="columns" :data="req.data" :loading="req.loading" height="320" />
369
447
  <ZlPagination
370
- :total="req.total" :page-num="req.current" :page-size="req.pageSize"
448
+ :total="req.total"
449
+ :page-num="req.current"
450
+ :page-size="req.pageSize"
371
451
  @change="({ pageNum, pageSize }) => req.changePagination(pageNum, pageSize)"
372
452
  />
373
453
  ```
374
454
 
375
455
  #### ④ `ZlSearch` 触发 `run(params)`
456
+
376
457
  ```ts
377
458
  const req = usePaginationRequest(getResourcePage, { manual: true })
378
- function onSearch(params) { req.run({ pageNum: 1, pageSize: 6, ...params }) }
459
+ function onSearch(params) {
460
+ req.run({ pageNum: 1, pageSize: 6, ...params })
461
+ }
379
462
  ```
463
+
380
464
  ```vue
381
465
  <ZlSearch :items="queryItems" @search="onSearch" />
382
466
  ```
383
- `ZlSearch` 自带 `overflowCount`(默认 4,折叠溢出项),`@search` 回传查询参数对象。
467
+
468
+ `ZlSearch` 按容器宽度自适应排列(每项最小 240px,列数随宽度变化)。**一行放不下的项会自动隐藏**,
469
+ 此时「查询」左侧出现展开按钮(筛选图标):点击在查询条上层展开全量表单,再点即收起。
470
+ 是否溢出由实测宽度算出(不是按项数猜),窗口拉宽后按钮会自动消失。`@search` 回传查询参数对象。
384
471
 
385
472
  #### ⑤ `ZlDictTag` —— 注入字典后由 `useDict` 解析
386
473
 
@@ -391,8 +478,14 @@ function onSearch(params) { req.run({ pageNum: 1, pageSize: 6, ...params }) }
391
478
  **A. 组件级直传(最轻量,推荐一次性/局部使用)**
392
479
 
393
480
  ```vue
394
- <ZlDictTag dict-key="resourceType" :value="row.type"
395
- :dict="[{ label: '图片', value: '1', icon: 'zl:image' }, { label: '视频', value: '2' }]" />
481
+ <ZlDictTag
482
+ dict-key="resourceType"
483
+ :value="row.type"
484
+ :dict="[
485
+ { label: '图片', value: '1', icon: 'zl:image' },
486
+ { label: '视频', value: '2' },
487
+ ]"
488
+ />
396
489
  ```
397
490
 
398
491
  **B. 全局注册数据源(应用入口注册一次,全项目共享,适配不同项目)**
@@ -400,10 +493,14 @@ function onSearch(params) { req.run({ pageNum: 1, pageSize: 6, ...params }) }
400
493
  ```ts
401
494
  import { setDictSource } from '@zl-ui-kit/composables'
402
495
  // 静态字典表
403
- setDictSource({ resourceType: [{ label: '图片', value: '1' }], resourceStatus: [{ label: '正常', value: '1' }] })
496
+ setDictSource({
497
+ resourceType: [{ label: '图片', value: '1' }],
498
+ resourceStatus: [{ label: '正常', value: '1' }],
499
+ })
404
500
  // 或按需异步加载(推荐对接各自项目后端)
405
501
  setDictSource(async (key) => await api.getDictOptions(key))
406
502
  ```
503
+
407
504
  之后任意 `<ZlDictTag dict-key="resourceType" :value="row.type" />` 自动翻译,无需逐个传 `dict`。
408
505
 
409
506
  **C. 局部注入(为某棵组件子树单独指定数据源,覆盖全局)**
@@ -418,26 +515,33 @@ useDictProvider({ source: { resourceType: [...] } })
418
515
  <ZlDictTag dict-key="resourceType" :value="row.type" />
419
516
  <ZlDictTag dict-key="resourceType" :value="row.type" simple />
420
517
  ```
518
+
421
519
  > **注意**:`ZlTable` 列上的 `dictKey` 仅作 schema 字段透传,**不会**自动渲染字典标签,需用列插槽自行渲染 `ZlDictTag`(如 demo 中 `#type`/`#status`/`#region` 插槽)。
422
520
 
423
521
  #### ⑥ `ZlUpload` —— 传上传 service
522
+
424
523
  ```vue
425
524
  <ZlUpload v-model="uploadModel" :request="uploadFile" accept=".png,.jpg,.pdf" :max-size="5" :limit="3" />
426
525
  ```
526
+
427
527
  `request` 接收 `FormData` 返回 `{ url }`;`maxSize` 单位 MB。
428
528
 
429
529
  #### ⑦ `ZlTree` —— `useRequest` 绑定 `data`
530
+
430
531
  ```ts
431
532
  const treeReq = useRequest(getTreeData)
432
533
  // 必须提取为顶层 ref,否则模板中取到的是 Ref 对象本身(见 6.2 注意事项)
433
534
  const { data: treeData, loading: treeLoading } = treeReq
434
535
  ```
536
+
435
537
  ```vue
436
538
  <ZlTree v-if="!treeLoading" :data="treeData" :props="{ label: 'title', children: 'children' }" />
437
539
  ```
438
540
 
439
541
  #### ⑧ `ZlChart` —— `useDataRequest` 解包后构建 option
542
+
440
543
  `ZlChart` 显式 prop 为 `series`,其余配置(title/xAxis/yAxis/tooltip/grid)经 attrs 透传,故用 `v-bind` 传完整 echarts option:
544
+
441
545
  ```ts
442
546
  const chartReq = useDataRequest(getChartDataApi, { dataKey: 'data' })
443
547
  const chartOption = computed(() => {
@@ -451,18 +555,20 @@ const chartOption = computed(() => {
451
555
  }
452
556
  })
453
557
  ```
558
+
454
559
  ```vue
455
560
  <ZlChart v-bind="chartOption" />
456
561
  ```
457
562
 
458
- | Prop | 类型 | 说明 |
459
- | --- | --- | --- |
460
- | `series` | `object \| object[]` | 系列(单个或数组);其余 option 字段经 attrs 透传 |
461
- | `theme` | `string` | 主题名,initialize 时指定。需先注册,如 `import 'echarts/theme/v5'` 后传 `theme="v5"`;echarts 6 想保留 v5 观感时用 |
563
+ | Prop | 类型 | 说明 |
564
+ | -------- | -------------------- | ------------------------------------------------------------------------------------------------------------------- |
565
+ | `series` | `object \| object[]` | 系列(单个或数组);其余 option 字段经 attrs 透传 |
566
+ | `theme` | `string` | 主题名,initialize 时指定。需先注册,如 `import 'echarts/theme/v5'` 后传 `theme="v5"`;echarts 6 想保留 v5 观感时用 |
462
567
 
463
568
  > 暴露方法:`clear()`(模板 ref 调用)。尺寸自适应由 `useResizeObserver` 负责,容器需有明确高度。
464
569
 
465
570
  #### ⑨ `useRequest` 生命周期面板
571
+
466
572
  ```ts
467
573
  const req = useRequest(getResourcePageMaybeFail, { defaultParams: [{ pageNum: 1, pageSize: 5 }] })
468
574
  req.refresh() // 重跑
@@ -480,18 +586,23 @@ req.cancel() // 取消进行中请求
480
586
  // ❌ 错误:模板里取到的是 Ref 对象
481
587
  const req = useRequest(getList)
482
588
  ```
589
+
483
590
  ```vue
484
591
  <Table v-if="!req.loading" :data="req.data" />
485
592
  ```
593
+
486
594
  ```ts
487
595
  // ✅ 正确:提取为顶层 ref,模板中自动解包
488
596
  const req = useRequest(getList)
489
597
  const { data: listData, loading: listLoading } = req
490
598
  ```
599
+
491
600
  ```vue
492
601
  <Table v-if="!listLoading" :data="listData" />
493
602
  ```
603
+
494
604
  方法调用不受影响(事件处理器中可直接写 `req.refresh()`,无需解包)。
605
+
495
606
  3. **`ZlChart` 传参**:用 `series` prop + 其余 attrs 透传(推荐 `v-bind` 传整个 option),勿只传 `:option`。
496
607
  4. **图标名必须存在**:字典/组件 `icon` 用的名字须在 `icons.json` 真实存在。
497
608
  5. **分页键名对齐**:后端用 `current/pageSize/list` 而非 `pageNum/pageSize/rows` 时,用 `pagination` 选项或 `setGlobalOptions` 覆盖。
@@ -501,6 +612,7 @@ req.cancel() // 取消进行中请求
501
612
  ## 7. 表单与交互组件
502
613
 
503
614
  ### ZlForm —— schema 驱动
615
+
504
616
  ```ts
505
617
  const items: FormItem[] = [
506
618
  { model: 'name', label: '名称', component: 'el-input', props: { placeholder: '请输入' }, rules: [{ required: true }] },
@@ -508,23 +620,41 @@ const items: FormItem[] = [
508
620
  { model: 'enable', label: '启用', component: 'ZlSwitch' },
509
621
  ]
510
622
  ```
623
+
511
624
  ```vue
512
625
  <ZlForm :model="form" :items="items" label-width="auto" />
513
626
  ```
627
+
514
628
  `FormItem` 关键字段:`model`(必填) / `label` / `component`(组件名或组件) / `props`(自动包装 `update:modelValue` 回写) / `slots` / `rules` / `defaultValue` / `visible`(布尔或函数) / `tooltip`(label 后帮助图标 + tooltip)。
515
629
 
516
630
  ### ZlSearch —— 查询条
631
+
517
632
  见 6.3 ④。`items: SearchItem[]`,`SearchItem` 继承 `FormItem` 并扩展 `toLabel`(值→条件标签) 与 `toParams`(值→查询参数合并)。
518
633
 
634
+ **自适应溢出**(`useSearchFormOverflow`,移植自源组件逻辑,非按项数猜):
635
+
636
+ - 布局 `auto-fill` 网格,单列 `minmax(min(240px, 100%), 1fr)`,列数随容器宽度变化;
637
+ - 按实测宽度算出**一行能放几列**,记下最后可见项下标 `lastVisibleIndex`;超出的项打上
638
+ `zl-search-form-item-hide`(`position: absolute` + `visibility: hidden`,不占位但**仍在表单里**,
639
+ 校验与取值不受影响),所以查询条永远只有一行高;
640
+ - `ResizeObserver` 监听宽度变化重算,拉宽窗口后展开按钮会自己消失;查询项增删/显隐后也会重测。
641
+
642
+ **展开 / 收起**:`lastVisibleIndex !== null` 时在「查询」左侧出现筛选图标按钮,点击在查询条**上层**
643
+ 展开全量表单浮层(`position: absolute` + 上滑 `--28px` 淡入,不改变页面高度),再点收起;查询/重置后自动收起。
644
+ `showLabels` 不显式传时,仅在发生溢出时展示「筛选条件」标签行。
645
+
519
646
  ### ZlDrawer / ZlPopconfirm / ZlSwitch
647
+
520
648
  - `ZlDrawer`:自绘 footer(okLoading/hideCancel/readonly 语义保持),`loading`→`v-loading`。
521
649
  - `ZlPopconfirm`:基于 `el-popover` 自绘面板,保留 title/content 双插槽与确认/取消事件。
522
650
  - `ZlSwitch`:`active-value`/`inactive-value` 包装,文本在侧(`checked-text`)。
523
651
 
524
652
  ### ZlAction / ZlActionList —— 操作列与操作列表
653
+
525
654
  基于 `ActionItem`(label/icon/onClick/disabled/divider 等),`ZlTable` 列 `actions` 即渲染 `ZlActionList`。
526
655
 
527
656
  ### ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
657
+
528
658
  - `ZlRadioTag`/`ZlCheckboxTag`:隐藏原生 input,标签本体即 `ZlTag`,checked 由 model 推导;`ZlCheckboxTag` 支持 exclusive。
529
659
  - `ZlCheckAll`:全选态 computed 推导。
530
660
  - `ZlSorter`/`ZlSorterList`:排序控件。
@@ -532,6 +662,7 @@ const items: FormItem[] = [
532
662
  - `ZlLayoutSwitch`:布局形态切换(el-radio-button + `zl:` 图标)。
533
663
 
534
664
  ### ZlTabs / ZlDynamicComponent / ZlGrid
665
+
535
666
  - `ZlTabs`:`el-tabs` 封装,schema `{ key, title, lazy }`,extra 经外层绝对定位承载。
536
667
  - `ZlDynamicComponent`:schema→VNode 渲染引擎,默认 `el-input`。
537
668
  - `ZlGrid`(+`ZlGridItem`):自绘栅格,label 自适应/跨列/省略提示/字典。
@@ -541,13 +672,16 @@ const items: FormItem[] = [
541
672
  ## 8. 布局与权限
542
673
 
543
674
  ### ZlAppLayout / ZlAppMenu
675
+
544
676
  - `ZlAppLayout`:horizontal/vertical 双形态布局骨架,折叠按钮 `el-button circle`。
545
677
  - `ZlAppMenu`(+Item):`el-menu` 重写(index=menu.name),主题经 `--zl-menu-*` CSS 变量对接 `--el-menu-*`。
546
678
 
547
679
  ### ZlPermission
680
+
548
681
  配合 `usePermissionProvider` 提供权限上下文,`usePermission` 校验;样例见 `/general`。
549
682
 
550
683
  ### ZlHorizontalTable
684
+
551
685
  `el-row`/`el-col`(24 栅格)实现的横向描述表。
552
686
 
553
687
  ---
@@ -595,9 +729,7 @@ setupMonacoEnvironment((_, label) => {
595
729
  **让编辑器不进首屏**(体积 3MB+,务必异步):
596
730
 
597
731
  ```ts
598
- const ZlEditor = defineAsyncComponent(() =>
599
- import('@zl-ui-kit/components/editor').then(m => m.ZlEditor),
600
- )
732
+ const ZlEditor = defineAsyncComponent(() => import('@zl-ui-kit/components/editor').then((m) => m.ZlEditor))
601
733
  ```
602
734
 
603
735
  路由级拆分(`() => import('./EditorPage.vue')`)效果相同 —— 只要 `@zl-ui-kit/components/editor`
@@ -616,6 +748,7 @@ const ZlEditor = defineAsyncComponent(() =>
616
748
  > 主题负责「视觉」的定义与覆盖;**「文案」的同等人格能力见第 13 章**(`createZlI18n`,与 `defineTheme` 对称)。
617
749
 
618
750
  ### L1 变量直覆(小幅微调)
751
+
619
752
  ```css
620
753
  body {
621
754
  --zl-primary-6: #3056d3;
@@ -625,23 +758,36 @@ body {
625
758
  ```
626
759
 
627
760
  ### L2 运行时定义主题(换肤/多租户推荐)
761
+
628
762
  ```ts
629
763
  import { defineTheme, setTheme, enableThemePersistence, useTheme } from '@zl-ui-kit/theme'
630
- defineTheme({ name: 'brand-purple', base: 'light', colors: { primary: '#722ED1', danger: '#f53f3f' }, apply: true })
764
+ defineTheme({
765
+ name: 'brand-purple',
766
+ base: 'light',
767
+ colors: { primary: '#722ED1', danger: '#f53f3f' },
768
+ apply: true,
769
+ })
631
770
  setTheme('brand-purple')
632
- enableThemePersistence() // 可选:localStorage 记住选择(key: zl-theme)
633
- const { theme, themes, setTheme } = useTheme() // 组件内响应式
771
+ enableThemePersistence() // 可选:localStorage 记住选择(key: zl-theme)
772
+ const { theme, themes, setTheme } = useTheme() // 组件内响应式
634
773
  ```
774
+
635
775
  自定义主题与内置主题变量完全同构,色阶派生算法与 EP theme-chalk 对齐,支持任意数量并存切换;`tokens` 参数可覆盖任意底层 token 深度定制。
636
776
 
637
777
  ### L3 构建时生成主题(深度定制,规划中)
778
+
638
779
  需求 §12-Q14:将提供 CLI 产出与内置同构的完整 CSS,当前可先用 L2 `tokens` 覆盖近似。
639
780
 
640
781
  ### SCSS 工具(编译期定制)
782
+
641
783
  ```scss
642
784
  @use '@zl-ui-kit/theme/scss/colors.scss' as *;
643
- .my-card { @include colorGradient(primary, to right); color: var(--zl-primary-6); }
785
+ .my-card {
786
+ @include colorGradient(primary, to right);
787
+ color: var(--zl-primary-6);
788
+ }
644
789
  ```
790
+
645
791
  - `scss/colors.scss`:`colorForEach` / `colorGradient`
646
792
  - `scss/map.scss`:`mapGet`
647
793
  - `scss/theme.scss`:`theme()` mixin(为每套主题生成选择器块)
@@ -651,13 +797,14 @@ const { theme, themes, setTheme } = useTheme() // 组件内响应式
651
797
  ## 11. 调试与常见问题
652
798
 
653
799
  ### 各包常用命令
654
- | 包 | 生成 | 构建 | 单测 |
655
- | --- | --- | --- | --- |
656
- | @zl-ui-kit/icons | `pnpm --filter @zl-ui-kit/icons gen`(svg → icons.json,prefix `zl`) | 同 gen | — |
657
- | @zl-ui-kit/theme | `pnpm --filter @zl-ui-kit/theme gen`(_json → generated/) | `build`(gen + tsup) | — |
658
- | @zl-ui-kit/utils | — | `build`(tsup) | `test:unit`(vitest) |
659
- | @zl-ui-kit/composables | — | `build`(tsup) | — |
660
- | @zl-ui-kit/components | — | `build`(vite lib + dts + 样式注入) | — |
800
+
801
+ | 包 | 生成 | 构建 | 单测 |
802
+ | ---------------------- | --------------------------------------------------------------------- | ---------------------------------- | ------------------- |
803
+ | @zl-ui-kit/icons | `pnpm --filter @zl-ui-kit/icons gen`(svg → icons.json,prefix `zl`) | 同 gen | — |
804
+ | @zl-ui-kit/theme | `pnpm --filter @zl-ui-kit/theme gen`(_json → generated/) | `build`(gen + tsup) | — |
805
+ | @zl-ui-kit/utils | — | `build`(tsup) | `test:unit`(vitest) |
806
+ | @zl-ui-kit/composables | — | `build`(tsup) | — |
807
+ | @zl-ui-kit/components | — | `build`(vite lib + dts + 样式注入) | — |
661
808
 
662
809
  ### 文档维护位置
663
810
 
@@ -669,6 +816,7 @@ const { theme, themes, setTheme } = useTheme() // 组件内响应式
669
816
  - 其余四包 README 只保留本包速查,并在顶部指向本页。
670
817
 
671
818
  ### 常见问题
819
+
672
820
  - **改了 theme 的 `_json/*.json` 不生效**:先 `pnpm --filter @zl-ui-kit/theme gen`(生成 `src/generated/`),再刷新 playground。
673
821
  - **新增 svg 图标**:放入 `packages/icons/src/svg/`,执行 icons 的 `gen` 后重启 playground。
674
822
  - **`@zl-ui-kit/theme/scss/*.scss` 找不到**:确认已执行 theme `gen`(`generated/_constants.scss` 是其依赖)。
@@ -707,7 +855,9 @@ setGlobalOptions({ pagination: { currentKey: 'current', totalKey: 'totalCount',
707
855
 
708
856
  // 自定义插件示例
709
857
  const logPlugin = defineUseRequestPlugin((inst) => ({
710
- onSuccess(data) { console.log('[req]', inst.params.value, data) },
858
+ onSuccess(data) {
859
+ console.log('[req]', inst.params.value, data)
860
+ },
711
861
  }))
712
862
  const { data } = useRequest(getList, {}, [logPlugin])
713
863
  ```
@@ -718,6 +868,7 @@ const { data } = useRequest(getList, {}, [logPlugin])
718
868
  import { useGlobalData } from '@zl-ui-kit/composables'
719
869
  const g = useGlobalData()
720
870
  ```
871
+
721
872
  响应式字段(均为 `WritableComputedRef`):`locale` / `theme` / `token` / `isI18nKeyVisible` / `roles` / `permissions` / `user` / `localeMessages` / `elLocaleMessages` / `config`。(注:字典数据已独立为 `useDictStore`,不挂在全局数据上。)
722
873
 
723
874
  方法:`getConfig(key, default?)` / `isConfig(key, compareValue='true')` / `setAndWaitUntil({ set?, until? })`(设置并等待条件成立)/ `resetUser()`。
@@ -726,12 +877,12 @@ const g = useGlobalData()
726
877
  ```ts
727
878
  // 应用入口:初始化登录态与业务配置
728
879
  const g = useGlobalData()
729
- g.token.value = loginToken // 持久化到 $zl_token
730
- g.config.value = { 'zl.service.type': 'platform' } // useServiceType 读取它
880
+ g.token.value = loginToken // 持久化到 $zl_token
881
+ g.config.value = { 'zl.service.type': 'platform' } // useServiceType 读取它
731
882
  g.user.value = { name: '张三' }
732
883
 
733
- g.locale.value = 'en' // 切换语言,useLocale / ZlI18nProvider 跟随
734
- g.resetUser() // 登出:清 user / roles / permissions / token
884
+ g.locale.value = 'en' // 切换语言,useLocale / ZlI18nProvider 跟随
885
+ g.resetUser() // 登出:清 user / roles / permissions / token
735
886
  ```
736
887
 
737
888
  > 本 hook 只依赖 `localStorage`,**不依赖任何微前端框架**。它替代了 `0.4.x` 及更早版本的
@@ -756,11 +907,18 @@ g.resetUser() // 登出:清 user
756
907
  const { Message, Modal, Notification } = useGlobalMessage()
757
908
  Message.success('保存成功')
758
909
  // Modal 在 ElMessageBox 基础上扩展了 confirmPromise
759
- const r = await Modal.confirmPromise({ title: '删除', message: '确认删除?' },
760
- async (ctx) => { await doDelete() }, // onOk
761
- async (ctx) => { /* onCancel */ })
910
+ const r = await Modal.confirmPromise(
911
+ { title: '删除', message: '确认删除?' },
912
+ async (ctx) => {
913
+ await doDelete()
914
+ }, // onOk
915
+ async (ctx) => {
916
+ /* onCancel */
917
+ },
918
+ )
762
919
  // r: 'Ok' | 'Cancel' | false(onOk 抛错且 throwOnOk=false 时)
763
920
  ```
921
+
764
922
  `throwOnOk` / `throwOnCancel` 控制错误是否向上抛出(默认吞错 resolve(false) / resolve('Cancel'))。
765
923
 
766
924
  #### 12.1.5 其它 Hooks
@@ -776,7 +934,7 @@ const r = await Modal.confirmPromise({ title: '删除', message: '确认删除
776
934
 
777
935
  ```ts
778
936
  import { createRequest, deepCopy, formatFilesize /* … */ } from '@zl-ui-kit/utils'
779
- import request from '@zl-ui-kit/utils' // 默认导出一个开箱即用的 createRequest 实例
937
+ import request from '@zl-ui-kit/utils' // 默认导出一个开箱即用的 createRequest 实例
780
938
  ```
781
939
 
782
940
  #### 12.2.1 网络请求封装 `createRequest`
@@ -795,30 +953,34 @@ api.get('/resources', { params: { pageNum: 1, pageSize: 10 } })
795
953
 
796
954
  #### 12.2.2 数组 / 对象 / 类型判断
797
955
 
798
- | 函数 | 说明 |
799
- | --- | --- |
800
- | `convertArrayToTree(list, { id='id', pid='pid', children='children' })` | 扁平数组转树(基于 id/pid,支持乱序输入) |
801
- | `ensureArray(val)` | 非数组值包装为单元素数组 |
802
- | `deepCopy(obj)` / `shallowCopy(obj)` | 深拷贝 / 浅拷贝(内部用 `hasOwn`) |
803
- | `hasOwn(obj, key)` | `Object.prototype.hasOwnProperty` 封装 |
804
- | `isObject` / `isPlainObject` / `isArray` / `isFunction` / `isPromise` / `isBoolean` / `isNumber` / `isDefined` | 类型判断(TS 类型守卫) |
956
+ | 函数 | 说明 |
957
+ | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
958
+ | `convertArrayToTree(list, { id='id', pid='pid', children='children' })` | 扁平数组转树(基于 id/pid,支持乱序输入) |
959
+ | `ensureArray(val)` | 非数组值包装为单元素数组 |
960
+ | `deepCopy(obj)` / `shallowCopy(obj)` | 深拷贝 / 浅拷贝(内部用 `hasOwn`) |
961
+ | `hasOwn(obj, key)` | `Object.prototype.hasOwnProperty` 封装 |
962
+ | `isObject` / `isPlainObject` / `isArray` / `isFunction` / `isPromise` / `isBoolean` / `isNumber` / `isDefined` | 类型判断(TS 类型守卫) |
805
963
 
806
964
  #### 12.2.3 函数 / 加密 / DOM / 文件 / 杂项
807
965
 
808
966
  **函数**
967
+
809
968
  - `debounce(fn, delay = 300)`:防抖。
810
969
  - `traverseTree(tree, cb, { children = 'children' })`:深度遍历树结构数组。
811
970
  - `withResolvers<T>()`:`Promise.withResolvers` 兼容实现,返回 `{ resolve, reject, promise }`。
812
971
 
813
972
  **加密**(CryptoJS AES-CBC-PKCS7)
973
+
814
974
  - `aesEncrypt(plain, aesKey = DEFAULT_AES_KEY, aesIvKey = DEFAULT_AES_IV_KEY)` / `aesDecrypt(cipher, ...)`
815
975
  - 默认密钥常量:`DEFAULT_AES_KEY` / `DEFAULT_AES_IV_KEY`、`DATABASE_AES_KEY` / `DATABASE_AES_IV_KEY`(均可自行传入覆盖)。
816
976
 
817
977
  **DOM**
978
+
818
979
  - `getRelativeRect(target, relative)` → `{ top, bottom, left, right, width, height }`:元素相对参照元素的矩形。
819
980
  - `getStyle(el, prop)`:读取样式(含计算样式回退;`float` → `cssFloat`)。
820
981
 
821
982
  **文件**
983
+
822
984
  - `fileSave`(re-export `file-saver` 的 `saveAs`)。
823
985
  - `joinFilePrefix(path, prefix = '/_file')`:拼接文件服务前缀路径。
824
986
  - `downloadFileByUrl(url, prefix?)`:创建临时 `<a>` 触发浏览器下载。
@@ -826,6 +988,7 @@ api.get('/resources', { params: { pageNum: 1, pageSize: 10 } })
826
988
  - `formatFilesize(size, { precision = 2, units })`:文件大小格式化(B/KB/MB/GB)。
827
989
 
828
990
  **杂项**
991
+
829
992
  - `generateUUID()`:UUID v4。
830
993
  - `getRandomInt(min, max)`:`[min, max]` 区间随机整数。
831
994
  - `paginate(data, pageSize, pageNum)` → `{ rows, pageNum, total }`:内存数组静态分页。
@@ -840,11 +1003,11 @@ api.get('/resources', { params: { pageNum: 1, pageSize: 10 } })
840
1003
 
841
1004
  ### 13.1 三层结构
842
1005
 
843
- | 层 | 来源 | 负责 |
844
- | --- | --- | --- |
845
- | 业务文案多语言 | 宿主经 `createZlI18n`(或底层 `useLocale`)安装的 vue-i18n 实例 | `t('zl.xxx')` 解析内置包 + 覆盖包 |
846
- | Element Plus 内置组件本地化 | `ZlI18nProvider` → `<el-config-provider>` | 绑定 `elLocaleMessages` 到 EP |
847
- | 调试开关 | `isI18nKeyVisible` | 开启后所有 `t()` 直接显示 key,便于排查漏翻 |
1006
+ | 层 | 来源 | 负责 |
1007
+ | --------------------------- | --------------------------------------------------------------- | ------------------------------------------- |
1008
+ | 业务文案多语言 | 宿主经 `createZlI18n`(或底层 `useLocale`)安装的 vue-i18n 实例 | `t('zl.xxx')` 解析内置包 + 覆盖包 |
1009
+ | Element Plus 内置组件本地化 | `ZlI18nProvider` → `<el-config-provider>` | 绑定 `elLocaleMessages` 到 EP |
1010
+ | 调试开关 | `isI18nKeyVisible` | 开启后所有 `t()` 直接显示 key,便于排查漏翻 |
848
1011
 
849
1012
  > ⚠️ **关键:仅 `useLocale` 不够。** `elLocaleMessages` 由 `useLocale` 的 `loader` 写入全局数据,但必须由 `ZlI18nProvider` 经 `<el-config-provider>` 真正挂载到 Element Plus,否则分页器等内置组件不会翻译。
850
1013
 
@@ -865,9 +1028,9 @@ locale.value = 'zh'
865
1028
  const { i18n } = createZlI18n({
866
1029
  // 只覆盖想改的 key;未写的走组件库内置默认包
867
1030
  messages: {
868
- zh: { 'zl.login.username': '账号' }, // 覆盖已有语言
1031
+ zh: { 'zl.login.username': '账号' }, // 覆盖已有语言
869
1032
  en: { 'zl.empty.noData': 'Nothing here yet' },
870
- ja: { 'zl.empty.noData': 'データがありません' }, // 新增语言
1033
+ ja: { 'zl.empty.noData': 'データがありません' }, // 新增语言
871
1034
  },
872
1035
  // Element Plus 语言包(随 locale 自动切换,由 <ZlI18nProvider> 挂载)
873
1036
  elLocales: { zh: zhCn, en },
@@ -923,14 +1086,14 @@ const text = t('zl.empty.noData', '暂无相关数据')
923
1086
 
924
1087
  主题让消费者「定义并覆盖视觉」,国际化让消费者「定义并覆盖文案」——二者地位对等:
925
1088
 
926
- | 能力 | 主题(`@zl-ui-kit/theme`) | 国际化(`@zl-ui-kit/components` + `@zl-ui-kit/composables`) |
927
- | --- | --- | --- |
928
- | 内置默认 | 5 套主题(light / dark / red-light / red-dark / blue) | `zlMessages`(zh / zh-cn / en) |
929
- | 运行时定义 | `defineTheme({ name, base, colors, tokens })` | `createZlI18n({ messages })` 覆盖 / 新增语言 |
930
- | 引用 / 切换 | `setTheme('dark')` / `useTheme()` | `locale.value = 'en'` / `useLocale()` 返回的 `locale` |
931
- | 持久化 | `enableThemePersistence()` | `useGlobalData().locale` 经 `$zl_locale` 持久化 |
932
- | 细粒度覆盖 | CSS 变量 L1 覆写(`--zl-primary-6`) | `mergeMessages` / 直接覆盖单个 key |
933
- | 挂载点 | `body[data-theme]` | `<ZlI18nProvider>`(EP locale)+ `app.use(i18n)`(业务文案) |
1089
+ | 能力 | 主题(`@zl-ui-kit/theme`) | 国际化(`@zl-ui-kit/components` + `@zl-ui-kit/composables`) |
1090
+ | ----------- | ------------------------------------------------------ | ------------------------------------------------------------ |
1091
+ | 内置默认 | 5 套主题(light / dark / red-light / red-dark / blue) | `zlMessages`(zh / zh-cn / en) |
1092
+ | 运行时定义 | `defineTheme({ name, base, colors, tokens })` | `createZlI18n({ messages })` 覆盖 / 新增语言 |
1093
+ | 引用 / 切换 | `setTheme('dark')` / `useTheme()` | `locale.value = 'en'` / `useLocale()` 返回的 `locale` |
1094
+ | 持久化 | `enableThemePersistence()` | `useGlobalData().locale` 经 `$zl_locale` 持久化 |
1095
+ | 细粒度覆盖 | CSS 变量 L1 覆写(`--zl-primary-6`) | `mergeMessages` / 直接覆盖单个 key |
1096
+ | 挂载点 | `body[data-theme]` | `<ZlI18nProvider>`(EP locale)+ `app.use(i18n)`(业务文案) |
934
1097
 
935
1098
  **三种覆盖方式(按力度递增)**
936
1099
 
@@ -951,23 +1114,2743 @@ const { i18n } = useLocale({ messages })
951
1114
 
952
1115
  **内置可覆盖 key 一览**(`zl.<组件>.<语义>`)
953
1116
 
954
- | 组件 | key | 默认(zh) |
955
- | --- | --- | --- |
956
- | ZlEmpty | `zl.empty.noData` | 暂无相关数据 |
957
- | ZlDrawer | `zl.drawer.cancel` / `confirm` / `close` | 取消 / 确定 / 关闭 |
958
- | ZlPopconfirm | `zl.popconfirm.confirm` / `cancel` | 确定 / 取消 |
959
- | ZlLayoutSwitch | `zl.layoutSwitch.grid` / `table` | 网格 / 表格 |
960
- | ZlUpload | `zl.upload.accept` / `limit` / `maxSize` / `nameSpace` | 仅支持{accept}格式的文件 / 最多可上传{limit}个 / 大小不超过{maxSize}MB / 文件名中不得包含空格 |
961
- | ZlSearch | `zl.search.search` / `filterConditions` / `all` | 查询 / 筛选条件 / 全部 |
962
- | ZlLogin | `zl.login.username` / `password` / `usernamePlaceholder` / `passwordPlaceholder` / `slideRequired` / `slideText` / `slideSuccess` / `submit` / `welcome` | 用户名 / 密码 / 请输入用户名 / 请输入密码 / 请将滑块移至右侧 / 请滑动到右侧 / 验证通过 / 登 录 / 欢迎登录 |
963
- | ZlFilePreview | `zl.filePreview.typeError` / `fetchError` | 获取文件类型失败 / 文件获取失败 |
964
- | ZlAction | `zl.action.more` | 更多 |
965
- | ZlCheckAll | `zl.checkAll.selectAll` | 全选 |
966
- | ZlCopy | `zl.copy.copy` / `success` / `failed` | 复制 / 复制成功 / 复制失败 |
967
- | ZlDescription | `zl.description.empty` | 暂无 |
968
- | ZlGrid | `zl.grid.empty` | 暂无 |
969
- | ZlSqlEditor | `zl.sqlEditor.invalid` | 请检查SQL语法 |
1117
+ | 组件 | key | 默认(zh) |
1118
+ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
1119
+ | ZlEmpty | `zl.empty.noData` | 暂无相关数据 |
1120
+ | ZlDrawer | `zl.drawer.cancel` / `confirm` / `close` | 取消 / 确定 / 关闭 |
1121
+ | ZlPopconfirm | `zl.popconfirm.confirm` / `cancel` | 确定 / 取消 |
1122
+ | ZlLayoutSwitch | `zl.layoutSwitch.grid` / `table` | 网格 / 表格 |
1123
+ | ZlUpload | `zl.upload.accept` / `limit` / `maxSize` / `nameSpace` | 仅支持{accept}格式的文件 / 最多可上传{limit}个 / 大小不超过{maxSize}MB / 文件名中不得包含空格 |
1124
+ | ZlSearch | `zl.search.search` / `filterConditions` / `all` | 查询 / 筛选条件 / 全部 |
1125
+ | ZlLogin | `zl.login.username` / `password` / `usernamePlaceholder` / `passwordPlaceholder` / `slideRequired` / `slideText` / `slideSuccess` / `submit` / `welcome` | 用户名 / 密码 / 请输入用户名 / 请输入密码 / 请将滑块移至右侧 / 请滑动到右侧 / 验证通过 / 登 录 / 欢迎登录 |
1126
+ | ZlFilePreview | `zl.filePreview.typeError` / `fetchError` | 获取文件类型失败 / 文件获取失败 |
1127
+ | ZlAction | `zl.action.more` | 更多 |
1128
+ | ZlCheckAll | `zl.checkAll.selectAll` | 全选 |
1129
+ | ZlCopy | `zl.copy.copy` / `success` / `failed` | 复制 / 复制成功 / 复制失败 |
1130
+ | ZlDescription | `zl.description.empty` | 暂无 |
1131
+ | ZlGrid | `zl.grid.empty` | 暂无 |
1132
+ | ZlSqlEditor | `zl.sqlEditor.invalid` | 请检查SQL语法 |
970
1133
 
971
1134
  > **props 优先于 i18n**:组件显式传入的 props(如 `ZlPopconfirm` 的 `confirmButtonText`、`ZlDescription`/`ZlGrid` 的 `emptyText`)优先;i18n 只决定「未传时的默认文案」。新增文案请同步补 `packages/components/src/locales/{zh-cn,en}.ts`。
972
1135
 
973
1136
  > **当前未接入 i18n 的中文**:仅剩开发态告警(`ZlDynamicComponent` 的 `console.warn`、`ZlPermission` 的 `throw new Error('权限格式错误')`、`ZlEditor` 的 worker 未配置提示)——这些不面向终端用户,保持中文以便排查。
1137
+
1138
+ ---
1139
+
1140
+ <!-- API:START -->
1141
+
1142
+ ## 14. 组件 API 参考(自动生成)
1143
+
1144
+ > 本章由 `pnpm docs:api`(`scripts/gen-component-api.mjs`)从各组件源码**静态提取**后自动写入,**请勿手改**——会被下次生成覆盖。要补充 prop 说明,请给源码里的 prop 加 `/** ... */` 注释。
1145
+ >
1146
+ > 提取口径:`defineProps`(含 `withDefaults` 默认值、`defineComponent({ props })` 选项式)/ `defineEmits` / `<slot>` / `defineExpose`。类型列显示的是源码里的 TS 类型表达式,可直接当入参类型用。
1147
+ >
1148
+ > 代码块取自 `apps/playground/src/pages/gallery-demos.ts` 的逐组件最小示例(同一份代码在冒烟测试里真实渲染),因此不会出现过期写法;改示例后重跑即同步。
1149
+ >
1150
+ > **每个 prop / 每个插槽都有示例**:`props` 表的「示例」列是该属性的**可直接粘贴写法**(`v-model` 用简写,布尔值按默认值给反例,字面量联合取首个取值,数组 / 对象 / 函数给空字面量占位);`插槽` 表的「示例」列是对应的 `<template #name>` 片段。想直接改原始代码,用上面的「用法示例 / 插槽用法」块。
1151
+ >
1152
+ > 同一次生成还会写出 `apps/playground/src/data/component-api.json`,playground 的 **UI 组件使用手册**(`/#/manual`)页直接渲染它 —— 可检索、可复制 `import`,内容与本章一致。
1153
+
1154
+ ### 组件索引
1155
+
1156
+ | 组件 | 入口 | props | 事件 | 插槽 | 暴露 |
1157
+ | -------------------- | ------------------- | ----- | ---- | ---- | ---- |
1158
+ | `ZlAction` | 主入口 | 0 | 0 | 0 | 0 |
1159
+ | `ZlActionList` | 主入口 | 6 | 1 | 1 | 0 |
1160
+ | `ZlAddSub` | 主入口 | 2 | 1 | 1 | 0 |
1161
+ | `ZlAppLayout` | 主入口 | 1 | 0 | 1 | 0 |
1162
+ | `ZlAppMenu` | 主入口 | 3 | 1 | 0 | 0 |
1163
+ | `ZlAppSlogan` | 主入口 | 3 | 0 | 0 | 0 |
1164
+ | `ZlAutoTooltip` | 主入口 | 0 | 0 | 1 | 0 |
1165
+ | `ZlAvatar` | 主入口 | 3 | 0 | 0 | 0 |
1166
+ | `ZlAvatarGroup` | 主入口 | 3 | 0 | 0 | 0 |
1167
+ | `ZlCard` | 主入口 | 1 | 0 | 8 | 0 |
1168
+ | `ZlCardPage` | 主入口 | 6 | 1 | 3 | 3 |
1169
+ | `ZlCheckAll` | 主入口 | 2 | 1 | 0 | 0 |
1170
+ | `ZlCheckboxTag` | 主入口 | 7 | 1 | 1 | 0 |
1171
+ | `ZlCopy` | 主入口 | 2 | 0 | 2 | 0 |
1172
+ | `ZlDescription` | 主入口 | 5 | 0 | 1 | 0 |
1173
+ | `ZlDictTag` | 主入口 | 6 | 0 | 0 | 0 |
1174
+ | `ZlDrawer` | 主入口 | 6 | 1 | 2 | 0 |
1175
+ | `ZlDynamicComponent` | 主入口 | 3 | 2 | 0 | 0 |
1176
+ | `ZlPdfViewer` | 主入口 | 2 | 0 | 0 | 0 |
1177
+ | `ZlLogin` | 主入口 | 2 | 0 | 2 | 0 |
1178
+ | `ZlLoginForm` | 主入口 | 1 | 0 | 1 | 0 |
1179
+ | `ZlEmpty` | 主入口 | 2 | 0 | 0 | 0 |
1180
+ | `ZlForm` | 主入口 | 2 | 0 | 3 | 0 |
1181
+ | `ZlFormChild` | 主入口 | 1 | 0 | 0 | 0 |
1182
+ | `ZlGridItem` | 主入口 | 1 | 0 | 1 | 0 |
1183
+ | `ZlGrid` | 主入口 | 9 | 0 | 2 | 0 |
1184
+ | `ZlHorizontalTable` | 主入口 | 4 | 0 | 1 | 0 |
1185
+ | `ZlIcon` | 主入口 | 1 | 0 | 1 | 0 |
1186
+ | `ZlI18nProvider` | 主入口 | 0 | 0 | 1 | 0 |
1187
+ | `ZlIconHover` | 主入口 | 0 | 0 | 0 | 0 |
1188
+ | `ZlIconLabel` | 主入口 | 1 | 1 | 1 | 0 |
1189
+ | `ZlCornerTag` | 主入口 | 3 | 0 | 1 | 0 |
1190
+ | `ZlLayoutSwitch` | 主入口 | 2 | 1 | 0 | 0 |
1191
+ | `ZlPagination` | 主入口 | 3 | 3 | 0 | 0 |
1192
+ | `ZlPermission` | 主入口 | 1 | 0 | 1 | 0 |
1193
+ | `ZlPopconfirm` | 主入口 | 4 | 2 | 3 | 0 |
1194
+ | `ZlRadioTag` | 主入口 | 3 | 1 | 1 | 0 |
1195
+ | `ZlSearch` | 主入口 | 5 | 2 | 2 | 3 |
1196
+ | `ZlSearchTable` | 主入口 | 5 | 1 | 3 | 4 |
1197
+ | `ZlSection` | 主入口 | 4 | 0 | 3 | 0 |
1198
+ | `ZlSorter` | 主入口 | 2 | 2 | 1 | 0 |
1199
+ | `ZlSorterList` | 主入口 | 2 | 1 | 0 | 0 |
1200
+ | `ZlSwitch` | 主入口 | 6 | 1 | 2 | 0 |
1201
+ | `ZlTable` | 主入口 | 6 | 3 | 3 | 0 |
1202
+ | `ZlTabs` | 主入口 | 4 | 0 | 3 | 0 |
1203
+ | `ZlTag` | 主入口 | 15 | 4 | 1 | 0 |
1204
+ | `ZlText` | 主入口 | 1 | 0 | 1 | 0 |
1205
+ | `ZlTitle` | 主入口 | 5 | 0 | 3 | 0 |
1206
+ | `ZlUpload` | 主入口 | 11 | 1 | 1 | 0 |
1207
+ | `ZlTree` | 主入口 | 5 | 0 | 3 | 0 |
1208
+ | `ZlTreeSelect` | 主入口 | 6 | 1 | 0 | 0 |
1209
+ | `ZlChart` | 子入口 chart | 2 | 0 | 0 | 1 |
1210
+ | `ZlEditor` | 子入口 editor | 3 | 1 | 0 | 0 |
1211
+ | `ZlSqlEditor` | 子入口 editor | 4 | 1 | 0 | 0 |
1212
+ | `ZlFilePreview` | 子入口 file-preview | 1 | 0 | 0 | 0 |
1213
+ | `ZlFileViewer` | 子入口 file-preview | 1 | 0 | 0 | 0 |
1214
+
1215
+ > 说明列为 `—` 表示该属性在源码里没写 `/** */` 注释(当前 133/189 个);补完注释重跑 `pnpm docs:api` 即可同步。
1216
+
1217
+ ### 14.1 主入口组件(`@zl-ui-kit/components`)
1218
+
1219
+ #### `ZlAction`
1220
+
1221
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAction/index.vue`</sub>
1222
+
1223
+ **简介**:操作列与操作列表
1224
+
1225
+ **用法示例**
1226
+
1227
+ ```vue
1228
+ <script setup lang="ts">
1229
+ import { ZlAction } from '@zl-ui-kit/components'
1230
+ </script>
1231
+
1232
+ <template>
1233
+ <ZlAction />
1234
+ </template>
1235
+ ```
1236
+
1237
+ > 把 `$attrs` 透传给 `ZlActionList`,未列出的属性会继续下传
1238
+
1239
+ > 纯容器组件:不接收 props,也无自定义事件/插槽/暴露方法。
1240
+
1241
+ **完整示例**:见 §7 表单与交互组件 › ZlAction / ZlActionList —— 操作列与操作列表
1242
+
1243
+ #### `ZlActionList`
1244
+
1245
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAction/List.vue`</sub>
1246
+
1247
+ **简介**:操作列与操作列表
1248
+
1249
+ **接口概览**:6 props · 1 事件 · 1 插槽
1250
+
1251
+ **用法示例**
1252
+
1253
+ ```vue
1254
+ <script setup lang="ts">
1255
+ import { ZlActionList } from '@zl-ui-kit/components'
1256
+ </script>
1257
+
1258
+ <template>
1259
+ <ZlActionList :list-count="2" />
1260
+ </template>
1261
+ ```
1262
+
1263
+ **插槽用法**
1264
+
1265
+ ```vue
1266
+ <template>
1267
+ <ZlActionList>
1268
+ <template #more>…</template>
1269
+ </ZlActionList>
1270
+ </template>
1271
+ ```
1272
+
1273
+ **props**
1274
+
1275
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1276
+ | ------------- | -------------------------------- | ---------- | ---- | ----------------------- | ------------------------------------ |
1277
+ | `actions` | `ActionItem[]` | `() => []` | 否 | `:actions="actions"` | — |
1278
+ | `actionArgs` | `any[]` | `() => []` | 否 | `:action-args="[]"` | — |
1279
+ | `visibleArgs` | `any[]` | `() => []` | 否 | `:visible-args="[]"` | — |
1280
+ | `listCount` | `number` | `2` | 否 | `:list-count="1"` | 直接展示的操作数,超出收入"更多"下拉 |
1281
+ | `iconMore` | `boolean \| Record<string, any>` | — | 否 | `:icon-more="iconMore"` | — |
1282
+ | `separator` | `boolean` | — | 否 | `separator` | — |
1283
+
1284
+ **事件(emits)**
1285
+
1286
+ | 事件 | 参数 | 说明 |
1287
+ | -------- | ------------------- | ---- |
1288
+ | `action` | `ActionItem, any[]` | — |
1289
+
1290
+ **插槽(slots)**
1291
+
1292
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1293
+ | ------ | ---------- | ------------------------------ | ---- |
1294
+ | `more` | — | `<template #more>…</template>` | — |
1295
+
1296
+ **完整示例**:见 §7 表单与交互组件 › ZlAction / ZlActionList —— 操作列与操作列表
1297
+
1298
+ #### `ZlAddSub`
1299
+
1300
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAddSub/index.vue`</sub>
1301
+
1302
+ **接口概览**:2 props · 1 事件 · 1 插槽
1303
+
1304
+ **用法示例**
1305
+
1306
+ ```vue
1307
+ <script setup lang="ts">
1308
+ import { ZlAddSub } from '@zl-ui-kit/components'
1309
+ </script>
1310
+
1311
+ <template>
1312
+ <ZlAddSub :model-value="['示例项']" />
1313
+ </template>
1314
+ ```
1315
+
1316
+ > 示例中的 `modelValue` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1317
+
1318
+ **插槽用法**
1319
+
1320
+ ```vue
1321
+ <template>
1322
+ <ZlAddSub>
1323
+ <template #add="{ index }">…</template>
1324
+ </ZlAddSub>
1325
+ </template>
1326
+ ```
1327
+
1328
+ **props**
1329
+
1330
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1331
+ | ------------ | ----------------- | ---------- | ---- | --------------------------- | -------------- |
1332
+ | `model` | `any[]` | `() => []` | 否 | `v-model:model="value"` | — |
1333
+ | `defaultVal` | `any[] \| string` | `() => []` | 否 | `:default-val="defaultVal"` | 新增项的默认值 |
1334
+
1335
+ **事件(emits)**
1336
+
1337
+ | 事件 | 参数 | 说明 |
1338
+ | -------------- | ------- | ---- |
1339
+ | `update:model` | `any[]` | — |
1340
+
1341
+ **插槽(slots)**
1342
+
1343
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1344
+ | ----- | ---------- | ----------------------------------------- | ---- |
1345
+ | `add` | `index` | `<template #add="{ index }">…</template>` | — |
1346
+
1347
+ **完整示例**:见 §7 表单与交互组件 › ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
1348
+
1349
+ #### `ZlAppLayout`
1350
+
1351
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAppLayout/index.vue`</sub>
1352
+
1353
+ **接口概览**:1 props · 1 插槽
1354
+
1355
+ **用法示例**
1356
+
1357
+ ```vue
1358
+ <script setup lang="ts">
1359
+ import { ZlAppLayout } from '@zl-ui-kit/components'
1360
+ </script>
1361
+
1362
+ <template>
1363
+ <ZlAppLayout />
1364
+ </template>
1365
+ ```
1366
+
1367
+ **插槽用法**
1368
+
1369
+ ```vue
1370
+ <template>
1371
+ <ZlAppLayout>
1372
+ <template #default>…</template>
1373
+ </ZlAppLayout>
1374
+ </template>
1375
+ ```
1376
+
1377
+ **props**
1378
+
1379
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1380
+ | -------- | ---------------------------- | -------------- | ---- | --------------------- | ---- |
1381
+ | `layout` | `'horizontal' \| 'vertical'` | `'horizontal'` | 否 | `layout="horizontal"` | — |
1382
+
1383
+ > 选项式组件(`defineComponent`),props 定义在 `props: {}` 中
1384
+ > 把 `$attrs` 透传给内部组件,未列出的属性会继续下传
1385
+
1386
+ **插槽(slots)**
1387
+
1388
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1389
+ | --------- | ---------- | --------------------------------- | ------------------------------------------- |
1390
+ | `default` | — | `<template #default>…</template>` | 整个 `slots` 对象原样透传,插槽由子组件决定 |
1391
+
1392
+ **完整示例**:见 §8 布局与权限 › ZlAppLayout / ZlAppMenu
1393
+
1394
+ #### `ZlAppMenu`
1395
+
1396
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAppMenu/AppMenu.vue`</sub>
1397
+
1398
+ **接口概览**:3 props · 1 事件
1399
+
1400
+ **用法示例**
1401
+
1402
+ ```vue
1403
+ <script setup lang="ts">
1404
+ import { ZlAppMenu } from '@zl-ui-kit/components'
1405
+ </script>
1406
+
1407
+ <template>
1408
+ <ZlAppMenu :menus="menus" />
1409
+ </template>
1410
+ ```
1411
+
1412
+ > 示例中的 `menus` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1413
+
1414
+ **props**
1415
+
1416
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1417
+ | ----------- | ---------------------------- | ------------ | ---- | ------------------- | ----------------------------------- |
1418
+ | `collapsed` | `boolean` | `false` | 否 | `collapsed` | — |
1419
+ | `layout` | `'vertical' \| 'horizontal'` | `'vertical'` | 否 | `layout="vertical"` | el-menu 模式:vertical / horizontal |
1420
+ | `menus` | `MenuItem[]` | `() => []` | 否 | `:menus="menus"` | — |
1421
+
1422
+ **事件(emits)**
1423
+
1424
+ | 事件 | 参数 | 说明 |
1425
+ | ----------------- | ---------- | ---- |
1426
+ | `menu-item-click` | `MenuItem` | — |
1427
+
1428
+ **完整示例**:见 §8 布局与权限 › ZlAppLayout / ZlAppMenu
1429
+
1430
+ #### `ZlAppSlogan`
1431
+
1432
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAppSlogan/index.vue`</sub>
1433
+
1434
+ **简介**:应用标识(Logo + 标题):侧栏折叠时可用 `collapsed` 只显示图标
1435
+
1436
+ **接口概览**:3 props
1437
+
1438
+ **用法示例**
1439
+
1440
+ ```vue
1441
+ <script setup lang="ts">
1442
+ import { ZlAppSlogan } from '@zl-ui-kit/components'
1443
+ </script>
1444
+
1445
+ <template>
1446
+ <ZlAppSlogan title="ZL UI 组件库" />
1447
+ </template>
1448
+ ```
1449
+
1450
+ **props**
1451
+
1452
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1453
+ | ----------- | --------- | ------ | ---- | ------------------------------------- | ---- |
1454
+ | `collapsed` | `boolean` | — | 否 | `collapsed` | — |
1455
+ | `logo` | `string` | — | 否 | `logo="https://example.com/logo.png"` | — |
1456
+ | `title` | `string` | — | 否 | `title="标题"` | — |
1457
+
1458
+ #### `ZlAutoTooltip`
1459
+
1460
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAutoTooltip/index.vue`</sub>
1461
+
1462
+ **简介**:文本溢出自动 tooltip:内容超出容器宽度时才出提示,未溢出不出
1463
+
1464
+ **接口概览**:1 插槽
1465
+
1466
+ **用法示例**
1467
+
1468
+ ```vue
1469
+ <script setup lang="ts">
1470
+ import { ZlAutoTooltip } from '@zl-ui-kit/components'
1471
+ </script>
1472
+
1473
+ <template>
1474
+ <ZlAutoTooltip> 超长文本自动省略并悬浮提示:zl-ui 是 Vue3 + Element Plus 组件库 </ZlAutoTooltip>
1475
+ </template>
1476
+ ```
1477
+
1478
+ **插槽用法**
1479
+
1480
+ ```vue
1481
+ <template>
1482
+ <ZlAutoTooltip>
1483
+ <template #default>…</template>
1484
+ </ZlAutoTooltip>
1485
+ </template>
1486
+ ```
1487
+
1488
+ **插槽(slots)**
1489
+
1490
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1491
+ | --------- | ---------- | --------------------------------- | ---- |
1492
+ | `default` | — | `<template #default>…</template>` | — |
1493
+
1494
+ #### `ZlAvatar`
1495
+
1496
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAvatar/index.vue`</sub>
1497
+
1498
+ **接口概览**:3 props
1499
+
1500
+ **用法示例**
1501
+
1502
+ ```vue
1503
+ <script setup lang="ts">
1504
+ import { ZlAvatar } from '@zl-ui-kit/components'
1505
+ </script>
1506
+
1507
+ <template>
1508
+ <ZlAvatar label="湛" size="40px" />
1509
+ </template>
1510
+ ```
1511
+
1512
+ **props**
1513
+
1514
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1515
+ | ---------- | -------- | -------- | ---- | -------------------------------------------- | ---------------- |
1516
+ | `imageUrl` | `string` | — | 否 | `image-url="https://example.com/avatar.png"` | — |
1517
+ | `label` | `string` | — | 否 | `label="标签"` | — |
1518
+ | `size` | `string` | `'20px'` | 否 | `size="24px"` | 尺寸(CSS 长度) |
1519
+
1520
+ #### `ZlAvatarGroup`
1521
+
1522
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlAvatar/Group.vue`</sub>
1523
+
1524
+ **接口概览**:3 props
1525
+
1526
+ **用法示例**
1527
+
1528
+ ```vue
1529
+ <script setup lang="ts">
1530
+ import { ZlAvatarGroup } from '@zl-ui-kit/components'
1531
+ </script>
1532
+
1533
+ <template>
1534
+ <ZlAvatarGroup :list="list" size="32px" />
1535
+ </template>
1536
+ ```
1537
+
1538
+ > 示例中的 `list` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1539
+
1540
+ **props**
1541
+
1542
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1543
+ | ------- | --------------------------------------- | -------------------------------------------------- | ---- | -------------- | ----------------------------------- |
1544
+ | `list` | `Array<Record<string, any>>` | — | 是 | `:list="list"` | — |
1545
+ | `props` | `{ imageUrl?: string; label?: string }` | `() => ({ imageUrl: 'imageUrl', label: 'label' })` | 否 | `:props="{}"` | 字段映射(imageUrl/label 的取值键) |
1546
+ | `size` | `string` | — | 否 | `size="24px"` | — |
1547
+
1548
+ #### `ZlCard`
1549
+
1550
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlCard/index.vue`</sub>
1551
+
1552
+ **简介**:卡片容器:默认带悬停阴影(`hoverable`),内容走默认插槽
1553
+
1554
+ **接口概览**:1 props · 8 插槽
1555
+
1556
+ **用法示例**
1557
+
1558
+ ```vue
1559
+ <script setup lang="ts">
1560
+ import { ZlCard } from '@zl-ui-kit/components'
1561
+ </script>
1562
+
1563
+ <template>
1564
+ <ZlCard style="max-width: 360px">
1565
+ <template #title>数据库资源</template>
1566
+ <template #subtitle>副标题描述文案</template>
1567
+ </ZlCard>
1568
+ </template>
1569
+ ```
1570
+
1571
+ **插槽用法**
1572
+
1573
+ ```vue
1574
+ <template>
1575
+ <ZlCard>
1576
+ <template #icon>…</template>
1577
+ <template #title>…</template>
1578
+ <template #title-append>…</template>
1579
+ <template #subtitle>…</template>
1580
+ <template #default>…</template>
1581
+ <template #footer-prepend>…</template>
1582
+ <template #footer>…</template>
1583
+ <template #extra>…</template>
1584
+ </ZlCard>
1585
+ </template>
1586
+ ```
1587
+
1588
+ **props**
1589
+
1590
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1591
+ | ----------- | --------- | ------ | ---- | -------------------- | ---- |
1592
+ | `hoverable` | `boolean` | `true` | 否 | `:hoverable="false"` | — |
1593
+
1594
+ **插槽(slots)**
1595
+
1596
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1597
+ | ---------------- | ---------- | ---------------------------------------- | ---- |
1598
+ | `icon` | — | `<template #icon>…</template>` | — |
1599
+ | `title` | — | `<template #title>…</template>` | — |
1600
+ | `title-append` | — | `<template #title-append>…</template>` | — |
1601
+ | `subtitle` | — | `<template #subtitle>…</template>` | — |
1602
+ | `default` | — | `<template #default>…</template>` | — |
1603
+ | `footer-prepend` | — | `<template #footer-prepend>…</template>` | — |
1604
+ | `footer` | — | `<template #footer>…</template>` | — |
1605
+ | `extra` | — | `<template #extra>…</template>` | — |
1606
+
1607
+ #### `ZlCardPage`
1608
+
1609
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlCardPage/index.vue`</sub>
1610
+
1611
+ **简介**:直接传 service
1612
+
1613
+ **接口概览**:6 props · 1 事件 · 3 插槽 · 3 暴露
1614
+
1615
+ **用法示例**
1616
+
1617
+ ```vue
1618
+ <script setup lang="ts">
1619
+ import { ZlCardPage } from '@zl-ui-kit/components'
1620
+ </script>
1621
+
1622
+ <template>
1623
+ <ZlCardPage :request="mockPageRequest" card-min-width="180px" />
1624
+ </template>
1625
+ ```
1626
+
1627
+ > 示例中的 `request` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1628
+
1629
+ **插槽用法**
1630
+
1631
+ ```vue
1632
+ <template>
1633
+ <ZlCardPage>
1634
+ <template #search-actions>…</template>
1635
+ <template #default="{ data }">…</template>
1636
+ <!-- 动态插槽:名字运行时取自 search-${slot} -->
1637
+ </ZlCardPage>
1638
+ </template>
1639
+ ```
1640
+
1641
+ **props**
1642
+
1643
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1644
+ | -------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------- | ---- | --------------------------- | --------------------------------- |
1645
+ | `immediate` | `boolean` | `true` | 否 | `:immediate="false"` | — |
1646
+ | `request` | `\| ((...args: any[]) => Promise<any>) \| { service: (...args: any[]) => Promise<any>; options?: Record<string, any> }` | — | 是 | `:request="async () => {}"` | 请求函数,或 { service, options } |
1647
+ | `queryItems` | `SearchItem[]` | `() => []` | 否 | `:query-items="queryItems"` | — |
1648
+ | `pagination` | `Record<string, any> \| boolean` | `true` | 否 | `:pagination="{}"` | — |
1649
+ | `itemKey` | `string` | `'id'` | 否 | `item-key="id"` | — |
1650
+ | `cardMinWidth` | `string` | — | 否 | `card-min-width="280px"` | — |
1651
+
1652
+ **事件(emits)**
1653
+
1654
+ | 事件 | 参数 | 说明 |
1655
+ | -------------- | ---- | ---- |
1656
+ | `search-reset` | — | — |
1657
+
1658
+ **插槽(slots)**
1659
+
1660
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1661
+ | ------------------ | ------------------------------ | -------------------------------------------------- | ---------------------------- |
1662
+ | `search-actions` | — | `<template #search-actions>…</template>` | — |
1663
+ | `[search-${slot}]` | `v-bind="scope"` 展开 | `<template #[search-${slot}]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
1664
+ | `default` | `v-bind="{ data: item }"` 展开 | `<template #default="{ data }">…</template>` | — |
1665
+
1666
+ **暴露(defineExpose)**
1667
+
1668
+ | 名称 | 说明 |
1669
+ | --------- | ---- |
1670
+ | `refresh` | — |
1671
+ | `params` | — |
1672
+ | `search` | — |
1673
+
1674
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ② ZlCardPage —— 直接传 service
1675
+
1676
+ #### `ZlCheckAll`
1677
+
1678
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlCheckAll/index.vue`</sub>
1679
+
1680
+ **简介**:全选开关:勾选/取消全部(支持半选态),选项可带 disabled
1681
+
1682
+ **接口概览**:2 props · 1 事件
1683
+
1684
+ **用法示例**
1685
+
1686
+ ```vue
1687
+ <script setup lang="ts">
1688
+ import { ZlCheckAll } from '@zl-ui-kit/components'
1689
+ </script>
1690
+
1691
+ <template>
1692
+ <ZlCheckAll :model-value="modelValue" />
1693
+ </template>
1694
+ ```
1695
+
1696
+ > 示例中的 `modelValue` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1697
+
1698
+ **props**
1699
+
1700
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1701
+ | --------- | ------------------------- | ---------- | ---- | ----------------------- | ---- |
1702
+ | `options` | `CheckAllOption[]` | `() => []` | 否 | `:options="options"` | — |
1703
+ | `model` | `Array<string \| number>` | `() => []` | 否 | `v-model:model="value"` | — |
1704
+
1705
+ **事件(emits)**
1706
+
1707
+ | 事件 | 参数 | 说明 |
1708
+ | -------------- | ------------------------- | ---- |
1709
+ | `update:model` | `Array<string \| number>` | — |
1710
+
1711
+ **完整示例**:见 §7 表单与交互组件 › ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
1712
+
1713
+ #### `ZlCheckboxTag`
1714
+
1715
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlCheckboxTag/index.vue`</sub>
1716
+
1717
+ **接口概览**:7 props · 1 事件 · 1 插槽
1718
+
1719
+ **用法示例**
1720
+
1721
+ ```vue
1722
+ <script setup lang="ts">
1723
+ import { ZlCheckboxTag } from '@zl-ui-kit/components'
1724
+ </script>
1725
+
1726
+ <template>
1727
+ <ZlCheckboxTag v-model="value" />
1728
+ </template>
1729
+ ```
1730
+
1731
+ **插槽用法**
1732
+
1733
+ ```vue
1734
+ <template>
1735
+ <ZlCheckboxTag>
1736
+ <template #default="{ item, checked }">…</template>
1737
+ </ZlCheckboxTag>
1738
+ </template>
1739
+ ```
1740
+
1741
+ **props**
1742
+
1743
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1744
+ | ------------ | ------------------------------- | ---------- | ---- | -------------------- | -------------------------------------------- |
1745
+ | `modelValue` | `any` | — | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
1746
+ | `options` | `CheckboxTagOption[]` | `() => []` | 否 | `:options="options"` | — |
1747
+ | `single` | `boolean` | — | 否 | `single` | 单选模式(值为单值) |
1748
+ | `rounded` | `boolean` | `true` | 否 | `:rounded="false"` | — |
1749
+ | `bordered` | `boolean` | `true` | 否 | `:bordered="false"` | — |
1750
+ | `fill` | `boolean` | `true` | 否 | `:fill="false"` | — |
1751
+ | `size` | `'mini' \| 'small' \| 'medium'` | `'small'` | 否 | `size="mini"` | — |
1752
+
1753
+ **事件(emits)**
1754
+
1755
+ | 事件 | 参数 | 说明 |
1756
+ | ------------------- | ----- | -------------- |
1757
+ | `update:modelValue` | `any` | `v-model` 更新 |
1758
+
1759
+ **插槽(slots)**
1760
+
1761
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1762
+ | --------- | ------------------------------------------------------------- | ----------------------------------------------------- | ---- |
1763
+ | `default` | `v-bind="{ item, checked: checkedSet.has(item.value) }"` 展开 | `<template #default="{ item, checked }">…</template>` | — |
1764
+
1765
+ **完整示例**:见 §7 表单与交互组件 › ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
1766
+
1767
+ #### `ZlCopy`
1768
+
1769
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlCopy/index.vue`</sub>
1770
+
1771
+ **简介**:一键复制
1772
+
1773
+ **接口概览**:2 props · 2 插槽
1774
+
1775
+ **用法示例**
1776
+
1777
+ ```vue
1778
+ <script setup lang="ts">
1779
+ import { ZlCopy } from '@zl-ui-kit/components'
1780
+ </script>
1781
+
1782
+ <template>
1783
+ <ZlCopy text="被复制的文本内容" />
1784
+ </template>
1785
+ ```
1786
+
1787
+ **插槽用法**
1788
+
1789
+ ```vue
1790
+ <template>
1791
+ <ZlCopy>
1792
+ <template #default>…</template>
1793
+ <template #trigger="{ copy }">…</template>
1794
+ </ZlCopy>
1795
+ </template>
1796
+ ```
1797
+
1798
+ **props**
1799
+
1800
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1801
+ | ---------- | -------- | ------ | ---- | ---------------------- | ---- |
1802
+ | `text` | `string` | — | 否 | `text="文本"` | — |
1803
+ | `copyText` | `string` | — | 否 | `copy-text="复制内容"` | — |
1804
+
1805
+ **插槽(slots)**
1806
+
1807
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1808
+ | --------- | ---------- | -------------------------------------------- | ---- |
1809
+ | `default` | — | `<template #default>…</template>` | — |
1810
+ | `trigger` | `copy` | `<template #trigger="{ copy }">…</template>` | — |
1811
+
1812
+ **完整示例**:见 §5 通用展示组件 › ZlCopy — 一键复制
1813
+
1814
+ #### `ZlDescription`
1815
+
1816
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlDescription/index.vue`</sub>
1817
+
1818
+ **接口概览**:5 props · 1 插槽
1819
+
1820
+ **用法示例**
1821
+
1822
+ ```vue
1823
+ <script setup lang="ts">
1824
+ import { ZlDescription } from '@zl-ui-kit/components'
1825
+ </script>
1826
+
1827
+ <template>
1828
+ <ZlDescription :items="items" :data="{ name: '订单-1024', type: 'API', count: 32 }" secondary />
1829
+ </template>
1830
+ ```
1831
+
1832
+ > 示例中的 `items`、`data` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1833
+
1834
+ **插槽用法**
1835
+
1836
+ ```vue
1837
+ <template>
1838
+ <ZlDescription>
1839
+ <!-- 动态插槽:名字运行时取自 item.key -->
1840
+ </ZlDescription>
1841
+ </template>
1842
+ ```
1843
+
1844
+ **props**
1845
+
1846
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1847
+ | -------------- | ----------------------------------------------------------------- | -------------------------------------- | ---- | --------------------------- | -------------------------------------------------------------------- |
1848
+ | `items` | `DescriptionItem[]` | — | 是 | `:items="items"` | — |
1849
+ | `data` | `Record<string, any>` | `() => ({})` | 否 | `:data="{}"` | — |
1850
+ | `emptyChecker` | `(value: any, key: string, data: Record<string, any>) => boolean` | `(val: any) => !val && !isNumber(val)` | 否 | `:empty-checker="() => {}"` | — |
1851
+ | `emptyText` | `string` | — | 否 | `empty-text="暂无数据"` | 空值占位文案(缺省走 i18n zl.description.empty,未接入时兜底"暂无") |
1852
+ | `secondary` | `boolean` | — | 否 | `secondary` | — |
1853
+
1854
+ **插槽(slots)**
1855
+
1856
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1857
+ | ------------ | ---------- | ------------------------------------ | ---------------------------- |
1858
+ | `[item.key]` | — | `<template #[item.key]>…</template>` | 动态插槽:名字由该表达式决定 |
1859
+
1860
+ #### `ZlDictTag`
1861
+
1862
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlDictTag/index.vue`</sub>
1863
+
1864
+ **简介**:字典标签
1865
+
1866
+ **接口概览**:6 props
1867
+
1868
+ **用法示例**
1869
+
1870
+ ```vue
1871
+ <script setup lang="ts">
1872
+ import { ZlDictTag } from '@zl-ui-kit/components'
1873
+ </script>
1874
+
1875
+ <template>
1876
+ <ZlDictTag dict-key="resourceType" value="1" :dict="dict" />
1877
+ </template>
1878
+ ```
1879
+
1880
+ > 示例中的 `dict` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1881
+
1882
+ **props**
1883
+
1884
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1885
+ | ---------- | ------------------------------------------------------------------------- | ------- | ---- | ------------------- | ------------------------------------------------------------------------------------------------- |
1886
+ | `dictKey` | `string` | — | 是 | `dict-key="gender"` | 字典键(对应全局字典缓存的键;外部直传数据也以该键写入共享缓存) |
1887
+ | `dict` | `DictItem[]` | — | 否 | `:dict="dict"` | 外部直传字典数据:无需依赖全局数据源即可翻译。格式同 DictItem[]({ label, value, icon?, type? }) |
1888
+ | `corner` | `boolean \| 'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `false` | 否 | `corner="top-left"` | — |
1889
+ | `value` | `string` | — | 否 | `value="1"` | — |
1890
+ | `simple` | `boolean` | — | 否 | `simple` | — |
1891
+ | `hideIcon` | `boolean` | — | 否 | `hide-icon` | — |
1892
+
1893
+ > 把 `$attrs` 透传给 `zl-corner-tag`,未列出的属性会继续下传
1894
+
1895
+ **完整示例**:见 §5 通用展示组件 › ZlDictTag — 字典标签
1896
+
1897
+ #### `ZlDrawer`
1898
+
1899
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlDrawer/index.vue`</sub>
1900
+
1901
+ **接口概览**:6 props · 1 事件 · 2 插槽
1902
+
1903
+ **用法示例**
1904
+
1905
+ ```vue
1906
+ <script setup lang="ts">
1907
+ import { ZlDrawer } from '@zl-ui-kit/components'
1908
+ </script>
1909
+
1910
+ <template>
1911
+ <ZlDrawer v-model:visible="value" title="抽屉标题" />
1912
+ </template>
1913
+ ```
1914
+
1915
+ **插槽用法**
1916
+
1917
+ ```vue
1918
+ <template>
1919
+ <ZlDrawer>
1920
+ <template #default>…</template>
1921
+ <template #footer>…</template>
1922
+ </ZlDrawer>
1923
+ </template>
1924
+ ```
1925
+
1926
+ **props**
1927
+
1928
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1929
+ | ----------------------- | --------------------------------------------------- | ------- | ---- | ----------------------------------- | -------------------------------------------- |
1930
+ | `visible` | `boolean` | `false` | 否 | `v-model:visible="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
1931
+ | `onCancel` | `() => boolean \| void \| Promise<boolean \| void>` | — | 否 | `:on-cancel="async () => {}"` | — |
1932
+ | `onOk` | `() => void \| Promise<void>` | — | 否 | `:on-ok="async () => {}"` | — |
1933
+ | `autoCloseAfterConfirm` | `boolean` | `true` | 否 | `:auto-close-after-confirm="false"` | — |
1934
+ | `readonly` | `boolean` | — | 否 | `readonly` | — |
1935
+ | `loading` | `boolean` | — | 否 | `loading` | — |
1936
+
1937
+ **事件(emits)**
1938
+
1939
+ | 事件 | 参数 | 说明 |
1940
+ | ---------------- | --------- | -------------- |
1941
+ | `update:visible` | `boolean` | `v-model` 更新 |
1942
+
1943
+ **插槽(slots)**
1944
+
1945
+ | 插槽 | 作用域参数 | 示例 | 说明 |
1946
+ | --------- | ---------- | --------------------------------- | ---- |
1947
+ | `default` | — | `<template #default>…</template>` | — |
1948
+ | `footer` | — | `<template #footer>…</template>` | — |
1949
+
1950
+ **完整示例**:见 §7 表单与交互组件 › ZlDrawer / ZlPopconfirm / ZlSwitch
1951
+
1952
+ #### `ZlDynamicComponent`
1953
+
1954
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlDynamicComponent/index.vue`</sub>
1955
+
1956
+ **接口概览**:3 props · 2 事件
1957
+
1958
+ **用法示例**
1959
+
1960
+ ```vue
1961
+ <script setup lang="ts">
1962
+ import { ZlDynamicComponent } from '@zl-ui-kit/components'
1963
+ </script>
1964
+
1965
+ <template>
1966
+ <ZlDynamicComponent :model="{ keyword: '' }" :component="component" />
1967
+ </template>
1968
+ ```
1969
+
1970
+ > 示例中的 `model`、`component` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
1971
+
1972
+ **props**
1973
+
1974
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
1975
+ | ----------- | ---------------------------------- | ----------------------------------- | ---- | ----------------- | ---- |
1976
+ | `model` | `Record<string, any>` | `() => ({})` | 否 | `:model="{}"` | — |
1977
+ | `value` | `[String, Number, Array, Boolean]` | `null` | 否 | `:value="value"` | — |
1978
+ | `component` | `Record<string, any>` | `() => ({ component: 'el-input' })` | 否 | `:component="{}"` | — |
1979
+
1980
+ > 选项式组件(`defineComponent`),props 定义在 `props: {}` 中
1981
+
1982
+ **事件(emits)**
1983
+
1984
+ | 事件 | 参数 | 说明 |
1985
+ | ------------------- | ---- | ---- |
1986
+ | `update:modelValue` | — | — |
1987
+ | `input` | — | — |
1988
+
1989
+ **完整示例**:见 §7 表单与交互组件 › ZlTabs / ZlDynamicComponent / ZlGrid
1990
+
1991
+ #### `ZlPdfViewer`
1992
+
1993
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlPdfViewer/index.vue`</sub>
1994
+
1995
+ **简介**:PDF 预览:用浏览器原生 object 渲染,无重型依赖(所以留在主入口)
1996
+
1997
+ **接口概览**:2 props
1998
+
1999
+ **用法示例**
2000
+
2001
+ ```vue
2002
+ <script setup lang="ts">
2003
+ import { ZlPdfViewer } from '@zl-ui-kit/components'
2004
+ </script>
2005
+
2006
+ <template>
2007
+ <ZlPdfViewer :width="420" />
2008
+ </template>
2009
+ ```
2010
+
2011
+ **props**
2012
+
2013
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2014
+ | ------- | ------------------ | ------ | ---- | ------------------------------------ | ---- |
2015
+ | `url` | `string` | — | 否 | `url="https://example.com/file.pdf"` | — |
2016
+ | `width` | `number \| string` | — | 否 | `:width="width"` | — |
2017
+
2018
+ #### `ZlLogin`
2019
+
2020
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlLogin/index.vue`</sub>
2021
+
2022
+ **接口概览**:2 props · 2 插槽
2023
+
2024
+ **用法示例**
2025
+
2026
+ ```vue
2027
+ <script setup lang="ts">
2028
+ import { ZlLogin } from '@zl-ui-kit/components'
2029
+ </script>
2030
+
2031
+ <template>
2032
+ <ZlLogin :config="{ title: 'ZL 统一登录' }" :on-submit="() => {}" />
2033
+ </template>
2034
+ ```
2035
+
2036
+ > 示例中的 `config`、`onSubmit` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2037
+
2038
+ **插槽用法**
2039
+
2040
+ ```vue
2041
+ <template>
2042
+ <ZlLogin>
2043
+ <template #slogan>…</template>
2044
+ <template #default>…</template>
2045
+ </ZlLogin>
2046
+ </template>
2047
+ ```
2048
+
2049
+ **props**
2050
+
2051
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2052
+ | ---------- | ------------------------------------------------------ | ------------ | ---- | ----------------------------- | ---- |
2053
+ | `onSubmit` | `(form: Record<string, any>) => Promise<void> \| void` | — | 否 | `:on-submit="async () => {}"` | — |
2054
+ | `config` | `ZlLoginConfig` | `() => ({})` | 否 | `:config="config"` | — |
2055
+
2056
+ **插槽(slots)**
2057
+
2058
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2059
+ | --------- | ---------- | --------------------------------- | ---- |
2060
+ | `slogan` | — | `<template #slogan>…</template>` | — |
2061
+ | `default` | — | `<template #default>…</template>` | — |
2062
+
2063
+ #### `ZlLoginForm`
2064
+
2065
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlLogin/components/LoginForm.vue`</sub>
2066
+
2067
+ **简介**:登录表单(账号 + 密码 + 可选滑块校验),提交经 `onSubmit` 回调交给宿主
2068
+
2069
+ **接口概览**:1 props · 1 插槽
2070
+
2071
+ **用法示例**
2072
+
2073
+ ```vue
2074
+ <script setup lang="ts">
2075
+ import { ZlLoginForm } from '@zl-ui-kit/components'
2076
+ </script>
2077
+
2078
+ <template>
2079
+ <ZlLoginForm :on-submit="() => {}" />
2080
+ </template>
2081
+ ```
2082
+
2083
+ > 示例中的 `onSubmit` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2084
+
2085
+ **插槽用法**
2086
+
2087
+ ```vue
2088
+ <template>
2089
+ <ZlLoginForm>
2090
+ <template #action>…</template>
2091
+ </ZlLoginForm>
2092
+ </template>
2093
+ ```
2094
+
2095
+ **props**
2096
+
2097
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2098
+ | ---------- | ------------------------------------------------------ | ------ | ---- | ----------------------------- | ---- |
2099
+ | `onSubmit` | `(form: Record<string, any>) => Promise<void> \| void` | — | 否 | `:on-submit="async () => {}"` | — |
2100
+
2101
+ **插槽(slots)**
2102
+
2103
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2104
+ | -------- | ---------- | -------------------------------- | ---- |
2105
+ | `action` | — | `<template #action>…</template>` | — |
2106
+
2107
+ #### `ZlEmpty`
2108
+
2109
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlEmpty/index.vue`</sub>
2110
+
2111
+ **简介**:空状态
2112
+
2113
+ **接口概览**:2 props
2114
+
2115
+ **用法示例**
2116
+
2117
+ ```vue
2118
+ <script setup lang="ts">
2119
+ import { ZlEmpty } from '@zl-ui-kit/components'
2120
+ </script>
2121
+
2122
+ <template>
2123
+ <ZlEmpty />
2124
+ </template>
2125
+ ```
2126
+
2127
+ **props**
2128
+
2129
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2130
+ | ------- | -------- | ------ | ---- | --------------------------------------- | ------------------------------------------- |
2131
+ | `image` | `string` | — | 否 | `image="https://example.com/empty.png"` | 自定义空状态图片(缺省用内置轻量 SVG 线稿) |
2132
+ | `text` | `string` | `''` | 否 | `text="文本"` | 空状态文案(缺省走 i18n,未接入时兜底中文) |
2133
+
2134
+ **完整示例**:见 §5 通用展示组件 › ZlEmpty — 空状态
2135
+
2136
+ #### `ZlForm`
2137
+
2138
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlForm/index.vue`</sub>
2139
+
2140
+ **简介**:schema 驱动
2141
+
2142
+ **接口概览**:2 props · 3 插槽
2143
+
2144
+ **用法示例**
2145
+
2146
+ ```vue
2147
+ <script setup lang="ts">
2148
+ import { ZlForm } from '@zl-ui-kit/components'
2149
+ </script>
2150
+
2151
+ <template>
2152
+ <ZlForm :model="model" :items="items" label-width="80px" style="max-width: 420px" />
2153
+ </template>
2154
+ ```
2155
+
2156
+ > 示例中的 `model`、`items` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2157
+
2158
+ **插槽用法**
2159
+
2160
+ ```vue
2161
+ <template>
2162
+ <ZlForm>
2163
+ <template #label="{ label, item }">…</template>
2164
+ <template #default>…</template>
2165
+ <!-- 动态插槽:名字运行时取自 item.model -->
2166
+ </ZlForm>
2167
+ </template>
2168
+ ```
2169
+
2170
+ **props**
2171
+
2172
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2173
+ | ------- | --------------------- | ---------- | ---- | ---------------- | ---- |
2174
+ | `items` | `FormItem[]` | `() => []` | 否 | `:items="items"` | — |
2175
+ | `model` | `Record<string, any>` | — | 否 | `:model="{}"` | — |
2176
+
2177
+ > 把 `$attrs` 透传给 `el-form`,未列出的属性会继续下传
2178
+
2179
+ **插槽(slots)**
2180
+
2181
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2182
+ | -------------- | ------------------------------------------- | --------------------------------------------------------- | ---------------------------- |
2183
+ | `label` | `v-bind="{ label: item.label, item }"` 展开 | `<template #label="{ label, item }">…</template>` | — |
2184
+ | `[item.model]` | `model` / `field` | `<template #[item.model]="{ model, field }">…</template>` | 动态插槽:名字由该表达式决定 |
2185
+ | `default` | — | `<template #default>…</template>` | — |
2186
+
2187
+ **完整示例**:见 §7 表单与交互组件 › ZlForm —— schema 驱动
2188
+
2189
+ #### `ZlFormChild`
2190
+
2191
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlForm/ZlFormChild.vue`</sub>
2192
+
2193
+ **接口概览**:1 props
2194
+
2195
+ **用法示例**
2196
+
2197
+ ```vue
2198
+ <script setup lang="ts">
2199
+ import { ZlFormChild } from '@zl-ui-kit/components'
2200
+ </script>
2201
+
2202
+ <template>
2203
+ <ZlFormChild :item="item" />
2204
+ </template>
2205
+ ```
2206
+
2207
+ > 示例中的 `item` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2208
+
2209
+ **props**
2210
+
2211
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2212
+ | ------ | --------------------- | ------ | ---- | ------------ | ---- |
2213
+ | `item` | `Record<string, any>` | — | 是 | `:item="{}"` | — |
2214
+
2215
+ > 选项式组件(`defineComponent`),props 定义在 `props: {}` 中
2216
+
2217
+ #### `ZlGridItem`
2218
+
2219
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlGrid/ZlGridItem.vue`</sub>
2220
+
2221
+ **简介**:单个描述项:由 `ZlGrid` 内部渲染,一般不单独使用
2222
+
2223
+ **接口概览**:1 props · 1 插槽
2224
+
2225
+ **用法示例**
2226
+
2227
+ ```vue
2228
+ <script setup lang="ts">
2229
+ import { ZlGridItem } from '@zl-ui-kit/components'
2230
+ </script>
2231
+
2232
+ <template>
2233
+ <ZlGridItem :item="item" />
2234
+ </template>
2235
+ ```
2236
+
2237
+ > 示例中的 `item` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2238
+
2239
+ **插槽用法**
2240
+
2241
+ ```vue
2242
+ <template>
2243
+ <ZlGridItem>
2244
+ <template #default>…</template>
2245
+ </ZlGridItem>
2246
+ </template>
2247
+ ```
2248
+
2249
+ **props**
2250
+
2251
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2252
+ | ------ | --------------------------------------------------------------------------------- | ------ | ---- | -------------- | ---- |
2253
+ | `item` | `IGridItem & { text?: any; size?: number \| 'auto'; dict?: Record<string, any> }` | — | 是 | `:item="item"` | — |
2254
+
2255
+ **插槽(slots)**
2256
+
2257
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2258
+ | --------- | ---------- | --------------------------------- | ---- |
2259
+ | `default` | — | `<template #default>…</template>` | — |
2260
+
2261
+ #### `ZlGrid`
2262
+
2263
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlGrid/index.vue`</sub>
2264
+
2265
+ **接口概览**:9 props · 2 插槽
2266
+
2267
+ **用法示例**
2268
+
2269
+ ```vue
2270
+ <script setup lang="ts">
2271
+ import { ZlGrid } from '@zl-ui-kit/components'
2272
+ </script>
2273
+
2274
+ <template>
2275
+ <ZlGrid :data="data" :cols="2" border :grid="grid" />
2276
+ </template>
2277
+ ```
2278
+
2279
+ > 示例中的 `data`、`grid` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2280
+
2281
+ **插槽用法**
2282
+
2283
+ ```vue
2284
+ <template>
2285
+ <ZlGrid>
2286
+ <template #default>…</template>
2287
+ <!-- 动态插槽:名字运行时取自 item.key -->
2288
+ </ZlGrid>
2289
+ </template>
2290
+ ```
2291
+
2292
+ **props**
2293
+
2294
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2295
+ | --------------- | ----------------------------------------------------------------- | ------------ | ---- | --------------------------- | ------------------------------------------------------------- |
2296
+ | `data` | `Record<string, any>` | `() => ({})` | 否 | `:data="{}"` | — |
2297
+ | `grid` | `IGridItem[]` | `() => []` | 否 | `:grid="grid"` | — |
2298
+ | `cols` | `number` | `3` | 否 | `:cols="1"` | — |
2299
+ | `border` | `boolean` | — | 否 | `border` | — |
2300
+ | `emptyChecker` | `(value: any, key: string, data: Record<string, any>) => boolean` | — | 否 | `:empty-checker="() => {}"` | — |
2301
+ | `labelWidth` | `string \| number` | `'auto'` | 否 | `:label-width="labelWidth"` | — |
2302
+ | `labelSuffix` | `string` | — | 否 | `label-suffix=":"` | — |
2303
+ | `labelPosition` | `'left' \| 'top' \| 'right'` | `'left'` | 否 | `label-position="left"` | — |
2304
+ | `emptyText` | `string` | — | 否 | `empty-text="暂无数据"` | 空值占位文案(缺省走 i18n zl.grid.empty,未接入时兜底"暂无") |
2305
+
2306
+ **插槽(slots)**
2307
+
2308
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2309
+ | ------------ | ---------- | ------------------------------------ | ---------------------------- |
2310
+ | `[item.key]` | — | `<template #[item.key]>…</template>` | 动态插槽:名字由该表达式决定 |
2311
+ | `default` | — | `<template #default>…</template>` | — |
2312
+
2313
+ **完整示例**:见 §7 表单与交互组件 › ZlTabs / ZlDynamicComponent / ZlGrid
2314
+
2315
+ #### `ZlHorizontalTable`
2316
+
2317
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlHorizontalTable/index.vue`</sub>
2318
+
2319
+ **接口概览**:4 props · 1 插槽
2320
+
2321
+ **用法示例**
2322
+
2323
+ ```vue
2324
+ <script setup lang="ts">
2325
+ import { ZlHorizontalTable } from '@zl-ui-kit/components'
2326
+ </script>
2327
+
2328
+ <template>
2329
+ <ZlHorizontalTable :items="items" :span="12" />
2330
+ </template>
2331
+ ```
2332
+
2333
+ > 示例中的 `items` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2334
+
2335
+ **插槽用法**
2336
+
2337
+ ```vue
2338
+ <template>
2339
+ <ZlHorizontalTable>
2340
+ <!-- 动态插槽:名字运行时取自 item.slot -->
2341
+ </ZlHorizontalTable>
2342
+ </template>
2343
+ ```
2344
+
2345
+ **props**
2346
+
2347
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2348
+ | ------------ | ----------------------- | ---------- | ---- | --------------------- | ---- |
2349
+ | `items` | `HorizontalTableItem[]` | `() => []` | 否 | `:items="items"` | — |
2350
+ | `span` | `number \| string` | `24` | 否 | `:span="span"` | — |
2351
+ | `labelWidth` | `string` | `'88px'` | 否 | `label-width="100px"` | — |
2352
+ | `labelAlign` | `string` | `'center'` | 否 | `label-align="left"` | — |
2353
+
2354
+ **插槽(slots)**
2355
+
2356
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2357
+ | ------------- | -------------------- | -------------------------------------------- | ---------------------------- |
2358
+ | `[item.slot]` | `v-bind="item"` 展开 | `<template #[item.slot]="item">…</template>` | 动态插槽:名字由该表达式决定 |
2359
+
2360
+ **完整示例**:见 §8 布局与权限 › ZlHorizontalTable
2361
+
2362
+ #### `ZlIcon`
2363
+
2364
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlIcon/index.vue`</sub>
2365
+
2366
+ **接口概览**:1 props · 1 插槽
2367
+
2368
+ **用法示例**
2369
+
2370
+ ```vue
2371
+ <script setup lang="ts">
2372
+ import { ZlIcon } from '@zl-ui-kit/components'
2373
+ </script>
2374
+
2375
+ <template>
2376
+ <ZlIcon icon="zl:bug" />
2377
+ </template>
2378
+ ```
2379
+
2380
+ **插槽用法**
2381
+
2382
+ ```vue
2383
+ <template>
2384
+ <ZlIcon>
2385
+ <template #default>…</template>
2386
+ </ZlIcon>
2387
+ </template>
2388
+ ```
2389
+
2390
+ **props**
2391
+
2392
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2393
+ | ------ | -------- | ------ | ---- | ------------------ | --------------------------------------------------------------- |
2394
+ | `icon` | `string` | — | 是 | `icon="zl:search"` | 图标:zl:xxx(本地图标集)/ http(s) 地址 / 本地 svg sprite 名称 |
2395
+
2396
+ **插槽(slots)**
2397
+
2398
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2399
+ | --------- | ---------- | --------------------------------- | ---- |
2400
+ | `default` | — | `<template #default>…</template>` | — |
2401
+
2402
+ #### `ZlI18nProvider`
2403
+
2404
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlI18nProvider/index.vue`</sub>
2405
+
2406
+ **简介**:国际化根容器:将全局数据里的 Element Plus 语言包(elLocaleMessages) 经 <el-config-provider> 绑定到 Element Plus,使分页/日期选择器等内置组件 随应用语言切换而本地化。 用法:在应用根(或子树根)包裹一次即可。 <ZlI18nProvider> <A…
2407
+
2408
+ **接口概览**:1 插槽
2409
+
2410
+ **用法示例**
2411
+
2412
+ ```vue
2413
+ <script setup lang="ts">
2414
+ import { ZlI18nProvider } from '@zl-ui-kit/components'
2415
+ </script>
2416
+
2417
+ <template>
2418
+ <ZlI18nProvider />
2419
+ </template>
2420
+ ```
2421
+
2422
+ **插槽用法**
2423
+
2424
+ ```vue
2425
+ <template>
2426
+ <ZlI18nProvider>
2427
+ <template #default>…</template>
2428
+ </ZlI18nProvider>
2429
+ </template>
2430
+ ```
2431
+
2432
+ **插槽(slots)**
2433
+
2434
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2435
+ | --------- | ---------- | --------------------------------- | ---- |
2436
+ | `default` | — | `<template #default>…</template>` | — |
2437
+
2438
+ #### `ZlIconHover`
2439
+
2440
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlIconHover/index.vue`</sub>
2441
+
2442
+ **简介**:悬停变色的图标:内部复用 `ZlIconLabel`,仅换配色
2443
+
2444
+ **用法示例**
2445
+
2446
+ ```vue
2447
+ <script setup lang="ts">
2448
+ import { ZlIconHover } from '@zl-ui-kit/components'
2449
+ </script>
2450
+
2451
+ <template>
2452
+ <ZlIconHover icon="zl:setting"> 悬浮操作 </ZlIconHover>
2453
+ </template>
2454
+ ```
2455
+
2456
+ > 纯容器组件:不接收 props,也无自定义事件/插槽/暴露方法。
2457
+
2458
+ #### `ZlIconLabel`
2459
+
2460
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlIconLabel/index.vue`</sub>
2461
+
2462
+ **接口概览**:1 props · 1 事件 · 1 插槽
2463
+
2464
+ **用法示例**
2465
+
2466
+ ```vue
2467
+ <script setup lang="ts">
2468
+ import { ZlIconLabel } from '@zl-ui-kit/components'
2469
+ </script>
2470
+
2471
+ <template>
2472
+ <ZlIconLabel icon="zl:database"> 图标 + 文字 </ZlIconLabel>
2473
+ </template>
2474
+ ```
2475
+
2476
+ **插槽用法**
2477
+
2478
+ ```vue
2479
+ <template>
2480
+ <ZlIconLabel>
2481
+ <template #default>…</template>
2482
+ </ZlIconLabel>
2483
+ </template>
2484
+ ```
2485
+
2486
+ **props**
2487
+
2488
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2489
+ | ------------- | --------- | ------- | ---- | -------------- | ------------------------ |
2490
+ | `darkSurface` | `boolean` | `false` | 否 | `dark-surface` | 深色表面(悬浮背景更深) |
2491
+
2492
+ > 把 `$attrs` 透传给 `zl-icon`,未列出的属性会继续下传
2493
+
2494
+ **事件(emits)**
2495
+
2496
+ | 事件 | 参数 | 说明 |
2497
+ | ------- | ------------ | ---- |
2498
+ | `click` | `MouseEvent` | — |
2499
+
2500
+ **插槽(slots)**
2501
+
2502
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2503
+ | --------- | ---------- | --------------------------------- | ---- |
2504
+ | `default` | — | `<template #default>…</template>` | — |
2505
+
2506
+ #### `ZlCornerTag`
2507
+
2508
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTag/ZlCornerTag.vue`</sub>
2509
+
2510
+ **简介**:角落标签:贴在容器四个角(`position`),常用于「新」「热」等标记
2511
+
2512
+ **接口概览**:3 props · 1 插槽
2513
+
2514
+ **用法示例**
2515
+
2516
+ ```vue
2517
+ <script setup lang="ts">
2518
+ import { ZlCornerTag } from '@zl-ui-kit/components'
2519
+ </script>
2520
+
2521
+ <template>
2522
+ <ZlCornerTag color="purple"> 角标 </ZlCornerTag>
2523
+ </template>
2524
+ ```
2525
+
2526
+ **插槽用法**
2527
+
2528
+ ```vue
2529
+ <template>
2530
+ <ZlCornerTag>
2531
+ <template #default>…</template>
2532
+ </ZlCornerTag>
2533
+ </template>
2534
+ ```
2535
+
2536
+ **props**
2537
+
2538
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2539
+ | ---------- | -------------------------------------------------------------- | ------------- | ---- | --------------------- | ---- |
2540
+ | `icon` | `string` | — | 否 | `icon="zl:search"` | — |
2541
+ | `color` | `string` | — | 否 | `color="#409eff"` | — |
2542
+ | `position` | `'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `'top-right'` | 否 | `position="top-left"` | — |
2543
+
2544
+ **插槽(slots)**
2545
+
2546
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2547
+ | --------- | ---------- | --------------------------------- | ---- |
2548
+ | `default` | — | `<template #default>…</template>` | — |
2549
+
2550
+ #### `ZlLayoutSwitch`
2551
+
2552
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlLayoutSwitch/index.vue`</sub>
2553
+
2554
+ **简介**:布局切换:在网格视图(grid)与表格视图(table)之间切换
2555
+
2556
+ **接口概览**:2 props · 1 事件
2557
+
2558
+ **用法示例**
2559
+
2560
+ ```vue
2561
+ <script setup lang="ts">
2562
+ import { ZlLayoutSwitch } from '@zl-ui-kit/components'
2563
+ </script>
2564
+
2565
+ <template>
2566
+ <ZlLayoutSwitch v-model="value" />
2567
+ </template>
2568
+ ```
2569
+
2570
+ **props**
2571
+
2572
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2573
+ | ------------ | ------------------- | -------- | ---- | ----------------- | -------------------------------------------- |
2574
+ | `modelValue` | `'grid' \| 'table'` | — | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
2575
+ | `value` | `'grid' \| 'table'` | `'grid'` | 否 | `value="grid"` | — |
2576
+
2577
+ **事件(emits)**
2578
+
2579
+ | 事件 | 参数 | 说明 |
2580
+ | ------------------- | ------------------- | -------------- |
2581
+ | `update:modelValue` | `'grid' \| 'table'` | `v-model` 更新 |
2582
+
2583
+ **完整示例**:见 §7 表单与交互组件 › ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
2584
+
2585
+ #### `ZlPagination`
2586
+
2587
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlPagination/index.vue`</sub>
2588
+
2589
+ **简介**:自行 usePaginationRequest
2590
+
2591
+ **接口概览**:3 props · 3 事件
2592
+
2593
+ **用法示例**
2594
+
2595
+ ```vue
2596
+ <script setup lang="ts">
2597
+ import { ZlPagination } from '@zl-ui-kit/components'
2598
+ </script>
2599
+
2600
+ <template>
2601
+ <ZlPagination :total="120" :page-num="1" :page-size="30" />
2602
+ </template>
2603
+ ```
2604
+
2605
+ **props**
2606
+
2607
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2608
+ | ------------- | ------------ | ------ | ---- | ----------------------------- | ---------------------------------- |
2609
+ | `pageNum` | `(未声明)` | — | 否 | `:page-num="pageNum"` | 运行时从 `$attrs` 读取,无类型约束 |
2610
+ | `pageSize` | `(未声明)` | — | 否 | `:page-size="pageSize"` | 运行时从 `$attrs` 读取,无类型约束 |
2611
+ | `currentPage` | `(未声明)` | — | 否 | `:current-page="currentPage"` | 运行时从 `$attrs` 读取,无类型约束 |
2612
+
2613
+ > 本组件不声明 props,入参由 `$attrs` 动态读取
2614
+
2615
+ **事件(emits)**
2616
+
2617
+ | 事件 | 参数 | 说明 |
2618
+ | ------------------ | --------------------------------------- | ---------------------------------- |
2619
+ | `change` | `{ pageNum: number; pageSize: number }` | — |
2620
+ | `page-change` | `number` | 仅页码变化(区别于 pageSize 变化) |
2621
+ | `page-size-change` | `number` | 仅每页条数变化 |
2622
+
2623
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ③ ZlTable + ZlPagination —— 自行 usePaginationRequest
2624
+
2625
+ #### `ZlPermission`
2626
+
2627
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlPermission/index.vue`</sub>
2628
+
2629
+ **接口概览**:1 props · 1 插槽
2630
+
2631
+ **用法示例**
2632
+
2633
+ ```vue
2634
+ <script setup lang="ts">
2635
+ import { ZlPermission } from '@zl-ui-kit/components'
2636
+ </script>
2637
+
2638
+ <template>
2639
+ <ZlPermission permission="table:edit:*" />
2640
+ </template>
2641
+ ```
2642
+
2643
+ **插槽用法**
2644
+
2645
+ ```vue
2646
+ <template>
2647
+ <ZlPermission>
2648
+ <template #default>…</template>
2649
+ </ZlPermission>
2650
+ </template>
2651
+ ```
2652
+
2653
+ **props**
2654
+
2655
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2656
+ | ------------ | -------------------- | ------ | ---- | ------------------ | ---------------------------------------- |
2657
+ | `permission` | `string \| string[]` | — | 是 | `:permission="[]"` | 权限键(三段式,可传多个任一命中即显示) |
2658
+
2659
+ **插槽(slots)**
2660
+
2661
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2662
+ | --------- | ---------- | --------------------------------- | ---- |
2663
+ | `default` | — | `<template #default>…</template>` | — |
2664
+
2665
+ **完整示例**:见 §8 布局与权限 › ZlPermission
2666
+
2667
+ #### `ZlPopconfirm`
2668
+
2669
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlPopconfirm/index.vue`</sub>
2670
+
2671
+ **简介**:气泡确认框:点击触发气泡二次确认,文案可被 i18n 覆盖
2672
+
2673
+ **接口概览**:4 props · 2 事件 · 3 插槽
2674
+
2675
+ **用法示例**
2676
+
2677
+ ```vue
2678
+ <script setup lang="ts">
2679
+ import { ZlPopconfirm } from '@zl-ui-kit/components'
2680
+ </script>
2681
+
2682
+ <template>
2683
+ <ZlPopconfirm title="确认删除?" content="删除后不可恢复" />
2684
+ </template>
2685
+ ```
2686
+
2687
+ **插槽用法**
2688
+
2689
+ ```vue
2690
+ <template>
2691
+ <ZlPopconfirm>
2692
+ <template #default>…</template>
2693
+ <template #title>…</template>
2694
+ <template #content>…</template>
2695
+ </ZlPopconfirm>
2696
+ </template>
2697
+ ```
2698
+
2699
+ **props**
2700
+
2701
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2702
+ | ------------------- | -------- | ------ | ---- | -------------------------------------- | ---- |
2703
+ | `title` | `string` | — | 否 | `title="标题"` | — |
2704
+ | `content` | `string` | — | 否 | `content="删除后不可恢复,是否继续?"` | — |
2705
+ | `confirmButtonText` | `string` | — | 否 | `confirm-button-text="确定"` | — |
2706
+ | `cancelButtonText` | `string` | — | 否 | `cancel-button-text="取消"` | — |
2707
+
2708
+ > 把 `$attrs` 透传给 `el-popover`,未列出的属性会继续下传
2709
+
2710
+ **事件(emits)**
2711
+
2712
+ | 事件 | 参数 | 说明 |
2713
+ | --------- | ---- | ---- |
2714
+ | `confirm` | — | — |
2715
+ | `cancel` | — | — |
2716
+
2717
+ **插槽(slots)**
2718
+
2719
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2720
+ | --------- | ---------- | --------------------------------- | ---- |
2721
+ | `default` | — | `<template #default>…</template>` | — |
2722
+ | `title` | — | `<template #title>…</template>` | — |
2723
+ | `content` | — | `<template #content>…</template>` | — |
2724
+
2725
+ **完整示例**:见 §7 表单与交互组件 › ZlDrawer / ZlPopconfirm / ZlSwitch
2726
+
2727
+ #### `ZlRadioTag`
2728
+
2729
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlRadioTag/index.vue`</sub>
2730
+
2731
+ **简介**:单选标签组:以标签形式做单选,选项支持图标与 disabled
2732
+
2733
+ **接口概览**:3 props · 1 事件 · 1 插槽
2734
+
2735
+ **用法示例**
2736
+
2737
+ ```vue
2738
+ <script setup lang="ts">
2739
+ import { ZlRadioTag } from '@zl-ui-kit/components'
2740
+ </script>
2741
+
2742
+ <template>
2743
+ <ZlRadioTag v-model="value" />
2744
+ </template>
2745
+ ```
2746
+
2747
+ **插槽用法**
2748
+
2749
+ ```vue
2750
+ <template>
2751
+ <ZlRadioTag>
2752
+ <template #default="{ item, checked }">…</template>
2753
+ </ZlRadioTag>
2754
+ </template>
2755
+ ```
2756
+
2757
+ **props**
2758
+
2759
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2760
+ | ------------ | ------------------------------- | ---------- | ---- | -------------------- | -------------------------------------------- |
2761
+ | `modelValue` | `string \| number \| undefined` | — | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
2762
+ | `options` | `RadioTagOption[]` | `() => []` | 否 | `:options="options"` | — |
2763
+ | `size` | `'mini' \| 'small' \| 'medium'` | `'small'` | 否 | `size="mini"` | — |
2764
+
2765
+ **事件(emits)**
2766
+
2767
+ | 事件 | 参数 | 说明 |
2768
+ | ------------------- | ------------------------------- | -------------- |
2769
+ | `update:modelValue` | `string \| number \| undefined` | `v-model` 更新 |
2770
+
2771
+ **插槽(slots)**
2772
+
2773
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2774
+ | --------- | ------------------------------------------------------- | ----------------------------------------------------- | ---- |
2775
+ | `default` | `v-bind="{ item, checked: model === item.value }"` 展开 | `<template #default="{ item, checked }">…</template>` | — |
2776
+
2777
+ **完整示例**:见 §7 表单与交互组件 › ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
2778
+
2779
+ #### `ZlSearch`
2780
+
2781
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlSearch/index.vue`</sub>
2782
+
2783
+ **简介**:查询条:表单项按容器宽度自适应排列(auto-fill 网格),放不下的项自动隐藏, 并在「查询」左侧给出展开按钮(点击后在查询条上层展开全量表单,再点收起)。
2784
+
2785
+ **接口概览**:5 props · 2 事件 · 2 插槽 · 3 暴露
2786
+
2787
+ **用法示例**
2788
+
2789
+ ```vue
2790
+ <script setup lang="ts">
2791
+ import { ZlSearch } from '@zl-ui-kit/components'
2792
+ </script>
2793
+
2794
+ <template>
2795
+ <ZlSearch :items="items" />
2796
+ </template>
2797
+ ```
2798
+
2799
+ > 示例中的 `items` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2800
+
2801
+ **插槽用法**
2802
+
2803
+ ```vue
2804
+ <template>
2805
+ <ZlSearch>
2806
+ <template #actions>…</template>
2807
+ <!-- 动态插槽:名字运行时取自 slot -->
2808
+ </ZlSearch>
2809
+ </template>
2810
+ ```
2811
+
2812
+ **props**
2813
+
2814
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2815
+ | ------------ | --------------------- | ----------- | ---- | -------------------- | -------------------------------------------------------------------------------------------- |
2816
+ | `items` | `SearchItem[]` | `() => []` | 否 | `:items="items"` | 查询项定义(SearchItem[]),按数组顺序排列 |
2817
+ | `model` | `Record<string, any>` | — | 否 | `:model="{}"` | 表单数据。传入时组件直接读写该对象(受控); 不传则用内部副本,`params` / 标签行仍可正常工作 |
2818
+ | `immediate` | `boolean` | `true` | 否 | `:immediate="false"` | 挂载后立即执行一次查询(默认 true) |
2819
+ | `disabled` | `boolean` | `false` | 否 | `disabled` | 禁用全部查询项 |
2820
+ | `showLabels` | `boolean` | `undefined` | 否 | `show-labels` | 是否展示「筛选条件」标签行;不传时按「是否发生溢出」自动判定 |
2821
+
2822
+ **事件(emits)**
2823
+
2824
+ | 事件 | 参数 | 说明 |
2825
+ | -------- | --------------------- | ---------------------------------------- |
2826
+ | `search` | `Record<string, any>` | 查询:回传经 `toParams` 合并后的参数对象 |
2827
+ | `reset` | — | 重置:表单已恢复初始值并重新查询之后触发 |
2828
+
2829
+ **插槽(slots)**
2830
+
2831
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2832
+ | --------- | --------------------- | ---------------------------------------- | ---------------------------- |
2833
+ | `[slot]` | `v-bind="scope"` 展开 | `<template #[slot]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
2834
+ | `actions` | — | `<template #actions>…</template>` | — |
2835
+
2836
+ **暴露(defineExpose)**
2837
+
2838
+ | 名称 | 说明 |
2839
+ | -------- | ---- |
2840
+ | `params` | — |
2841
+ | `search` | — |
2842
+ | `reset` | — |
2843
+
2844
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ④ ZlSearch 触发 run(params)
2845
+
2846
+ #### `ZlSearchTable`
2847
+
2848
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlSearchTable/index.vue`</sub>
2849
+
2850
+ **简介**:直接传 service
2851
+
2852
+ **接口概览**:5 props · 1 事件 · 3 插槽 · 4 暴露
2853
+
2854
+ **用法示例**
2855
+
2856
+ ```vue
2857
+ <script setup lang="ts">
2858
+ import { ZlSearchTable } from '@zl-ui-kit/components'
2859
+ </script>
2860
+
2861
+ <template>
2862
+ <ZlSearchTable
2863
+ :request="mockPageRequest"
2864
+ :columns="tableColumns"
2865
+ :query-items="queryItems"
2866
+ :pagination="{ pageSize: 5 }"
2867
+ height="320"
2868
+ />
2869
+ </template>
2870
+ ```
2871
+
2872
+ > 示例中的 `request`、`columns`、`queryItems`、`pagination` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
2873
+
2874
+ **插槽用法**
2875
+
2876
+ ```vue
2877
+ <template>
2878
+ <ZlSearchTable>
2879
+ <template #search-actions>…</template>
2880
+ <!-- 动态插槽:名字运行时取自 slot.slot -->
2881
+ <!-- 动态插槽:名字运行时取自 slot -->
2882
+ </ZlSearchTable>
2883
+ </template>
2884
+ ```
2885
+
2886
+ **props**
2887
+
2888
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2889
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------- | ---------- | ---- | --------------------------- | --------------------------------------------------------------- |
2890
+ | `immediate` | `boolean` | `true` | 否 | `:immediate="false"` | — |
2891
+ | `request` | `\| ((...args: any[]) => Promise<any>) \| { service: (...args: any[]) => Promise<any>; options?: Record<string, any> }` | — | 是 | `:request="async () => {}"` | 请求函数,或 { service, options }(usePageableRequest options) |
2892
+ | `columns` | `TableColumn[]` | `() => []` | 否 | `:columns="columns"` | — |
2893
+ | `queryItems` | `SearchItem[]` | `() => []` | 否 | `:query-items="queryItems"` | — |
2894
+ | `pagination` | `Record<string, any> \| boolean` | — | 否 | `:pagination="{}"` | — |
2895
+
2896
+ > 把 `$attrs` 透传给 `ZlTable`,未列出的属性会继续下传
2897
+
2898
+ **事件(emits)**
2899
+
2900
+ | 事件 | 参数 | 说明 |
2901
+ | -------------- | ---- | ---- |
2902
+ | `search-reset` | — | — |
2903
+
2904
+ **插槽(slots)**
2905
+
2906
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2907
+ | ---------------- | --------------------- | --------------------------------------------- | ---------------------------- |
2908
+ | `search-actions` | — | `<template #search-actions>…</template>` | — |
2909
+ | `[slot.slot]` | `v-bind="scope"` 展开 | `<template #[slot.slot]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
2910
+ | `[slot]` | `v-bind="scope"` 展开 | `<template #[slot]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
2911
+
2912
+ **暴露(defineExpose)**
2913
+
2914
+ | 名称 | 说明 |
2915
+ | --------- | ---- |
2916
+ | `refresh` | — |
2917
+ | `params` | — |
2918
+ | `search` | — |
2919
+ | `table` | — |
2920
+
2921
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ① ZlSearchTable —— 直接传 service
2922
+
2923
+ #### `ZlSection`
2924
+
2925
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlSection/index.vue`</sub>
2926
+
2927
+ **接口概览**:4 props · 3 插槽
2928
+
2929
+ **用法示例**
2930
+
2931
+ ```vue
2932
+ <script setup lang="ts">
2933
+ import { ZlSection } from '@zl-ui-kit/components'
2934
+ </script>
2935
+
2936
+ <template>
2937
+ <ZlSection title="分区标题" icon="bug" block />
2938
+ </template>
2939
+ ```
2940
+
2941
+ **插槽用法**
2942
+
2943
+ ```vue
2944
+ <template>
2945
+ <ZlSection>
2946
+ <template #title-prepend>…</template>
2947
+ <template #actions>…</template>
2948
+ <template #default>…</template>
2949
+ </ZlSection>
2950
+ </template>
2951
+ ```
2952
+
2953
+ **props**
2954
+
2955
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
2956
+ | ------------- | --------- | ------ | ---- | ------------------ | ------------------------------ |
2957
+ | `icon` | `string` | — | 否 | `icon="zl:search"` | 标题图标名(zl: 前缀自动补全) |
2958
+ | `title` | `string` | — | 否 | `title="标题"` | — |
2959
+ | `block` | `boolean` | — | 否 | `block` | 块状布局(内容区滚动) |
2960
+ | `blockHidden` | `boolean` | — | 否 | `block-hidden` | 块状布局且隐藏溢出 |
2961
+
2962
+ **插槽(slots)**
2963
+
2964
+ | 插槽 | 作用域参数 | 示例 | 说明 |
2965
+ | --------------- | ---------- | --------------------------------------- | ---- |
2966
+ | `title-prepend` | — | `<template #title-prepend>…</template>` | — |
2967
+ | `actions` | — | `<template #actions>…</template>` | — |
2968
+ | `default` | — | `<template #default>…</template>` | — |
2969
+
2970
+ #### `ZlSorter`
2971
+
2972
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlSorter/index.vue`</sub>
2973
+
2974
+ **简介**:单字段排序:点一次升序、再点降序、第三次取消(`v-model` 为 '' | 'asc' | 'desc')
2975
+
2976
+ **接口概览**:2 props · 2 事件 · 1 插槽
2977
+
2978
+ **用法示例**
2979
+
2980
+ ```vue
2981
+ <script setup lang="ts">
2982
+ import { ZlSorter } from '@zl-ui-kit/components'
2983
+ </script>
2984
+
2985
+ <template>
2986
+ <ZlSorter label="名称" v-model="value" />
2987
+ </template>
2988
+ ```
2989
+
2990
+ **插槽用法**
2991
+
2992
+ ```vue
2993
+ <template>
2994
+ <ZlSorter>
2995
+ <template #default>…</template>
2996
+ </ZlSorter>
2997
+ </template>
2998
+ ```
2999
+
3000
+ **props**
3001
+
3002
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3003
+ | ------------ | ----------------------- | ------ | ---- | ----------------- | -------------------------------------------- |
3004
+ | `modelValue` | `'' \| 'asc' \| 'desc'` | — | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
3005
+ | `label` | `string` | — | 否 | `label="标签"` | — |
3006
+
3007
+ **事件(emits)**
3008
+
3009
+ | 事件 | 参数 | 说明 |
3010
+ | ------------------- | ----------------------- | -------------- |
3011
+ | `update:modelValue` | `'' \| 'asc' \| 'desc'` | `v-model` 更新 |
3012
+ | `change` | `'' \| 'asc' \| 'desc'` | — |
3013
+
3014
+ **插槽(slots)**
3015
+
3016
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3017
+ | --------- | ---------- | --------------------------------- | ---- |
3018
+ | `default` | — | `<template #default>…</template>` | — |
3019
+
3020
+ **完整示例**:见 §7 表单与交互组件 › ZlRadioTag / ZlCheckboxTag / ZlCheckAll / ZlSorter / ZlAddSub / ZlLayoutSwitch
3021
+
3022
+ #### `ZlSorterList`
3023
+
3024
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlSorter/ZlSorterList.vue`</sub>
3025
+
3026
+ **简介**:多字段排序列表:把若干个 `ZlSorter` 组织成一组,可单选/多选
3027
+
3028
+ **接口概览**:2 props · 1 事件
3029
+
3030
+ **用法示例**
3031
+
3032
+ ```vue
3033
+ <script setup lang="ts">
3034
+ import { ZlSorterList } from '@zl-ui-kit/components'
3035
+ </script>
3036
+
3037
+ <template>
3038
+ <ZlSorterList :model-value="{ name: 'asc' }" :sorters="sorters" />
3039
+ </template>
3040
+ ```
3041
+
3042
+ > 示例中的 `modelValue`、`sorters` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3043
+
3044
+ **props**
3045
+
3046
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3047
+ | ---------- | -------------- | ---------- | ---- | -------------------- | ---- |
3048
+ | `sorters` | `SorterItem[]` | `() => []` | 否 | `:sorters="sorters"` | — |
3049
+ | `multiple` | `boolean` | `false` | 否 | `multiple` | — |
3050
+
3051
+ **事件(emits)**
3052
+
3053
+ | 事件 | 参数 | 说明 |
3054
+ | -------- | ------------------------------------- | ---- |
3055
+ | `change` | `Record<string, any>, string, string` | — |
3056
+
3057
+ #### `ZlSwitch`
3058
+
3059
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlSwitch/index.vue`</sub>
3060
+
3061
+ **简介**:开关:值可为 boolean/string/number,支持 checkedText/uncheckedText 文案
3062
+
3063
+ **接口概览**:6 props · 1 事件 · 2 插槽
3064
+
3065
+ **用法示例**
3066
+
3067
+ ```vue
3068
+ <script setup lang="ts">
3069
+ import { ZlSwitch } from '@zl-ui-kit/components'
3070
+ </script>
3071
+
3072
+ <template>
3073
+ <ZlSwitch model-value="1" checked-value="1" unchecked-value="0" checked-text="开启" unchecked-text="关闭" />
3074
+ </template>
3075
+ ```
3076
+
3077
+ **插槽用法**
3078
+
3079
+ ```vue
3080
+ <template>
3081
+ <ZlSwitch>
3082
+ <template #checked>…</template>
3083
+ <template #unchecked>…</template>
3084
+ </ZlSwitch>
3085
+ </template>
3086
+ ```
3087
+
3088
+ **props**
3089
+
3090
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3091
+ | ---------------- | ----------------------------- | ------- | ---- | ----------------------------------- | ---- |
3092
+ | `modelValue` | `boolean \| string \| number` | — | 否 | `v-model="value"` | — |
3093
+ | `defaultChecked` | `boolean` | `false` | 否 | `default-checked` | — |
3094
+ | `checkedValue` | `boolean \| string \| number` | `true` | 否 | `:checked-value="checkedValue"` | — |
3095
+ | `uncheckedValue` | `boolean \| string \| number` | `false` | 否 | `:unchecked-value="uncheckedValue"` | — |
3096
+ | `checkedText` | `string` | — | 否 | `checked-text="开"` | — |
3097
+ | `uncheckedText` | `string` | — | 否 | `unchecked-text="关"` | — |
3098
+
3099
+ > 把 `$attrs` 透传给 `el-switch`,未列出的属性会继续下传
3100
+
3101
+ **事件(emits)**
3102
+
3103
+ | 事件 | 参数 | 说明 |
3104
+ | ------------------- | ----------------------------- | ---- |
3105
+ | `update:modelValue` | `boolean \| string \| number` | — |
3106
+
3107
+ **插槽(slots)**
3108
+
3109
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3110
+ | ----------- | ---------- | ----------------------------------- | ---- |
3111
+ | `checked` | — | `<template #checked>…</template>` | — |
3112
+ | `unchecked` | — | `<template #unchecked>…</template>` | — |
3113
+
3114
+ **完整示例**:见 §7 表单与交互组件 › ZlDrawer / ZlPopconfirm / ZlSwitch
3115
+
3116
+ #### `ZlTable`
3117
+
3118
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTable/index.vue`</sub>
3119
+
3120
+ **简介**:自行 usePaginationRequest
3121
+
3122
+ **接口概览**:6 props · 3 事件 · 3 插槽
3123
+
3124
+ **用法示例**
3125
+
3126
+ ```vue
3127
+ <script setup lang="ts">
3128
+ import { ZlTable } from '@zl-ui-kit/components'
3129
+ </script>
3130
+
3131
+ <template>
3132
+ <ZlTable :columns="tableColumns" :data="tableData" :pagination="{ total: tableData.length }" />
3133
+ </template>
3134
+ ```
3135
+
3136
+ > 示例中的 `columns`、`data`、`pagination` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3137
+
3138
+ **插槽用法**
3139
+
3140
+ ```vue
3141
+ <template>
3142
+ <ZlTable>
3143
+ <template #expand="scope">…</template>
3144
+ <!-- 动态插槽:名字运行时取自 column.headerSlotName -->
3145
+ <!-- 动态插槽:名字运行时取自 column.slotName -->
3146
+ </ZlTable>
3147
+ </template>
3148
+ ```
3149
+
3150
+ **props**
3151
+
3152
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3153
+ | -------------- | -------------------------------- | -------- | ---- | -------------------- | ---------------------------------------------------------------------------- |
3154
+ | `columns` | `TableColumn[]` | — | 是 | `:columns="columns"` | — |
3155
+ | `data` | `any[] \| Record<string, any>` | — | 是 | `:data="data"` | 数组(本地数据)或 { [dataKey]: rows, pageNum, pageSize, total }(分页数据) |
3156
+ | `dataKey` | `string` | `'rows'` | 否 | `data-key="rows"` | — |
3157
+ | `expandAction` | `boolean` | `false` | 否 | `expand-action` | actions 列宽加宽(参考实现 expandAction 语义) |
3158
+ | `pagination` | `Record<string, any> \| boolean` | — | 否 | `:pagination="{}"` | — |
3159
+ | `loading` | `boolean` | `false` | 否 | `loading` | 表格 loading(作用于表格区) |
3160
+
3161
+ > 把 `$attrs` 透传给 `el-table`,未列出的属性会继续下传
3162
+
3163
+ **事件(emits)**
3164
+
3165
+ | 事件 | 参数 | 说明 |
3166
+ | ------------------- | --------------------------------------- | ---- |
3167
+ | `pagination-change` | `{ pageNum: number; pageSize: number }` | — |
3168
+ | `page-change` | `number` | — |
3169
+ | `page-size-change` | `number` | — |
3170
+
3171
+ **插槽(slots)**
3172
+
3173
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3174
+ | ------------------------- | --------------------- | --------------------------------------------------------- | ---------------------------- |
3175
+ | `expand` | `v-bind="scope"` 展开 | `<template #expand="scope">…</template>` | — |
3176
+ | `[column.headerSlotName]` | `v-bind="scope"` 展开 | `<template #[column.headerSlotName]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
3177
+ | `[column.slotName]` | `v-bind="scope"` 展开 | `<template #[column.slotName]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
3178
+
3179
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ③ ZlTable + ZlPagination —— 自行 usePaginationRequest
3180
+
3181
+ #### `ZlTabs`
3182
+
3183
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTabs/index.vue`</sub>
3184
+
3185
+ **接口概览**:4 props · 3 插槽
3186
+
3187
+ **用法示例**
3188
+
3189
+ ```vue
3190
+ <script setup lang="ts">
3191
+ import { ZlTabs } from '@zl-ui-kit/components'
3192
+ </script>
3193
+
3194
+ <template>
3195
+ <ZlTabs :tabs="tabs">
3196
+ <template #a>页签 A 内容</template>
3197
+ <template #b>页签 B 内容</template>
3198
+ </ZlTabs>
3199
+ </template>
3200
+ ```
3201
+
3202
+ > 示例中的 `tabs` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3203
+
3204
+ **插槽用法**
3205
+
3206
+ ```vue
3207
+ <template>
3208
+ <ZlTabs>
3209
+ <template #default>…</template>
3210
+ <template #extra>…</template>
3211
+ <!-- 动态插槽:名字运行时取自 key -->
3212
+ </ZlTabs>
3213
+ </template>
3214
+ ```
3215
+
3216
+ **props**
3217
+
3218
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3219
+ | --------- | --------- | ---------- | ---- | ------------------- | ---- |
3220
+ | `tabs` | `any[]` | `() => []` | 否 | `:tabs="[]"` | — |
3221
+ | `border` | `boolean` | `true` | 否 | `:border="false"` | — |
3222
+ | `fit` | `boolean` | — | 否 | `fit` | — |
3223
+ | `darkNav` | `boolean` | `true` | 否 | `:dark-nav="false"` | — |
3224
+
3225
+ > 选项式组件(`defineComponent`),props 定义在 `props: {}` 中
3226
+ > 把 `$attrs` 透传给内部组件,未列出的属性会继续下传
3227
+
3228
+ **插槽(slots)**
3229
+
3230
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3231
+ | --------- | ---------- | --------------------------------- | ---------------------------- |
3232
+ | `[key]` | — | `<template #[key]>…</template>` | 动态插槽:名字由该表达式决定 |
3233
+ | `default` | — | `<template #default>…</template>` | — |
3234
+ | `extra` | — | `<template #extra>…</template>` | — |
3235
+
3236
+ **完整示例**:见 §7 表单与交互组件 › ZlTabs / ZlDynamicComponent / ZlGrid
3237
+
3238
+ #### `ZlTag`
3239
+
3240
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTag/index.vue`</sub>
3241
+
3242
+ **简介**:标签
3243
+
3244
+ **接口概览**:15 props · 4 事件 · 1 插槽
3245
+
3246
+ **用法示例**
3247
+
3248
+ ```vue
3249
+ <script setup lang="ts">
3250
+ import { ZlTag } from '@zl-ui-kit/components'
3251
+ </script>
3252
+
3253
+ <template>
3254
+ <ZlTag color="blue" bordered> blue 边框 </ZlTag>
3255
+ </template>
3256
+ ```
3257
+
3258
+ **插槽用法**
3259
+
3260
+ ```vue
3261
+ <template>
3262
+ <ZlTag>
3263
+ <template #default>…</template>
3264
+ </ZlTag>
3265
+ </template>
3266
+ ```
3267
+
3268
+ **props**
3269
+
3270
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3271
+ | ----------------- | ------------------------------- | ----------- | ---- | -------------------------- | ---- |
3272
+ | `size` | `'mini' \| 'small' \| 'medium'` | `undefined` | 否 | `size="mini"` | — |
3273
+ | `color` | `string` | `undefined` | 否 | `color="#409eff"` | — |
3274
+ | `bordered` | `boolean` | `false` | 否 | `bordered` | — |
3275
+ | `fill` | `boolean` | `false` | 否 | `fill` | — |
3276
+ | `disabled` | `boolean` | `false` | 否 | `disabled` | — |
3277
+ | `icon` | `string` | `undefined` | 否 | `icon="zl:search"` | — |
3278
+ | `dotIcon` | `boolean` | `false` | 否 | `dot-icon` | — |
3279
+ | `iconColor` | `string` | `undefined` | 否 | `icon-color="#409eff"` | — |
3280
+ | `closable` | `boolean` | `false` | 否 | `closable` | — |
3281
+ | `visible` | `boolean \| undefined` | `undefined` | 否 | `v-model:visible="value"` | — |
3282
+ | `defaultVisible` | `boolean` | `true` | 否 | `:default-visible="false"` | — |
3283
+ | `selectable` | `boolean` | `false` | 否 | `selectable` | — |
3284
+ | `selected` | `boolean \| undefined` | `undefined` | 否 | `v-model:selected="value"` | — |
3285
+ | `defaultSelected` | `boolean` | `false` | 否 | `default-selected` | — |
3286
+ | `rounded` | `boolean` | `false` | 否 | `rounded` | — |
3287
+
3288
+ **事件(emits)**
3289
+
3290
+ | 事件 | 参数 | 说明 |
3291
+ | ----------------- | ------------ | ---- |
3292
+ | `close` | `MouseEvent` | — |
3293
+ | `update:visible` | `boolean` | — |
3294
+ | `update:selected` | `boolean` | — |
3295
+ | `select` | `boolean` | — |
3296
+
3297
+ **插槽(slots)**
3298
+
3299
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3300
+ | --------- | ---------- | --------------------------------- | ---- |
3301
+ | `default` | — | `<template #default>…</template>` | — |
3302
+
3303
+ **完整示例**:见 §5 通用展示组件 › ZlTag — 标签
3304
+
3305
+ #### `ZlText`
3306
+
3307
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlText/index.vue`</sub>
3308
+
3309
+ **简介**:纯文本展示:默认渲染 `modelValue`,也可用默认插槽覆盖内容
3310
+
3311
+ **接口概览**:1 props · 1 插槽
3312
+
3313
+ **用法示例**
3314
+
3315
+ ```vue
3316
+ <script setup lang="ts">
3317
+ import { ZlText } from '@zl-ui-kit/components'
3318
+ </script>
3319
+
3320
+ <template>
3321
+ <ZlText model-value="文本内容" />
3322
+ </template>
3323
+ ```
3324
+
3325
+ **插槽用法**
3326
+
3327
+ ```vue
3328
+ <template>
3329
+ <ZlText>
3330
+ <template #default>…</template>
3331
+ </ZlText>
3332
+ </template>
3333
+ ```
3334
+
3335
+ **props**
3336
+
3337
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3338
+ | ------------ | ----------------------------- | ------ | ---- | --------------------------- | ---- |
3339
+ | `modelValue` | `string \| number \| boolean` | — | 否 | `:model-value="modelValue"` | — |
3340
+
3341
+ **插槽(slots)**
3342
+
3343
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3344
+ | --------- | ---------- | --------------------------------- | ---- |
3345
+ | `default` | — | `<template #default>…</template>` | — |
3346
+
3347
+ #### `ZlTitle`
3348
+
3349
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTitle/index.vue`</sub>
3350
+
3351
+ **简介**:区块标题
3352
+
3353
+ **接口概览**:5 props · 3 插槽
3354
+
3355
+ **用法示例**
3356
+
3357
+ ```vue
3358
+ <script setup lang="ts">
3359
+ import { ZlTitle } from '@zl-ui-kit/components'
3360
+ </script>
3361
+
3362
+ <template>
3363
+ <ZlTitle title="页面标题" description="标题描述文案" tooltip="标题提示" />
3364
+ </template>
3365
+ ```
3366
+
3367
+ **插槽用法**
3368
+
3369
+ ```vue
3370
+ <template>
3371
+ <ZlTitle>
3372
+ <template #default>…</template>
3373
+ <template #description>…</template>
3374
+ <template #extra>…</template>
3375
+ </ZlTitle>
3376
+ </template>
3377
+ ```
3378
+
3379
+ **props**
3380
+
3381
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3382
+ | ------------- | -------------------------------- | ------ | ---- | ---------------------- | ---- |
3383
+ | `title` | `string` | — | 否 | `title="标题"` | — |
3384
+ | `description` | `string` | — | 否 | `description="副标题"` | — |
3385
+ | `marker` | `boolean` | `true` | 否 | `:marker="false"` | — |
3386
+ | `tooltip` | `string` | — | 否 | `tooltip="提示内容"` | — |
3387
+ | `size` | `'small' \| 'medium' \| 'large'` | — | 否 | `size="small"` | — |
3388
+
3389
+ **插槽(slots)**
3390
+
3391
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3392
+ | ------------- | ---------- | ------------------------------------- | ---- |
3393
+ | `default` | — | `<template #default>…</template>` | — |
3394
+ | `description` | — | `<template #description>…</template>` | — |
3395
+ | `extra` | — | `<template #extra>…</template>` | — |
3396
+
3397
+ **完整示例**:见 §5 通用展示组件 › ZlTitle — 区块标题
3398
+
3399
+ #### `ZlUpload`
3400
+
3401
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlUpload/index.vue`</sub>
3402
+
3403
+ **简介**:传上传 service
3404
+
3405
+ **接口概览**:11 props · 1 事件 · 1 插槽
3406
+
3407
+ **用法示例**
3408
+
3409
+ ```vue
3410
+ <script setup lang="ts">
3411
+ import { ZlUpload } from '@zl-ui-kit/components'
3412
+ </script>
3413
+
3414
+ <template>
3415
+ <ZlUpload :request="mockUpload" accept=".png,.jpg,.pdf" :max-size="5" :limit="3" style="max-width: 420px" />
3416
+ </template>
3417
+ ```
3418
+
3419
+ > 示例中的 `request` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3420
+
3421
+ **插槽用法**
3422
+
3423
+ ```vue
3424
+ <template>
3425
+ <ZlUpload>
3426
+ <template #default>…</template>
3427
+ </ZlUpload>
3428
+ </template>
3429
+ ```
3430
+
3431
+ **props**
3432
+
3433
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3434
+ | -------------------- | --------------------------------------------------------------- | -------- | ---- | ----------------------------------------- | -------------------------------------------- |
3435
+ | `request` | `(form: FormData, config: Record<string, any>) => Promise<any>` | — | 否 | `:request="async () => {}"` | 自定义上传函数(form, config)→ Promise |
3436
+ | `modelValue` | `string \| any[]` | `''` | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
3437
+ | `accept` | `string` | — | 否 | `accept=".png,.jpg,.pdf"` | — |
3438
+ | `maxSize` | `number` | — | 否 | `:max-size="1"` | 单文件大小上限(MB) |
3439
+ | `limit` | `number` | — | 否 | `:limit="1"` | — |
3440
+ | `tip` | `string` | — | 否 | `tip="支持批量上传,单个文件不超过 10MB"` | — |
3441
+ | `separator` | `string` | `';'` | 否 | `separator=","` | 多路径分隔符(modelValue 为字符串时) |
3442
+ | `responseUrlKey` | `string` | `'meta'` | 否 | `response-url-key="url"` | 响应中文件地址的取值键 |
3443
+ | `showDownloadButton` | `boolean` | `true` | 否 | `:show-download-button="false"` | — |
3444
+ | `showTip` | `boolean` | `true` | 否 | `:show-tip="false"` | — |
3445
+ | `verifySpace` | `boolean` | `false` | 否 | `verify-space` | 校验文件名不得含空格 |
3446
+
3447
+ **事件(emits)**
3448
+
3449
+ | 事件 | 参数 | 说明 |
3450
+ | ------------------- | ----- | -------------- |
3451
+ | `update:modelValue` | `any` | `v-model` 更新 |
3452
+
3453
+ **插槽(slots)**
3454
+
3455
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3456
+ | --------- | ---------- | --------------------------------- | ---- |
3457
+ | `default` | — | `<template #default>…</template>` | — |
3458
+
3459
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ⑥ ZlUpload —— 传上传 service
3460
+
3461
+ #### `ZlTree`
3462
+
3463
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTree/index.vue`</sub>
3464
+
3465
+ **简介**:useRequest 绑定 data
3466
+
3467
+ **接口概览**:5 props · 3 插槽
3468
+
3469
+ **用法示例**
3470
+
3471
+ ```vue
3472
+ <script setup lang="ts">
3473
+ import { ZlTree } from '@zl-ui-kit/components'
3474
+ </script>
3475
+
3476
+ <template>
3477
+ <ZlTree :data="treeData" :field-names="fieldNames" />
3478
+ </template>
3479
+ ```
3480
+
3481
+ > 示例中的 `data`、`fieldNames` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3482
+
3483
+ **插槽用法**
3484
+
3485
+ ```vue
3486
+ <template>
3487
+ <ZlTree>
3488
+ <template #search-extra>…</template>
3489
+ <template #title="{ node, data }">…</template>
3490
+ <!-- 动态插槽:名字运行时取自 slot -->
3491
+ </ZlTree>
3492
+ </template>
3493
+ ```
3494
+
3495
+ **props**
3496
+
3497
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3498
+ | ------------------ | ----------------------------------------------------- | -------------------------------------------------------------- | ---- | ------------------------------ | ------------------------------------------------------- |
3499
+ | `fieldNames` | `{ key?: string; title?: string; children?: string }` | `() => ({ key: 'key', title: 'title', children: 'children' })` | 否 | `:field-names="{}"` | 字段映射(arco fieldNames 兼容:title→label、children) |
3500
+ | `inputSearchProps` | `Record<string, any>` | — | 否 | `:input-search-props="{}"` | 搜索框透传(el-input 属性) |
3501
+ | `filterTreeNode` | `(value: string, data: any) => boolean` | — | 否 | `:filter-tree-node="() => {}"` | 自定义过滤函数(缺省按 title 包含匹配) |
3502
+ | `disableFilter` | `boolean` | — | 否 | `disable-filter` | 关闭搜索框 |
3503
+ | `loading` | `boolean` | — | 否 | `loading` | — |
3504
+
3505
+ **插槽(slots)**
3506
+
3507
+ | 插槽 | 作用域参数 | 示例 | 说明 |
3508
+ | -------------- | ------------------------------ | ------------------------------------------------ | ---------------------------- |
3509
+ | `search-extra` | — | `<template #search-extra>…</template>` | — |
3510
+ | `title` | `v-bind="{ node, data }"` 展开 | `<template #title="{ node, data }">…</template>` | — |
3511
+ | `[slot]` | `v-bind="scope"` 展开 | `<template #[slot]="scope">…</template>` | 动态插槽:名字由该表达式决定 |
3512
+
3513
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ⑦ ZlTree —— useRequest 绑定 data
3514
+
3515
+ #### `ZlTreeSelect`
3516
+
3517
+ <sub>入口 `@zl-ui-kit/components` · 源码 `packages/components/src/components/ZlTreeSelect/index.vue`</sub>
3518
+
3519
+ **接口概览**:6 props · 1 事件
3520
+
3521
+ **用法示例**
3522
+
3523
+ ```vue
3524
+ <script setup lang="ts">
3525
+ import { ZlTreeSelect } from '@zl-ui-kit/components'
3526
+ </script>
3527
+
3528
+ <template>
3529
+ <ZlTreeSelect :origin-tree-data="treeData" v-model="value" />
3530
+ </template>
3531
+ ```
3532
+
3533
+ > 示例中的 `originTreeData` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3534
+
3535
+ **props**
3536
+
3537
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3538
+ | ------------------- | ----------------------------------------------------- | -------------------------------------------------------------- | ---- | ------------------------ | ------------------------------------------------ |
3539
+ | `modelValue` | `any` | — | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
3540
+ | `originTreeData` | `any[]` | — | 是 | `:origin-tree-data="[]"` | 树数据 |
3541
+ | `allName` | `string` | — | 否 | `all-name="全部"` | "全部"节点名(启用全选控制条) |
3542
+ | `labelInValue` | `boolean` | `false` | 否 | `label-in-value` | 返回 {label, value} 对象数组(缺省返回键值数组) |
3543
+ | `fieldNames` | `{ key?: string; title?: string; children?: string }` | `() => ({ key: 'key', title: 'title', children: 'children' })` | 否 | `:field-names="{}"` | — |
3544
+ | `treeCheckStrictly` | `boolean` | `false` | 否 | `tree-check-strictly` | 父子不关联 |
3545
+
3546
+ > 把 `$attrs` 透传给 `el-tree-select`,未列出的属性会继续下传
3547
+
3548
+ **事件(emits)**
3549
+
3550
+ | 事件 | 参数 | 说明 |
3551
+ | ------------------- | ----- | -------------- |
3552
+ | `update:modelValue` | `any` | `v-model` 更新 |
3553
+
3554
+ ### 14.2 子路径入口组件(重型依赖,需单独安装)
3555
+
3556
+ #### `ZlChart`
3557
+
3558
+ <sub>入口 `@zl-ui-kit/components/chart` · 源码 `packages/components/src/components/ZlChart/index.vue` · ⚠️ 不在主入口,需从子路径 import,并自行安装对应 peer 依赖</sub>
3559
+
3560
+ **简介**:useDataRequest 解包后构建 option
3561
+
3562
+ **接口概览**:2 props · 1 暴露
3563
+
3564
+ **用法示例**
3565
+
3566
+ ```vue
3567
+ <script setup lang="ts">
3568
+ import { ZlChart } from '@zl-ui-kit/components/chart'
3569
+ </script>
3570
+
3571
+ <template>
3572
+ <ZlChart :series="series" :x-axis="xAxis" :y-axis="{ type: 'value' }" style="width: 520px; height: 260px" />
3573
+ </template>
3574
+ ```
3575
+
3576
+ > 示例中的 `series`、`xAxis`、`yAxis` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3577
+
3578
+ **props**
3579
+
3580
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3581
+ | -------- | --------------------------------------------------- | ------ | ---- | -------------- | ---------------------------------------------------------------------------------------------------------------- |
3582
+ | `series` | `Record<string, any> \| Array<Record<string, any>>` | — | 否 | `:series="{}"` | 系列(单对象或数组);其余图表配置经 attrs 透传(title/xAxis/yAxis/tooltip 等,可用 src/utils/echarts 工具构造) |
3583
+ | `theme` | `string` | — | 否 | `theme="dark"` | 主题名:先 `import 'echarts/theme/v5'` 之类注册主题,再传 `theme="v5"`。升级到 echarts 6 后想保持 v5 观感时用 |
3584
+
3585
+ **暴露(defineExpose)**
3586
+
3587
+ | 名称 | 说明 |
3588
+ | ------- | ---- |
3589
+ | `clear` | — |
3590
+
3591
+ **完整示例**:见 §6 数据型组件 + useRequest 体系(核心) › ⑧ ZlChart —— useDataRequest 解包后构建 option
3592
+
3593
+ #### `ZlEditor`
3594
+
3595
+ <sub>入口 `@zl-ui-kit/components/editor` · 源码 `packages/components/src/components/ZlEditor/index.vue` · ⚠️ 不在主入口,需从子路径 import,并自行安装对应 peer 依赖</sub>
3596
+
3597
+ **简介**:monaco worker 配置与首屏治理
3598
+
3599
+ **接口概览**:3 props · 1 事件
3600
+
3601
+ **用法示例**
3602
+
3603
+ ```vue
3604
+ <script setup lang="ts">
3605
+ import { ZlEditor } from '@zl-ui-kit/components/editor'
3606
+ </script>
3607
+
3608
+ <template>
3609
+ <ZlEditor language="javascript" v-model="value" />
3610
+ </template>
3611
+ ```
3612
+
3613
+ **props**
3614
+
3615
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3616
+ | ------------ | --------------------- | -------------- | ---- | ----------------------- | -------------------------------------------- |
3617
+ | `modelValue` | `string` | `''` | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
3618
+ | `language` | `string` | `'javascript'` | 否 | `language="javascript"` | — |
3619
+ | `options` | `Record<string, any>` | `() => ({})` | 否 | `:options="{}"` | — |
3620
+
3621
+ **事件(emits)**
3622
+
3623
+ | 事件 | 参数 | 说明 |
3624
+ | ------------------- | -------- | -------------- |
3625
+ | `update:modelValue` | `string` | `v-model` 更新 |
3626
+
3627
+ **完整示例**:见 §9 文件与编辑 › 9.1 ZlEditor:monaco worker 配置与首屏治理
3628
+
3629
+ #### `ZlSqlEditor`
3630
+
3631
+ <sub>入口 `@zl-ui-kit/components/editor` · 源码 `packages/components/src/components/ZlEditor/ZlSqlEditor.vue` · ⚠️ 不在主入口,需从子路径 import,并自行安装对应 peer 依赖</sub>
3632
+
3633
+ **接口概览**:4 props · 1 事件
3634
+
3635
+ **用法示例**
3636
+
3637
+ ```vue
3638
+ <script setup lang="ts">
3639
+ import { ZlSqlEditor } from '@zl-ui-kit/components/editor'
3640
+ </script>
3641
+
3642
+ <template>
3643
+ <ZlSqlEditor v-model="value" />
3644
+ </template>
3645
+ ```
3646
+
3647
+ **props**
3648
+
3649
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3650
+ | ----------------- | ------------------ | ---------- | ---- | ------------------------------- | -------------------------------------------- |
3651
+ | `modelValue` | `string` | — | 否 | `v-model="value"` | `v-model` 绑定的值(`defineModel` 隐式声明) |
3652
+ | `tableSchemas` | `SqlTableSchema[]` | `() => []` | 否 | `:table-schemas="tableSchemas"` | 表结构(补全提示) |
3653
+ | `customKeywords` | `string[]` | `() => []` | 否 | `:custom-keywords="[]"` | — |
3654
+ | `customFunctions` | `string[]` | `() => []` | 否 | `:custom-functions="[]"` | — |
3655
+
3656
+ > 把 `$attrs` 透传给 `ZlEditor`,未列出的属性会继续下传
3657
+
3658
+ **事件(emits)**
3659
+
3660
+ | 事件 | 参数 | 说明 |
3661
+ | ------------------- | -------- | -------------- |
3662
+ | `update:modelValue` | `string` | `v-model` 更新 |
3663
+
3664
+ #### `ZlFilePreview`
3665
+
3666
+ <sub>入口 `@zl-ui-kit/components/file-preview` · 源码 `packages/components/src/components/ZlFilePreview/index.vue` · ⚠️ 不在主入口,需从子路径 import,并自行安装对应 peer 依赖</sub>
3667
+
3668
+ **接口概览**:1 props
3669
+
3670
+ **用法示例**
3671
+
3672
+ ```vue
3673
+ <script setup lang="ts">
3674
+ import { ZlFilePreview } from '@zl-ui-kit/components/file-preview'
3675
+ </script>
3676
+
3677
+ <template>
3678
+ <ZlFilePreview :url="inlineImage" />
3679
+ </template>
3680
+ ```
3681
+
3682
+ > 示例中的 `url` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3683
+
3684
+ **props**
3685
+
3686
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3687
+ | ----- | -------- | ------ | ---- | ------------------------------------ | ---- |
3688
+ | `url` | `string` | — | 否 | `url="https://example.com/file.pdf"` | — |
3689
+
3690
+ #### `ZlFileViewer`
3691
+
3692
+ <sub>入口 `@zl-ui-kit/components/file-preview` · 源码 `packages/components/src/components/ZlFileViewer/index.vue` · ⚠️ 不在主入口,需从子路径 import,并自行安装对应 peer 依赖</sub>
3693
+
3694
+ **接口概览**:1 props
3695
+
3696
+ **用法示例**
3697
+
3698
+ ```vue
3699
+ <script setup lang="ts">
3700
+ import { ZlFileViewer } from '@zl-ui-kit/components/file-preview'
3701
+ </script>
3702
+
3703
+ <template>
3704
+ <ZlFileViewer :file-type="'image'" :src="inlineImage" style="width: 200px" />
3705
+ </template>
3706
+ ```
3707
+
3708
+ > 示例中的 `src` 是数组 / 对象 / 函数等非字面量入参,由调用方提供数据;其余属性写法可直接照搬。
3709
+
3710
+ **props**
3711
+
3712
+ | 属性 | 类型 | 默认值 | 必填 | 示例 | 说明 |
3713
+ | ---------- | ------------------------------------------------ | -------- | ---- | ------------------ | ---- |
3714
+ | `fileType` | `'word' \| 'pdf' \| 'excel' \| 'ppt' \| 'image'` | `'word'` | 否 | `file-type="word"` | — |
3715
+
3716
+ > 把 `$attrs` 透传给 `VueOfficePdf`,未列出的属性会继续下传
3717
+
3718
+ ### 14.3 公共类型声明(schema 用)
3719
+
3720
+ > 这些类型从 `packages/components/src/index.ts` 导出,宿主的 `columns` / `schema` / `actions` 等入参都按它们书写。启用 `strict` 时可直接获得类型提示。
3721
+
3722
+ #### `ActionItem`
3723
+
3724
+ <sub>源码 `packages/components/src/components/ZlAction/types.ts`</sub>
3725
+
3726
+ 操作项模型(ZlActionList / ZlTable actions 列共用)
3727
+
3728
+ | 字段 | 类型 | 必填 | 说明 |
3729
+ | ------------ | ----------------------------- | ---- | --------------------------------------------------- |
3730
+ | `label` | `string` | 是 | 操作文案 |
3731
+ | `icon` | `string` | 否 | 图标(`zl:` 前缀走 ZlIcon,其余按 iconify/EP 规则) |
3732
+ | `iconProps` | `Record<string, any>` | 否 | 传给图标组件的 props |
3733
+ | `iconClass` | `string` | 否 | 图标自定义类名 |
3734
+ | `tooltip` | `boolean` | 否 | 是否用 tooltip 包住文案(文字过长时) |
3735
+ | `disabled` | `boolean` | 否 | 禁用(点击无响应) |
3736
+ | `divided` | `boolean` | 否 | 与下一项之间显示分割线 |
3737
+ | `permission` | `string \| string[]` | 否 | 权限键(三段式,经 usePermission 校验) |
3738
+ | `visible` | `(...args: any[]) => boolean` | 否 | 显隐判定(接收 visibleArgs) |
3739
+ | `handler` | `(...args: any[]) => void` | 否 | 点击处理(接收 actionArgs) |
3740
+
3741
+ #### `IComponent`
3742
+
3743
+ <sub>源码 `packages/components/src/components/ZlDynamicComponent/types.ts`</sub>
3744
+
3745
+ | 字段 | 类型 | 必填 | 说明 |
3746
+ | ----------- | ------------------------------------------------------------------------------- | ---- | ---- |
3747
+ | `component` | `string \| any` | 是 | — |
3748
+ | `class` | `string \| Record<string, boolean> \| Array<string \| Record<string, boolean>>` | 否 | — |
3749
+ | `style` | `string \| Record<string, boolean> \| Array<string \| Record<string, boolean>>` | 否 | — |
3750
+ | `model` | `string` | 否 | — |
3751
+ | `props` | `Record<string, any>` | 否 | — |
3752
+ | `domProps` | `Record<string, any>` | 否 | — |
3753
+ | `on` | `Record<string, (...args: any[]) => any>` | 否 | — |
3754
+ | `nativeOn` | `Record<string, (...args: any[]) => any>` | 否 | — |
3755
+ | `slots` | `IComponentSlot[]` | 否 | — |
3756
+ | `children` | `string \| VNode \| Array<string \| VNode>` | 否 | — |
3757
+ | `refInFor` | `boolean` | 否 | — |
3758
+
3759
+ #### `IComponentSlot`
3760
+
3761
+ <sub>源码 `packages/components/src/components/ZlDynamicComponent/types.ts`</sub>
3762
+
3763
+ > 继承自 `IComponent`:下表只列自有字段,父类型字段同样可用。
3764
+
3765
+ | 字段 | 类型 | 必填 | 说明 |
3766
+ | ------ | -------- | ---- | ---- |
3767
+ | `name` | `string` | 否 | — |
3768
+
3769
+ #### `VForSlot`
3770
+
3771
+ <sub>源码 `packages/components/src/components/ZlDynamicComponent/types.ts`</sub>
3772
+
3773
+ > 继承自 `IComponentSlot`:下表只列自有字段,父类型字段同样可用。
3774
+
3775
+ | 字段 | 类型 | 必填 | 说明 |
3776
+ | ------ | -------- | ---- | ---- |
3777
+ | `type` | `'vFor'` | 是 | — |
3778
+ | `data` | `Item[]` | 是 | — |
3779
+
3780
+ #### `VModelSlot`
3781
+
3782
+ <sub>源码 `packages/components/src/components/ZlDynamicComponent/types.ts`</sub>
3783
+
3784
+ > 继承自 `IComponentSlot`:下表只列自有字段,父类型字段同样可用。
3785
+
3786
+ | 字段 | 类型 | 必填 | 说明 |
3787
+ | ------ | ---------- | ---- | ---- |
3788
+ | `type` | `'vModel'` | 是 | — |
3789
+
3790
+ #### `IGridItem`
3791
+
3792
+ <sub>源码 `packages/components/src/components/ZlGrid/types.ts`</sub>
3793
+
3794
+ ZlGrid 子项 schema
3795
+
3796
+ | 字段 | 类型 | 必填 | 说明 |
3797
+ | ---------- | ---------------------------------------------------------------------------------- | ---- | ---------------------------------------------------------------------------- |
3798
+ | `label` | `string` | 是 | 字段标签 |
3799
+ | `key` | `string` | 是 | 取值字段名(同时作为插槽名 `#key`) |
3800
+ | `size` | `number \| 'auto'` | 否 | 跨列数('auto' 占满剩余列) |
3801
+ | `getValue` | `(data: Record<string, any>, key: string, item: IGridItem) => any` | 否 | 自定义取值(缺省按 key 从 data 取) |
3802
+ | `visible` | `boolean \| ((value: unknown, key: string, data: Record<string, any>) => boolean)` | 否 | 显隐判定 |
3803
+ | `dict` | `string \| { dictKey: string; simple?: boolean; showType?: boolean }` | 否 | 字典:字典 key,或 `{ dictKey, simple, showType }` 配置(走 ZlDictTag 翻译) |
3804
+ | `slot` | `boolean` | 否 | 是否启用具名插槽(#key)渲染 |
3805
+ | `ellipsis` | `number \| boolean` | 否 | 溢出省略行数(悬浮提示) |
3806
+
3807
+ #### `TableColumn`
3808
+
3809
+ <sub>源码 `packages/components/src/types.ts`</sub>
3810
+
3811
+ 表格列定义:label/prop(或 dataIndex)/slot/actions/columnSlot + el-table-column 其余属性
3812
+
3813
+ | 字段 | 类型 | 必填 | 说明 |
3814
+ | ------------- | --------------------- | ---- | -------------------------------------------------- |
3815
+ | `label` | `string` | 否 | 列标题(优先于 title) |
3816
+ | `title` | `string` | 否 | 列标题(兼容 arco/antd 写法,label 缺省时生效) |
3817
+ | `prop` | `string` | 否 | 取值字段名(优先于 dataIndex) |
3818
+ | `dataIndex` | `string` | 否 | 取值字段名(兼容 arco/antd 写法,prop 缺省时生效) |
3819
+ | `slot` | `string \| boolean` | 否 | 单元格插槽名(缺省用 prop) |
3820
+ | `columnSlot` | `boolean` | 否 | 启用表头插槽(header-{prop}) |
3821
+ | `actions` | `ActionItem[]` | 否 | 操作列(渲染 ZlActionList) |
3822
+ | `actionProps` | `Record<string, any>` | 否 | 透传给操作列 ZlActionList 的 props |
3823
+
3824
+ #### `FormItem`
3825
+
3826
+ <sub>源码 `packages/components/src/types.ts`</sub>
3827
+
3828
+ 表单项 schema(ZlForm / ZlSearch 共用)
3829
+
3830
+ | 字段 | 类型 | 必填 | 说明 |
3831
+ | --------------- | ---------------------------------------------------------------------- | ---- | --------------------------------------------------- |
3832
+ | `model` | `string` | 是 | 字段名(必填) |
3833
+ | `label` | `string` | 否 | 标签文案(缺省用 model) |
3834
+ | `component` | `string \| any` | 否 | 动态组件名/组件对象(如 'el-input'、ElSelect) |
3835
+ | `props` | `Record<string, any>` | 否 | 组件 props(自动包装 update:modelValue 回写 model) |
3836
+ | `slots` | `Record<string, any>` | 否 | 组件插槽 |
3837
+ | `defaultValue` | `any` | 否 | 默认值 |
3838
+ | `slot` | `boolean` | 否 | 是否启用具名插槽(#model)自定义渲染 |
3839
+ | `formItemProps` | `Record<string, any>` | 否 | el-form-item 其余属性(rules 等) |
3840
+ | `tooltip` | `string` | 否 | 标签旁的问号提示文案 |
3841
+ | `visible` | `boolean \| ((model: Record<string, any>, item: FormItem) => boolean)` | 否 | 显隐控制:布尔值或判定函数 |
3842
+
3843
+ #### `SearchItem`
3844
+
3845
+ <sub>源码 `packages/components/src/types.ts`</sub>
3846
+
3847
+ 搜索项 schema(ZlSearch / ZlSearchTable)
3848
+
3849
+ > 继承自 `FormItem`:下表只列自有字段,父类型字段同样可用。
3850
+
3851
+ | 字段 | 类型 | 必填 | 说明 |
3852
+ | ---------- | --------------------------------------------------------------- | ---- | -------------------------------------- |
3853
+ | `toLabel` | `(value: any) => any` | 否 | 值 → 条件标签文本 |
3854
+ | `toParams` | `(value: any, acc: Record<string, any>) => Record<string, any>` | 否 | 值 → 查询参数(返回对象合并入 params) |
3855
+
3856
+ <!-- API:END -->