@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
package/src/dev.jsx DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * z-frontend-common 开发调试入口
3
- */
4
- import React from 'react'
5
- import ReactDOM from 'react-dom/client'
6
- import {LoginPage, StatusTag} from './index'
7
-
8
- const DevApp = () => {
9
- return (
10
- <div style={{padding: 20}}>
11
- <h1>z-frontend-common Dev</h1>
12
-
13
- <h2>StatusTag 示例</h2>
14
- <StatusTag status={1}/>
15
- <StatusTag status={0}/>
16
- <StatusTag status="pending"/>
17
- <StatusTag status="approved"/>
18
- <StatusTag status="rejected"/>
19
-
20
- <h2>LoginPage 示例</h2>
21
- <div style={{height: 400, border: '1px solid #ccc', borderRadius: 8, overflow: 'hidden'}}>
22
- <LoginPage title="测试登录"/>
23
- </div>
24
- </div>
25
- )
26
- }
27
-
28
- ReactDOM.createRoot(document.getElementById('root')).render(<DevApp/>)
@@ -1,7 +0,0 @@
1
- /** 占位 stub: agentTeam 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const agentTeamApi = {
5
- health: () => request.get('/agentTeam/health').then(r => r.data),
6
- }
7
- export default agentTeamApi
@@ -1,84 +0,0 @@
1
- /**
2
- * z-frontend-common 兼容垫片 - 之前在 z-opc-main-starter-frontend/services/api.ts 里的所有 API
3
- */
4
- import axios from 'axios'
5
-
6
- let _baseURL = '/api'
7
- export function configureBaseURL(baseURL) { _baseURL = baseURL || '/api' }
8
- function makeRequest() {
9
- return axios.create({baseURL: _baseURL, timeout: 15000})
10
- }
11
- const request = makeRequest()
12
- const authRequest = makeRequest()
13
-
14
- // 拦截器
15
- request.interceptors.request.use(config => {
16
- const token = localStorage.getItem('token')
17
- if (token) config.headers.Authorization = `Bearer ${token}`
18
- return config
19
- })
20
-
21
- // === 鉴权 API (FEATURE015) ===
22
- export const login = (data) => request.post('/ctc/auth/login', data).then(r => r.data)
23
- export const getCurrentUser = () => {
24
- try {
25
- const raw = localStorage.getItem('userInfo')
26
- return Promise.resolve(raw ? JSON.parse(raw) : null)
27
- } catch {
28
- return Promise.resolve(null)
29
- }
30
- }
31
- export const switchTenant = (tenantCode, domainCode) =>
32
- authRequest.post('/ctc/auth/switch-tenant', {tenantCode: tenantCode || '', domainCode: domainCode || ''}).then(r => r.data)
33
-
34
- // === 占位 (实际调用从 z-ctc-frontend-component) ===
35
- export const getDomainByTenantCode = async () => [{domainCode: 'default', domainName: '默认域'}]
36
- export const getTenantList = async () => []
37
- export const getDynamicMenu = async () => []
38
-
39
- // === 动态 API 路由表 (从 apiRouter.ts 迁入) ===
40
- function makeApi(name) {
41
- return {
42
- list: (params) => request.get(`/${name}/list`, {params}).then(r => r.data),
43
- page: (params) => request.get(`/${name}/page`, {params}).then(r => r.data),
44
- get: (id) => request.get(`/${name}/${id}`).then(r => r.data),
45
- create: (data) => request.post(`/${name}`, data).then(r => r.data),
46
- update: (id, data) => request.put(`/${name}/${id}`, data).then(r => r.data),
47
- delete: (id) => request.delete(`/${name}/${id}`).then(r => r.data),
48
- }
49
- }
50
-
51
- export const configApi = makeApi('config')
52
- export const approvalApi = makeApi('approval')
53
- export const designerApi = makeApi('designer')
54
- export const mcpApi = makeApi('mcp')
55
- export const mockPlatformApi = makeApi('mock')
56
- export const namingApi = makeApi('naming')
57
- export const opsApi = makeApi('ops')
58
- export const ossApi = makeApi('oss')
59
- export const scriptApi = makeApi('script')
60
- export const skillApi = makeApi('skill')
61
- export const agentApi = makeApi('agent')
62
- export const flowApi = makeApi('flow')
63
- export const traceApi = makeApi('trace')
64
- export const llmApi = makeApi('llm')
65
- export const productApi = makeApi('product')
66
- export const sceneApi = makeApi('scene')
67
- export const userOrgRelApi = {
68
- usersByDept: (_code) => Promise.resolve([]),
69
- usersByGroup: (_code) => Promise.resolve([]),
70
- }
71
-
72
- // === 项目 / 任务 (FEATURE015) ===
73
- export const listMyProjects = () => authRequest.get('/project/user/list').then(r => r.data)
74
- export const createProject = (data) => request.post('/project', data).then(r => r.data)
75
- export const updateProject = (id, data) => request.put(`/project/${id}`, data).then(r => r.data)
76
- export const archiveProject = (id) => request.put(`/project/${id}/archive`).then(r => r.data)
77
- export const listTasksByProject = (projectId) => request.get('/task/project/list', {params: {projectId}}).then(r => r.data)
78
- export const createTask = (data) => request.post('/task', data).then(r => r.data)
79
- export const completeTask = (id) => request.post('/task/complete', null, {params: {taskId: id}}).then(r => r.data)
80
- export const moveTask = (taskId, targetListId, position) =>
81
- request.put('/task/move', null, {params: {taskId, targetListId, position}}).then(r => r.data)
82
- export const listTasksByList = (listId) => request.get('/task/list', {params: {listId}}).then(r => r.data)
83
-
84
- export default request
@@ -1,7 +0,0 @@
1
- /** 占位 stub: ctcAc 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const ctcAcApi = {
5
- health: () => request.get('/ctcAc/health').then(r => r.data),
6
- }
7
- export default ctcAcApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: ctcAcDomain 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const ctcAcDomainApi = {
5
- health: () => request.get('/ctcAcDomain/health').then(r => r.data),
6
- }
7
- export default ctcAcDomainApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: ctcAuthorization 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const ctcAuthorizationApi = {
5
- health: () => request.get('/ctcAuthorization/health').then(r => r.data),
6
- }
7
- export default ctcAuthorizationApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: ctcSurl 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const ctcSurlApi = {
5
- health: () => request.get('/ctcSurl/health').then(r => r.data),
6
- }
7
- export default ctcSurlApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: ctcUser 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const ctcUserApi = {
5
- health: () => request.get('/ctcUser/health').then(r => r.data),
6
- }
7
- export default ctcUserApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: job 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const jobApi = {
5
- health: () => request.get('/job/health').then(r => r.data),
6
- }
7
- export default jobApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: metaApp 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const metaAppApi = {
5
- health: () => request.get('/metaApp/health').then(r => r.data),
6
- }
7
- export default metaAppApi
@@ -1,7 +0,0 @@
1
- /** 占位 stub: privateConfig 服务 — 之前在 z-opc-main-starter-frontend/services/ 里的实现
2
- * 实际调用方应迁移到具体业务包 (z-ctc-frontend-component, z-meta-frontend-component 等). */
3
- import request from './request'
4
- export const privateConfigApi = {
5
- health: () => request.get('/privateConfig/health').then(r => r.data),
6
- }
7
- export default privateConfigApi
@@ -1,6 +0,0 @@
1
- /** 占位 stub: z-webide 后端服务 */
2
- import request from './request'
3
- export const webideApi = {
4
- health: () => request.get('/webide/health').then(r => r.data),
5
- }
6
- export default webideApi
@@ -1,21 +0,0 @@
1
- /**
2
- * workspace 服务 — FEATURE016 工作空间 / 工作项 (z-agent-team 后端)
3
- * 占位 stub: 实际 API 在 z-agent-frontend-component 内的 agentTeam service.
4
- */
5
- import request from './request'
6
-
7
- export const workspaceApi = {
8
- list: () => request.get('/agent/team/workspace/list').then(r => r.data),
9
- create: (data) => request.post('/agent/team/workspace', data).then(r => r.data),
10
- update: (id, data) => request.put(`/agent/team/workspace/${id}`, data).then(r => r.data),
11
- delete: (id) => request.delete(`/agent/team/workspace/${id}`).then(r => r.data),
12
- getFileTree: (path) => request.get('/agent/team/workspace/file-tree-by-path', {params: {path}}).then(r => r.data),
13
- getFileContent: (path) => request.get('/agent/team/workspace/file-content', {params: {path}}).then(r => r.data),
14
- }
15
-
16
- export const workItemApi = {
17
- list: (conversationId) => request.get(`/agent/team/conversation/${conversationId}/work-items`).then(r => r.data),
18
- create: (data) => request.post('/agent/team/work-item', data).then(r => r.data),
19
- update: (id, data) => request.put(`/agent/team/work-item/${id}`, data).then(r => r.data),
20
- delete: (id) => request.delete(`/agent/team/work-item/${id}`).then(r => r.data),
21
- }
@@ -1,102 +0,0 @@
1
- import axios, {AxiosInstance, AxiosResponse} from 'axios'
2
-
3
- /**
4
- * 业务响应解包:识别后端约定的 {code, data, message} 格式。
5
- *
6
- * 标准(所有后端应遵守):
7
- * - 成功:{code: 200, data: T, message: 'ok'} → 返回 data
8
- * - 失败:{code: 4xx/5xx, data: null, message: '...'} → reject(new Error(message))
9
- *
10
- * 容错:响应不含 `code` 字段(旧的 Map / ResponseEntity 直返),按 pass-through 处理,
11
- * 业务侧自行读取 res.data / res.success。
12
- */
13
- function defaultUnwrap(data: unknown): unknown {
14
- if (data && typeof data === 'object' && 'code' in data && 'data' in data) {
15
- const wrapped = data as {code: number | string; data: unknown; message?: string}
16
- if (wrapped.code !== 200) {
17
- return Promise.reject(new Error(wrapped.message || '请求失败'))
18
- }
19
- return wrapped.data
20
- }
21
- return data
22
- }
23
-
24
- /**
25
- * 请求拦截器配置
26
- * @param options.tokenKey 自定义 token 键名,默认 'token'
27
- * @param options.userInfoKey 自定义 userInfo 键名,默认 'userInfo'
28
- * @param options.unauthorizedRedirect 401 时跳转的地址,默认 '/login'
29
- */
30
- export function setupInterceptors(
31
- instance: AxiosInstance,
32
- options: {
33
- tokenKey?: string
34
- userInfoKey?: string
35
- unauthorizedRedirect?: string
36
- } = {}
37
- ) {
38
- const {
39
- tokenKey = 'token',
40
- userInfoKey = 'userInfo',
41
- unauthorizedRedirect = '/login',
42
- } = options
43
-
44
- instance.interceptors.request.use((config) => {
45
- const token = localStorage.getItem(tokenKey)
46
- if (token) {
47
- config.headers.Authorization = `Bearer ${token}`
48
- }
49
- return config
50
- })
51
-
52
- instance.interceptors.response.use(
53
- (response: AxiosResponse) => defaultUnwrap(response.data),
54
- (error) => {
55
- if (error.response?.status === 401) {
56
- localStorage.removeItem(tokenKey)
57
- localStorage.removeItem(userInfoKey)
58
- window.location.href = unauthorizedRedirect
59
- } else if (error.response?.status === 403) {
60
- console.error('没有权限访问该资源')
61
- } else if (error.response?.status === 500) {
62
- console.error('服务器内部错误')
63
- }
64
- return Promise.reject(error)
65
- }
66
- )
67
- }
68
-
69
- /**
70
- * 创建请求实例。所有实例共用同一种响应解包策略(见 defaultUnwrap 注释)。
71
- *
72
- * @param options.baseURL 接口前缀,默认 '/api'
73
- * @param options.timeout 超时毫秒,默认 10000
74
- * @param options.tokenKey token localStorage key,默认 'token'
75
- * @param options.userInfoKey userInfo localStorage key,默认 'userInfo'
76
- * @param options.unauthorizedRedirect 401 跳转地址,默认 '/login'
77
- */
78
- export function createRequest(options: {
79
- baseURL?: string
80
- timeout?: number
81
- tokenKey?: string
82
- userInfoKey?: string
83
- unauthorizedRedirect?: string
84
- } = {}): AxiosInstance {
85
- const instance = axios.create({
86
- baseURL: options.baseURL ?? '/api',
87
- timeout: options.timeout ?? 10000,
88
- })
89
- setupInterceptors(instance, {
90
- tokenKey: options.tokenKey,
91
- userInfoKey: options.userInfoKey,
92
- unauthorizedRedirect: options.unauthorizedRedirect,
93
- })
94
- return instance
95
- }
96
-
97
- // 默认实例:用于主应用,baseURL = /api
98
- const request = createRequest()
99
- const authRequest = createRequest()
100
-
101
- export {authRequest}
102
- export default request