Skip to content

Commit 886a64c

Browse files
author
chj_damon
committed
refactor: 按umi最新结构精简依赖包
精简并升级所有依赖到最新版本 暂时关闭dynamicImport,否则会引起页面渲染两次的问题 删除一些无用文件
1 parent c15b524 commit 886a64c

29 files changed

+857
-7066
lines changed

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

config/config.prod.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { defineConfig } from 'umi';
22
import AntdDayjsWebpackPlugin from 'antd-dayjs-webpack-plugin';
3-
import SentryWebpackPlugin from '@sentry/webpack-plugin';
43
import routeConfig from './routeConfig';
54

65
export default defineConfig({
76
dynamicImport: {
87
loading: '@/components/LoadingPage/index',
98
},
9+
dynamicImportSyntax: {},
1010
hash: true,
1111
outputPath: 'build',
1212
routes: routeConfig,
@@ -53,16 +53,6 @@ export default defineConfig({
5353
chunks: ['vendors', 'umi'],
5454
chainWebpack(config) {
5555
config.plugin('dayjs').use(AntdDayjsWebpackPlugin);
56-
config.plugin('sentry').use(
57-
new SentryWebpackPlugin({
58-
url: 'http://60.12.241.84:29177/',
59-
authToken: '2e322b834f5945989d35cd4065c9c2d651b25f5d9ae84911b125487f6575a36e',
60-
org: 'leishu',
61-
project: 'spa-template',
62-
include: '.',
63-
ignore: ['node_modules'],
64-
}),
65-
);
6656
config.merge({
6757
optimization: {
6858
splitChunks: {

config/config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import AntdDayjsWebpackPlugin from 'antd-dayjs-webpack-plugin';
33
import routeConfig from './routeConfig';
44

55
export default defineConfig({
6-
dynamicImport: {
7-
loading: '@/components/LoadingPage/index',
8-
},
6+
dynamicImportSyntax: {},
97
hash: true,
108
outputPath: 'build',
119
routes: routeConfig,

config/routeConfig.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,8 @@ export default [
2727
component: './hotel',
2828
routes: [
2929
{ path: '/hotel/hotelInfo', component: './hotel/HotelInfo', title: '酒店基本信息' },
30-
{
31-
path: '/hotel/hotelOtherInfo',
32-
component: './hotel/HotelOtherInfo',
33-
title: '酒店其他信息',
34-
},
3530
],
3631
},
37-
{
38-
path: '/order',
39-
component: './order',
40-
routes: [{ path: '/order/order', component: './order/Order', title: '订单' }],
41-
},
42-
{ path: '/swr/user', component: './swr/user', title: '用户' },
4332
],
4433
},
4534
{ path: '*', component: './404' },

global.d.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

mock/route.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@ export default {
1717
apiUrl: '/hotel/hotelInfo',
1818
description: '酒店基本信息',
1919
},
20-
{
21-
name: 'hotelOtherInfo',
22-
apiUrl: '/hotel/hotelOtherInfo',
23-
description: '酒店其他信息',
24-
},
2520
],
2621
},
27-
{
28-
name: 'hotelOrder',
29-
apiUrl: '/order/order',
30-
description: '酒店订单',
31-
},
3222
],
3323
code: 20000,
3424
message: '成功',

package.json

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"nc-u": "npx npm-check --registry=http://npm.taobao.org/ -u",
1717
"commit": "git-cz",
18-
"start": "cross-env UMI_UI=1 umi dev",
18+
"start": "cross-env umi dev",
1919
"analyze": "cross-env UMI_ENV=prod ANALYZE=1 umi build",
2020
"build": "cross-env UMI_ENV=prod MOCK=none umi build",
2121
"test": "jest --passWithNoTests --detectOpenHandles --watch",
@@ -46,70 +46,43 @@
4646
]
4747
},
4848
"dependencies": {
49-
"@ant-design/icons": "^4.3.0",
50-
"@ant-design/pro-form": "^1.15.1",
51-
"@ant-design/pro-layout": "^6.10.9",
52-
"@ant-design/pro-table": "^2.25.1",
53-
"@sentry/react": "^6.0.1",
54-
"@sentry/tracing": "^6.0.1",
55-
"ahooks": "^2.9.4",
56-
"antd": "^4.10.2",
49+
"@ant-design/pro-form": "^1.18.1",
50+
"@ant-design/pro-layout": "^6.5.0",
51+
"@umijs/preset-react": "1.x",
5752
"classnames": "^2.2.6",
58-
"dayjs": "^1.10.3",
59-
"immer": "^8.0.0",
60-
"lodash-es": "^4.17.20",
61-
"lscache": "^1.3.0",
62-
"normalize.css": "^8.0.1",
6353
"react": "^17.0.1",
6454
"react-dom": "^17.0.1",
65-
"swr": "^0.4.0",
66-
"umi": "^3.3.4",
67-
"use-immer": "^0.4.2"
55+
"umi": "^3.4.2"
6856
},
6957
"devDependencies": {
70-
"@babel/core": "^7.12.10",
71-
"@babel/preset-env": "^7.12.11",
72-
"@babel/preset-react": "^7.12.10",
73-
"@babel/preset-typescript": "^7.12.7",
74-
"@commitlint/cli": "^11.0.0",
75-
"@commitlint/config-conventional": "^11.0.0",
76-
"@sentry/webpack-plugin": "^1.14.0",
58+
"@commitlint/cli": "^12.0.1",
59+
"@commitlint/config-conventional": "^12.0.1",
7760
"@testing-library/jest-dom": "^5.11.9",
78-
"@testing-library/react": "^11.2.3",
79-
"@testing-library/react-hooks": "^5.0.0",
61+
"@testing-library/react": "^11.2.5",
62+
"@testing-library/react-hooks": "^5.1.0",
8063
"@types/classnames": "^2.2.11",
8164
"@types/jest": "^26.0.20",
82-
"@types/lodash-es": "^4.17.4",
83-
"@types/lscache": "^1.3.0",
84-
"@types/react": "^17.0.0",
85-
"@types/react-dom": "^17.0.0",
86-
"@umijs/fabric": "^2.4.11",
65+
"@types/react": "^17.0.3",
66+
"@types/react-dom": "^17.0.2",
8767
"@umijs/plugin-esbuild": "^1.1.0",
88-
"@umijs/preset-react": "^1.7.9",
89-
"@umijs/preset-ui": "^2.2.9",
90-
"antd-dayjs-webpack-plugin": "^1.0.4",
91-
"babel-eslint": "^10.1.0",
92-
"babel-jest": "^26.6.3",
93-
"commitizen": "^4.2.1",
68+
"antd-dayjs-webpack-plugin": "^1.0.6",
69+
"commitizen": "^4.2.3",
9470
"conventional-changelog-cli": "^2.1.0",
9571
"conventional-changelog-custom-config": "^0.3.1",
9672
"cross-env": "^7.0.3",
9773
"cz-customizable": "^6.3.0",
98-
"eslint-plugin-react": "^7.22.0",
99-
"husky": "^4.3.7",
74+
"husky": "^5.1.3",
10075
"jest": "^26.6.3",
10176
"jest-fetch-mock": "^3.0.3",
102-
"jest-localstorage-mock": "^2.4.6",
103-
"lint-staged": "^10.5.3",
77+
"jest-localstorage-mock": "^2.4.8",
78+
"lint-staged": "^10.5.4",
10479
"pont-engine": "^1.0.13",
10580
"prettier": "^2.2.1",
10681
"react-test-renderer": "^17.0.1",
107-
"regenerator-runtime": "^0.13.7",
108-
"standard-version": "^9.1.0",
109-
"stylelint": "^13.8.0",
110-
"ts-jest": "^26.4.4",
111-
"typescript": "^4.1.3",
112-
"umi-plugin-page-creator": "^1.6.1"
82+
"standard-version": "^9.1.1",
83+
"stylelint": "^13.12.0",
84+
"ts-jest": "^26.5.3",
85+
"typescript": "^4.2.3"
11386
},
11487
"engines": {
11588
"node": ">=8.0.0"

src/app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import request from 'umi-request';
1010
import type { MenuDataItem } from '@ant-design/pro-layout';
1111
import arrayUtils from '@/utils/array';
12-
import { isEmpty } from 'lodash-es';
1312
import { LOGIN_CONFIG } from './constant';
1413

1514
/** 初始化数据 */
@@ -55,7 +54,7 @@ export async function getInitialState() {
5554
*/
5655
function convertResourceToMenu(list: PrivilegeResource[]): MenuDataItem[] {
5756
return list.map((item) => {
58-
if (!isEmpty(item.children)) {
57+
if (item.children && item.children.length > 0) {
5958
return {
6059
name: item.description,
6160
key: `${item.apiUrl}`,

src/global.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
import 'normalize.css';
2-
import 'dayjs/locale/zh-cn';
31
import '@/api';
4-
5-
// 在这里引入sentry
6-
import * as Sentry from '@sentry/react';
7-
import { Integrations } from '@sentry/tracing';
8-
9-
Sentry.init({
10-
dsn: 'http://[email protected]:29177/3',
11-
autoSessionTracking: true,
12-
integrations: [new Integrations.BrowserTracing()],
13-
tracesSampleRate: 1.0,
14-
});

src/layouts/BasicLayout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function BasicLayout(props: IRouteComponentProps) {
4242
</Link>
4343
);
4444
}}
45-
subMenuItemRender={(menuItemProps, defaultDom) => {
45+
subMenuItemRender={(menuItemProps: any, defaultDom: any) => {
4646
return (
4747
<span>
4848
{menuItemProps.customIcon && (

0 commit comments

Comments
 (0)