neo-cmp-cli 1.12.7 → 1.12.9
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 +204 -6
- package/dist/index2.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/{neo-bi-cmps → asset-manage-template}/README.md +65 -10
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/{neo-bi-cmps → asset-manage-template}/package.json +28 -16
- package/template/asset-manage-template/src/assets/img/chart.svg +1 -0
- package/template/asset-manage-template/src/components/README.md +3 -0
- package/template/asset-manage-template/src/components/assetManage__c/assetApi.ts +70 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetCreateModal.tsx +260 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetGrid.tsx +48 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetSidebar.tsx +74 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetToolbar.tsx +79 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/assetDisplay.tsx +72 -0
- package/template/asset-manage-template/src/components/assetManage__c/constants.ts +28 -0
- package/template/asset-manage-template/src/components/assetManage__c/index.tsx +258 -0
- package/template/asset-manage-template/src/components/assetManage__c/model.ts +75 -0
- package/template/asset-manage-template/src/components/assetManage__c/style.scss +425 -0
- package/template/asset-manage-template/src/components/assetManage__c/types.ts +60 -0
- package/template/asset-manage-template/src/components/bidList__c/cmps/BidCard.tsx +47 -0
- package/template/asset-manage-template/src/components/bidList__c/constants.ts +6 -0
- package/template/asset-manage-template/src/components/bidList__c/formatUtils.ts +14 -0
- package/template/asset-manage-template/src/components/bidList__c/index.tsx +194 -0
- package/template/asset-manage-template/src/components/bidList__c/model.ts +57 -0
- package/template/asset-manage-template/src/components/bidList__c/style.scss +179 -0
- package/template/asset-manage-template/src/components/bidList__c/types.ts +10 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/BidPackageHeader.tsx +140 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/PackageItemTable.tsx +148 -0
- package/template/asset-manage-template/src/components/bidPackage__c/index.tsx +394 -0
- package/template/asset-manage-template/src/components/bidPackage__c/mainTableColumns.tsx +57 -0
- package/template/asset-manage-template/src/components/bidPackage__c/model.ts +86 -0
- package/template/asset-manage-template/src/components/bidPackage__c/style.scss +256 -0
- package/template/asset-manage-template/src/components/bidPackage__c/types.ts +35 -0
- package/template/asset-manage-template/src/components/bidPackage__c/utils.ts +19 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/axiosFetcher.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/queryObjectData.ts +0 -0
- package/template/asset-manage-template/src/utils/url.ts +82 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/xobjects.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/tsconfig.json +1 -1
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-h5-cmps/neo.config.js +34 -76
- package/template/neo-h5-cmps/package.json +7 -3
- package/template/neo-h5-cmps/src/components/entityList__c/index.tsx +0 -4
- package/template/neo-h5-cmps/src/components/entityList__c/model.ts +10 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/index.tsx +29 -17
- package/template/neo-h5-cmps/src/components/entityTabs__c/model.ts +25 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/style.scss +11 -22
- package/template/neo-h5-cmps/src/components/openChatPageBtn__c/index.tsx +3 -1
- package/template/neo-h5-cmps/src/utils/xobjects.ts +8 -3
- package/template/neo-h5-cmps/tsconfig.json +1 -1
- package/template/neo-order-cmps/package.json +2 -2
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/develop/BI /351/241/271/347/233/256/345/210/206/346/236/220/346/212/245/345/221/212.md" +0 -562
- package/template/develop/ChatPage /347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216/346/226/207/346/241/243.md" +0 -507
- package/template/develop/EntityGrid Web /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -868
- package/template/develop/EntityList H5 /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -1386
- package/template/develop/GlobalSearch/347/273/204/344/273/266/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -866
- package/template/develop/Neo /344/270/255/345/217/257/347/224/250 amis /347/273/204/344/273/266.md" +0 -1490
- package/template/develop/cmpEventFunctions.ts +0 -257
- package/template/develop/cmpEvents.ts +0 -864
- package/template/develop/comTree/347/224/237/346/210/220/350/277/207/347/250/213/345/210/206/346/236/220.md +0 -469
- package/template/develop/commonModules.js +0 -55
- package/template/develop/components-table.md +0 -50
- package/template/develop/neo-custom-cmp-template/README.md +0 -48
- package/template/develop/neo-custom-cmp-template/docs/README.md +0 -13
- package/template/develop/neo-custom-cmp-template/neo.config.js +0 -121
- package/template/develop/neo-custom-cmp-template/package.json +0 -63
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/README.md +0 -65
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/index.tsx +0 -180
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/model.ts +0 -50
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/style.scss +0 -260
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/README.md +0 -94
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/index.tsx +0 -252
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/model.ts +0 -56
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/style.scss +0 -120
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/README.md +0 -115
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/index.tsx +0 -304
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/model.ts +0 -87
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/style.scss +0 -127
- package/template/develop/neo-custom-cmp-template/src/utils/axiosFetcher.ts +0 -29
- package/template/develop/neo-custom-cmp-template/src/utils/queryObjectData.ts +0 -39
- package/template/develop/neo-custom-cmp-template/src/utils/xobjects.ts +0 -203
- package/template/develop/neo-custom-cmp-template/tsconfig.json +0 -68
- package/template/develop/neo-ui-component-h5.md +0 -105
- package/template/develop/neo-ui-component-web-xregister.md +0 -31
- package/template/develop/neo-ui-component-web.md +0 -292
- package/template/develop/neoCmps.ts +0 -7508
- package/template/develop/neoGlobalSearchInput /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -497
- package/template/develop/pageSchema1.json +0 -744
- package/template/develop//344/272/213/344/273/266/345/212/250/344/275/234/344/277/235/345/255/230/346/265/201/347/250/213/345/210/206/346/236/220.md +0 -390
- package/template/develop//345/215/225/345/205/203/346/265/213/350/257/225/344/275/277/347/224/250/350/257/264/346/230/216.md +0 -1139
- package/template/neo-bi-cmps/.prettierrc.js +0 -12
- package/template/neo-bi-cmps/commitlint.config.js +0 -59
- package/template/neo-bi-cmps/neo.config.js +0 -124
- package/template/neo-bi-cmps/public/css/base.css +0 -283
- package/template/neo-bi-cmps/public/scripts/app/bluebird.js +0 -6679
- package/template/neo-bi-cmps/public/template.html +0 -13
- package/template/neo-bi-cmps/src/assets/css/common.scss +0 -127
- package/template/neo-bi-cmps/src/assets/css/mixin.scss +0 -47
- package/template/neo-bi-cmps/src/assets/img/NeoCRM.jpg +0 -0
- package/template/neo-bi-cmps/src/assets/img/custom-widget.svg +0 -1
- package/template/neo-bi-cmps/src/assets/img/favicon.png +0 -0
- package/template/neo-bi-cmps/src/assets/img/table.svg +0 -1
- package/template/neo-bi-cmps/src/components/targetNumber__c/README.md +0 -100
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts +0 -253
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.scss +0 -76
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.tsx +0 -148
- package/template/neo-bi-cmps/src/components/targetNumber__c/index.tsx +0 -440
- package/template/neo-bi-cmps/src/components/targetNumber__c/model.ts +0 -128
- package/template/neo-bi-cmps/src/components/targetNumber__c/style.scss +0 -173
- package/template/neo-h5-cmps/src/components/simpleTable__c/README.md +0 -90
- package/template/neo-h5-cmps/src/components/simpleTable__c/index.tsx +0 -277
- package/template/neo-h5-cmps/src/components/simpleTable__c/model.ts +0 -91
- package/template/neo-h5-cmps/src/components/simpleTable__c/style.scss +0 -116
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/@types/neo-ui-common.d.ts +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/commitlint.config.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/css/base.css +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/scripts/app/bluebird.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/template.html +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/common.scss +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/AIBtn.gif +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/aiLogo.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/card-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/contact-form.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/custom-form.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/data-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/detail.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/map.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/search.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/table.svg +0 -0
|
@@ -1,562 +0,0 @@
|
|
|
1
|
-
# BI 项目库缺陷分析报告
|
|
2
|
-
|
|
3
|
-
## 一、项目概述
|
|
4
|
-
|
|
5
|
-
**项目名称**: neo-ui-component-bi
|
|
6
|
-
**版本**: 1.0.0-develop.16
|
|
7
|
-
**描述**: 新版本 BI 绘制核心库,包含 web、h5 公用绘制核心,各种数据处理类、工具类
|
|
8
|
-
|
|
9
|
-
**技术栈**:
|
|
10
|
-
- React 16.13.1
|
|
11
|
-
- TypeScript
|
|
12
|
-
- ECharts 5.4.2
|
|
13
|
-
- Handsontable 6.2.2
|
|
14
|
-
- Webpack
|
|
15
|
-
- 微前端架构 (Module Federation)
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 二、严重缺陷
|
|
20
|
-
|
|
21
|
-
### 2.1 React 生命周期方法使用过时 API
|
|
22
|
-
|
|
23
|
-
**问题描述**: 项目中大量使用了已废弃的 `UNSAFE_componentWillReceiveProps` 生命周期方法。
|
|
24
|
-
|
|
25
|
-
**影响范围**:
|
|
26
|
-
- `src/components/renderView/renderCore/kpiView/index.tsx` (第229行)
|
|
27
|
-
- `src/components/renderView/renderCore/echartsView/pcEchartsView/index.tsx` (第171行)
|
|
28
|
-
- `src/components/renderView/renderCore/echartsView/mobileEchartsView/index.tsx` (第216行)
|
|
29
|
-
- `src/components/renderView/renderCore/biMapView/pcMapView/index.tsx` (第190行)
|
|
30
|
-
- `src/components/renderView/renderCore/biMapView/mobileMapView/index.tsx` (第198行)
|
|
31
|
-
|
|
32
|
-
**风险**:
|
|
33
|
-
- React 18+ 版本中这些方法可能被完全移除
|
|
34
|
-
- 可能导致组件更新逻辑失效
|
|
35
|
-
- 不符合 React 最佳实践
|
|
36
|
-
|
|
37
|
-
**建议**:
|
|
38
|
-
- 使用 `componentDidUpdate` 或 `useEffect` 替代
|
|
39
|
-
- 对于函数组件,使用 `useEffect` 配合依赖数组
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
### 2.2 类型安全问题 - 过度使用 `any` 类型
|
|
44
|
-
|
|
45
|
-
**问题描述**: 项目中存在大量 `any` 类型使用,严重削弱了 TypeScript 的类型安全优势。
|
|
46
|
-
|
|
47
|
-
**统计数据**:
|
|
48
|
-
- 在 `src/components/renderView` 目录下发现 **967 处** `any` 类型使用
|
|
49
|
-
- 涉及 **115 个文件**
|
|
50
|
-
|
|
51
|
-
**典型问题**:
|
|
52
|
-
```typescript
|
|
53
|
-
// 示例:propsInterface 中大量使用 any
|
|
54
|
-
interface propsInterface {
|
|
55
|
-
viewInfo: ViewInfoTypes,
|
|
56
|
-
viewData: any, // ❌ 应该定义具体类型
|
|
57
|
-
viewClickEventHandel?: Array<Function>, // ❌ Function 类型过于宽泛
|
|
58
|
-
viewConfig: any, // ❌ 应该定义 ViewConfig 接口
|
|
59
|
-
[key: string]: any // ❌ 索引签名过于宽松
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**影响**:
|
|
64
|
-
- 失去编译时类型检查
|
|
65
|
-
- IDE 智能提示失效
|
|
66
|
-
- 运行时错误风险增加
|
|
67
|
-
- 代码可维护性降低
|
|
68
|
-
|
|
69
|
-
**建议**:
|
|
70
|
-
- 为所有数据结构定义明确的接口类型
|
|
71
|
-
- 使用泛型替代 `any`
|
|
72
|
-
- 启用 TypeScript 严格模式检查
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
### 2.3 性能问题 - 使用 JSON.stringify 进行深度比较
|
|
77
|
-
|
|
78
|
-
**问题描述**: 在 `shouldComponentUpdate` 中使用 `JSON.stringify` 进行对象比较,性能开销巨大。
|
|
79
|
-
|
|
80
|
-
**问题位置**:
|
|
81
|
-
- `src/components/renderView/renderCore/echartsView/pcEchartsView/index.tsx` (第185-191行)
|
|
82
|
-
- `src/components/renderView/renderCore/echartsView/mobileEchartsView/index.tsx`
|
|
83
|
-
- `src/components/renderView/renderCore/echartsView/component/echartsViewMain/index.tsx` (第47行)
|
|
84
|
-
- 其他多处位置
|
|
85
|
-
|
|
86
|
-
**代码示例**:
|
|
87
|
-
```typescript
|
|
88
|
-
shouldComponentUpdate(newProps: propsInterface, newState: stateInterface) {
|
|
89
|
-
if (JSON.stringify(newProps.viewData) !== JSON.stringify(this.props.viewData)) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
if (JSON.stringify(newProps.viewInfo) !== JSON.stringify(this.props.viewInfo)) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**问题**:
|
|
100
|
-
- `JSON.stringify` 性能开销大,特别是对于大型对象
|
|
101
|
-
- 对象属性顺序不同会导致误判
|
|
102
|
-
- 无法处理循环引用
|
|
103
|
-
- 每次渲染都会执行序列化操作
|
|
104
|
-
|
|
105
|
-
**建议**:
|
|
106
|
-
- 使用浅比较库(如 `shallowequal`)
|
|
107
|
-
- 使用 React.memo 配合自定义比较函数
|
|
108
|
-
- 使用 `useMemo` 缓存计算结果
|
|
109
|
-
- 考虑使用 `useMemo` 和 `useCallback` 优化
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
### 2.4 内存泄漏风险 - 事件监听器未正确清理
|
|
114
|
-
|
|
115
|
-
**问题描述**: 部分组件在绑定事件监听器后未在组件卸载时清理。
|
|
116
|
-
|
|
117
|
-
**问题位置**:
|
|
118
|
-
- `src/components/renderView/renderCore/echartsView/component/echartsViewMain/index.tsx`
|
|
119
|
-
- `src/components/renderView/renderCore/biMapView/pcMapView/index.tsx`
|
|
120
|
-
|
|
121
|
-
**代码示例**:
|
|
122
|
-
```typescript
|
|
123
|
-
bindCanvasEvent(echartsInstance: any) {
|
|
124
|
-
if (echartsInstance === undefined) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const canvas = echartsInstance.getZr();
|
|
128
|
-
canvas.on('click', this.onEmptyClick.bind(this));
|
|
129
|
-
canvas.on('mousemove', this.onEmptyMouseMove.bind(this));
|
|
130
|
-
// ❌ 缺少 componentWillUnmount 中的清理逻辑
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**影响**:
|
|
135
|
-
- 内存泄漏
|
|
136
|
-
- 事件监听器重复绑定
|
|
137
|
-
- 性能下降
|
|
138
|
-
|
|
139
|
-
**建议**:
|
|
140
|
-
- 在 `componentWillUnmount` 中移除所有事件监听器
|
|
141
|
-
- 使用 `useEffect` 的清理函数(函数组件)
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
### 2.5 错误处理不完善
|
|
146
|
-
|
|
147
|
-
**问题描述**: 错误处理机制不完善,大量错误被静默忽略。
|
|
148
|
-
|
|
149
|
-
**问题位置**:
|
|
150
|
-
- `src/components/services/baseService.ts` (第6-19行)
|
|
151
|
-
|
|
152
|
-
**代码示例**:
|
|
153
|
-
```typescript
|
|
154
|
-
const errorMessage = (err: any) => {
|
|
155
|
-
// message.destroy();
|
|
156
|
-
// if (err && err.response) {
|
|
157
|
-
// message.error("接口异常", 1)
|
|
158
|
-
// }
|
|
159
|
-
}
|
|
160
|
-
const successWarningMessage = (response: any) => {
|
|
161
|
-
// message.destroy();
|
|
162
|
-
// if (response) {
|
|
163
|
-
// msag(response.status)
|
|
164
|
-
// } else {
|
|
165
|
-
// message.error("接口异常", 1)
|
|
166
|
-
// }
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
**问题**:
|
|
171
|
-
- 错误处理逻辑被注释掉
|
|
172
|
-
- 用户无法感知错误
|
|
173
|
-
- 调试困难
|
|
174
|
-
- 没有错误边界(Error Boundary)
|
|
175
|
-
|
|
176
|
-
**建议**:
|
|
177
|
-
- 实现全局错误边界组件
|
|
178
|
-
- 恢复并完善错误处理逻辑
|
|
179
|
-
- 添加错误日志记录
|
|
180
|
-
- 提供用户友好的错误提示
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## 三、代码质量问题
|
|
185
|
-
|
|
186
|
-
### 3.1 代码重复
|
|
187
|
-
|
|
188
|
-
**问题描述**: 存在大量重复代码,特别是 PC 端和移动端的实现。
|
|
189
|
-
|
|
190
|
-
**典型示例**:
|
|
191
|
-
- `pcEchartsView` 和 `mobileEchartsView` 存在大量相似逻辑
|
|
192
|
-
- `pcMapView` 和 `mobileMapView` 代码高度重复
|
|
193
|
-
- 多个视图类型的 adapter 实现模式相同但代码重复
|
|
194
|
-
|
|
195
|
-
**影响**:
|
|
196
|
-
- 维护成本高
|
|
197
|
-
- Bug 修复需要多处修改
|
|
198
|
-
- 代码体积增大
|
|
199
|
-
|
|
200
|
-
**建议**:
|
|
201
|
-
- 提取公共逻辑到共享组件或工具函数
|
|
202
|
-
- 使用配置驱动的方式减少重复
|
|
203
|
-
- 考虑使用 HOC 或 Render Props 模式
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
### 3.2 组件设计问题
|
|
208
|
-
|
|
209
|
-
**问题描述**:
|
|
210
|
-
1. 类组件和函数组件混用,风格不统一
|
|
211
|
-
2. 组件职责不清晰,单个组件过于庞大
|
|
212
|
-
|
|
213
|
-
**示例**:
|
|
214
|
-
- `src/components/renderView/renderCore/hotTableView/components/tableViewMain/index.tsx` 超过 **1160 行**
|
|
215
|
-
- `src/components/renderView/renderCore/kpiView/index.tsx` 超过 **382 行**
|
|
216
|
-
|
|
217
|
-
**问题**:
|
|
218
|
-
- 代码可读性差
|
|
219
|
-
- 难以测试
|
|
220
|
-
- 难以维护
|
|
221
|
-
|
|
222
|
-
**建议**:
|
|
223
|
-
- 拆分大组件为多个小组件
|
|
224
|
-
- 统一使用函数组件 + Hooks
|
|
225
|
-
- 遵循单一职责原则
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
### 3.3 注释代码和调试代码
|
|
230
|
-
|
|
231
|
-
**问题描述**: 存在大量注释掉的代码和调试代码。
|
|
232
|
-
|
|
233
|
-
**问题位置**:
|
|
234
|
-
- `src/components/services/baseService.ts` (第4-67行大量注释代码)
|
|
235
|
-
- `public/index.html` (第80-81行 console.log)
|
|
236
|
-
- `webpack.development.js` (第8-14行注释的环境配置)
|
|
237
|
-
|
|
238
|
-
**影响**:
|
|
239
|
-
- 代码混乱
|
|
240
|
-
- 增加理解成本
|
|
241
|
-
- 可能包含敏感信息
|
|
242
|
-
|
|
243
|
-
**建议**:
|
|
244
|
-
- 删除无用的注释代码
|
|
245
|
-
- 使用环境变量管理配置
|
|
246
|
-
- 使用专业的日志库替代 console.log
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
### 3.4 命名不规范
|
|
251
|
-
|
|
252
|
-
**问题描述**: 存在命名不一致的问题。
|
|
253
|
-
|
|
254
|
-
**示例**:
|
|
255
|
-
- `viewClickEventHandel` (拼写错误,应为 `handle`)
|
|
256
|
-
- `renderFinished` vs `renderFinishedCallback`
|
|
257
|
-
- `echartsOption` vs `echartsOptions`
|
|
258
|
-
|
|
259
|
-
**建议**:
|
|
260
|
-
- 统一命名规范
|
|
261
|
-
- 使用 ESLint 规则强制规范
|
|
262
|
-
- 修复拼写错误
|
|
263
|
-
|
|
264
|
-
---
|
|
265
|
-
|
|
266
|
-
## 四、依赖管理问题
|
|
267
|
-
|
|
268
|
-
### 4.1 依赖版本过旧
|
|
269
|
-
|
|
270
|
-
**问题描述**: 多个核心依赖版本过旧,存在安全风险和功能限制。
|
|
271
|
-
|
|
272
|
-
**问题依赖**:
|
|
273
|
-
- `react`: ^16.13.1 (当前最新为 18.x)
|
|
274
|
-
- `react-dom`: ^16.13.1
|
|
275
|
-
- `axios`: ^0.21.1 (存在已知安全漏洞)
|
|
276
|
-
- `@types/node`: ^12.0.0 (过旧)
|
|
277
|
-
- `moment`: ^2.29.1 (已停止维护,建议迁移到 date-fns 或 dayjs)
|
|
278
|
-
|
|
279
|
-
**风险**:
|
|
280
|
-
- 安全漏洞
|
|
281
|
-
- 缺少新特性
|
|
282
|
-
- 性能问题
|
|
283
|
-
- 兼容性问题
|
|
284
|
-
|
|
285
|
-
**建议**:
|
|
286
|
-
- 制定依赖升级计划
|
|
287
|
-
- 优先修复安全漏洞(axios)
|
|
288
|
-
- 考虑迁移 moment 到现代替代方案
|
|
289
|
-
- 逐步升级 React 到 18.x
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
### 4.2 依赖版本冲突
|
|
294
|
-
|
|
295
|
-
**问题描述**: `resolutions` 字段显示存在版本冲突。
|
|
296
|
-
|
|
297
|
-
```json
|
|
298
|
-
"resolutions": {
|
|
299
|
-
"react-error-overlay": "6.0.9",
|
|
300
|
-
"@types/react": "17.0.30"
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
**问题**:
|
|
305
|
-
- React 16 但 @types/react 17
|
|
306
|
-
- 可能导致类型定义不匹配
|
|
307
|
-
|
|
308
|
-
**建议**:
|
|
309
|
-
- 统一依赖版本
|
|
310
|
-
- 移除不必要的 resolutions
|
|
311
|
-
- 使用 yarn/npm 的依赖解析机制
|
|
312
|
-
|
|
313
|
-
---
|
|
314
|
-
|
|
315
|
-
### 4.3 浏览器兼容性配置不合理
|
|
316
|
-
|
|
317
|
-
**问题描述**: browserslist 配置要求支持 IE9,但现代库可能不支持。
|
|
318
|
-
|
|
319
|
-
```json
|
|
320
|
-
"browserslist": {
|
|
321
|
-
"production": [
|
|
322
|
-
">0.2%",
|
|
323
|
-
"not dead",
|
|
324
|
-
"not op_mini all",
|
|
325
|
-
"ie >= 9" // ❌ IE9 已停止支持
|
|
326
|
-
]
|
|
327
|
-
}
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
**建议**:
|
|
331
|
-
- 移除 IE 支持(IE 已停止维护)
|
|
332
|
-
- 更新 browserslist 配置为现代浏览器
|
|
333
|
-
|
|
334
|
-
---
|
|
335
|
-
|
|
336
|
-
## 五、测试和文档问题
|
|
337
|
-
|
|
338
|
-
### 5.1 缺少单元测试
|
|
339
|
-
|
|
340
|
-
**问题描述**: 项目中未发现任何测试文件(.test.ts, .spec.ts)。
|
|
341
|
-
|
|
342
|
-
**影响**:
|
|
343
|
-
- 无法保证代码质量
|
|
344
|
-
- 重构风险高
|
|
345
|
-
- Bug 发现滞后
|
|
346
|
-
|
|
347
|
-
**建议**:
|
|
348
|
-
- 添加单元测试(Jest + React Testing Library)
|
|
349
|
-
- 添加集成测试
|
|
350
|
-
- 设置测试覆盖率目标(至少 60%)
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
|
-
### 5.2 文档不完善
|
|
355
|
-
|
|
356
|
-
**问题描述**:
|
|
357
|
-
- README.md 仅包含简单的打包指令
|
|
358
|
-
- 缺少 API 文档
|
|
359
|
-
- 缺少开发指南
|
|
360
|
-
- 缺少架构说明
|
|
361
|
-
|
|
362
|
-
**建议**:
|
|
363
|
-
- 完善 README.md
|
|
364
|
-
- 添加 API 文档(使用 TypeDoc)
|
|
365
|
-
- 添加开发指南
|
|
366
|
-
- 添加架构设计文档
|
|
367
|
-
|
|
368
|
-
---
|
|
369
|
-
|
|
370
|
-
## 六、性能问题
|
|
371
|
-
|
|
372
|
-
### 6.1 不必要的重新渲染
|
|
373
|
-
|
|
374
|
-
**问题描述**:
|
|
375
|
-
1. `shouldComponentUpdate` 实现不当
|
|
376
|
-
2. 缺少 React.memo 优化
|
|
377
|
-
3. 内联函数和对象导致子组件频繁更新
|
|
378
|
-
|
|
379
|
-
**示例**:
|
|
380
|
-
```typescript
|
|
381
|
-
// ❌ 每次渲染都创建新对象
|
|
382
|
-
<EchartsViewMain
|
|
383
|
-
onViewClick={this.onViewClick.bind(this)} // 每次创建新函数
|
|
384
|
-
renderFinished={this.renderFinished.bind(this)}
|
|
385
|
-
/>
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
**建议**:
|
|
389
|
-
- 使用 `useCallback` 缓存函数
|
|
390
|
-
- 使用 `useMemo` 缓存对象
|
|
391
|
-
- 使用 React.memo 优化子组件
|
|
392
|
-
|
|
393
|
-
---
|
|
394
|
-
|
|
395
|
-
### 6.2 大型组件懒加载不当
|
|
396
|
-
|
|
397
|
-
**问题描述**: 虽然使用了 `React.lazy`,但 fallback 为空组件。
|
|
398
|
-
|
|
399
|
-
```typescript
|
|
400
|
-
const ReactEcharts = React.lazy(() => import('echarts-for-react'))
|
|
401
|
-
return (
|
|
402
|
-
<React.Suspense fallback={<></>}> // ❌ 空 fallback 体验差
|
|
403
|
-
<ReactEcharts ... />
|
|
404
|
-
</React.Suspense>
|
|
405
|
-
)
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
**建议**:
|
|
409
|
-
- 提供有意义的 loading 组件
|
|
410
|
-
- 考虑使用骨架屏
|
|
411
|
-
|
|
412
|
-
---
|
|
413
|
-
|
|
414
|
-
### 6.3 数据深拷贝性能问题
|
|
415
|
-
|
|
416
|
-
**问题描述**: 频繁使用 `cloneDeep` 进行深拷贝。
|
|
417
|
-
|
|
418
|
-
**问题位置**:
|
|
419
|
-
- `src/components/renderView/renderCore/echartsView/pcEchartsView/index.tsx` (第44-47行)
|
|
420
|
-
|
|
421
|
-
**影响**:
|
|
422
|
-
- 性能开销大
|
|
423
|
-
- 内存占用高
|
|
424
|
-
|
|
425
|
-
**建议**:
|
|
426
|
-
- 评估是否真的需要深拷贝
|
|
427
|
-
- 使用不可变数据结构(Immutable.js)
|
|
428
|
-
- 使用浅拷贝 + 按需深拷贝
|
|
429
|
-
|
|
430
|
-
---
|
|
431
|
-
|
|
432
|
-
## 七、安全性问题
|
|
433
|
-
|
|
434
|
-
### 7.1 XSS 风险
|
|
435
|
-
|
|
436
|
-
**问题描述**: 使用 `ReactDOMServer.renderToString` 渲染用户内容。
|
|
437
|
-
|
|
438
|
-
**问题位置**:
|
|
439
|
-
- `src/components/renderView/renderCore/echartsView/pcEchartsView/index.tsx` (第95行)
|
|
440
|
-
|
|
441
|
-
**代码示例**:
|
|
442
|
-
```typescript
|
|
443
|
-
renderToolTip(echartsOption: BiViewOptionTypes, viewInfo: ViewInfoTypes, params: any) {
|
|
444
|
-
// ...
|
|
445
|
-
return (
|
|
446
|
-
ReactDOMServer.renderToString(
|
|
447
|
-
<PcTooltip
|
|
448
|
-
color={params.color}
|
|
449
|
-
tipDataList={valueList} // 用户数据可能包含恶意脚本
|
|
450
|
-
renderCustomTip={...}
|
|
451
|
-
/>
|
|
452
|
-
)
|
|
453
|
-
)
|
|
454
|
-
}
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
**建议**:
|
|
458
|
-
- 对用户输入进行转义
|
|
459
|
-
- 使用 DOMPurify 清理 HTML
|
|
460
|
-
- 验证和过滤用户数据
|
|
461
|
-
|
|
462
|
-
---
|
|
463
|
-
|
|
464
|
-
### 7.2 敏感信息泄露
|
|
465
|
-
|
|
466
|
-
**问题描述**: webpack 配置文件中包含硬编码的环境地址。
|
|
467
|
-
|
|
468
|
-
**问题位置**:
|
|
469
|
-
- `webpack.development.js` (第7-14行)
|
|
470
|
-
|
|
471
|
-
**建议**:
|
|
472
|
-
- 使用环境变量
|
|
473
|
-
- 不要将敏感信息提交到代码库
|
|
474
|
-
- 使用 .env 文件管理配置
|
|
475
|
-
|
|
476
|
-
---
|
|
477
|
-
|
|
478
|
-
## 八、架构问题
|
|
479
|
-
|
|
480
|
-
### 8.1 状态管理混乱
|
|
481
|
-
|
|
482
|
-
**问题描述**:
|
|
483
|
-
- 使用类组件的 state 管理
|
|
484
|
-
- 缺少统一的状态管理方案
|
|
485
|
-
- 状态提升不清晰
|
|
486
|
-
|
|
487
|
-
**建议**:
|
|
488
|
-
- 考虑引入状态管理库(Redux、Zustand、Jotai)
|
|
489
|
-
- 明确状态提升规则
|
|
490
|
-
- 使用 Context API 管理全局状态
|
|
491
|
-
|
|
492
|
-
---
|
|
493
|
-
|
|
494
|
-
### 8.2 配置硬编码
|
|
495
|
-
|
|
496
|
-
**问题描述**: 大量配置硬编码在代码中。
|
|
497
|
-
|
|
498
|
-
**示例**:
|
|
499
|
-
- `biViewConfigMap` 中的视图配置
|
|
500
|
-
- 样式配置硬编码
|
|
501
|
-
|
|
502
|
-
**建议**:
|
|
503
|
-
- 使用配置文件
|
|
504
|
-
- 支持动态配置
|
|
505
|
-
- 考虑配置中心
|
|
506
|
-
|
|
507
|
-
---
|
|
508
|
-
|
|
509
|
-
## 九、改进建议优先级
|
|
510
|
-
|
|
511
|
-
### 🔴 高优先级(立即修复)
|
|
512
|
-
|
|
513
|
-
1. **修复 UNSAFE_componentWillReceiveProps** - React 兼容性问题
|
|
514
|
-
2. **升级 axios** - 安全漏洞
|
|
515
|
-
3. **添加错误处理** - 用户体验和调试
|
|
516
|
-
4. **修复内存泄漏** - 性能和稳定性
|
|
517
|
-
|
|
518
|
-
### 🟡 中优先级(近期修复)
|
|
519
|
-
|
|
520
|
-
1. **减少 any 类型使用** - 类型安全
|
|
521
|
-
2. **优化性能比较逻辑** - 性能优化
|
|
522
|
-
3. **添加单元测试** - 代码质量保障
|
|
523
|
-
4. **修复代码重复** - 可维护性
|
|
524
|
-
|
|
525
|
-
### 🟢 低优先级(长期优化)
|
|
526
|
-
|
|
527
|
-
1. **升级 React 到 18** - 现代化
|
|
528
|
-
2. **迁移 moment 到 dayjs** - 减少包体积
|
|
529
|
-
3. **完善文档** - 开发体验
|
|
530
|
-
4. **统一组件风格** - 代码一致性
|
|
531
|
-
|
|
532
|
-
---
|
|
533
|
-
|
|
534
|
-
## 十、总结
|
|
535
|
-
|
|
536
|
-
### 主要问题统计
|
|
537
|
-
|
|
538
|
-
- **严重缺陷**: 5 项
|
|
539
|
-
- **代码质量问题**: 4 项
|
|
540
|
-
- **依赖管理问题**: 3 项
|
|
541
|
-
- **测试和文档问题**: 2 项
|
|
542
|
-
- **性能问题**: 3 项
|
|
543
|
-
- **安全问题**: 2 项
|
|
544
|
-
- **架构问题**: 2 项
|
|
545
|
-
|
|
546
|
-
### 总体评价
|
|
547
|
-
|
|
548
|
-
该项目是一个功能完整的 BI 可视化组件库,但在代码质量、类型安全、性能优化和现代化方面存在较大改进空间。建议按照优先级逐步改进,重点关注 React 兼容性、类型安全和性能优化。
|
|
549
|
-
|
|
550
|
-
### 关键指标
|
|
551
|
-
|
|
552
|
-
- **类型安全**: ⚠️ 低(大量 any 使用)
|
|
553
|
-
- **代码质量**: ⚠️ 中(存在重复和过时代码)
|
|
554
|
-
- **性能**: ⚠️ 中(存在性能瓶颈)
|
|
555
|
-
- **可维护性**: ⚠️ 中(缺少测试和文档)
|
|
556
|
-
- **安全性**: ⚠️ 低(存在安全风险)
|
|
557
|
-
|
|
558
|
-
---
|
|
559
|
-
|
|
560
|
-
**报告生成时间**: 2024年
|
|
561
|
-
**分析工具**: 代码审查、静态分析
|
|
562
|
-
**建议审查周期**: 每季度一次
|