king-design-analyzer 1.0.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/README.md +151 -0
- package/components/affix.json +178 -0
- package/components/az.json +86 -0
- package/components/badge.json +162 -0
- package/components/billtypes.json +90 -0
- package/components/breadcrumb.json +220 -0
- package/components/button.json +511 -0
- package/components/card.json +334 -0
- package/components/cardcontent.json +144 -0
- package/components/carousel.json +207 -0
- package/components/cascader.json +373 -0
- package/components/checkbox.json +298 -0
- package/components/code.json +318 -0
- package/components/collapse.json +358 -0
- package/components/copy.json +220 -0
- package/components/datepicker.json +529 -0
- package/components/descriptions.json +309 -0
- package/components/dialog.json +460 -0
- package/components/divider.json +287 -0
- package/components/drawer.json +563 -0
- package/components/dropdown.json +407 -0
- package/components/editable.json +331 -0
- package/components/ellipsis.json +218 -0
- package/components/form.json +638 -0
- package/components/grid.json +377 -0
- package/components/icon.json +442 -0
- package/components/input.json +821 -0
- package/components/layoutcontent.json +210 -0
- package/components/menu.json +482 -0
- package/components/message.json +345 -0
- package/components/pagination.json +444 -0
- package/components/paginationplus.json +74 -0
- package/components/popover.json +456 -0
- package/components/progress.json +354 -0
- package/components/protable.json +132 -0
- package/components/radio.json +246 -0
- package/components/region.json +115 -0
- package/components/select.json +676 -0
- package/components/slider.json +422 -0
- package/components/spin.json +232 -0
- package/components/spinner.json +441 -0
- package/components/status.json +75 -0
- package/components/steps.json +292 -0
- package/components/switch.json +357 -0
- package/components/table.json +1057 -0
- package/components/tablecolumnid.json +217 -0
- package/components/tabs.json +363 -0
- package/components/tag.json +504 -0
- package/components/timepicker.json +447 -0
- package/components/tip.json +322 -0
- package/components/tooltip.json +416 -0
- package/components/tour.json +395 -0
- package/components/transfer.json +414 -0
- package/components/tree.json +480 -0
- package/components/treeselect.json +478 -0
- package/components/upload.json +499 -0
- package/components/virtuallist.json +178 -0
- package/dist/ast/index.d.mts +71 -0
- package/dist/ast/index.d.ts +71 -0
- package/dist/ast/index.js +15 -0
- package/dist/ast/index.mjs +2 -0
- package/dist/chunk-4BUGNH4F.mjs +62 -0
- package/dist/chunk-5H7N2A5X.mjs +1 -0
- package/dist/chunk-5IF32MBB.js +603 -0
- package/dist/chunk-ARWRNWDW.js +219 -0
- package/dist/chunk-C3L4IXJC.mjs +577 -0
- package/dist/chunk-GNVCC37B.js +102 -0
- package/dist/chunk-N4UIA6DN.js +68 -0
- package/dist/chunk-RAMIBZAU.mjs +216 -0
- package/dist/chunk-RNQHI7YG.js +64 -0
- package/dist/chunk-TB6BF5TJ.mjs +99 -0
- package/dist/chunk-UX7KGX45.mjs +66 -0
- package/dist/chunk-YTEYDSDW.js +2 -0
- package/dist/full/index.d.mts +29 -0
- package/dist/full/index.d.ts +29 -0
- package/dist/full/index.js +16 -0
- package/dist/full/index.mjs +3 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +43 -0
- package/dist/index.mjs +6 -0
- package/dist/runtime/index.d.mts +14 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.mjs +2 -0
- package/dist/sfcCompiler-m51JOfWs.d.mts +22 -0
- package/dist/sfcCompiler-m51JOfWs.d.ts +22 -0
- package/dist/static/index.d.mts +14 -0
- package/dist/static/index.d.ts +14 -0
- package/dist/static/index.js +19 -0
- package/dist/static/index.mjs +2 -0
- package/package.json +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# king-design-analyzer
|
|
2
|
+
|
|
3
|
+
AST-based code analyzer for King Design Vue components with on-demand modular imports.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install king-design-analyzer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
| Module | Import Path | Description |
|
|
14
|
+
|--------|-------------|-------------|
|
|
15
|
+
| Static Check | `king-design-analyzer/static` | SFC structure & syntax validation |
|
|
16
|
+
| AST Analysis | `king-design-analyzer/ast` | Component rules, props, events, slots checking |
|
|
17
|
+
| Runtime | `king-design-analyzer/runtime` | Script execution pre-check |
|
|
18
|
+
| Full | `king-design-analyzer/full` | All three layers combined |
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### On-demand Import (Recommended)
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Only static check - minimal bundle size
|
|
26
|
+
import { validateCompilation, compileSFC } from 'king-design-analyzer/static';
|
|
27
|
+
|
|
28
|
+
// Only AST analysis
|
|
29
|
+
import { analyzeCodeWithAST, componentRegistry } from 'king-design-analyzer/ast';
|
|
30
|
+
|
|
31
|
+
// Only runtime detection
|
|
32
|
+
import { validateRuntimePrecheck } from 'king-design-analyzer/runtime';
|
|
33
|
+
|
|
34
|
+
// Full validation (compilation + AST + runtime)
|
|
35
|
+
import { validateCode, validateCodeSync } from 'king-design-analyzer/full';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Full Import
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import {
|
|
42
|
+
validateCode,
|
|
43
|
+
analyzeCodeWithAST,
|
|
44
|
+
compileSFC,
|
|
45
|
+
validateCompilation,
|
|
46
|
+
validateRuntimePrecheck
|
|
47
|
+
} from 'king-design-analyzer';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API Reference
|
|
51
|
+
|
|
52
|
+
### Static Module (`/static`)
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Validate SFC structure and syntax
|
|
56
|
+
function validateCompilation(code: string): ValidationLayer;
|
|
57
|
+
|
|
58
|
+
// Compile Vue SFC, extract template/script/style
|
|
59
|
+
function compileSFC(code: string, scopeId: string): CompilationResult;
|
|
60
|
+
|
|
61
|
+
interface ValidationLayer {
|
|
62
|
+
name: string;
|
|
63
|
+
passed: boolean;
|
|
64
|
+
errors: string[];
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### AST Module (`/ast`)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Analyze code for component rule violations
|
|
72
|
+
async function analyzeCodeWithAST(code: string): Promise<RuleViolation[]>;
|
|
73
|
+
|
|
74
|
+
// Component metadata registry
|
|
75
|
+
const componentRegistry: ComponentRegistry;
|
|
76
|
+
|
|
77
|
+
interface RuleViolation {
|
|
78
|
+
rule: string;
|
|
79
|
+
match: string;
|
|
80
|
+
suggestion: string;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Runtime Module (`/runtime`)
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Pre-check if script can execute correctly
|
|
88
|
+
function validateRuntimePrecheck(code: string): ValidationLayer;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Full Module (`/full`)
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Full validation with all three layers (async)
|
|
95
|
+
async function validateCode(code: string): Promise<UnifiedValidationResult>;
|
|
96
|
+
|
|
97
|
+
// Sync version without AST check
|
|
98
|
+
function validateCodeSync(code: string): SyncValidationResult;
|
|
99
|
+
|
|
100
|
+
interface UnifiedValidationResult {
|
|
101
|
+
passed: boolean;
|
|
102
|
+
layers: {
|
|
103
|
+
compilation: ValidationLayer;
|
|
104
|
+
ast: ValidationLayer;
|
|
105
|
+
runtime: ValidationLayer;
|
|
106
|
+
};
|
|
107
|
+
summary: string;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Example
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { validateCode } from 'king-design-analyzer/full';
|
|
115
|
+
|
|
116
|
+
const code = `
|
|
117
|
+
<script setup lang="ts">
|
|
118
|
+
import { Button } from '@king-design/vue';
|
|
119
|
+
import { ref } from 'vue';
|
|
120
|
+
const count = ref(0);
|
|
121
|
+
</script>
|
|
122
|
+
<template>
|
|
123
|
+
<Button @click="count++">{{ count }}</Button>
|
|
124
|
+
</template>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
const result = await validateCode(code);
|
|
128
|
+
|
|
129
|
+
if (result.passed) {
|
|
130
|
+
console.log('✅ All checks passed');
|
|
131
|
+
} else {
|
|
132
|
+
console.log('❌ Validation failed:', result.summary);
|
|
133
|
+
result.layers.compilation.errors.forEach(e => console.log(' Compile:', e));
|
|
134
|
+
result.layers.ast.errors.forEach(e => console.log(' AST:', e));
|
|
135
|
+
result.layers.runtime.errors.forEach(e => console.log(' Runtime:', e));
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Peer Dependencies
|
|
140
|
+
|
|
141
|
+
For full functionality, install these peer dependencies:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm install @vue/compiler-sfc typescript
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> Note: `@vue/compiler-sfc` is required for AST analysis. `typescript` is optional.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "affix",
|
|
3
|
+
"name": "Affix",
|
|
4
|
+
"displayName": "图钉",
|
|
5
|
+
"category": "navigation",
|
|
6
|
+
"description": "将页面元素固定在可视窗口的某个位置。常用于侧边菜单、侧边导航等。",
|
|
7
|
+
"importStatement": "import { Affix } from '@king-design/vue';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "top",
|
|
11
|
+
"description": "距离窗口顶部的偏移量,设置为 undefined 则不生效",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "number",
|
|
14
|
+
"kind": "number"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"default": "undefined",
|
|
18
|
+
"usageExample": "<Affix :top=\"100\">"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "bottom",
|
|
22
|
+
"description": "距离窗口底部的偏移量,设置为 undefined 则不生效",
|
|
23
|
+
"type": {
|
|
24
|
+
"raw": "number",
|
|
25
|
+
"kind": "number"
|
|
26
|
+
},
|
|
27
|
+
"required": false,
|
|
28
|
+
"default": "undefined",
|
|
29
|
+
"usageExample": "<Affix :bottom=\"50\">"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "shouldFix",
|
|
33
|
+
"description": "自定义是否需要固定的函数,返回 boolean",
|
|
34
|
+
"type": {
|
|
35
|
+
"raw": "Function",
|
|
36
|
+
"kind": "function"
|
|
37
|
+
},
|
|
38
|
+
"required": false,
|
|
39
|
+
"default": "undefined",
|
|
40
|
+
"usageExample": "<Affix :shouldFix=\"checkFix\">"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "exclude",
|
|
44
|
+
"description": "自定义排除固定的函数,返回 boolean 表示不固定",
|
|
45
|
+
"type": {
|
|
46
|
+
"raw": "Function",
|
|
47
|
+
"kind": "function"
|
|
48
|
+
},
|
|
49
|
+
"required": false,
|
|
50
|
+
"default": "undefined",
|
|
51
|
+
"usageExample": "<Affix :exclude=\"checkExclude\">"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "disabled",
|
|
55
|
+
"description": "是否禁用固定功能",
|
|
56
|
+
"type": {
|
|
57
|
+
"raw": "boolean",
|
|
58
|
+
"kind": "boolean"
|
|
59
|
+
},
|
|
60
|
+
"required": false,
|
|
61
|
+
"default": "false",
|
|
62
|
+
"usageExample": "<Affix disabled>"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"events": [
|
|
66
|
+
{
|
|
67
|
+
"name": "change",
|
|
68
|
+
"description": "固定状态改变时触发",
|
|
69
|
+
"params": [
|
|
70
|
+
{
|
|
71
|
+
"name": "isFixed",
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"description": "当前是否处于固定状态"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"usageExample": "<Affix @change=\"handleChange\">"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"methods": [],
|
|
80
|
+
"slots": [
|
|
81
|
+
{
|
|
82
|
+
"name": "default",
|
|
83
|
+
"description": "需要被固定的元素",
|
|
84
|
+
"vueTemplate": "#default",
|
|
85
|
+
"usageExample": "<Affix><Button>Fixed Button</Button></Affix>"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"examples": [
|
|
89
|
+
{
|
|
90
|
+
"id": "affix_top",
|
|
91
|
+
"title": "固定在顶部",
|
|
92
|
+
"description": "设置 distance-top",
|
|
93
|
+
"difficulty": "easy",
|
|
94
|
+
"code": "<script setup lang=\"ts\">\nimport { Affix, Button } from '@king-design/vue';\n</script>\n<template>\n <Affix :top=\"10\">\n <Button type=\"primary\">距离顶部 10px 固定</Button>\n </Affix>\n</template>",
|
|
95
|
+
"tags": [
|
|
96
|
+
"top",
|
|
97
|
+
"basic"
|
|
98
|
+
],
|
|
99
|
+
"usedProps": [
|
|
100
|
+
"top"
|
|
101
|
+
],
|
|
102
|
+
"usedEvents": [],
|
|
103
|
+
"usedSlots": [
|
|
104
|
+
"default"
|
|
105
|
+
],
|
|
106
|
+
"usedMethods": [],
|
|
107
|
+
"scenario": "将导航或工具栏固定在页面顶部"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "affix_bottom",
|
|
111
|
+
"title": "固定在底部",
|
|
112
|
+
"description": "设置 distance-bottom",
|
|
113
|
+
"difficulty": "easy",
|
|
114
|
+
"code": "<script setup lang=\"ts\">\nimport { Affix, Button } from '@king-design/vue';\n</script>\n<template>\n <Affix :bottom=\"10\">\n <Button type=\"primary\">距离底部 10px 固定</Button>\n </Affix>\n</template>",
|
|
115
|
+
"tags": [
|
|
116
|
+
"bottom",
|
|
117
|
+
"basic"
|
|
118
|
+
],
|
|
119
|
+
"usedProps": [
|
|
120
|
+
"bottom"
|
|
121
|
+
],
|
|
122
|
+
"usedEvents": [],
|
|
123
|
+
"usedSlots": [
|
|
124
|
+
"default"
|
|
125
|
+
],
|
|
126
|
+
"usedMethods": [],
|
|
127
|
+
"scenario": "将帮助按钮或操作栏固定在页面底部"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"id": "affix_change",
|
|
131
|
+
"title": "监听状态改变",
|
|
132
|
+
"description": "监听 change 事件获取固定状态",
|
|
133
|
+
"difficulty": "medium",
|
|
134
|
+
"code": "<script setup lang=\"ts\">\nimport { Affix, Button } from '@king-design/vue';\n\nconst onChange = (isFixed: boolean) => {\n console.log('Fixed state:', isFixed);\n};\n</script>\n<template>\n <Affix :top=\"100\" @change=\"onChange\">\n <Button>滚动页面触发固定</Button>\n </Affix>\n</template>",
|
|
135
|
+
"tags": [
|
|
136
|
+
"event",
|
|
137
|
+
"change"
|
|
138
|
+
],
|
|
139
|
+
"usedProps": [
|
|
140
|
+
"top"
|
|
141
|
+
],
|
|
142
|
+
"usedEvents": [
|
|
143
|
+
"change"
|
|
144
|
+
],
|
|
145
|
+
"usedSlots": [
|
|
146
|
+
"default"
|
|
147
|
+
],
|
|
148
|
+
"usedMethods": [],
|
|
149
|
+
"scenario": "根据固定状态改变样式"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"commonMistakes": [
|
|
153
|
+
{
|
|
154
|
+
"id": "affix_container_scroll",
|
|
155
|
+
"description": "父容器滚动问题",
|
|
156
|
+
"wrongCode": "<div style=\"overflow: auto; height: 200px;\">\n <Affix :top=\"10\">...</Affix>\n</div>",
|
|
157
|
+
"correctCode": "<!-- Affix 默认基于 window 滚动,如果需要在特定容器内滚动固定,Affix实现可能不支持或需要特殊配置,通常 Affix基于 window -->",
|
|
158
|
+
"explanation": "Affix 一般是基于 window 滚动的,如果放在有 overflow 滚动的这容器内,可能 won't work expectedly。目前组件文档未明确支持 target 容器,需注意。",
|
|
159
|
+
"relatedProps": []
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"searchKeywords": [
|
|
163
|
+
"图钉",
|
|
164
|
+
"affix",
|
|
165
|
+
"fix",
|
|
166
|
+
"sticky",
|
|
167
|
+
"固定",
|
|
168
|
+
"顶部",
|
|
169
|
+
"底部"
|
|
170
|
+
],
|
|
171
|
+
"useCases": [
|
|
172
|
+
"侧边导航栏固定",
|
|
173
|
+
"顶部工具栏固定",
|
|
174
|
+
"底部操作栏固定",
|
|
175
|
+
"悬浮按钮"
|
|
176
|
+
],
|
|
177
|
+
"relatedComponents": []
|
|
178
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "az",
|
|
3
|
+
"name": "AZ",
|
|
4
|
+
"displayName": "可用区选择",
|
|
5
|
+
"category": "form",
|
|
6
|
+
"description": "可用区(Availability Zone)选择组件。",
|
|
7
|
+
"importStatement": "import { AZ } from '@ksyun-internal/versatile';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "modelValue",
|
|
11
|
+
"description": "选中的可用区编码",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "string",
|
|
14
|
+
"kind": "string"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"usageExample": "<AZ v-model=\"azCode\" />"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "regionCode",
|
|
21
|
+
"description": "所属地域编码",
|
|
22
|
+
"type": {
|
|
23
|
+
"raw": "string",
|
|
24
|
+
"kind": "string"
|
|
25
|
+
},
|
|
26
|
+
"required": false,
|
|
27
|
+
"usageExample": "<AZ regionCode=\"cn-beijing-6\" />"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "packages",
|
|
31
|
+
"description": "可用区配置列表(通常从Region组件联动获取,或通过API获取)",
|
|
32
|
+
"type": {
|
|
33
|
+
"raw": "AZ[]",
|
|
34
|
+
"kind": "array"
|
|
35
|
+
},
|
|
36
|
+
"required": false,
|
|
37
|
+
"usageExample": "<AZ :packages=\"packages\" />"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "showLearnMore",
|
|
41
|
+
"description": "是否显示了解更多",
|
|
42
|
+
"type": {
|
|
43
|
+
"raw": "boolean",
|
|
44
|
+
"kind": "boolean"
|
|
45
|
+
},
|
|
46
|
+
"required": false,
|
|
47
|
+
"default": "true"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "learnMoreUrl",
|
|
51
|
+
"description": "了解更多链接ID",
|
|
52
|
+
"type": {
|
|
53
|
+
"raw": "number",
|
|
54
|
+
"kind": "number"
|
|
55
|
+
},
|
|
56
|
+
"required": false
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"events": [
|
|
60
|
+
{
|
|
61
|
+
"name": "change",
|
|
62
|
+
"vueEventName": "update:modelValue",
|
|
63
|
+
"description": "可用区改变时触发",
|
|
64
|
+
"payload": [
|
|
65
|
+
{
|
|
66
|
+
"name": "value",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "新的AZCode"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"usageExample": "<AZ @update:modelValue=\"v => console.log(v)\" />",
|
|
72
|
+
"handlerExample": "(val) => { console.log(val); }"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"methods": [],
|
|
76
|
+
"examples": [],
|
|
77
|
+
"searchKeywords": [
|
|
78
|
+
"az",
|
|
79
|
+
"zone",
|
|
80
|
+
"可用区",
|
|
81
|
+
"机房"
|
|
82
|
+
],
|
|
83
|
+
"useCases": [
|
|
84
|
+
"购买页选择可用区"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "badge",
|
|
3
|
+
"name": "Badge",
|
|
4
|
+
"displayName": "徽标",
|
|
5
|
+
"category": "data",
|
|
6
|
+
"description": "出现在按钮、图标旁的数字或状态标记。",
|
|
7
|
+
"importStatement": "import { Badge } from '@king-design/vue';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "text",
|
|
11
|
+
"description": "显示的文本内容或数字。如果不传,则显示为一个小红点。",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "string | number",
|
|
14
|
+
"kind": "union"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"default": "undefined",
|
|
18
|
+
"usageExample": "<Badge :text=\"10\">"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "max",
|
|
22
|
+
"description": "显示的最大数值,超过最大值会显示为 max+。仅在 text 为 numeric 时生效。",
|
|
23
|
+
"type": {
|
|
24
|
+
"raw": "number",
|
|
25
|
+
"kind": "number"
|
|
26
|
+
},
|
|
27
|
+
"required": false,
|
|
28
|
+
"default": "undefined",
|
|
29
|
+
"usageExample": "<Badge :text=\"100\" :max=\"99\">"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "disabled",
|
|
33
|
+
"description": "是否隐藏徽标",
|
|
34
|
+
"type": {
|
|
35
|
+
"raw": "boolean",
|
|
36
|
+
"kind": "boolean"
|
|
37
|
+
},
|
|
38
|
+
"required": false,
|
|
39
|
+
"default": "false",
|
|
40
|
+
"usageExample": "<Badge disabled>"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"events": [],
|
|
44
|
+
"methods": [],
|
|
45
|
+
"slots": [
|
|
46
|
+
{
|
|
47
|
+
"name": "default",
|
|
48
|
+
"description": "徽标包裹的元素",
|
|
49
|
+
"vueTemplate": "#default",
|
|
50
|
+
"usageExample": "<Badge><Button>Button</Button></Badge>"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"examples": [
|
|
54
|
+
{
|
|
55
|
+
"id": "badge_basic",
|
|
56
|
+
"title": "基础用法",
|
|
57
|
+
"description": "包裹其他元素,显示数字或红点",
|
|
58
|
+
"difficulty": "easy",
|
|
59
|
+
"code": "<script setup lang=\"ts\">\nimport { Badge, Button } from '@king-design/vue';\n</script>\n<template>\n <Badge :text=\"5\">\n <Button>评论</Button>\n </Badge>\n <Badge>\n <Button>新消息</Button>\n </Badge>\n</template>",
|
|
60
|
+
"tags": [
|
|
61
|
+
"basic",
|
|
62
|
+
"dot"
|
|
63
|
+
],
|
|
64
|
+
"usedProps": [
|
|
65
|
+
"text"
|
|
66
|
+
],
|
|
67
|
+
"usedEvents": [],
|
|
68
|
+
"usedSlots": [
|
|
69
|
+
"default"
|
|
70
|
+
],
|
|
71
|
+
"usedMethods": [],
|
|
72
|
+
"scenario": "在按钮右上角显示未读消息数"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "badge_max",
|
|
76
|
+
"title": "最大值限制",
|
|
77
|
+
"description": "超过 max 值显示为 max+",
|
|
78
|
+
"difficulty": "easy",
|
|
79
|
+
"code": "<script setup lang=\"ts\">\nimport { Badge, Button } from '@king-design/vue';\n</script>\n<template>\n <Badge :text=\"200\" :max=\"99\">\n <Button>消息</Button>\n </Badge>\n</template>",
|
|
80
|
+
"tags": [
|
|
81
|
+
"max",
|
|
82
|
+
"limit"
|
|
83
|
+
],
|
|
84
|
+
"usedProps": [
|
|
85
|
+
"text",
|
|
86
|
+
"max"
|
|
87
|
+
],
|
|
88
|
+
"usedEvents": [],
|
|
89
|
+
"usedSlots": [
|
|
90
|
+
"default"
|
|
91
|
+
],
|
|
92
|
+
"usedMethods": [],
|
|
93
|
+
"scenario": "消息数过多时显示 99+"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "badge_text",
|
|
97
|
+
"title": "自定义文字",
|
|
98
|
+
"description": "text 属性可以是字符串",
|
|
99
|
+
"difficulty": "easy",
|
|
100
|
+
"code": "<script setup lang=\"ts\">\nimport { Badge, Button } from '@king-design/vue';\n</script>\n<template>\n <Badge text=\"new\">\n <Button>功能</Button>\n </Badge>\n <Badge text=\"hot\">\n <Button>活动</Button>\n </Badge>\n</template>",
|
|
101
|
+
"tags": [
|
|
102
|
+
"text",
|
|
103
|
+
"custom"
|
|
104
|
+
],
|
|
105
|
+
"usedProps": [
|
|
106
|
+
"text"
|
|
107
|
+
],
|
|
108
|
+
"usedEvents": [],
|
|
109
|
+
"usedSlots": [
|
|
110
|
+
"default"
|
|
111
|
+
],
|
|
112
|
+
"usedMethods": [],
|
|
113
|
+
"scenario": "标记新功能或热门活动"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"id": "badge_independent",
|
|
117
|
+
"title": "独立使用",
|
|
118
|
+
"description": "不包裹任何元素,独立展示",
|
|
119
|
+
"difficulty": "easy",
|
|
120
|
+
"code": "<script setup lang=\"ts\">\nimport { Badge } from '@king-design/vue';\n</script>\n<template>\n <span>新消息</span>\n <Badge :text=\"10\" />\n</template>",
|
|
121
|
+
"tags": [
|
|
122
|
+
"independent"
|
|
123
|
+
],
|
|
124
|
+
"usedProps": [
|
|
125
|
+
"text"
|
|
126
|
+
],
|
|
127
|
+
"usedEvents": [],
|
|
128
|
+
"usedSlots": [],
|
|
129
|
+
"usedMethods": [],
|
|
130
|
+
"scenario": "在列表行尾显示数量"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"commonMistakes": [
|
|
134
|
+
{
|
|
135
|
+
"id": "badge_number_string",
|
|
136
|
+
"description": "数字作为字符串传入",
|
|
137
|
+
"wrongCode": "<Badge text=\"10\" :max=\"9\">",
|
|
138
|
+
"correctCode": "<Badge :text=\"10\" :max=\"9\">",
|
|
139
|
+
"explanation": "如果 text 传入的是字符串 \"10\",max 属性可能无法正确比较。建议数字类型使用 v-bind 传入。",
|
|
140
|
+
"relatedProps": [
|
|
141
|
+
"text",
|
|
142
|
+
"max"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"searchKeywords": [
|
|
147
|
+
"徽标",
|
|
148
|
+
"badge",
|
|
149
|
+
"mark",
|
|
150
|
+
"notify",
|
|
151
|
+
"notification",
|
|
152
|
+
"count",
|
|
153
|
+
"number"
|
|
154
|
+
],
|
|
155
|
+
"useCases": [
|
|
156
|
+
"消息通知数量",
|
|
157
|
+
"待办事项数量",
|
|
158
|
+
"新功能标记",
|
|
159
|
+
"状态点"
|
|
160
|
+
],
|
|
161
|
+
"relatedComponents": []
|
|
162
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "billtypes",
|
|
3
|
+
"name": "BillTypes",
|
|
4
|
+
"displayName": "计费类型选择",
|
|
5
|
+
"category": "form",
|
|
6
|
+
"description": "计费类型选择组件,支持按量付费、包年包月等多种计费模式展示与选择。",
|
|
7
|
+
"importStatement": "import { BillTypes } from '@ksyun-internal/versatile';",
|
|
8
|
+
"props": [
|
|
9
|
+
{
|
|
10
|
+
"name": "modelValue",
|
|
11
|
+
"description": "选中的计费类型ID",
|
|
12
|
+
"type": {
|
|
13
|
+
"raw": "number",
|
|
14
|
+
"kind": "number"
|
|
15
|
+
},
|
|
16
|
+
"required": false,
|
|
17
|
+
"usageExample": "<BillTypes v-model=\"billType\" />"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "packages",
|
|
21
|
+
"description": "计费类型配置列表",
|
|
22
|
+
"type": {
|
|
23
|
+
"raw": "BillType[]",
|
|
24
|
+
"kind": "array"
|
|
25
|
+
},
|
|
26
|
+
"required": false,
|
|
27
|
+
"usageExample": "<BillTypes :packages=\"packages\" />"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "showTrial",
|
|
31
|
+
"description": "是否显示试用选项",
|
|
32
|
+
"type": {
|
|
33
|
+
"raw": "boolean",
|
|
34
|
+
"kind": "boolean"
|
|
35
|
+
},
|
|
36
|
+
"required": false,
|
|
37
|
+
"default": "false",
|
|
38
|
+
"usageExample": "<BillTypes showTrial />"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "showLearnMore",
|
|
42
|
+
"description": "是否显示了解更多链接",
|
|
43
|
+
"type": {
|
|
44
|
+
"raw": "boolean",
|
|
45
|
+
"kind": "boolean"
|
|
46
|
+
},
|
|
47
|
+
"required": false,
|
|
48
|
+
"default": "true",
|
|
49
|
+
"usageExample": "<BillTypes showLearnMore />"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "learnMoreUrl",
|
|
53
|
+
"description": "了解更多链接的帮助文档ID",
|
|
54
|
+
"type": {
|
|
55
|
+
"raw": "number",
|
|
56
|
+
"kind": "number"
|
|
57
|
+
},
|
|
58
|
+
"required": false,
|
|
59
|
+
"usageExample": "<BillTypes :learnMoreUrl=\"123\" />"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"events": [
|
|
63
|
+
{
|
|
64
|
+
"name": "change",
|
|
65
|
+
"vueEventName": "update:modelValue",
|
|
66
|
+
"description": "选中值改变时触发",
|
|
67
|
+
"payload": [
|
|
68
|
+
{
|
|
69
|
+
"name": "value",
|
|
70
|
+
"type": "number",
|
|
71
|
+
"description": "新的计费类型ID"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"usageExample": "<BillTypes @update:modelValue=\"v => console.log(v)\" />",
|
|
75
|
+
"handlerExample": "(val) => { console.log(val); }"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"methods": [],
|
|
79
|
+
"examples": [],
|
|
80
|
+
"searchKeywords": [
|
|
81
|
+
"bill",
|
|
82
|
+
"price",
|
|
83
|
+
"charge",
|
|
84
|
+
"计费",
|
|
85
|
+
"价格"
|
|
86
|
+
],
|
|
87
|
+
"useCases": [
|
|
88
|
+
"购买页选择计费模式"
|
|
89
|
+
]
|
|
90
|
+
}
|