king-design-analyzer 2.1.7 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/actions.json +101 -0
- package/components/advancedset.json +127 -0
- package/components/affix.json +7 -0
- package/components/aksk.json +172 -0
- package/components/az.json +15 -2
- package/components/badge.json +7 -0
- package/components/billtypes.json +14 -2
- package/components/breadcrumb.json +7 -0
- package/components/button.json +191 -0
- package/components/buttonlink.json +73 -0
- package/components/card.json +8 -1
- package/components/cardcol.json +142 -0
- package/components/cardcols.json +121 -0
- package/components/cardcontent.json +15 -3
- package/components/cardtabs.json +172 -0
- package/components/carousel.json +7 -0
- package/components/cascader.json +520 -368
- package/components/checkbox.json +51 -4
- package/components/cidrinput.json +140 -0
- package/components/code.json +8 -1
- package/components/collapse.json +7 -0
- package/components/colorpicker.json +217 -0
- package/components/copy.json +7 -0
- package/components/copyhover.json +111 -0
- package/components/copyrow.json +124 -0
- package/components/datepicker.json +656 -524
- package/components/description.json +98 -0
- package/components/dialog.json +522 -455
- package/components/divider.json +8 -1
- package/components/drawer.json +571 -558
- package/components/dropdown.json +464 -384
- package/components/duration.json +125 -0
- package/components/editable.json +66 -0
- package/components/ellipsis.json +34 -1
- package/components/filtertablefieldsdialog.json +128 -0
- package/components/flex.json +151 -0
- package/components/form.json +131 -0
- package/components/formiteminput.json +214 -0
- package/components/formitemspinner.json +213 -0
- package/components/formitemswitch.json +185 -0
- package/components/formitemtableconfigs.json +210 -0
- package/components/grid.json +7 -0
- package/components/header.json +161 -0
- package/components/icon.json +13 -1
- package/components/icontooltip.json +19 -1
- package/components/input.json +188 -4
- package/components/instancelist.json +194 -0
- package/components/instancenum.json +196 -0
- package/components/ipinput.json +117 -0
- package/components/kspstatus.json +205 -0
- package/components/kvcode.json +120 -0
- package/components/layoutcontent.json +15 -3
- package/components/layoutlistcontent.json +148 -0
- package/components/layoutpermissioncontent.json +155 -0
- package/components/layoutstandardlist.json +275 -0
- package/components/layouttabs.json +168 -0
- package/components/lazymount.json +86 -0
- package/components/lazyteleport.json +118 -0
- package/components/menu.json +7 -0
- package/components/pagination.json +12 -0
- package/components/paginationplus.json +30 -3
- package/components/password.json +121 -0
- package/components/popover.json +457 -437
- package/components/projects.json +129 -0
- package/components/protable.json +97 -8
- package/components/queuevisualrange.json +110 -0
- package/components/radio.json +82 -2
- package/components/rate.json +199 -0
- package/components/region.json +14 -2
- package/components/search.json +221 -0
- package/components/searchinput.json +132 -0
- package/components/searchitems.json +215 -0
- package/components/searchselect.json +195 -0
- package/components/select.json +686 -666
- package/components/sidebar.json +198 -0
- package/components/skeleton.json +233 -0
- package/components/spin.json +8 -1
- package/components/split.json +260 -0
- package/components/sshkeys.json +138 -0
- package/components/status.json +60 -3
- package/components/steps.json +7 -0
- package/components/switch.json +8 -1
- package/components/table.json +18 -1
- package/components/tablecolumnid.json +14 -2
- package/components/tabs.json +12 -0
- package/components/timeline.json +213 -0
- package/components/timepicker.json +147 -3
- package/components/timerange.json +262 -0
- package/components/tip.json +7 -0
- package/components/tooltip.json +484 -395
- package/components/tour.json +418 -372
- package/components/transfer.json +27 -3
- package/components/tree.json +6 -4
- package/components/treeselect.json +556 -475
- package/components/upload.json +474 -473
- package/components/vdialog.json +308 -0
- package/components/vdrawer.json +331 -0
- package/components/virtuallist.json +7 -0
- package/dist/ast/index.d.mts +35 -1
- package/dist/ast/index.d.ts +35 -1
- package/dist/ast/index.js +5 -3
- package/dist/ast/index.mjs +3 -1
- package/dist/{chunk-DSWKLUIX.mjs → chunk-3LYQ5XFM.mjs} +1 -1
- package/dist/chunk-BI5TIQID.mjs +330 -0
- package/dist/{chunk-6QS5IGS6.js → chunk-CJGGFVQJ.js} +8 -8
- package/dist/chunk-CR3GC4H3.js +353 -0
- package/dist/{chunk-NZ6TLWMD.mjs → chunk-D2SXGGTX.mjs} +28 -17
- package/dist/{chunk-D3Y6FGWA.js → chunk-EYKZY2F3.js} +29 -18
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/chunk-KF5YBEM5.js +143 -0
- package/dist/chunk-KMIDURUR.mjs +33324 -0
- package/dist/chunk-QC6VTSA3.mjs +117 -0
- package/dist/chunk-SZYVGYKK.js +33350 -0
- package/dist/{chunk-WYSRJVX4.js → chunk-TA3SV4SP.js} +2 -2
- package/dist/chunk-UJCSKKID.mjs +27 -0
- package/dist/{chunk-FVSQ6BU6.mjs → chunk-XGPHQHLR.mjs} +4 -4
- package/dist/docs/index.js +1 -1
- package/dist/docs/index.mjs +1 -1
- package/dist/full/index.js +8 -6
- package/dist/full/index.mjs +6 -4
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -13
- package/dist/index.mjs +7 -5
- package/dist/metadata/index.d.mts +22 -2
- package/dist/metadata/index.d.ts +22 -2
- package/dist/metadata/index.js +27 -17
- package/dist/metadata/index.mjs +27 -16
- package/dist/resolve-BsLBxlBi.d.mts +24 -0
- package/dist/resolve-BsLBxlBi.d.ts +24 -0
- package/dist/runtime/index.js +5 -4
- package/dist/runtime/index.mjs +3 -2
- package/dist/shared/index.d.mts +10 -0
- package/dist/shared/index.d.ts +10 -0
- package/dist/shared/index.js +23 -0
- package/dist/shared/index.mjs +2 -0
- package/dist/static/index.js +6 -5
- package/dist/static/index.mjs +3 -2
- package/docs_for_llm/actions.doc.md +77 -0
- package/docs_for_llm/advancedset.doc.md +89 -0
- package/docs_for_llm/affix.doc.md +15 -7
- package/docs_for_llm/aksk.doc.md +111 -0
- package/docs_for_llm/az.doc.md +17 -11
- package/docs_for_llm/badge.doc.md +6 -5
- package/docs_for_llm/billtypes.doc.md +17 -11
- package/docs_for_llm/breadcrumb.doc.md +6 -3
- package/docs_for_llm/button.doc.md +34 -18
- package/docs_for_llm/buttonlink.doc.md +55 -0
- package/docs_for_llm/card.doc.md +8 -5
- package/docs_for_llm/cardcol.doc.md +78 -0
- package/docs_for_llm/cardcols.doc.md +84 -0
- package/docs_for_llm/cardcontent.doc.md +10 -10
- package/docs_for_llm/cardtabs.doc.md +106 -0
- package/docs_for_llm/carousel.doc.md +8 -7
- package/docs_for_llm/cascader.doc.md +46 -25
- package/docs_for_llm/checkbox.doc.md +25 -13
- package/docs_for_llm/cidrinput.doc.md +83 -0
- package/docs_for_llm/code.doc.md +22 -11
- package/docs_for_llm/collapse.doc.md +9 -6
- package/docs_for_llm/colorpicker.doc.md +104 -0
- package/docs_for_llm/copy.doc.md +15 -13
- package/docs_for_llm/copyhover.doc.md +59 -0
- package/docs_for_llm/copyrow.doc.md +71 -0
- package/docs_for_llm/datepicker.doc.md +51 -39
- package/docs_for_llm/description.doc.md +75 -0
- package/docs_for_llm/descriptions.doc.md +9 -6
- package/docs_for_llm/dialog.doc.md +48 -77
- package/docs_for_llm/divider.doc.md +9 -7
- package/docs_for_llm/drawer.doc.md +43 -84
- package/docs_for_llm/dropdown.doc.md +52 -21
- package/docs_for_llm/duration.doc.md +76 -0
- package/docs_for_llm/editable.doc.md +36 -14
- package/docs_for_llm/ellipsis.doc.md +10 -5
- package/docs_for_llm/filtertablefieldsdialog.doc.md +99 -0
- package/docs_for_llm/flex.doc.md +74 -0
- package/docs_for_llm/form.doc.md +33 -14
- package/docs_for_llm/formiteminput.doc.md +128 -0
- package/docs_for_llm/formitemspinner.doc.md +105 -0
- package/docs_for_llm/formitemswitch.doc.md +113 -0
- package/docs_for_llm/formitemtableconfigs.doc.md +95 -0
- package/docs_for_llm/grid.doc.md +7 -5
- package/docs_for_llm/header.doc.md +85 -0
- package/docs_for_llm/icon.doc.md +12 -8
- package/docs_for_llm/icontooltip.doc.md +121 -0
- package/docs_for_llm/input.doc.md +90 -39
- package/docs_for_llm/instancelist.doc.md +113 -0
- package/docs_for_llm/instancenum.doc.md +95 -0
- package/docs_for_llm/ipinput.doc.md +77 -0
- package/docs_for_llm/kspstatus.doc.md +82 -0
- package/docs_for_llm/kvcode.doc.md +76 -0
- package/docs_for_llm/layoutcontent.doc.md +17 -17
- package/docs_for_llm/layoutlistcontent.doc.md +95 -0
- package/docs_for_llm/layoutpermissioncontent.doc.md +84 -0
- package/docs_for_llm/layoutstandardlist.doc.md +120 -0
- package/docs_for_llm/layouttabs.doc.md +101 -0
- package/docs_for_llm/lazymount.doc.md +73 -0
- package/docs_for_llm/lazyteleport.doc.md +76 -0
- package/docs_for_llm/menu.doc.md +14 -11
- package/docs_for_llm/message.doc.md +48 -10
- package/docs_for_llm/pagination.doc.md +30 -17
- package/docs_for_llm/paginationplus.doc.md +31 -10
- package/docs_for_llm/password.doc.md +86 -0
- package/docs_for_llm/popover.doc.md +24 -55
- package/docs_for_llm/progress.doc.md +13 -10
- package/docs_for_llm/projects.doc.md +91 -0
- package/docs_for_llm/protable.doc.md +89 -15
- package/docs_for_llm/queuevisualrange.doc.md +78 -0
- package/docs_for_llm/radio.doc.md +23 -8
- package/docs_for_llm/rate.doc.md +122 -0
- package/docs_for_llm/region.doc.md +25 -13
- package/docs_for_llm/search.doc.md +120 -0
- package/docs_for_llm/searchinput.doc.md +111 -0
- package/docs_for_llm/searchitems.doc.md +116 -0
- package/docs_for_llm/searchselect.doc.md +126 -0
- package/docs_for_llm/select.doc.md +40 -55
- package/docs_for_llm/sidebar.doc.md +133 -0
- package/docs_for_llm/skeleton.doc.md +117 -0
- package/docs_for_llm/slider.doc.md +31 -21
- package/docs_for_llm/spin.doc.md +8 -5
- package/docs_for_llm/spinner.doc.md +28 -18
- package/docs_for_llm/split.doc.md +157 -0
- package/docs_for_llm/sshkeys.doc.md +88 -0
- package/docs_for_llm/status.doc.md +14 -9
- package/docs_for_llm/steps.doc.md +10 -7
- package/docs_for_llm/switch.doc.md +17 -14
- package/docs_for_llm/table.doc.md +118 -51
- package/docs_for_llm/tablecolumnid.doc.md +36 -16
- package/docs_for_llm/tabs.doc.md +19 -10
- package/docs_for_llm/tag.doc.md +19 -10
- package/docs_for_llm/timeline.doc.md +109 -0
- package/docs_for_llm/timepicker.doc.md +57 -38
- package/docs_for_llm/timerange.doc.md +157 -0
- package/docs_for_llm/tip.doc.md +20 -11
- package/docs_for_llm/tooltip.doc.md +55 -29
- package/docs_for_llm/tour.doc.md +48 -29
- package/docs_for_llm/transfer.doc.md +40 -29
- package/docs_for_llm/tree.doc.md +65 -23
- package/docs_for_llm/treeselect.doc.md +37 -48
- package/docs_for_llm/upload.doc.md +56 -32
- package/docs_for_llm/useCRUD.doc.md +49 -0
- package/docs_for_llm/useCountdown.doc.md +43 -0
- package/docs_for_llm/useDetail.doc.md +48 -0
- package/docs_for_llm/useDialog.doc.md +46 -0
- package/docs_for_llm/useEntity.doc.md +45 -0
- package/docs_for_llm/useEventListener.doc.md +44 -0
- package/docs_for_llm/useFalseUntilTruthy.doc.md +41 -0
- package/docs_for_llm/useGetCopyAuthText.doc.md +35 -0
- package/docs_for_llm/useGetUserPermission.doc.md +43 -0
- package/docs_for_llm/useGroup.doc.md +48 -0
- package/docs_for_llm/useIdEntities.doc.md +48 -0
- package/docs_for_llm/useIdEntity.doc.md +103 -0
- package/docs_for_llm/useInterval.doc.md +43 -0
- package/docs_for_llm/useLayoutStandardList.doc.md +38 -0
- package/docs_for_llm/useMessage.doc.md +46 -0
- package/docs_for_llm/useModifyCache.doc.md +37 -0
- package/docs_for_llm/useOpenDialog.doc.md +41 -0
- package/docs_for_llm/usePagination.doc.md +60 -0
- package/docs_for_llm/usePersist.doc.md +54 -0
- package/docs_for_llm/usePoll.doc.md +41 -0
- package/docs_for_llm/useRoutePlus.doc.md +34 -0
- package/docs_for_llm/useRouterPlus.doc.md +34 -0
- package/docs_for_llm/useSearch.doc.md +68 -0
- package/docs_for_llm/useShell.doc.md +43 -0
- package/docs_for_llm/useSkip.doc.md +41 -0
- package/docs_for_llm/useStorageIdEntity.doc.md +46 -0
- package/docs_for_llm/useStore.doc.md +34 -0
- package/docs_for_llm/useTable.doc.md +57 -0
- package/docs_for_llm/useTableGroup.doc.md +47 -0
- package/docs_for_llm/useTableSort.doc.md +40 -0
- package/docs_for_llm/useToState.doc.md +112 -0
- package/docs_for_llm/useUser.doc.md +38 -0
- package/docs_for_llm/useValidForm.doc.md +41 -0
- package/docs_for_llm/vdialog.doc.md +129 -0
- package/docs_for_llm/vdrawer.doc.md +119 -0
- package/docs_for_llm/virtuallist.doc.md +6 -3
- package/hooks/useCRUD.json +61 -0
- package/hooks/useCountdown.json +49 -0
- package/hooks/useDetail.json +67 -0
- package/hooks/useDialog.json +49 -0
- package/hooks/useEntity.json +61 -0
- package/hooks/useEventListener.json +61 -0
- package/hooks/useFalseUntilTruthy.json +43 -0
- package/hooks/useGetCopyAuthText.json +36 -0
- package/hooks/useGetUserPermission.json +55 -0
- package/hooks/useGroup.json +49 -0
- package/hooks/useIdEntities.json +61 -0
- package/hooks/useInterval.json +55 -0
- package/hooks/useLayoutStandardList.json +36 -0
- package/hooks/useMessage.json +73 -0
- package/hooks/useModifyCache.json +36 -0
- package/hooks/useOpenDialog.json +43 -0
- package/hooks/usePagination.json +49 -0
- package/hooks/usePersist.json +61 -0
- package/hooks/usePoll.json +43 -0
- package/hooks/useRoutePlus.json +36 -0
- package/hooks/useRouterPlus.json +36 -0
- package/hooks/useSearch.json +56 -0
- package/hooks/useShell.json +49 -0
- package/hooks/useSkip.json +43 -0
- package/hooks/useStorageIdEntity.json +67 -0
- package/hooks/useStore.json +36 -0
- package/hooks/useTable.json +49 -0
- package/hooks/useTableGroup.json +43 -0
- package/hooks/useTableSort.json +43 -0
- package/hooks/useUser.json +36 -0
- package/hooks/useValidForm.json +43 -0
- package/package.json +12 -6
- package/dist/chunk-HDV7ETXE.mjs +0 -1055
- package/dist/chunk-HPAUCD5I.js +0 -156
- package/dist/chunk-L4DS3EXI.mjs +0 -133
- package/dist/chunk-YWY3D4J7.js +0 -1082
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 表格操作弹窗 (useOpenDialog)
|
|
2
|
+
|
|
3
|
+
针对表格单行操作和批量操作封装弹窗打开逻辑,统一维护当前操作项和批量操作项集合。
|
|
4
|
+
|
|
5
|
+
**关键词**: useOpenDialog, 批量操作, 表格操作, dialog, 单行操作, tableRef
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useOpenDialog } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| tableRef | `Ref<Table | undefined>` | 否 | 表格实例引用,批量操作时可从表格中读取选中项 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ isShowDialog: Ref<boolean>; dialogRef: Ref<any>; opCols: Ref<T[] | undefined>; opCol: Ref<T | undefined>; show: Function; hide: Function; handleClickOpBtn: Function; handleClickBatchOpBtn: Function; }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 批量操作场景未传入 tableRef,导致无法读取选中项
|
|
24
|
+
> **错误用法**: `const dialog = useOpenDialog();`
|
|
25
|
+
> **正确写法**: `const dialog = useOpenDialog(tableRef);`
|
|
26
|
+
> **说明**: 如果需要 handleClickBatchOpBtn 读取表格选中项,应传入 tableRef。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### 表格操作弹窗
|
|
30
|
+
点击单行操作按钮时打开弹窗并记录当前行数据
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { ref } from 'vue';
|
|
35
|
+
import { useOpenDialog } from '@ksyun-internal/versatile';
|
|
36
|
+
|
|
37
|
+
const tableRef = ref();
|
|
38
|
+
const { isShowDialog, opCol, handleClickOpBtn } = useOpenDialog(tableRef);
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# 分页状态管理 (usePagination)
|
|
2
|
+
|
|
3
|
+
管理列表页常用的 page、limit、limits 以及分页变更回调,适合和 ProTable、PaginationPlus、Search 组合使用。
|
|
4
|
+
|
|
5
|
+
**关键词**: usePagination, 分页, page, limit, PaginationPlus, 列表页
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { usePagination } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| options | `{ page?: number; limit?: number; limits?: number[]; callback?: (v: PaginationChangeData) => void }` | 否 | 分页初始化配置,可预设页码、每页条数、可选 limits 及翻页后的回调 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ page: Ref<number>; limit: Ref<number>; limits: Ref<number[]>; pageChange: (pageParams: PaginationChangeData) => void; }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 只绑定 page,没有同步维护 limit
|
|
24
|
+
> **错误用法**: `const { page } = usePagination();`
|
|
25
|
+
> **正确写法**: `const { page, limit } = usePagination();`
|
|
26
|
+
> **说明**: 如果页面支持切换每页条数,应同时使用 hook 返回的 limit。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### 基础分页用法
|
|
30
|
+
通过 hook 统一管理列表页码和每页条数
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { PaginationPlus, usePagination } from '@ksyun-internal/versatile';
|
|
35
|
+
|
|
36
|
+
const { page, limit, pageChange } = usePagination({
|
|
37
|
+
page: 1,
|
|
38
|
+
limit: 20,
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<PaginationPlus v-model="page" v-model:limit="limit" :total="200" @change="pageChange" />
|
|
44
|
+
</template>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 带回调的分页
|
|
48
|
+
在分页变化后触发数据刷新或埋点逻辑
|
|
49
|
+
|
|
50
|
+
```vue
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import { usePagination } from '@ksyun-internal/versatile';
|
|
53
|
+
|
|
54
|
+
const fetchList = () => console.log('reload');
|
|
55
|
+
const { page, limit, pageChange } = usePagination({
|
|
56
|
+
callback: () => fetchList(),
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
60
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 本地持久化 (usePersist)
|
|
2
|
+
|
|
3
|
+
将响应式数据持久化到 localStorage 或 sessionStorage,适合保存列表筛选、用户偏好和表格配置。
|
|
4
|
+
|
|
5
|
+
**关键词**: usePersist, localStorage, sessionStorage, 持久化, 列表偏好, 缓存状态
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { usePersist } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| key | `string` | 是 | 存储键名 |
|
|
16
|
+
| defaultValue | `T` | 是 | 初始化默认值 |
|
|
17
|
+
| options | `PersistOptions<T>` | 否 | 持久化配置,可切换 storage、自定义序列化和 watch 行为 |
|
|
18
|
+
|
|
19
|
+
## 返回值
|
|
20
|
+
```typescript
|
|
21
|
+
Ref<T>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
25
|
+
### 使用会变化的 key,导致同一份状态被重复写入
|
|
26
|
+
> **错误用法**: `usePersist(`table-${Date.now()}`, []);`
|
|
27
|
+
> **正确写法**: `usePersist('instance-table-fields', []);`
|
|
28
|
+
> **说明**: key 应保持稳定,否则无法复用持久化结果。
|
|
29
|
+
|
|
30
|
+
## 使用示例
|
|
31
|
+
### 持久化表格配置
|
|
32
|
+
保存用户的列显隐或筛选配置
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { usePersist } from '@ksyun-internal/versatile';
|
|
37
|
+
|
|
38
|
+
const tableFields = usePersist('table-fields', ['name', 'status']);
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 使用 sessionStorage
|
|
43
|
+
仅在当前会话内保留搜索状态
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { usePersist } from '@ksyun-internal/versatile';
|
|
48
|
+
|
|
49
|
+
const searchState = usePersist('instance-search', { key: 'name', value: '' }, {
|
|
50
|
+
storage: sessionStorage,
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 查询轮询 (usePoll)
|
|
2
|
+
|
|
3
|
+
包装 Apollo 查询结果并启用轮询场景,适合在列表页、详情页中持续刷新接口数据。
|
|
4
|
+
|
|
5
|
+
**关键词**: usePoll, 轮询, apollo, useQuery, 自动刷新, 列表轮询
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { usePoll } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| result | `UseQueryReturn<any, any>` | 是 | Apollo useQuery 返回的查询对象 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
UseQueryReturn<any, any>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 传入普通 Promise 或自定义对象而不是 Apollo 查询返回值
|
|
24
|
+
> **错误用法**: `const result = usePoll(fetchList());`
|
|
25
|
+
> **正确写法**: `const result = usePoll(useQuery(GET_LIST));`
|
|
26
|
+
> **说明**: usePoll 依赖 Apollo 的 UseQueryReturn 结构。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### 轮询查询结果
|
|
30
|
+
对 useQuery 返回值启用轮询式刷新
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { useQuery } from '@vue/apollo-composable';
|
|
35
|
+
import { usePoll } from '@ksyun-internal/versatile';
|
|
36
|
+
|
|
37
|
+
const queryResult = useQuery(GET_INSTANCE_LIST);
|
|
38
|
+
const pollResult = usePoll(queryResult);
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# 增强路由读取 (useRoutePlus)
|
|
2
|
+
|
|
3
|
+
对 vue-router 的 route 做包装,直接返回 params、query 及其 refs,便于在组合式函数中按字段响应式使用。
|
|
4
|
+
|
|
5
|
+
**关键词**: useRoutePlus, route params, query refs, vue-router, 详情页参数, 路由读取
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useRoutePlus } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 返回值
|
|
13
|
+
```typescript
|
|
14
|
+
{ $route: RouteLocationNormalizedLoadedGeneric; params: Record<string, string>; paramRefs: ToRefs<Record<string, string>>; query: LocationQuery; queryRefs: ToRefs<LocationQuery>; }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
18
|
+
### 直接修改 paramRefs/queryRefs,期望同步改写路由地址
|
|
19
|
+
> **错误用法**: `paramRefs.id.value = '2';`
|
|
20
|
+
> **正确写法**: `如需跳转,请配合 useRouterPlus 或 router.push。`
|
|
21
|
+
> **说明**: 这个 hook 主要用于读取路由状态,不负责写回 URL。
|
|
22
|
+
|
|
23
|
+
## 使用示例
|
|
24
|
+
### 读取详情页路由参数
|
|
25
|
+
把详情页 id 和 query 参数拆成可直接使用的 refs
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { useRoutePlus } from '@ksyun-internal/versatile';
|
|
30
|
+
|
|
31
|
+
const { params, paramRefs, queryRefs } = useRoutePlus();
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# 增强路由跳转 (useRouterPlus)
|
|
2
|
+
|
|
3
|
+
对 vue-router 的导航能力做统一封装,提供新开页签跳转和可回退的导航能力。
|
|
4
|
+
|
|
5
|
+
**关键词**: useRouterPlus, goNewPage, goBack, 路由跳转, 新开页签, vue-router
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useRouterPlus } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 返回值
|
|
13
|
+
```typescript
|
|
14
|
+
{ $router: Router; goNewPage: (to: string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric, currentLocation?: RouteLocationNormalizedLoadedGeneric) => void; goBack: (back?: string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric) => void; }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
18
|
+
### 调用 goBack 但没有提供兜底地址,历史栈不足时体验不稳定
|
|
19
|
+
> **错误用法**: `goBack();`
|
|
20
|
+
> **正确写法**: `goBack({ name: 'instance-list' });`
|
|
21
|
+
> **说明**: 在业务列表/详情页之间跳转时,建议提供明确回退目标。
|
|
22
|
+
|
|
23
|
+
## 使用示例
|
|
24
|
+
### 跳转详情页或新页签打开
|
|
25
|
+
在列表页操作列中统一处理跳转行为
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { useRouterPlus } from '@ksyun-internal/versatile';
|
|
30
|
+
|
|
31
|
+
const { goNewPage, goBack } = useRouterPlus();
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# 搜索状态管理 (useSearch)
|
|
2
|
+
|
|
3
|
+
管理 Search 和 SearchItems 常用的搜索状态,统一维护 searchKey、searchValue、searchItems 及其变更方法。配合列表页分页时可在筛选变化后重置页码。
|
|
4
|
+
|
|
5
|
+
**关键词**: useSearch, Search, SearchItems, 列表筛选, 搜索状态, 检索条件
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useSearch } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| options | `{ defaultSearchKey?: string; page?: Ref<number> }` | 否 | 初始化配置,可指定默认搜索字段,并传入分页页码以便搜索变化时联动重置 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ searchKey: Ref<string>; searchKeyRela: Ref<string>; searchValue: Ref<string>; searchItems: Ref<T | undefined>; searchItemsRef: Ref<any>; handleChangeSearchValue: Function; handleChangeSingleValue: Function; handleChangeSearchSingleValue: Function; }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 列表页搜索变化时没有传入 page,导致筛选后仍停留在旧页码
|
|
24
|
+
> **错误用法**: `const search = useSearch();`
|
|
25
|
+
> **正确写法**: `const search = useSearch({ page });`
|
|
26
|
+
> **说明**: 在分页列表中建议把 page 传给 useSearch,让搜索条件变化时同步回到第一页。
|
|
27
|
+
|
|
28
|
+
### 重复自己维护 searchKey/searchValue,和 hook 返回值并存
|
|
29
|
+
> **错误用法**: `const searchKey = ref('name'); const searchValue = ref(''); const { searchItems } = useSearch();`
|
|
30
|
+
> **正确写法**: `const { searchKey, searchValue, searchItems } = useSearch({ defaultSearchKey: 'name' });`
|
|
31
|
+
> **说明**: 优先使用 useSearch 返回的整套状态,避免来源分裂。
|
|
32
|
+
|
|
33
|
+
## 使用示例
|
|
34
|
+
### 列表页搜索状态
|
|
35
|
+
在列表页中统一维护搜索 key、搜索值和搜索项
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import { Search, SearchItems, usePagination, useSearch } from '@ksyun-internal/versatile';
|
|
40
|
+
|
|
41
|
+
const { page } = usePagination();
|
|
42
|
+
const { searchKey, searchValue, searchItems } = useSearch({
|
|
43
|
+
defaultSearchKey: 'name',
|
|
44
|
+
page,
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<Search v-model:search-key="searchKey" v-model:search-value="searchValue" :searches="[]" />
|
|
50
|
+
<SearchItems v-model="searchItems" />
|
|
51
|
+
</template>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 手动处理搜索值变更
|
|
55
|
+
通过返回的方法接管批量搜索或单值搜索的更新逻辑
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<script setup lang="ts">
|
|
59
|
+
import { useSearch } from '@ksyun-internal/versatile';
|
|
60
|
+
|
|
61
|
+
const { handleChangeSearchValue } = useSearch();
|
|
62
|
+
|
|
63
|
+
const onSearch = (value?: string) => {
|
|
64
|
+
handleChangeSearchValue(value, value);
|
|
65
|
+
};
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Shell 内容挂载 (useShell)
|
|
2
|
+
|
|
3
|
+
在弹窗显示时把 shell 或命令内容挂载到指定容器引用,适合命令预览、终端输出展示等场景。
|
|
4
|
+
|
|
5
|
+
**关键词**: useShell, shell, 命令预览, dialog content, 终端输出, shellRef
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useShell } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| content | `WatchSource<string | undefined | null>` | 是 | 需要展示的 shell 内容 |
|
|
16
|
+
| isShowDialog | `Ref<boolean>` | 是 | 弹窗显隐状态 |
|
|
17
|
+
|
|
18
|
+
## 返回值
|
|
19
|
+
```typescript
|
|
20
|
+
{ shellRef: Ref<any> }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
24
|
+
### 传入一次性字符串字面量,后续更新不会同步
|
|
25
|
+
> **错误用法**: `useShell('kubectl get pods', isShowDialog);`
|
|
26
|
+
> **正确写法**: `const content = ref('kubectl get pods'); useShell(content, isShowDialog);`
|
|
27
|
+
> **说明**: 内容建议使用 Ref 或 getter,便于后续更新时同步渲染。
|
|
28
|
+
|
|
29
|
+
## 使用示例
|
|
30
|
+
### 命令预览弹窗
|
|
31
|
+
在弹窗打开时渲染命令或脚本内容
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { ref } from 'vue';
|
|
36
|
+
import { useShell } from '@ksyun-internal/versatile';
|
|
37
|
+
|
|
38
|
+
const content = ref('kubectl get pods');
|
|
39
|
+
const isShowDialog = ref(false);
|
|
40
|
+
const { shellRef } = useShell(content, isShowDialog);
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 头部返回跳转 (useSkip)
|
|
2
|
+
|
|
3
|
+
从 Header 的 back 配置中提取统一跳转逻辑,适合详情页和购买链路页的返回按钮行为。
|
|
4
|
+
|
|
5
|
+
**关键词**: useSkip, Header back, 返回跳转, 详情页返回, goLink, layout header
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useSkip } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| back | `Ref<LayoutHeaderProps['back']>` | 是 | Header 的 back 配置项 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ goLink: () => any }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 直接传普通对象而不是 Ref,导致 back 配置变化无法联动
|
|
24
|
+
> **错误用法**: `useSkip({ to: { name: 'list' } });`
|
|
25
|
+
> **正确写法**: `const back = ref({ to: { name: 'list' } }); useSkip(back);`
|
|
26
|
+
> **说明**: hook 设计为消费 Header back 的响应式配置。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### Header 返回按钮
|
|
30
|
+
复用 Header back 配置实现统一返回跳转
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { ref } from 'vue';
|
|
35
|
+
import { useSkip } from '@ksyun-internal/versatile';
|
|
36
|
+
|
|
37
|
+
const back = ref({ to: { name: 'instance-list' } });
|
|
38
|
+
const { goLink } = useSkip(back);
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# 带存储的 ID 实体映射 (useStorageIdEntity)
|
|
2
|
+
|
|
3
|
+
在 useIdEntity 的基础上增加存储键能力,适合把当前选中的实体 ID 与本地缓存联动,支持刷新后恢复选择。
|
|
4
|
+
|
|
5
|
+
**关键词**: useStorageIdEntity, 本地记忆选择, storage, 实体映射, 刷新恢复, workspace
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useStorageIdEntity } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| id | `Ref<string | number | undefined | null>` | 是 | 当前选中的实体 ID |
|
|
16
|
+
| list | `Ref<Entity[] | undefined | null>` | 是 | 实体源列表 |
|
|
17
|
+
| key | `keyof Entity` | 是 | 实体主键字段 |
|
|
18
|
+
| storageName | `string` | 否 | 本地存储使用的键名 |
|
|
19
|
+
| emit | `(entity: Entity | undefined) => void` | 否 | 实体变化时的回调 |
|
|
20
|
+
|
|
21
|
+
## 返回值
|
|
22
|
+
```typescript
|
|
23
|
+
Ref<Entity | undefined>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
27
|
+
### 多个页面复用同一个 storageName,导致选择串数据
|
|
28
|
+
> **错误用法**: `useStorageIdEntity(id, list, 'id', 'selected-id');`
|
|
29
|
+
> **正确写法**: `useStorageIdEntity(id, list, 'id', 'instance-workspace-id');`
|
|
30
|
+
> **说明**: storageName 建议按业务域区分,避免不同页面互相覆盖。
|
|
31
|
+
|
|
32
|
+
## 使用示例
|
|
33
|
+
### 记住上次选择的实体
|
|
34
|
+
页面刷新后仍恢复用户上次选择的对象
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
import { ref } from 'vue';
|
|
39
|
+
import { useStorageIdEntity } from '@ksyun-internal/versatile';
|
|
40
|
+
|
|
41
|
+
const selectedId = ref('ws-001');
|
|
42
|
+
const workspaceList = ref([{ WorkspaceId: 'ws-001', WorkspaceName: '工作空间1' }]);
|
|
43
|
+
const currentWorkspace = useStorageIdEntity(selectedId, workspaceList, 'WorkspaceId', 'workspace-id');
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# 轻量全局状态 (useStore)
|
|
2
|
+
|
|
3
|
+
读取和写入 versatile 内部维护的轻量全局状态,当前暴露地域 key 和地域列表的读写能力。
|
|
4
|
+
|
|
5
|
+
**关键词**: useStore, regionKey, regionList, 全局状态, 地域缓存, 共享状态
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useStore } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 返回值
|
|
13
|
+
```typescript
|
|
14
|
+
{ setRegionKey: (regionKey: string) => void; setRegionList: (regionList: any[]) => void; regionKey: ComputedRef<string>; regionList: ComputedRef<any[]>; }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
18
|
+
### 直接修改 regionList/regionKey,而不是走 setter
|
|
19
|
+
> **错误用法**: `regionKey.value = 'cn-beijing-6';`
|
|
20
|
+
> **正确写法**: `setRegionKey('cn-beijing-6');`
|
|
21
|
+
> **说明**: 返回的状态是 computed,只读修改应通过 setter 完成。
|
|
22
|
+
|
|
23
|
+
## 使用示例
|
|
24
|
+
### 共享地域状态
|
|
25
|
+
在 Region、AZ 或购买页中共享当前地域选择
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { useStore } from '@ksyun-internal/versatile';
|
|
30
|
+
|
|
31
|
+
const { regionKey, regionList, setRegionKey, setRegionList } = useStore();
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 表格状态管理 (useTable)
|
|
2
|
+
|
|
3
|
+
集中管理表格勾选、展开、列显隐和导出相关状态,适合原子 Table 和业务表格容器共享同一套表格控制逻辑。
|
|
4
|
+
|
|
5
|
+
**关键词**: useTable, Table, 勾选状态, 列显隐, 导出表格, rowKey
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useTable } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| options | `{ rowKey?: string; notCheckTip?: string; tableFields?: TableFields }` | 否 | 表格配置,可指定 rowKey、未勾选提示文案和列配置定义 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ checkedKeys: Ref<string[]>; expandedKeys: Ref<(string | number)[]>; isChecked: ComputedRef<number>; canCheck: ComputedRef<{ disabled: boolean; msg: string }>; tableRef: Ref<Table | undefined>; componentRef: Ref<any>; noCheckedColFields: Ref<string[]>; setRowKey: Function; exportTableData: Function; hideCol: Function; getTableColTitle: ((key: string) => string) | null; initTableColumnProps: Function; }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 多选或导出场景没有稳定 rowKey,导致勾选数据不稳定
|
|
24
|
+
> **错误用法**: `const table = useTable();`
|
|
25
|
+
> **正确写法**: `const table = useTable({ rowKey: 'id' });`
|
|
26
|
+
> **说明**: 在业务表格中建议显式指定 rowKey,避免勾选项和导出数据映射错乱。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### 管理表格勾选和列显隐
|
|
30
|
+
在列表页中集中维护勾选状态和动态列配置
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { useTable } from '@ksyun-internal/versatile';
|
|
35
|
+
|
|
36
|
+
const tableFields = [
|
|
37
|
+
{ key: 'name', label: '实例名称', checked: true },
|
|
38
|
+
{ key: 'status', label: '状态', checked: true },
|
|
39
|
+
];
|
|
40
|
+
const { checkedKeys, tableRef, canCheck, initTableColumnProps } = useTable({
|
|
41
|
+
rowKey: 'id',
|
|
42
|
+
tableFields,
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 导出当前表格数据
|
|
48
|
+
通过 hook 暴露的导出方法触发表格导出
|
|
49
|
+
|
|
50
|
+
```vue
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import { useTable } from '@ksyun-internal/versatile';
|
|
53
|
+
|
|
54
|
+
const { exportTableData } = useTable({ rowKey: 'id' });
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 表格分组筛选状态 (useTableGroup)
|
|
2
|
+
|
|
3
|
+
管理 Table 或 ProTable 的 group 筛选状态,并可与 SearchItems 联动生成可展示的筛选项。
|
|
4
|
+
|
|
5
|
+
**关键词**: useTableGroup, group, ProTable, 表格筛选, SearchItems, 状态分组
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useTableGroup } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| options | `{ page?: Ref<number>; key?: string; defalutValue?: any; searchItemsRef?: Ref<any>; labelMaps?: Record<string, string> | Ref<Record<string, string>>; groupLabel?: string | Record<string, string | { label: string }>; isShowSearchItem?: boolean }` | 否 | 分组筛选配置,可联动分页、SearchItems 和字段标签映射 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ status: ComputedRef<any>; group: Ref<Record<string, any>>; resetGroup: Function; changeGroup: Function; }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### SearchItems 展示 group 条件时没有提供 labelMaps 或 groupLabel
|
|
24
|
+
> **错误用法**: `useTableGroup({ searchItemsRef });`
|
|
25
|
+
> **正确写法**: `useTableGroup({ searchItemsRef, labelMaps, groupLabel: '状态' });`
|
|
26
|
+
> **说明**: 如果要把 group 同步到 SearchItems,建议补齐展示文案映射。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### 配合 ProTable 的 group 筛选
|
|
30
|
+
将 group 状态和 SearchItems 联动,统一驱动表格筛选
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { ref } from 'vue';
|
|
35
|
+
import { usePagination, useTableGroup } from '@ksyun-internal/versatile';
|
|
36
|
+
|
|
37
|
+
const { page } = usePagination();
|
|
38
|
+
const searchItemsRef = ref();
|
|
39
|
+
const { group, changeGroup, resetGroup } = useTableGroup({
|
|
40
|
+
page,
|
|
41
|
+
key: 'status',
|
|
42
|
+
searchItemsRef,
|
|
43
|
+
labelMaps: { using: '运行中', shutdown: '已关机' },
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# 表格排序状态 (useTableSort)
|
|
2
|
+
|
|
3
|
+
统一管理表格排序字段和方向,并提供多种派生排序状态,适合请求参数、UI 高亮和布尔/整数映射场景。
|
|
4
|
+
|
|
5
|
+
**关键词**: useTableSort, 排序, TableSortValue, ProTable, 列表排序, sort
|
|
6
|
+
|
|
7
|
+
## 导入语句
|
|
8
|
+
```typescript
|
|
9
|
+
import { useTableSort } from '@ksyun-internal/versatile';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 参数 (Params)
|
|
13
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| page | `Ref<number | undefined>` | 否 | 分页页码,传入后在切换排序时可联动重置页码 |
|
|
16
|
+
|
|
17
|
+
## 返回值
|
|
18
|
+
```typescript
|
|
19
|
+
{ sort: Ref<TableSortValue>; curSortKey: ComputedRef<string | undefined>; curSortType: ComputedRef<'desc' | 'asc' | undefined>; curSortTypeByInt: ComputedRef<0 | 1 | -1>; curSortTypeByBoolean: ComputedRef<boolean | ''>; changeSort: Function; }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 常见错误与正确用法 (Anti-Hallucination)
|
|
23
|
+
### 自己维护 asc/desc 和 0/1/-1 的映射,重复实现 hook 已有能力
|
|
24
|
+
> **错误用法**: `const sortType = computed(() => sort.value.type === 'asc' ? 1 : -1);`
|
|
25
|
+
> **正确写法**: `const { curSortTypeByInt } = useTableSort(page);`
|
|
26
|
+
> **说明**: hook 已经提供多种派生排序表示,优先复用。
|
|
27
|
+
|
|
28
|
+
## 使用示例
|
|
29
|
+
### 列表排序状态
|
|
30
|
+
将排序状态集中管理,并把变更方法绑定给表格
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { usePagination, useTableSort } from '@ksyun-internal/versatile';
|
|
35
|
+
|
|
36
|
+
const { page } = usePagination();
|
|
37
|
+
const { sort, curSortKey, curSortType, changeSort } = useTableSort(page);
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|