Skip to content

Commit 4818629

Browse files
authored
Merge pull request #541 from GraceWalk/dev
前端代码打包优化 & bug 修复
2 parents 69cd1ff + d566725 commit 4818629

File tree

31 files changed

+86
-73
lines changed

31 files changed

+86
-73
lines changed

km-console/packages/config-manager-fe/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from 'react';
22
import { BrowserRouter as Router, Redirect, Switch } from 'react-router-dom';
33
import _ from 'lodash';
44
import './constants/axiosConfig';
5-
import dantdZhCN from 'knowdesign/lib/locale/zh_CN';
6-
import dantdEnUS from 'knowdesign/lib/locale/en_US';
5+
import dantdZhCN from 'knowdesign/es/locale/zh_CN';
6+
import dantdEnUS from 'knowdesign/es/locale/en_US';
77
import intlZhCN from './locales/zh';
88
import intlEnUS from './locales/en';
99
import { AppContainer, RouteGuard, DProLayout } from 'knowdesign';

km-console/packages/config-manager-fe/src/components/TagsWithHide/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DownOutlined } from '@ant-design/icons';
22
import { Popover } from 'knowdesign';
3-
import { TooltipPlacement } from 'knowdesign/lib/basic/tooltip';
3+
import { TooltipPlacement } from 'knowdesign/es/basic/tooltip';
44
import React, { useState, useRef, useEffect } from 'react';
55
import './index.less';
66

@@ -90,8 +90,9 @@ export default (props: PropsType) => {
9090
return (
9191
<div
9292
key={i}
93-
className={`container-item ${curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : ''
94-
}`}
93+
className={`container-item ${
94+
curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : ''
95+
}`}
9596
>
9697
{item}
9798
</div>

km-console/packages/config-manager-fe/src/pages/UserManage/RoleTabContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const RoleDetailAndUpdate = forwardRef((props, ref): JSX.Element => {
7777

7878
const onSubmit = () => {
7979
form.validateFields().then((formData) => {
80+
formData.permissionIdList = formData.permissionIdList.filter((l) => l);
8081
formData.permissionIdList.forEach((arr, i) => {
8182
// 如果分配的系统下的子权限,自动赋予该系统的权限
8283
if (arr !== null && arr.length) {
@@ -212,7 +213,7 @@ const RoleDetailAndUpdate = forwardRef((props, ref): JSX.Element => {
212213
rules={[
213214
() => ({
214215
validator(_, value) {
215-
if (Array.isArray(value) && value.some((item) => !!item.length)) {
216+
if (Array.isArray(value) && value.some((item) => !!item?.length)) {
216217
return Promise.resolve();
217218
}
218219
return Promise.reject(new Error('请为角色至少分配一项权限'));

km-console/packages/layout-clusters-fe/config/CoverHtmlWebpackPlugin.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ class CoverHtmlWebpackPlugin {
8686

8787
assetJson.reverse().forEach((item) => {
8888
if (/\.js$/.test(item)) {
89-
// if (item.includes('vendor~')) {
90-
// vendors += `<script async src="${item}"></script>`;
91-
// } else {
92-
// TODO: entry 只有一个
93-
portalMap['@portal/layout'] = item;
94-
// }
89+
if (item.includes('vendor~')) {
90+
vendors += `<script async src="${item}"></script>`;
91+
} else {
92+
// TODO: entry 只有一个
93+
portalMap['@portal/layout'] = item;
94+
}
9595
} else if (/\.css$/.test(item)) {
9696
links += `<link href="${item}" rel="stylesheet">`;
9797
}

km-console/packages/layout-clusters-fe/config/d1-webpack.base.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const TerserJSPlugin = require('terser-webpack-plugin');
99
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
1010
const theme = require('./theme');
1111
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
12-
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
1312

1413
const isProd = process.env.NODE_ENV === 'production';
1514
const babelOptions = {
@@ -43,7 +42,6 @@ const babelOptions = {
4342
module.exports = () => {
4443
const cssFileName = isProd ? '[name]-[chunkhash].css' : '[name].css';
4544
const plugins = [
46-
// !isProd && new HardSourceWebpackPlugin(),
4745
new CoverHtmlWebpackPlugin(),
4846
new ProgressBarPlugin(),
4947
new CaseSensitivePathsPlugin(),
@@ -150,23 +148,21 @@ module.exports = () => {
150148
],
151149
},
152150
optimization: Object.assign(
153-
// {
154-
// splitChunks: {
155-
// cacheGroups: {
156-
// vendor: {
157-
// test: /[\\/]node_modules[\\/]/,
158-
// chunks: 'all',
159-
// name: 'vendor',
160-
// priority: 10,
161-
// enforce: true,
162-
// minChunks: 1,
163-
// maxSize: 3500000,
164-
// },
165-
// },
166-
// },
167-
// },
168151
isProd
169152
? {
153+
splitChunks: {
154+
cacheGroups: {
155+
vendor: {
156+
test: /[\\/]node_modules[\\/]/,
157+
chunks: 'all',
158+
name: 'vendor',
159+
priority: 10,
160+
enforce: true,
161+
minChunks: 1,
162+
maxSize: 3000000,
163+
},
164+
},
165+
},
170166
minimizer: [
171167
new TerserJSPlugin({
172168
cache: true,

km-console/packages/layout-clusters-fe/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import React, { useState, useEffect, useLayoutEffect } from 'react';
44
import { BrowserRouter, Switch, Route, useLocation, useHistory } from 'react-router-dom';
55
import { get as lodashGet } from 'lodash';
66
import { DProLayout, AppContainer, IconFont, Menu, Utils, Page403, Page404, Page500, Modal } from 'knowdesign';
7-
import dantdZhCN from 'knowdesign/lib/locale/zh_CN';
8-
import dantdEnUS from 'knowdesign/lib/locale/en_US';
7+
import dantdZhCN from 'knowdesign/es/locale/zh_CN';
8+
import dantdEnUS from 'knowdesign/es/locale/en_US';
99
import { DotChartOutlined } from '@ant-design/icons';
1010
import { licenseEventBus } from './constants/axiosConfig';
1111
import intlZhCN from './locales/zh';

km-console/packages/layout-clusters-fe/src/components/TagsWithHide/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DownOutlined } from '@ant-design/icons';
22
import { Popover } from 'knowdesign';
3-
import { TooltipPlacement } from 'knowdesign/lib/basic/tooltip';
3+
import { TooltipPlacement } from 'knowdesign/es/basic/tooltip';
44
import React, { useState, useRef, useEffect } from 'react';
55
import './index.less';
66

@@ -93,8 +93,9 @@ export default (props: PropsType) => {
9393
return (
9494
<div
9595
key={i}
96-
className={`container-item ${curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : ''
97-
}`}
96+
className={`container-item ${
97+
curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : ''
98+
}`}
9899
>
99100
{item}
100101
</div>

km-console/packages/layout-clusters-fe/src/pages/BrokerControllerChangeLog/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import API from '../../api';
55
import { getControllerChangeLogListColumns, defaultPagination } from './config';
66
import BrokerDetail from '../BrokerDetail';
77
import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck';
8-
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb';
8+
import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
99
import './index.less';
1010

1111
const { request } = Utils;

km-console/packages/layout-clusters-fe/src/pages/BrokerDashboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { MetricType } from '@src/api';
33
import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck';
44
import DashboardDragChart from '@src/components/DashboardDragChart';
5-
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb';
5+
import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
66
import { AppContainer } from 'knowdesign';
77

88
const BrokerDashboard = (): JSX.Element => {

km-console/packages/layout-clusters-fe/src/pages/BrokerList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { dealTableRequestParams } from '../../constants/common';
77
import BrokerDetail from '../BrokerDetail';
88
import CardBar from '@src/components/CardBar';
99
import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck';
10-
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb';
10+
import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
1111
import './index.less';
1212
const { request } = Utils;
1313

0 commit comments

Comments
 (0)