@yuku123/z-frontend-common 0.2.9 → 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.
Files changed (57) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +55 -42
  3. package/dist/index.js +1 -0
  4. package/package.json +49 -44
  5. package/src/components/ErrorBoundary/index.jsx +24 -77
  6. package/src/components/Layout/index.jsx +141 -38
  7. package/src/components/LoginPage/index.jsx +47 -21
  8. package/src/components/StatusTag/index.jsx +14 -12
  9. package/src/index.js +32 -38
  10. package/src/services/request.js +74 -4
  11. package/dist/z-frontend-common.css +0 -1
  12. package/dist/z-frontend-common.es.js +0 -51275
  13. package/dist/z-frontend-common.umd.js +0 -459
  14. package/src/components/Ctc/Layout.jsx +0 -330
  15. package/src/components/Ctc/Layout.module.css +0 -145
  16. package/src/components/Ctc/agentTeam/index.tsx +0 -308
  17. package/src/components/Ctc/login/AuthPage.module.css +0 -26
  18. package/src/components/Ctc/login/AuthPage.tsx +0 -235
  19. package/src/components/Ctc/login/index.less +0 -49
  20. package/src/components/Ctc/login/index.tsx +0 -142
  21. package/src/components/Ctc/uc/UCLogin.tsx +0 -31
  22. package/src/components/Ctc/uc/UCPhoneLogin.tsx +0 -62
  23. package/src/components/Ctc/uc/UCRegister.tsx +0 -37
  24. package/src/components/Ctc/uc/UCResetPassword.tsx +0 -69
  25. package/src/components/Ctc/uc/index.tsx +0 -15
  26. package/src/components/Ctc/userPanel/index.tsx +0 -999
  27. package/src/components/Ctc/webide/index.tsx +0 -272
  28. package/src/components/LowCode/LowCodeModel.jsx +0 -962
  29. package/src/components/LowCode/LowCodePage.jsx +0 -31
  30. package/src/components/LowCode/LowCodeRuntime.jsx +0 -335
  31. package/src/components/LowCode/MaterializePage.jsx +0 -235
  32. package/src/components/LowCode/index.js +0 -1
  33. package/src/components/MockPlatform/CurlImportModal.jsx +0 -362
  34. package/src/components/MockPlatform/EndpointsTab.jsx +0 -509
  35. package/src/components/MockPlatform/EnvironmentsTab.jsx +0 -212
  36. package/src/components/MockPlatform/MockTemplateHelper.jsx +0 -200
  37. package/src/components/MockPlatform/OpenApiImportModal.jsx +0 -305
  38. package/src/components/MockPlatform/RecordingsTab.jsx +0 -397
  39. package/src/components/MockPlatform/RequestLogsTab.jsx +0 -239
  40. package/src/components/MockPlatform/ScenariosTab.jsx +0 -236
  41. package/src/components/MockPlatform/TestCasesTab.jsx +0 -462
  42. package/src/components/MockPlatform/index.jsx +0 -127
  43. package/src/components/Overview.jsx +0 -74
  44. package/src/dev.jsx +0 -28
  45. package/src/services/agentTeam.js +0 -7
  46. package/src/services/api.js +0 -84
  47. package/src/services/ctcAc.js +0 -7
  48. package/src/services/ctcAcDomain.js +0 -7
  49. package/src/services/ctcAuthorization.js +0 -7
  50. package/src/services/ctcSurl.js +0 -7
  51. package/src/services/ctcUser.js +0 -7
  52. package/src/services/job.js +0 -7
  53. package/src/services/metaApp.js +0 -7
  54. package/src/services/privateConfig.js +0 -7
  55. package/src/services/webide.js +0 -6
  56. package/src/services/workspace.js +0 -21
  57. package/src/utils/request.ts +0 -102
@@ -1,236 +0,0 @@
1
- import {useEffect, useState} from 'react'
2
- import {Alert, Button, Col, Form, Input, message, Modal, Popconfirm, Row, Space, Table, Tag, Typography} from 'antd'
3
- import {
4
- DeleteOutlined,
5
- EditOutlined,
6
- NodeIndexOutlined,
7
- PlusOutlined,
8
- ReloadOutlined,
9
- UndoOutlined
10
- } from '@ant-design/icons'
11
- import {mockPlatformApi} from '@/services/api'
12
-
13
- const {Text} = Typography
14
-
15
- /**
16
- * 场景状态机 Tab - 管理 Scenarios(订单流程、用户登录流程等状态机驱动的 Mock 集合)
17
- */
18
- export default function ScenariosTab() {
19
- const [scenarios, setScenarios] = useState([])
20
- const [loading, setLoading] = useState(false)
21
- const [modalOpen, setModalOpen] = useState(false)
22
- const [editing, setEditing] = useState(null)
23
- const [instancesOpen, setInstancesOpen] = useState(false)
24
- const [instances, setInstances] = useState(null)
25
- const [form] = Form.useForm()
26
-
27
- useEffect(() => {
28
- loadScenarios()
29
- }, [])
30
-
31
- const loadScenarios = async () => {
32
- setLoading(true)
33
- try {
34
- const res = await mockPlatformApi.scenarios.list()
35
- setScenarios(Array.isArray(res) ? res : [])
36
- } catch (e) {
37
- message.warning('加载场景列表失败')
38
- } finally {
39
- setLoading(false)
40
- }
41
- }
42
-
43
- const handleCreate = () => {
44
- setEditing(null)
45
- form.resetFields()
46
- form.setFieldsValue({initialState: 'started'})
47
- setModalOpen(true)
48
- }
49
-
50
- const handleEdit = (record) => {
51
- setEditing(record)
52
- form.setFieldsValue(record)
53
- setModalOpen(true)
54
- }
55
-
56
- const handleSave = async () => {
57
- try {
58
- const values = await form.validateFields()
59
- let states
60
- try {
61
- states = values.statesJson ? JSON.parse(values.statesJson) : null
62
- } catch (e) {
63
- message.error('状态列表 JSON 格式错误');
64
- return
65
- }
66
- const payload = {...values, states}
67
- delete payload.statesJson
68
- if (editing) {
69
- await mockPlatformApi.scenarios.update(editing.scenarioCode, payload)
70
- message.success('更新成功')
71
- } else {
72
- await mockPlatformApi.scenarios.create(payload)
73
- message.success('创建成功')
74
- }
75
- setModalOpen(false)
76
- loadScenarios()
77
- } catch (e) {
78
- if (!e?.errorFields) message.error('保存失败')
79
- }
80
- }
81
-
82
- const handleDelete = async (code) => {
83
- try {
84
- await mockPlatformApi.scenarios.delete(code)
85
- message.success('删除成功')
86
- loadScenarios()
87
- } catch (e) {
88
- message.error('删除失败')
89
- }
90
- }
91
-
92
- const handleReset = async (code) => {
93
- try {
94
- await mockPlatformApi.scenarios.reset(code)
95
- message.success('已重置所有实例状态')
96
- } catch (e) {
97
- message.error('重置失败')
98
- }
99
- }
100
-
101
- const handleShowInstances = async (code) => {
102
- try {
103
- const res = await mockPlatformApi.scenarios.instances(code)
104
- setInstances({code, list: res})
105
- setInstancesOpen(true)
106
- } catch (e) {
107
- message.error('加载失败')
108
- }
109
- }
110
-
111
- const columns = [
112
- {
113
- title: '场景编码', dataIndex: 'scenarioCode', key: 'scenarioCode', width: 160,
114
- render: (v) => <Text code>{v}</Text>
115
- },
116
- {title: '场景名称', dataIndex: 'scenarioName', key: 'scenarioName', width: 200},
117
- {
118
- title: '初始状态', dataIndex: 'initialState', key: 'initialState', width: 140,
119
- render: (v) => <Tag color="blue">{v}</Tag>
120
- },
121
- {
122
- title: '状态列表', dataIndex: 'states', key: 'states',
123
- render: (v) => {
124
- if (!v) return '-'
125
- try {
126
- const arr = typeof v === 'string' ? JSON.parse(v) : v
127
- return Array.isArray(arr) ? arr.map(s => <Tag key={s}>{s}</Tag>) : '-'
128
- } catch {
129
- return '-'
130
- }
131
- }
132
- },
133
- {
134
- title: '描述', dataIndex: 'description', key: 'description', width: 240,
135
- render: (v) => v || '-'
136
- },
137
- {
138
- title: '操作', key: 'action', width: 280, fixed: 'right',
139
- render: (_, record) => (
140
- <Space size="small">
141
- <Button size="small" type="link" icon={<NodeIndexOutlined/>}
142
- onClick={() => handleShowInstances(record.scenarioCode)}>实例</Button>
143
- <Button size="small" type="link" icon={<UndoOutlined/>}
144
- onClick={() => handleReset(record.scenarioCode)}>重置</Button>
145
- <Button size="small" type="link" icon={<EditOutlined/>}
146
- onClick={() => handleEdit(record)}/>
147
- <Popconfirm title={`删除场景 ${record.scenarioCode}?`}
148
- onConfirm={() => handleDelete(record.scenarioCode)}>
149
- <Button size="small" type="link" danger icon={<DeleteOutlined/>}/>
150
- </Popconfirm>
151
- </Space>
152
- )
153
- },
154
- ]
155
-
156
- return (
157
- <div>
158
- <Alert type="info" showIcon style={{marginBottom: 16}}
159
- title="场景状态机 (Scenario)"
160
- description="用状态机驱动 Mock 集合,模拟完整业务流程(如:未登录→登录中→已登录→下单→已支付→完成)。实例通过 X-Session-Id 或 X-Trace-Id 区分,每个实例独立维护当前状态。"
161
- />
162
-
163
- <Space style={{marginBottom: 16}}>
164
- <Button icon={<ReloadOutlined/>} onClick={loadScenarios}>刷新</Button>
165
- <Button type="primary" icon={<PlusOutlined/>} onClick={handleCreate}>新建场景</Button>
166
- </Space>
167
-
168
- <Table
169
- dataSource={scenarios}
170
- columns={columns}
171
- rowKey="id"
172
- loading={loading}
173
- pagination={{pageSize: 10}}
174
- scroll={{x: 1100}}
175
- size="small"
176
- />
177
-
178
- <Modal
179
- title={editing ? `编辑场景: ${editing.scenarioCode}` : '新建场景'}
180
- open={modalOpen}
181
- onCancel={() => setModalOpen(false)}
182
- onOk={handleSave}
183
- width={650}
184
- >
185
- <Form form={form} layout="vertical" style={{marginTop: 16}}>
186
- <Row gutter={16}>
187
- <Col span={12}>
188
- <Form.Item name="scenarioCode" label="场景编码" rules={[{required: true}]}>
189
- <Input placeholder="user-login-flow" disabled={!!editing}/>
190
- </Form.Item>
191
- </Col>
192
- <Col span={12}>
193
- <Form.Item name="scenarioName" label="场景名称">
194
- <Input placeholder="用户登录流程"/>
195
- </Form.Item>
196
- </Col>
197
- </Row>
198
- <Form.Item name="initialState" label="初始状态" rules={[{required: true}]}>
199
- <Input placeholder="started"/>
200
- </Form.Item>
201
- <Form.Item name="statesJson" label="状态列表 (JSON 数组)"
202
- extra='例: ["started", "logged-in", "checkout", "paid", "completed"]'>
203
- <Input.TextArea rows={3} placeholder='["started", "logged-in", "checkout", "paid"]'/>
204
- </Form.Item>
205
- <Form.Item name="description" label="描述">
206
- <Input.TextArea rows={3} placeholder="场景的业务说明"/>
207
- </Form.Item>
208
- </Form>
209
- </Modal>
210
-
211
- <Modal
212
- title={`场景实例: ${instances?.code}`}
213
- open={instancesOpen}
214
- onCancel={() => setInstancesOpen(false)}
215
- footer={<Button onClick={() => setInstancesOpen(false)}>关闭</Button>}
216
- width={700}
217
- >
218
- {instances && (
219
- <Table
220
- dataSource={Array.isArray(instances.list) ? instances.list : []}
221
- columns={[
222
- {title: '实例标识', dataIndex: 'instanceKey', key: 'instanceKey'},
223
- {
224
- title: '当前状态', dataIndex: 'currentState', key: 'currentState',
225
- render: (v) => <Tag color="blue">{v}</Tag>
226
- },
227
- {title: '最后变更', dataIndex: 'lastUpdateTime', key: 'lastUpdateTime'},
228
- ]}
229
- rowKey={(r, i) => r.instanceKey || i}
230
- pagination={false} size="small"
231
- />
232
- )}
233
- </Modal>
234
- </div>
235
- )
236
- }