@coffic/cosy-ui 0.9.39 → 0.9.41
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/dist/app.css +1 -1
- package/dist/index-astro.ts +20 -13
- package/dist/src-astro/api-test/ApiEndpointCard.astro +254 -0
- package/dist/src-astro/api-test/ApiTestScript.astro +357 -0
- package/dist/src-astro/api-test/ApiTester.astro +111 -0
- package/dist/src-astro/api-test/index.ts +5 -0
- package/dist/src-astro/api-test/index_astro.ts +5 -0
- package/dist/src-astro/avatar/Avatar.astro +118 -0
- package/dist/src-astro/avatar/index.ts +2 -0
- package/dist/src-astro/avatar/types.ts +29 -0
- package/dist/src-astro/contact/Contact.astro +155 -172
- package/dist/src-astro/container/Container.astro +16 -0
- package/dist/src-astro/features/FeatureCard.astro +63 -0
- package/dist/src-astro/features/FeatureShowcase.astro +164 -0
- package/dist/src-astro/features/index.ts +3 -0
- package/dist/src-astro/heading/Heading.astro +56 -8
- package/dist/src-astro/icons/AppStoreIcon.astro +1 -1
- package/dist/src-astro/layout-app/AppLayout.astro +3 -1
- package/dist/src-astro/mac-window/MacWindow.astro +11 -6
- package/dist/src-astro/picture-book/PictureBookPage.astro +6 -3
- package/dist/src-astro/products/ProductShowcase.astro +159 -0
- package/dist/src-astro/products/ProductShowcaseItem.astro +216 -0
- package/dist/src-astro/products/index.ts +4 -0
- package/dist/src-astro/review/Review.astro +159 -0
- package/dist/src-astro/review/Reviews.astro +162 -0
- package/dist/src-astro/review/index.ts +3 -0
- package/dist/src-astro/review/types.ts +127 -0
- package/dist/src-astro/stats-display/StatsDisplay.astro +201 -0
- package/dist/src-astro/stats-display/index.ts +10 -0
- package/dist/src-astro/stats-display/types.ts +79 -0
- package/dist/src-astro/text/Text.astro +4 -1
- package/dist/src-astro/types/api-test.ts +138 -0
- package/dist/src-vue/container/Container.vue +64 -62
- package/dist/src-vue/container/types.ts +3 -3
- package/dist/src-vue/heading/Heading.vue +64 -10
- package/dist/src-vue/heading/types.ts +9 -0
- package/dist/src-vue/mac-window/MacWindow.vue +164 -212
- package/package.json +1 -1
package/dist/index-astro.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// 基础组件和功能模块 (按字母顺序)
|
|
2
2
|
export * from './src-astro/alert';
|
|
3
3
|
export * from './src-astro/alert-dialog';
|
|
4
|
+
export * from './src-astro/api-test';
|
|
4
5
|
export * from './src-astro/article';
|
|
5
|
-
export * from './src-astro/
|
|
6
|
+
export * from './src-astro/avatar';
|
|
6
7
|
export * from './src-astro/badge';
|
|
8
|
+
export * from './src-astro/banner';
|
|
7
9
|
export * from './src-astro/button/index_astro';
|
|
8
10
|
export * from './src-astro/card';
|
|
9
11
|
export * from './src-astro/card-book';
|
|
@@ -13,11 +15,11 @@ export * from './src-astro/code-container';
|
|
|
13
15
|
export * from './src-astro/code-example';
|
|
14
16
|
export * from './src-astro/code-panel';
|
|
15
17
|
export * from './src-astro/confirm-dialog';
|
|
16
|
-
export * from './src-astro/install-tabs';
|
|
17
18
|
export * from './src-astro/contact';
|
|
18
19
|
export * from './src-astro/container';
|
|
19
20
|
export * from './src-astro/empty-state';
|
|
20
21
|
export * from './src-astro/errors';
|
|
22
|
+
export * from './src-astro/features';
|
|
21
23
|
export * from './src-astro/flex';
|
|
22
24
|
export * from './src-astro/footer';
|
|
23
25
|
export * from './src-astro/grid';
|
|
@@ -26,30 +28,34 @@ export * from './src-astro/heading';
|
|
|
26
28
|
export * from './src-astro/hero';
|
|
27
29
|
export * from './src-astro/icons';
|
|
28
30
|
export * from './src-astro/image';
|
|
29
|
-
export * from './src-astro/
|
|
30
|
-
export * from './src-astro/social-icon';
|
|
31
|
+
export * from './src-astro/install-tabs';
|
|
31
32
|
export * from './src-astro/language-switcher';
|
|
32
33
|
export * from './src-astro/layout-app';
|
|
33
34
|
export * from './src-astro/layout-basic';
|
|
34
35
|
export * from './src-astro/layout-basic/BaseLayout.astro';
|
|
35
36
|
export * from './src-astro/layout-dashboard';
|
|
36
|
-
export * from './src-astro/link';
|
|
37
|
+
export * from './src-astro/link';
|
|
38
|
+
export * from './src-astro/list';
|
|
37
39
|
export * from './src-astro/loading-overlay';
|
|
38
40
|
export * from './src-astro/login';
|
|
39
41
|
export * from './src-astro/logout';
|
|
40
|
-
export * from './src-astro/main';
|
|
41
42
|
export * from './src-astro/mac-window';
|
|
43
|
+
export * from './src-astro/main';
|
|
42
44
|
export * from './src-astro/modal';
|
|
43
45
|
export * from './src-astro/module';
|
|
44
46
|
export * from './src-astro/nav-section';
|
|
47
|
+
export * from './src-astro/picture-book';
|
|
45
48
|
export * from './src-astro/placeholder';
|
|
46
49
|
export * from './src-astro/products';
|
|
47
50
|
export * from './src-astro/register';
|
|
51
|
+
export * from './src-astro/review';
|
|
48
52
|
export * from './src-astro/sidebar';
|
|
49
53
|
export * from './src-astro/smart-bg';
|
|
54
|
+
export * from './src-astro/smart-icon';
|
|
55
|
+
export * from './src-astro/social-icon';
|
|
50
56
|
export * from './src-astro/speak';
|
|
51
57
|
export * from './src-astro/stack';
|
|
52
|
-
export * from './src-astro/
|
|
58
|
+
export * from './src-astro/stats-display';
|
|
53
59
|
export * from './src-astro/team-member';
|
|
54
60
|
export * from './src-astro/text';
|
|
55
61
|
export * from './src-astro/theme-switcher';
|
|
@@ -57,6 +63,7 @@ export * from './src-astro/toc';
|
|
|
57
63
|
export * from './src-astro/toast';
|
|
58
64
|
|
|
59
65
|
// 类型定义 (按字母顺序)
|
|
66
|
+
export * from './src-astro/types/api-test';
|
|
60
67
|
export * from './src-astro/types/article';
|
|
61
68
|
export * from './src-astro/types/footer';
|
|
62
69
|
export * from './src-astro/types/header';
|
|
@@ -68,17 +75,17 @@ export * from './src-astro/types/product';
|
|
|
68
75
|
export * from './src-astro/types/sidebar';
|
|
69
76
|
export * from './src-astro/types/static-path';
|
|
70
77
|
|
|
71
|
-
// 工具类型
|
|
78
|
+
// 工具类型 (按字母顺序)
|
|
72
79
|
export type { ImageProvider, ImageOptions } from './src/utils/image';
|
|
73
|
-
export * from './src/utils/image';
|
|
74
80
|
export * from './src/utils/i18n';
|
|
75
|
-
export * from './src/utils/
|
|
76
|
-
export * from './src/utils/url';
|
|
77
|
-
export * from './src/utils/language';
|
|
81
|
+
export * from './src/utils/image';
|
|
78
82
|
export * from './src/utils/lang_package';
|
|
79
|
-
export * from './src/utils/
|
|
83
|
+
export * from './src/utils/language';
|
|
80
84
|
export * from './src/utils/link';
|
|
85
|
+
export * from './src/utils/logger';
|
|
81
86
|
export * from './src/utils/mac-window-bg';
|
|
87
|
+
export * from './src/utils/path';
|
|
88
|
+
export * from './src/utils/url';
|
|
82
89
|
|
|
83
90
|
// 图标组件
|
|
84
91
|
export * from './src-astro/icons';
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* @component ApiEndpointCard
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* ApiEndpointCard 组件用于显示单个API端点的测试界面,包括参数输入、快速测试和测试结果展示。
|
|
7
|
+
* 支持多种参数类型,提供直观的测试体验。
|
|
8
|
+
*
|
|
9
|
+
* @design
|
|
10
|
+
* 设计理念:
|
|
11
|
+
* 1. 清晰的信息层次 - 通过视觉分组和间距清晰展示API信息
|
|
12
|
+
* 2. 直观的参数输入 - 支持多种输入类型,提供验证和默认值
|
|
13
|
+
* 3. 便捷的快速测试 - 预设常用参数组合,提高测试效率
|
|
14
|
+
* 4. 详细的结果展示 - 清晰展示请求和响应信息
|
|
15
|
+
*
|
|
16
|
+
* @usage
|
|
17
|
+
* 基本用法:
|
|
18
|
+
* ```astro
|
|
19
|
+
* <ApiEndpointCard endpoint={endpoint} />
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @props
|
|
23
|
+
* @prop {IApiEndpoint} endpoint - API端点配置信息
|
|
24
|
+
* @prop {string} [class] - 自定义CSS类名
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import Card from '../card/Card.astro';
|
|
28
|
+
import Button from '../button/Button.astro';
|
|
29
|
+
import Badge from '../badge/Badge.astro';
|
|
30
|
+
import type { IApiEndpoint } from '../types/api-test';
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
endpoint: IApiEndpoint;
|
|
34
|
+
class?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { endpoint, class: className } = Astro.props;
|
|
38
|
+
|
|
39
|
+
// 预处理数据
|
|
40
|
+
const hasParams = endpoint.params && endpoint.params.length > 0;
|
|
41
|
+
const hasQuickTests = endpoint.quickTests && endpoint.quickTests.length > 0;
|
|
42
|
+
const hasDescription = !!endpoint.description;
|
|
43
|
+
|
|
44
|
+
// 获取HTTP方法对应的颜色
|
|
45
|
+
const getMethodColor = (
|
|
46
|
+
method: string
|
|
47
|
+
):
|
|
48
|
+
| 'success'
|
|
49
|
+
| 'primary'
|
|
50
|
+
| 'warning'
|
|
51
|
+
| 'error'
|
|
52
|
+
| 'info'
|
|
53
|
+
| 'secondary'
|
|
54
|
+
| 'accent'
|
|
55
|
+
| 'ghost' => {
|
|
56
|
+
const colors: Record<
|
|
57
|
+
string,
|
|
58
|
+
| 'success'
|
|
59
|
+
| 'primary'
|
|
60
|
+
| 'warning'
|
|
61
|
+
| 'error'
|
|
62
|
+
| 'info'
|
|
63
|
+
| 'secondary'
|
|
64
|
+
| 'accent'
|
|
65
|
+
| 'ghost'
|
|
66
|
+
> = {
|
|
67
|
+
GET: 'success',
|
|
68
|
+
POST: 'primary',
|
|
69
|
+
PUT: 'warning',
|
|
70
|
+
DELETE: 'error',
|
|
71
|
+
PATCH: 'info',
|
|
72
|
+
};
|
|
73
|
+
return colors[method] || 'neutral';
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// 获取参数类型对应的输入元素
|
|
77
|
+
const getInputElement = (param: any) => {
|
|
78
|
+
const baseAttrs = {
|
|
79
|
+
'data-param': param.name,
|
|
80
|
+
'data-endpoint': endpoint.path,
|
|
81
|
+
'data-required': param.required || false,
|
|
82
|
+
'data-validation': JSON.stringify(param.validation || {}),
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
type: param.type || 'text',
|
|
87
|
+
attrs: baseAttrs,
|
|
88
|
+
options: param.options || [],
|
|
89
|
+
defaultValue: param.defaultValue,
|
|
90
|
+
placeholder: param.placeholder,
|
|
91
|
+
required: param.required,
|
|
92
|
+
validation: param.validation,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
<Card title={endpoint.name} class={className}>
|
|
98
|
+
<div class="space-y-4">
|
|
99
|
+
{/* HTTP方法和路径 */}
|
|
100
|
+
<div class="bg-base-200 p-3 rounded-lg flex items-center gap-2 flex-wrap">
|
|
101
|
+
<Badge variant={getMethodColor(endpoint.method)}>
|
|
102
|
+
{endpoint.method}
|
|
103
|
+
</Badge>
|
|
104
|
+
<code class="text-primary font-mono text-sm break-all">
|
|
105
|
+
{endpoint.path}
|
|
106
|
+
</code>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
{/* 描述 */}
|
|
110
|
+
{
|
|
111
|
+
hasDescription && (
|
|
112
|
+
<p class="text-base-content/70">{endpoint.description}</p>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
{/* 参数输入 */}
|
|
117
|
+
{
|
|
118
|
+
hasParams && (
|
|
119
|
+
<div class="space-y-3">
|
|
120
|
+
<p class="font-medium text-base-content">请求参数:</p>
|
|
121
|
+
{endpoint.params!.map((param) => {
|
|
122
|
+
const inputConfig = getInputElement(param);
|
|
123
|
+
return (
|
|
124
|
+
<div class="form-control">
|
|
125
|
+
<label class="label">
|
|
126
|
+
<span class="label-text">
|
|
127
|
+
{param.name}
|
|
128
|
+
{param.required && <span class="text-error ml-1">*</span>}
|
|
129
|
+
</span>
|
|
130
|
+
{param.validation?.message && (
|
|
131
|
+
<span class="label-text-alt text-warning">
|
|
132
|
+
{param.validation.message}
|
|
133
|
+
</span>
|
|
134
|
+
)}
|
|
135
|
+
</label>
|
|
136
|
+
|
|
137
|
+
{inputConfig.type === 'select' ? (
|
|
138
|
+
<select
|
|
139
|
+
class="select select-bordered w-full"
|
|
140
|
+
data-param={inputConfig.attrs['data-param']}
|
|
141
|
+
data-endpoint={inputConfig.attrs['data-endpoint']}
|
|
142
|
+
data-required={inputConfig.attrs['data-required']}
|
|
143
|
+
data-validation={inputConfig.attrs['data-validation']}
|
|
144
|
+
required={inputConfig.required}>
|
|
145
|
+
<option value="">请选择</option>
|
|
146
|
+
{inputConfig.options.map((option: string) => (
|
|
147
|
+
<option
|
|
148
|
+
value={option}
|
|
149
|
+
selected={option === inputConfig.defaultValue}>
|
|
150
|
+
{option}
|
|
151
|
+
</option>
|
|
152
|
+
))}
|
|
153
|
+
</select>
|
|
154
|
+
) : inputConfig.type === 'textarea' ? (
|
|
155
|
+
<textarea
|
|
156
|
+
class="textarea textarea-bordered w-full"
|
|
157
|
+
placeholder={inputConfig.placeholder}
|
|
158
|
+
rows={3}
|
|
159
|
+
data-param={inputConfig.attrs['data-param']}
|
|
160
|
+
data-endpoint={inputConfig.attrs['data-endpoint']}
|
|
161
|
+
data-required={inputConfig.attrs['data-required']}
|
|
162
|
+
data-validation={inputConfig.attrs['data-validation']}
|
|
163
|
+
required={inputConfig.required}>
|
|
164
|
+
{inputConfig.defaultValue || ''}
|
|
165
|
+
</textarea>
|
|
166
|
+
) : inputConfig.type === 'checkbox' ? (
|
|
167
|
+
<input
|
|
168
|
+
type="checkbox"
|
|
169
|
+
class="checkbox checkbox-primary"
|
|
170
|
+
data-param={inputConfig.attrs['data-param']}
|
|
171
|
+
data-endpoint={inputConfig.attrs['data-endpoint']}
|
|
172
|
+
data-required={inputConfig.attrs['data-required']}
|
|
173
|
+
data-validation={inputConfig.attrs['data-validation']}
|
|
174
|
+
checked={inputConfig.defaultValue || false}
|
|
175
|
+
/>
|
|
176
|
+
) : inputConfig.type === 'radio' ? (
|
|
177
|
+
<div class="flex flex-wrap gap-3">
|
|
178
|
+
{inputConfig.options.map((option: string) => (
|
|
179
|
+
<label class="label cursor-pointer gap-2">
|
|
180
|
+
<input
|
|
181
|
+
type="radio"
|
|
182
|
+
name={`${endpoint.path}-${param.name}`}
|
|
183
|
+
class="radio radio-primary"
|
|
184
|
+
value={option}
|
|
185
|
+
data-param={inputConfig.attrs['data-param']}
|
|
186
|
+
data-endpoint={inputConfig.attrs['data-endpoint']}
|
|
187
|
+
data-required={inputConfig.attrs['data-required']}
|
|
188
|
+
data-validation={inputConfig.attrs['data-validation']}
|
|
189
|
+
checked={option === inputConfig.defaultValue}
|
|
190
|
+
/>
|
|
191
|
+
<span class="label-text">{option}</span>
|
|
192
|
+
</label>
|
|
193
|
+
))}
|
|
194
|
+
</div>
|
|
195
|
+
) : (
|
|
196
|
+
<input
|
|
197
|
+
type={inputConfig.type}
|
|
198
|
+
placeholder={inputConfig.placeholder}
|
|
199
|
+
class="input input-bordered w-full"
|
|
200
|
+
data-param={inputConfig.attrs['data-param']}
|
|
201
|
+
data-endpoint={inputConfig.attrs['data-endpoint']}
|
|
202
|
+
data-required={inputConfig.attrs['data-required']}
|
|
203
|
+
data-validation={inputConfig.attrs['data-validation']}
|
|
204
|
+
required={inputConfig.required}
|
|
205
|
+
value={inputConfig.defaultValue || ''}
|
|
206
|
+
min={inputConfig.validation?.min}
|
|
207
|
+
max={inputConfig.validation?.max}
|
|
208
|
+
pattern={inputConfig.validation?.pattern}
|
|
209
|
+
/>
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
})}
|
|
214
|
+
</div>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
{/* 快速测试 */}
|
|
219
|
+
{
|
|
220
|
+
hasQuickTests && (
|
|
221
|
+
<div>
|
|
222
|
+
<p class="text-sm text-base-content/70 mb-3">快速填充参数:</p>
|
|
223
|
+
<div class="flex flex-wrap gap-2">
|
|
224
|
+
{endpoint.quickTests!.map((quickTest, index) => (
|
|
225
|
+
<Button
|
|
226
|
+
variant="outline"
|
|
227
|
+
size="sm"
|
|
228
|
+
data-quick-test={JSON.stringify(quickTest.values)}
|
|
229
|
+
data-endpoint={endpoint.path}
|
|
230
|
+
title={quickTest.description}>
|
|
231
|
+
{quickTest.label}
|
|
232
|
+
</Button>
|
|
233
|
+
))}
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
{/* 测试按钮 */}
|
|
240
|
+
<Button
|
|
241
|
+
variant="primary"
|
|
242
|
+
block
|
|
243
|
+
data-endpoint={endpoint.path}
|
|
244
|
+
data-method={endpoint.method}>
|
|
245
|
+
测试接口
|
|
246
|
+
</Button>
|
|
247
|
+
|
|
248
|
+
{/* 测试结果 */}
|
|
249
|
+
<div
|
|
250
|
+
class="hidden mt-4 p-4 bg-base-200 rounded-lg border-l-4 border-l-primary"
|
|
251
|
+
data-result={endpoint.path}>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</Card>
|