@yuku123/z-frontend-common 0.2.9 → 1.1.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/LICENSE +25 -0
- package/README.md +55 -42
- package/dist/PagedTable-DyjNokXN.js +1211 -0
- package/dist/index.js +310 -0
- package/dist/ui.js +27 -0
- package/package.json +52 -44
- package/src/components/ErrorBoundary/index.jsx +24 -77
- package/src/components/Layout/index.jsx +141 -38
- package/src/components/LoginPage/index.jsx +47 -21
- package/src/components/StatusTag/index.jsx +14 -12
- package/src/components/ui/CategoryDot.jsx +38 -0
- package/src/components/ui/DarkBanner.jsx +142 -0
- package/src/components/ui/EChartsChart.jsx +82 -0
- package/src/components/ui/EmptyState.jsx +94 -0
- package/src/components/ui/ErrorState.jsx +114 -0
- package/src/components/ui/FeatureCard.jsx +205 -0
- package/src/components/ui/GradientStatCard.jsx +196 -0
- package/src/components/ui/LoadingState.jsx +116 -0
- package/src/components/ui/PageHeader.jsx +143 -0
- package/src/components/ui/PagedTable.jsx +83 -0
- package/src/components/ui/SearchInput.jsx +111 -0
- package/src/components/ui/SectionHeader.jsx +76 -0
- package/src/components/ui/StatusBadge.jsx +66 -0
- package/src/components/ui/TableToolbar.jsx +58 -0
- package/src/components/ui/index.js +36 -0
- package/src/components/ui/tokens.js +224 -0
- package/src/index.js +33 -37
- package/src/services/request.js +74 -4
- package/dist/z-frontend-common.css +0 -1
- package/dist/z-frontend-common.es.js +0 -51275
- package/dist/z-frontend-common.umd.js +0 -459
- package/src/components/Ctc/Layout.jsx +0 -330
- package/src/components/Ctc/Layout.module.css +0 -145
- package/src/components/Ctc/agentTeam/index.tsx +0 -308
- package/src/components/Ctc/login/AuthPage.module.css +0 -26
- package/src/components/Ctc/login/AuthPage.tsx +0 -235
- package/src/components/Ctc/login/index.less +0 -49
- package/src/components/Ctc/login/index.tsx +0 -142
- package/src/components/Ctc/uc/UCLogin.tsx +0 -31
- package/src/components/Ctc/uc/UCPhoneLogin.tsx +0 -62
- package/src/components/Ctc/uc/UCRegister.tsx +0 -37
- package/src/components/Ctc/uc/UCResetPassword.tsx +0 -69
- package/src/components/Ctc/uc/index.tsx +0 -15
- package/src/components/Ctc/userPanel/index.tsx +0 -999
- package/src/components/Ctc/webide/index.tsx +0 -272
- package/src/components/LowCode/LowCodeModel.jsx +0 -962
- package/src/components/LowCode/LowCodePage.jsx +0 -31
- package/src/components/LowCode/LowCodeRuntime.jsx +0 -335
- package/src/components/LowCode/MaterializePage.jsx +0 -235
- package/src/components/LowCode/index.js +0 -1
- package/src/components/MockPlatform/CurlImportModal.jsx +0 -362
- package/src/components/MockPlatform/EndpointsTab.jsx +0 -509
- package/src/components/MockPlatform/EnvironmentsTab.jsx +0 -212
- package/src/components/MockPlatform/MockTemplateHelper.jsx +0 -200
- package/src/components/MockPlatform/OpenApiImportModal.jsx +0 -305
- package/src/components/MockPlatform/RecordingsTab.jsx +0 -397
- package/src/components/MockPlatform/RequestLogsTab.jsx +0 -239
- package/src/components/MockPlatform/ScenariosTab.jsx +0 -236
- package/src/components/MockPlatform/TestCasesTab.jsx +0 -462
- package/src/components/MockPlatform/index.jsx +0 -127
- package/src/components/Overview.jsx +0 -74
- package/src/dev.jsx +0 -28
- package/src/services/agentTeam.js +0 -7
- package/src/services/api.js +0 -84
- package/src/services/ctcAc.js +0 -7
- package/src/services/ctcAcDomain.js +0 -7
- package/src/services/ctcAuthorization.js +0 -7
- package/src/services/ctcSurl.js +0 -7
- package/src/services/ctcUser.js +0 -7
- package/src/services/job.js +0 -7
- package/src/services/metaApp.js +0 -7
- package/src/services/privateConfig.js +0 -7
- package/src/services/webide.js +0 -6
- package/src/services/workspace.js +0 -21
- package/src/utils/request.ts +0 -102
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import {useRef, useState} from 'react'
|
|
2
|
-
import {Alert, Button, Card, Col, Form, Input, message, Modal, Row, Select, Space, Table, Tabs, Tag, Upload} from 'antd'
|
|
3
|
-
import {
|
|
4
|
-
CloudUploadOutlined,
|
|
5
|
-
FileAddOutlined,
|
|
6
|
-
FileTextOutlined,
|
|
7
|
-
ImportOutlined,
|
|
8
|
-
ThunderboltOutlined
|
|
9
|
-
} from '@ant-design/icons'
|
|
10
|
-
import {mockPlatformApi} from '@/services/api'
|
|
11
|
-
|
|
12
|
-
const {TextArea} = Input
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* OpenAPI / Swagger / Postman 批量导入 Mock 端点
|
|
16
|
-
*
|
|
17
|
-
* 流程:上传/粘贴 → 解析 → 预览列表(可选择) → 批量入库
|
|
18
|
-
*/
|
|
19
|
-
export default function OpenApiImportModal({open, onClose, onSuccess, envOptions = []}) {
|
|
20
|
-
const [activeTab, setActiveTab] = useState('paste')
|
|
21
|
-
const [content, setContent] = useState('')
|
|
22
|
-
const [parsed, setParsed] = useState(null)
|
|
23
|
-
const [parseError, setParseError] = useState(null)
|
|
24
|
-
const [parsing, setParsing] = useState(false)
|
|
25
|
-
const [selectedRowKeys, setSelectedRowKeys] = useState([])
|
|
26
|
-
const [importing, setImporting] = useState(false)
|
|
27
|
-
const [form] = Form.useForm()
|
|
28
|
-
const uploadRef = useRef(null)
|
|
29
|
-
|
|
30
|
-
const reset = () => {
|
|
31
|
-
setContent('')
|
|
32
|
-
setParsed(null)
|
|
33
|
-
setParseError(null)
|
|
34
|
-
setSelectedRowKeys([])
|
|
35
|
-
form.resetFields()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const handleClose = () => {
|
|
39
|
-
reset()
|
|
40
|
-
onClose()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const handleParse = async () => {
|
|
44
|
-
if (!content.trim()) {
|
|
45
|
-
message.warning('请先粘贴或上传 API 规约');
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
setParseError(null)
|
|
49
|
-
setParsing(true)
|
|
50
|
-
try {
|
|
51
|
-
const res = await mockPlatformApi.openapi.parse(content)
|
|
52
|
-
if (res.success) {
|
|
53
|
-
setParsed(res)
|
|
54
|
-
setSelectedRowKeys((res.endpoints || []).map((_, i) => i))
|
|
55
|
-
form.setFieldsValue({
|
|
56
|
-
envCode: envOptions[0] || 'default',
|
|
57
|
-
projectCode: 'default',
|
|
58
|
-
defaultResponse: '{\n "code": 0,\n "message": "ok",\n "data": {}\n}',
|
|
59
|
-
defaultStatus: 200,
|
|
60
|
-
priority: 5,
|
|
61
|
-
tagPrefix: 'openapi-import',
|
|
62
|
-
})
|
|
63
|
-
message.success(`识别为 ${res.format},共 ${res.count} 个端点`)
|
|
64
|
-
} else {
|
|
65
|
-
setParseError(res.message || '解析失败')
|
|
66
|
-
}
|
|
67
|
-
} catch (e) {
|
|
68
|
-
setParseError(String(e?.message || e))
|
|
69
|
-
} finally {
|
|
70
|
-
setParsing(false)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const handleLoadSample = async (format) => {
|
|
75
|
-
try {
|
|
76
|
-
const res = await mockPlatformApi.openapi.sample(format)
|
|
77
|
-
if (res.success) {
|
|
78
|
-
setContent(res.content)
|
|
79
|
-
message.success(`已加载 ${res.format} 示例`)
|
|
80
|
-
}
|
|
81
|
-
} catch (e) {
|
|
82
|
-
message.error('加载示例失败: ' + e.message)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const handleFileUpload = (file) => {
|
|
87
|
-
const reader = new FileReader()
|
|
88
|
-
reader.onload = (e) => {
|
|
89
|
-
setContent(String(e.target?.result || ''))
|
|
90
|
-
message.success(`已读取 ${file.name}(${(file.size / 1024).toFixed(1)}KB)`)
|
|
91
|
-
}
|
|
92
|
-
reader.onerror = () => message.error('文件读取失败')
|
|
93
|
-
reader.readAsText(file)
|
|
94
|
-
return false // 阻止 antd Upload 自动上传
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const handleImport = async () => {
|
|
98
|
-
if (!parsed) {
|
|
99
|
-
message.warning('请先解析');
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
let values
|
|
103
|
-
try {
|
|
104
|
-
values = await form.validateFields()
|
|
105
|
-
} catch {
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
setImporting(true)
|
|
109
|
-
try {
|
|
110
|
-
const selected = (parsed.endpoints || []).map((ep, i) => ({
|
|
111
|
-
method: ep.method, path: ep.path
|
|
112
|
-
})).filter((_, i) => selectedRowKeys.includes(i))
|
|
113
|
-
const res = await mockPlatformApi.openapi.importBatch({
|
|
114
|
-
content,
|
|
115
|
-
selected,
|
|
116
|
-
envCode: values.envCode,
|
|
117
|
-
projectCode: values.projectCode,
|
|
118
|
-
defaultResponse: values.defaultResponse,
|
|
119
|
-
defaultStatus: values.defaultStatus,
|
|
120
|
-
priority: values.priority,
|
|
121
|
-
tagPrefix: values.tagPrefix,
|
|
122
|
-
})
|
|
123
|
-
if (res.success) {
|
|
124
|
-
message.success(`已导入 ${res.imported} 个 Mock 端点${res.failed > 0 ? `,失败 ${res.failed}` : ''}`)
|
|
125
|
-
onSuccess && onSuccess(res)
|
|
126
|
-
handleClose()
|
|
127
|
-
} else {
|
|
128
|
-
message.error(res.message || '导入失败')
|
|
129
|
-
}
|
|
130
|
-
} catch (e) {
|
|
131
|
-
message.error(String(e?.message || e))
|
|
132
|
-
} finally {
|
|
133
|
-
setImporting(false)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const columns = [
|
|
138
|
-
{
|
|
139
|
-
title: 'Method', dataIndex: 'method', width: 90,
|
|
140
|
-
render: (m) => <Tag color={methodColor(m)}>{m}</Tag>
|
|
141
|
-
},
|
|
142
|
-
{title: 'Path', dataIndex: 'path', width: 240, ellipsis: true},
|
|
143
|
-
{title: 'Summary', dataIndex: 'summary', ellipsis: true},
|
|
144
|
-
{
|
|
145
|
-
title: 'Tags', dataIndex: 'tags', width: 160,
|
|
146
|
-
render: (tags) => (tags || []).map(t => <Tag key={t}>{t}</Tag>)
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
title: 'Params', dataIndex: 'parameters', width: 80,
|
|
150
|
-
render: (p) => p?.length || 0,
|
|
151
|
-
align: 'center'
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
title: '示例', dataIndex: 'responseExample', width: 80,
|
|
155
|
-
render: (s) => s ? <Tag color="green">有</Tag> : <Tag>无</Tag>
|
|
156
|
-
},
|
|
157
|
-
]
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<Modal
|
|
161
|
-
title={<Space><CloudUploadOutlined/> 批量导入 API 规约</Space>}
|
|
162
|
-
open={open}
|
|
163
|
-
onCancel={handleClose}
|
|
164
|
-
footer={null}
|
|
165
|
-
width={1100}
|
|
166
|
-
destroyOnHidden
|
|
167
|
-
>
|
|
168
|
-
<Tabs
|
|
169
|
-
activeKey={activeTab}
|
|
170
|
-
onChange={setActiveTab}
|
|
171
|
-
items={[
|
|
172
|
-
{
|
|
173
|
-
key: 'paste',
|
|
174
|
-
label: <span><FileTextOutlined/> 粘贴 JSON</span>,
|
|
175
|
-
children: (
|
|
176
|
-
<div>
|
|
177
|
-
<TextArea
|
|
178
|
-
value={content}
|
|
179
|
-
onChange={(e) => setContent(e.target.value)}
|
|
180
|
-
placeholder='粘贴 OpenAPI 3.x / Swagger 2.0 / Postman v2.1 JSON 内容…'
|
|
181
|
-
autoSize={{minRows: 6, maxRows: 16}}
|
|
182
|
-
style={{fontFamily: 'Menlo, Monaco, monospace', fontSize: 12}}
|
|
183
|
-
/>
|
|
184
|
-
<Space style={{marginTop: 8}}>
|
|
185
|
-
<Button size="small" onClick={() => handleLoadSample('openapi3')}>加载 OpenAPI 3
|
|
186
|
-
示例</Button>
|
|
187
|
-
<Button size="small" onClick={() => handleLoadSample('swagger2')}>加载 Swagger 2
|
|
188
|
-
示例</Button>
|
|
189
|
-
<Button size="small" onClick={() => handleLoadSample('postman')}>加载 Postman
|
|
190
|
-
示例</Button>
|
|
191
|
-
</Space>
|
|
192
|
-
</div>
|
|
193
|
-
),
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
key: 'upload',
|
|
197
|
-
label: <span><FileAddOutlined/> 上传文件</span>,
|
|
198
|
-
children: (
|
|
199
|
-
<Upload.Dragger
|
|
200
|
-
ref={uploadRef}
|
|
201
|
-
accept=".json,.yaml,.yml,application/json,text/yaml"
|
|
202
|
-
beforeUpload={handleFileUpload}
|
|
203
|
-
showUploadList={false}
|
|
204
|
-
style={{padding: 24}}
|
|
205
|
-
>
|
|
206
|
-
<p className="ant-upload-drag-icon">
|
|
207
|
-
<CloudUploadOutlined style={{fontSize: 48, color: '#1890ff'}}/>
|
|
208
|
-
</p>
|
|
209
|
-
<p className="ant-upload-text">点击或拖拽 JSON / YAML 文件到此处</p>
|
|
210
|
-
<p className="ant-upload-hint">支持 OpenAPI 3.x / Swagger 2.0 / Postman v2.1</p>
|
|
211
|
-
</Upload.Dragger>
|
|
212
|
-
),
|
|
213
|
-
},
|
|
214
|
-
]}
|
|
215
|
-
/>
|
|
216
|
-
|
|
217
|
-
<Space style={{marginTop: 12}}>
|
|
218
|
-
<Button type="primary" icon={<ThunderboltOutlined/>} onClick={handleParse} loading={parsing}>
|
|
219
|
-
解析
|
|
220
|
-
</Button>
|
|
221
|
-
{parsed && (
|
|
222
|
-
<Tag color="blue">{parsed.format}</Tag>
|
|
223
|
-
)}
|
|
224
|
-
{parsed && (
|
|
225
|
-
<Tag>共 {parsed.count} 个端点,已选 {selectedRowKeys.length}</Tag>
|
|
226
|
-
)}
|
|
227
|
-
</Space>
|
|
228
|
-
|
|
229
|
-
{parseError && (
|
|
230
|
-
<Alert type="error" showIcon style={{marginTop: 12}} title="解析失败" description={parseError}/>
|
|
231
|
-
)}
|
|
232
|
-
|
|
233
|
-
{parsed && (
|
|
234
|
-
<Card size="small" style={{marginTop: 16}} title="预览(可勾选要导入的)">
|
|
235
|
-
<Table
|
|
236
|
-
size="small"
|
|
237
|
-
dataSource={parsed.endpoints || []}
|
|
238
|
-
columns={columns}
|
|
239
|
-
rowKey={(_, i) => i}
|
|
240
|
-
rowSelection={{
|
|
241
|
-
selectedRowKeys,
|
|
242
|
-
onChange: setSelectedRowKeys,
|
|
243
|
-
}}
|
|
244
|
-
pagination={{pageSize: 8}}
|
|
245
|
-
scroll={{y: 280}}
|
|
246
|
-
/>
|
|
247
|
-
</Card>
|
|
248
|
-
)}
|
|
249
|
-
|
|
250
|
-
{parsed && (
|
|
251
|
-
<Card size="small" style={{marginTop: 16}} title="导入配置">
|
|
252
|
-
<Form form={form} layout="vertical">
|
|
253
|
-
<Row gutter={16}>
|
|
254
|
-
<Col span={6}>
|
|
255
|
-
<Form.Item name="envCode" label="环境" rules={[{required: true}]}>
|
|
256
|
-
{envOptions.length > 0
|
|
257
|
-
? <Select options={envOptions.map(e => ({value: e, label: e}))}/>
|
|
258
|
-
: <Input/>}
|
|
259
|
-
</Form.Item>
|
|
260
|
-
</Col>
|
|
261
|
-
<Col span={6}>
|
|
262
|
-
<Form.Item name="projectCode" label="项目">
|
|
263
|
-
<Input/>
|
|
264
|
-
</Form.Item>
|
|
265
|
-
</Col>
|
|
266
|
-
<Col span={4}>
|
|
267
|
-
<Form.Item name="defaultStatus" label="默认状态码">
|
|
268
|
-
<Input type="number"/>
|
|
269
|
-
</Form.Item>
|
|
270
|
-
</Col>
|
|
271
|
-
<Col span={4}>
|
|
272
|
-
<Form.Item name="priority" label="优先级">
|
|
273
|
-
<Input type="number"/>
|
|
274
|
-
</Form.Item>
|
|
275
|
-
</Col>
|
|
276
|
-
<Col span={4}>
|
|
277
|
-
<Form.Item name="tagPrefix" label="Tag 前缀">
|
|
278
|
-
<Input/>
|
|
279
|
-
</Form.Item>
|
|
280
|
-
</Col>
|
|
281
|
-
</Row>
|
|
282
|
-
<Form.Item name="defaultResponse" label="默认响应(无 example 时使用)">
|
|
283
|
-
<TextArea autoSize={{minRows: 3, maxRows: 6}}
|
|
284
|
-
style={{fontFamily: 'Menlo, Monaco, monospace'}}/>
|
|
285
|
-
</Form.Item>
|
|
286
|
-
<Button
|
|
287
|
-
type="primary"
|
|
288
|
-
size="large"
|
|
289
|
-
icon={<ImportOutlined/>}
|
|
290
|
-
onClick={handleImport}
|
|
291
|
-
loading={importing}
|
|
292
|
-
disabled={selectedRowKeys.length === 0}
|
|
293
|
-
>
|
|
294
|
-
批量导入 {selectedRowKeys.length} 个端点
|
|
295
|
-
</Button>
|
|
296
|
-
</Form>
|
|
297
|
-
</Card>
|
|
298
|
-
)}
|
|
299
|
-
</Modal>
|
|
300
|
-
)
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function methodColor(method) {
|
|
304
|
-
return {GET: 'blue', POST: 'green', PUT: 'orange', DELETE: 'red', PATCH: 'purple'}[method] || 'default'
|
|
305
|
-
}
|