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,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useDialog",
|
|
3
|
+
"name": "useDialog",
|
|
4
|
+
"displayName": "弹窗状态管理",
|
|
5
|
+
"category": "dialog",
|
|
6
|
+
"description": "为 VDialog 或 Dialog 表单场景封装显隐、校验、重置和确认按钮行为,减少弹窗表单模板中的重复状态代码。",
|
|
7
|
+
"importStatement": "import { useDialog } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "emit",
|
|
12
|
+
"type": "() => any",
|
|
13
|
+
"required": false,
|
|
14
|
+
"description": "父组件传入的 emit,用于联动弹窗显隐或外部事件"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "isShowParentDialog",
|
|
18
|
+
"type": "Ref<boolean | undefined>",
|
|
19
|
+
"required": false,
|
|
20
|
+
"description": "父级弹窗显隐状态,适合嵌套弹窗场景"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"returnType": "{ dialogRef: Ref<Dialog | undefined>; isShowDialog: Ref<boolean>; formRef: Ref<Form | undefined>; validate: Function; validateByScroll: Function; reset: Function; handleClickOkBtn: Function; handleClickValidOkBtn: Function; show: Function; hide: Function; }",
|
|
24
|
+
"examples": [
|
|
25
|
+
{
|
|
26
|
+
"id": "dialog_form",
|
|
27
|
+
"title": "弹窗表单",
|
|
28
|
+
"description": "配合 VDialog 管理弹窗显隐和表单校验",
|
|
29
|
+
"code": "<script setup lang=\"ts\">\nimport { VDialog, useDialog } from '@ksyun-internal/versatile';\n\nconst { isShowDialog, formRef, show, hide, handleClickValidOkBtn } = useDialog();\n</script>\n\n<template>\n <VDialog v-model=\"isShowDialog\" :ok=\"handleClickValidOkBtn\">\n <Form ref=\"formRef\"></Form>\n </VDialog>\n</template>"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"commonMistakes": [
|
|
33
|
+
{
|
|
34
|
+
"id": "missing_form_ref",
|
|
35
|
+
"description": "调用 validate 或 handleClickValidOkBtn,但没有把 formRef 绑定到表单",
|
|
36
|
+
"wrongCode": "<Form></Form>",
|
|
37
|
+
"correctCode": "<Form ref=\"formRef\"></Form>",
|
|
38
|
+
"explanation": "校验相关方法依赖 formRef 指向真实表单实例。"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"searchKeywords": [
|
|
42
|
+
"useDialog",
|
|
43
|
+
"VDialog",
|
|
44
|
+
"弹窗表单",
|
|
45
|
+
"dialog",
|
|
46
|
+
"validate",
|
|
47
|
+
"show hide"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useEntity",
|
|
3
|
+
"name": "useEntity",
|
|
4
|
+
"displayName": "基础实体映射",
|
|
5
|
+
"category": "state",
|
|
6
|
+
"description": "根据单个 ID 和基础列表做实体同步回调,适合简单的字符串或数字值映射场景。",
|
|
7
|
+
"importStatement": "import { useEntity } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "id",
|
|
12
|
+
"type": "Ref<string | number | undefined | null>",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "当前选中的 ID"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "list",
|
|
18
|
+
"type": "Ref<string[] | number[] | undefined | null>",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "基础值列表"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "emit",
|
|
24
|
+
"type": "(entity: string | number | null | undefined) => void",
|
|
25
|
+
"required": false,
|
|
26
|
+
"description": "值变化时的回调"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "isNeedDefaultValue",
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"required": false,
|
|
32
|
+
"description": "是否需要默认值处理"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"returnType": "void",
|
|
36
|
+
"examples": [
|
|
37
|
+
{
|
|
38
|
+
"id": "simple_entity_mapping",
|
|
39
|
+
"title": "基础值映射",
|
|
40
|
+
"description": "根据当前值从列表里查找对应实体并回调给外层",
|
|
41
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { useEntity } from '@ksyun-internal/versatile';\n\nconst id = ref('cn-beijing-6a');\nconst list = ref(['cn-beijing-6a', 'cn-shanghai-2a']);\nuseEntity(id, list, (entity) => console.log(entity));\n</script>"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"commonMistakes": [
|
|
45
|
+
{
|
|
46
|
+
"id": "expect_return_value",
|
|
47
|
+
"description": "把 useEntity 当成返回实体 Ref 的 hook 使用",
|
|
48
|
+
"wrongCode": "const entity = useEntity(id, list);",
|
|
49
|
+
"correctCode": "useEntity(id, list, (entity) => { current.value = entity; });",
|
|
50
|
+
"explanation": "该 hook 主要通过副作用回调同步值,本身不返回实体 Ref。"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"searchKeywords": [
|
|
54
|
+
"useEntity",
|
|
55
|
+
"简单实体映射",
|
|
56
|
+
"id value",
|
|
57
|
+
"回调同步",
|
|
58
|
+
"基础列表",
|
|
59
|
+
"单值"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useEventListener",
|
|
3
|
+
"name": "useEventListener",
|
|
4
|
+
"displayName": "事件监听封装",
|
|
5
|
+
"category": "event",
|
|
6
|
+
"description": "为 HTMLElement、window、document 或 Ref 目标统一注册事件监听,并支持 throttle、debounce 与原生 addEventListener 配置。",
|
|
7
|
+
"importStatement": "import { useEventListener } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "target",
|
|
12
|
+
"type": "HTMLElement | Window | Document | Ref<HTMLElement | null> | (() => HTMLElement | null)",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "监听目标"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "event",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "事件名"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "handler",
|
|
24
|
+
"type": "EventListenerOrEventListenerObject",
|
|
25
|
+
"required": true,
|
|
26
|
+
"description": "事件处理函数"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "options",
|
|
30
|
+
"type": "{ throttle?: number; debounce?: number; nativeOptions?: boolean | AddEventListenerOptions }",
|
|
31
|
+
"required": false,
|
|
32
|
+
"description": "监听配置,支持节流、防抖和原生监听选项"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"returnType": "void",
|
|
36
|
+
"examples": [
|
|
37
|
+
{
|
|
38
|
+
"id": "window_resize",
|
|
39
|
+
"title": "监听窗口尺寸变化",
|
|
40
|
+
"description": "在页面中节流监听 resize 事件",
|
|
41
|
+
"code": "<script setup lang=\"ts\">\nimport { useEventListener } from '@ksyun-internal/versatile';\n\nuseEventListener(window, 'resize', () => {\n console.log('resize');\n}, { throttle: 200 });\n</script>"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"commonMistakes": [
|
|
45
|
+
{
|
|
46
|
+
"id": "throttle_and_debounce_conflict",
|
|
47
|
+
"description": "同时配置 throttle 和 debounce,但没有明确预期",
|
|
48
|
+
"wrongCode": "useEventListener(window, 'scroll', onScroll, { throttle: 100, debounce: 100 });",
|
|
49
|
+
"correctCode": "根据场景二选一:节流滚动用 throttle,输入联想用 debounce。",
|
|
50
|
+
"explanation": "两者语义不同,建议根据业务场景明确选一种。"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"searchKeywords": [
|
|
54
|
+
"useEventListener",
|
|
55
|
+
"事件监听",
|
|
56
|
+
"window resize",
|
|
57
|
+
"debounce",
|
|
58
|
+
"throttle",
|
|
59
|
+
"addEventListener"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useFalseUntilTruthy",
|
|
3
|
+
"name": "useFalseUntilTruthy",
|
|
4
|
+
"displayName": "延迟转真布尔态",
|
|
5
|
+
"category": "state",
|
|
6
|
+
"description": "将任意响应式值映射成布尔值,并在首次变为 truthy 前始终保持 false,适合权限、异步加载完成态和懒渲染控制。",
|
|
7
|
+
"importStatement": "import { useFalseUntilTruthy } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "value",
|
|
12
|
+
"type": "MaybeRefOrGetter<any>",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "任意响应式值、getter 或普通值"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"returnType": "Readonly<Ref<boolean>>",
|
|
18
|
+
"examples": [
|
|
19
|
+
{
|
|
20
|
+
"id": "guard_render",
|
|
21
|
+
"title": "控制懒渲染",
|
|
22
|
+
"description": "在异步数据真正可用前保持 false,避免中间闪烁",
|
|
23
|
+
"code": "<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { useFalseUntilTruthy } from '@ksyun-internal/versatile';\n\nconst dataReady = computed(() => true);\nconst canRender = useFalseUntilTruthy(dataReady);\n</script>"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"commonMistakes": [
|
|
27
|
+
{
|
|
28
|
+
"id": "expect_reset_false",
|
|
29
|
+
"description": "期望值在 truthy 之后再次回到 false",
|
|
30
|
+
"wrongCode": "const visible = useFalseUntilTruthy(flag); // 认为 flag 再次 false 时 visible 也会 false",
|
|
31
|
+
"correctCode": "如需双向切换,请直接使用 computed(() => !!flag.value)",
|
|
32
|
+
"explanation": "这个 hook 的语义是“在首次变为 truthy 前保持 false”,不是通用的布尔映射。"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"searchKeywords": [
|
|
36
|
+
"useFalseUntilTruthy",
|
|
37
|
+
"false until truthy",
|
|
38
|
+
"懒渲染",
|
|
39
|
+
"加载完成",
|
|
40
|
+
"布尔态",
|
|
41
|
+
"权限准备"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useGetCopyAuthText",
|
|
3
|
+
"name": "useGetCopyAuthText",
|
|
4
|
+
"displayName": "复制授权文案",
|
|
5
|
+
"category": "auth",
|
|
6
|
+
"description": "根据服务名和策略名生成复制授权相关文案,适合复制账号权限说明或 AK/SK 授权提示。",
|
|
7
|
+
"importStatement": "import { useGetCopyAuthText } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [],
|
|
10
|
+
"returnType": "(serviceNames: string | Record<string, string[]>, policyName: string) => string | undefined",
|
|
11
|
+
"examples": [
|
|
12
|
+
{
|
|
13
|
+
"id": "copy_auth_text",
|
|
14
|
+
"title": "生成复制授权提示",
|
|
15
|
+
"description": "根据服务和策略名输出授权说明文案",
|
|
16
|
+
"code": "<script setup lang=\"ts\">\nimport { useGetCopyAuthText } from '@ksyun-internal/versatile';\n\nconst getCopyAuthText = useGetCopyAuthText();\nconst text = getCopyAuthText('KEC', 'KecReadOnlyAccess');\n</script>"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"commonMistakes": [
|
|
20
|
+
{
|
|
21
|
+
"id": "invalid_policy_name",
|
|
22
|
+
"description": "策略名传入页面展示文案而不是实际 policyName",
|
|
23
|
+
"wrongCode": "getCopyAuthText('KEC', '云服务器只读');",
|
|
24
|
+
"correctCode": "getCopyAuthText('KEC', 'KecReadOnlyAccess');",
|
|
25
|
+
"explanation": "第二个参数应使用真实策略标识,而不是中文标题。"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"searchKeywords": [
|
|
29
|
+
"useGetCopyAuthText",
|
|
30
|
+
"复制授权文案",
|
|
31
|
+
"policyName",
|
|
32
|
+
"AKSK",
|
|
33
|
+
"权限说明",
|
|
34
|
+
"授权提示"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useGetUserPermission",
|
|
3
|
+
"name": "useGetUserPermission",
|
|
4
|
+
"displayName": "用户权限判断",
|
|
5
|
+
"category": "auth",
|
|
6
|
+
"description": "根据用户列表和目标权限集合计算当前数据是否具备权限,适合列表操作按钮、批量操作和详情页权限门禁判断。",
|
|
7
|
+
"importStatement": "import { useGetUserPermission } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "users",
|
|
12
|
+
"type": "Ref<User[] | null | undefined>",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "用户或授权主体列表"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "permissions",
|
|
18
|
+
"type": "string[]",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "目标权限编码列表"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "key",
|
|
24
|
+
"type": "keyof User",
|
|
25
|
+
"required": false,
|
|
26
|
+
"description": "权限字段所在的属性名,不传时使用默认字段"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"returnType": "ComputedRef<boolean>",
|
|
30
|
+
"examples": [
|
|
31
|
+
{
|
|
32
|
+
"id": "permission_guard",
|
|
33
|
+
"title": "控制按钮是否可操作",
|
|
34
|
+
"description": "根据用户权限列表生成可直接用于模板的布尔值",
|
|
35
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { useGetUserPermission } from '@ksyun-internal/versatile';\n\nconst users = ref([{ actions: ['instance:view', 'instance:delete'] }]);\nconst canDelete = useGetUserPermission(users, ['instance:delete'], 'actions');\n</script>"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"commonMistakes": [
|
|
39
|
+
{
|
|
40
|
+
"id": "wrong_key_field",
|
|
41
|
+
"description": "传入的 key 不是权限字段,导致结果始终错误",
|
|
42
|
+
"wrongCode": "useGetUserPermission(users, ['instance:delete'], 'name');",
|
|
43
|
+
"correctCode": "useGetUserPermission(users, ['instance:delete'], 'actions');",
|
|
44
|
+
"explanation": "key 应指向用户对象中真正存放权限列表的字段。"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"searchKeywords": [
|
|
48
|
+
"useGetUserPermission",
|
|
49
|
+
"权限判断",
|
|
50
|
+
"操作权限",
|
|
51
|
+
"按钮禁用",
|
|
52
|
+
"auth",
|
|
53
|
+
"permission"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useGroup",
|
|
3
|
+
"name": "useGroup",
|
|
4
|
+
"displayName": "数据分组映射",
|
|
5
|
+
"category": "data",
|
|
6
|
+
"description": "根据输入数据源和分组函数生成实体列表与分组结果,适合把接口返回的数据整理成按键聚合的展示结构。",
|
|
7
|
+
"importStatement": "import { useGroup } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "packages",
|
|
12
|
+
"type": "(() => P[] | undefined) | Ref<P[] | undefined>",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "原始数据源,可传 getter 或 Ref"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "forEach",
|
|
18
|
+
"type": "(pkg: P, fn: (key: K, data: T) => void) => void",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "遍历函数,用于从每个数据项中提取分组 key 和实体数据"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"returnType": "{ entities: Ref<T[] | undefined>; grouped: Ref<Record<K, P[]> | undefined>; }",
|
|
24
|
+
"examples": [
|
|
25
|
+
{
|
|
26
|
+
"id": "group_instances",
|
|
27
|
+
"title": "按状态分组实例列表",
|
|
28
|
+
"description": "把列表数据转换成状态分组结构,便于生成统计和分段展示",
|
|
29
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { useGroup } from '@ksyun-internal/versatile';\n\nconst packages = ref([\n { id: '1', status: 'running', name: '实例1' },\n { id: '2', status: 'stopped', name: '实例2' },\n]);\n\nconst { entities, grouped } = useGroup(packages, (pkg, push) => {\n push(pkg.status, pkg);\n});\n</script>"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"commonMistakes": [
|
|
33
|
+
{
|
|
34
|
+
"id": "forget_push",
|
|
35
|
+
"description": "forEach 中没有调用回调函数,导致 grouped 为空",
|
|
36
|
+
"wrongCode": "useGroup(packages, (pkg) => { console.log(pkg); });",
|
|
37
|
+
"correctCode": "useGroup(packages, (pkg, push) => { push(pkg.status, pkg); });",
|
|
38
|
+
"explanation": "hook 依赖回调函数收集 key 和 data,没有 push 就不会产生分组结果。"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"searchKeywords": [
|
|
42
|
+
"useGroup",
|
|
43
|
+
"分组",
|
|
44
|
+
"grouped",
|
|
45
|
+
"entities",
|
|
46
|
+
"数据整理",
|
|
47
|
+
"聚合展示"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useIdEntities",
|
|
3
|
+
"name": "useIdEntities",
|
|
4
|
+
"displayName": "ID 列表映射实体列表",
|
|
5
|
+
"category": "state",
|
|
6
|
+
"description": "根据多个 ID 从实体列表中映射出对应的实体数组,适合多选组件、批量操作和多实体回显场景。",
|
|
7
|
+
"importStatement": "import { useIdEntities } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "ids",
|
|
12
|
+
"type": "Ref<(string | number)[] | undefined | null>",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "选中的 ID 列表"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "list",
|
|
18
|
+
"type": "Ref<Entity[] | undefined | null>",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "实体源列表"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "key",
|
|
24
|
+
"type": "keyof Entity",
|
|
25
|
+
"required": true,
|
|
26
|
+
"description": "用于匹配的实体主键字段"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "emit",
|
|
30
|
+
"type": "(entity: Entity[] | undefined) => void",
|
|
31
|
+
"required": false,
|
|
32
|
+
"description": "实体数组变化时的回调"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"returnType": "Ref<Entity[] | undefined>",
|
|
36
|
+
"examples": [
|
|
37
|
+
{
|
|
38
|
+
"id": "multi_select_entities",
|
|
39
|
+
"title": "多选值回显实体数组",
|
|
40
|
+
"description": "根据选中的多个 ID 计算出完整对象列表",
|
|
41
|
+
"code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { useIdEntities } from '@ksyun-internal/versatile';\n\nconst ids = ref(['ws-1', 'ws-2']);\nconst list = ref([\n { WorkspaceId: 'ws-1', WorkspaceName: '工作空间1' },\n { WorkspaceId: 'ws-2', WorkspaceName: '工作空间2' },\n]);\nconst entities = useIdEntities(ids, list, 'WorkspaceId');\n</script>"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"commonMistakes": [
|
|
45
|
+
{
|
|
46
|
+
"id": "single_id_instead_of_array",
|
|
47
|
+
"description": "把单个 ID 当作 ids 传入",
|
|
48
|
+
"wrongCode": "useIdEntities(id, list, 'id');",
|
|
49
|
+
"correctCode": "useIdEntities(ids, list, 'id');",
|
|
50
|
+
"explanation": "这个 hook 面向多值场景,首参应是 ID 数组 Ref。"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"searchKeywords": [
|
|
54
|
+
"useIdEntities",
|
|
55
|
+
"多选实体映射",
|
|
56
|
+
"ids",
|
|
57
|
+
"entity list",
|
|
58
|
+
"批量回显",
|
|
59
|
+
"多选"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useInterval",
|
|
3
|
+
"name": "useInterval",
|
|
4
|
+
"displayName": "可暂停定时器",
|
|
5
|
+
"category": "timer",
|
|
6
|
+
"description": "对 setInterval 做响应式封装,提供 pause、resume 和 isActive,适合轮询、时钟和自动刷新场景。",
|
|
7
|
+
"importStatement": "import { useInterval } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "cb",
|
|
12
|
+
"type": "() => void",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "定时执行的回调"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "interval",
|
|
18
|
+
"type": "MaybeRefOrGetter<number>",
|
|
19
|
+
"required": false,
|
|
20
|
+
"description": "时间间隔,默认值由上游实现决定"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "options",
|
|
24
|
+
"type": "UseIntervalOptions",
|
|
25
|
+
"required": false,
|
|
26
|
+
"description": "定时器配置,可设置 immediate 和 immediateCallback"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"returnType": "{ isActive: Readonly<ShallowRef<boolean>>; pause: () => void; resume: () => void; }",
|
|
30
|
+
"examples": [
|
|
31
|
+
{
|
|
32
|
+
"id": "auto_refresh",
|
|
33
|
+
"title": "自动刷新列表",
|
|
34
|
+
"description": "以固定间隔刷新列表数据,并可手动暂停",
|
|
35
|
+
"code": "<script setup lang=\"ts\">\nimport { useInterval } from '@ksyun-internal/versatile';\n\nconst { pause, resume, isActive } = useInterval(() => {\n console.log('refresh');\n}, 5000, { immediate: true });\n</script>"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"commonMistakes": [
|
|
39
|
+
{
|
|
40
|
+
"id": "expect_resume_recreate",
|
|
41
|
+
"description": "暂停后修改了 interval,却以为 resume 会自动重建旧定时器逻辑",
|
|
42
|
+
"wrongCode": "pause(); interval.value = 1000; resume();",
|
|
43
|
+
"correctCode": "确认 interval 是响应式输入,或重新创建 useInterval。",
|
|
44
|
+
"explanation": "建议明确 interval 的响应式来源,避免把它当成一次性静态参数。"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"searchKeywords": [
|
|
48
|
+
"useInterval",
|
|
49
|
+
"定时器",
|
|
50
|
+
"pause",
|
|
51
|
+
"resume",
|
|
52
|
+
"自动刷新",
|
|
53
|
+
"轮询"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useLayoutStandardList",
|
|
3
|
+
"name": "useLayoutStandardList",
|
|
4
|
+
"displayName": "标准列表页组合状态",
|
|
5
|
+
"category": "table",
|
|
6
|
+
"description": "为 LayoutStandardList 组合分页、搜索、分组、排序、列设置和批量操作状态,适合标准列表页快速搭建。",
|
|
7
|
+
"importStatement": "import { useLayoutStandardList } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [],
|
|
10
|
+
"returnType": "{ layoutStandardListRef: Ref<any>; page: Ref<number>; limit: Ref<number>; searchValue: Ref<string>; searchItems: Ref<Record<string, any> | undefined>; group: Ref<Record<string, any>>; sort: Ref<TableSortValue>; checkedKeys: Ref<string[]>; tableRef: Ref<Table | undefined>; refetch: any; loading: any; isShowDialog: Ref<boolean>; showFilterTableFieldsDialog: Function; ... }",
|
|
11
|
+
"examples": [
|
|
12
|
+
{
|
|
13
|
+
"id": "standard_list_ref",
|
|
14
|
+
"title": "标准列表页容器",
|
|
15
|
+
"description": "在 LayoutStandardList 外层持有组合状态和实例引用",
|
|
16
|
+
"code": "<script setup lang=\"ts\">\nimport { LayoutStandardList, useLayoutStandardList } from '@ksyun-internal/versatile';\n\nconst { layoutStandardListRef, page, limit, searchItems, checkedKeys } = useLayoutStandardList();\n</script>\n\n<template>\n <LayoutStandardList ref=\"layoutStandardListRef\" :use-list=\"() => ({ loading: false, dataSource: [], total: 0 })\" />\n</template>"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"commonMistakes": [
|
|
20
|
+
{
|
|
21
|
+
"id": "duplicate_inner_hooks",
|
|
22
|
+
"description": "在 LayoutStandardList 外又重复手写 useSearch/usePagination/useTableSort,导致状态来源分裂",
|
|
23
|
+
"wrongCode": "const search = useSearch(); const pagination = usePagination(); const state = useLayoutStandardList();",
|
|
24
|
+
"correctCode": "const state = useLayoutStandardList();",
|
|
25
|
+
"explanation": "如果页面主体就是 LayoutStandardList,优先复用这个组合 hook。"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"searchKeywords": [
|
|
29
|
+
"useLayoutStandardList",
|
|
30
|
+
"LayoutStandardList",
|
|
31
|
+
"标准列表页",
|
|
32
|
+
"分页 搜索 排序",
|
|
33
|
+
"批量操作",
|
|
34
|
+
"表格组合状态"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useMessage",
|
|
3
|
+
"name": "useMessage",
|
|
4
|
+
"displayName": "变更消息反馈",
|
|
5
|
+
"category": "feedback",
|
|
6
|
+
"description": "为 Apollo mutation 封装统一的成功/失败消息处理逻辑,适合删除、编辑、创建等需要标准化提示文案的请求场景。",
|
|
7
|
+
"importStatement": "import { useMessage } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "onError",
|
|
12
|
+
"type": "UseMutationReturn<TResult, TVariables>['onError']",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "mutation 返回的错误监听函数"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "onDone",
|
|
18
|
+
"type": "UseMutationReturn<TResult, TVariables>['onDone']",
|
|
19
|
+
"required": false,
|
|
20
|
+
"description": "mutation 返回的完成监听函数"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "isSuccess",
|
|
24
|
+
"type": "(res: FetchResult<TResult>) => boolean",
|
|
25
|
+
"required": false,
|
|
26
|
+
"description": "自定义成功判定逻辑"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "action",
|
|
30
|
+
"type": "string | (() => string)",
|
|
31
|
+
"required": false,
|
|
32
|
+
"description": "操作名称,用于生成成功/失败提示文案"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "successCallback",
|
|
36
|
+
"type": "(res: FetchResult<TResult>) => any",
|
|
37
|
+
"required": false,
|
|
38
|
+
"description": "成功后的额外回调"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "failedCallback",
|
|
42
|
+
"type": "(e: Error) => any",
|
|
43
|
+
"required": false,
|
|
44
|
+
"description": "失败后的额外回调"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"returnType": "void",
|
|
48
|
+
"examples": [
|
|
49
|
+
{
|
|
50
|
+
"id": "mutation_feedback",
|
|
51
|
+
"title": "统一处理 mutation 提示",
|
|
52
|
+
"description": "把创建、删除等 mutation 的消息提示收口到 hook",
|
|
53
|
+
"code": "<script setup lang=\"ts\">\nimport { useMutation } from '@vue/apollo-composable';\nimport { useMessage } from '@ksyun-internal/versatile';\n\nconst { onError, onDone } = useMutation(CREATE_INSTANCE);\nuseMessage(onError, onDone, undefined, '创建实例');\n</script>"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"commonMistakes": [
|
|
57
|
+
{
|
|
58
|
+
"id": "no_success_judge",
|
|
59
|
+
"description": "接口返回结构不是标准成功态,但没有传 isSuccess,自定义失败被当成成功",
|
|
60
|
+
"wrongCode": "useMessage(onError, onDone, undefined, '删除');",
|
|
61
|
+
"correctCode": "useMessage(onError, onDone, (res) => res.data?.delete?.code === 200, '删除');",
|
|
62
|
+
"explanation": "如果后端不是默认成功结构,建议显式提供 isSuccess。"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"searchKeywords": [
|
|
66
|
+
"useMessage",
|
|
67
|
+
"mutation 提示",
|
|
68
|
+
"apollo",
|
|
69
|
+
"成功失败消息",
|
|
70
|
+
"toast",
|
|
71
|
+
"反馈"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "useModifyCache",
|
|
3
|
+
"name": "useModifyCache",
|
|
4
|
+
"displayName": "Apollo 缓存修改",
|
|
5
|
+
"category": "data",
|
|
6
|
+
"description": "返回一个可复用的 Apollo cache.modify 封装函数,适合在 mutation 后局部更新缓存而不重新发请求。",
|
|
7
|
+
"importStatement": "import { useModifyCache } from '@ksyun-internal/versatile';",
|
|
8
|
+
"source": "@ksyun-internal/versatile",
|
|
9
|
+
"params": [],
|
|
10
|
+
"returnType": "(identify: StoreObject | Reference, fields: Cache.ModifyOptions['fields']) => void",
|
|
11
|
+
"examples": [
|
|
12
|
+
{
|
|
13
|
+
"id": "apollo_modify_cache",
|
|
14
|
+
"title": "局部更新 Apollo 缓存",
|
|
15
|
+
"description": "在删除或编辑成功后直接修改缓存字段",
|
|
16
|
+
"code": "<script setup lang=\"ts\">\nimport { useModifyCache } from '@ksyun-internal/versatile';\n\nconst modifyCache = useModifyCache();\nmodifyCache({ __typename: 'Instance', id: 'ins-1' }, {\n name: () => 'new-name',\n});\n</script>"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"commonMistakes": [
|
|
20
|
+
{
|
|
21
|
+
"id": "invalid_identify",
|
|
22
|
+
"description": "identify 对象缺少 Apollo 可识别的标识字段",
|
|
23
|
+
"wrongCode": "modifyCache({ name: 'instance-1' }, { status: () => 'running' });",
|
|
24
|
+
"correctCode": "modifyCache({ __typename: 'Instance', id: 'ins-1' }, { status: () => 'running' });",
|
|
25
|
+
"explanation": "identify 需要能让 Apollo 唯一定位缓存实体。"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"searchKeywords": [
|
|
29
|
+
"useModifyCache",
|
|
30
|
+
"apollo cache",
|
|
31
|
+
"cache.modify",
|
|
32
|
+
"mutation",
|
|
33
|
+
"局部更新缓存",
|
|
34
|
+
"graphql"
|
|
35
|
+
]
|
|
36
|
+
}
|