Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d48c53

Browse files
committed
update
1 parent 98a15fb commit 7d48c53

File tree

8 files changed

+3126
-6707
lines changed

8 files changed

+3126
-6707
lines changed

‎package.json‎

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,66 +23,68 @@
2323
"pnp": false
2424
},
2525
"dependencies": {
26-
"@rematch/core": "^1.4.0",
27-
"antd": "4.6.1",
28-
"axios": "^0.20.0",
29-
"core-js": "^3.6.5",
26+
"@rematch/core": "^2.0.1",
27+
"antd": "4.16.0",
28+
"axios": "^0.21.1",
29+
"core-js": "^3.13.0",
30+
"dayjs": "^1.10.5",
3031
"history": "^4.10.1",
31-
"lodash": "^4.17.20",
32+
"lodash": "^4.17.21",
3233
"normalize.css": "^8.0.1",
33-
"react": "^16.13.1",
34-
"react-dom": "^16.13.1",
34+
"react": "^17.0.2",
35+
"react-dom": "^17.0.2",
3536
"react-loadable": "^5.5.0",
36-
"react-redux": "^7.2.1",
37+
"react-redux": "^7.2.4",
3738
"react-router-dom": "^5.2.0",
38-
"react-vcode": "^1.0.7",
39-
"redux": "^4.0.5"
39+
"react-vcode": "^1.0.11",
40+
"redux": "^4.1.0"
4041
},
4142
"devDependencies": {
42-
"@babel/core": "^7.11.4",
43-
"@babel/plugin-proposal-class-properties": "^7.10.4",
44-
"@babel/plugin-proposal-decorators": "^7.10.5",
45-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
46-
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
47-
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
43+
"@babel/core": "^7.14.3",
44+
"@babel/plugin-proposal-class-properties": "^7.13.0",
45+
"@babel/plugin-proposal-decorators": "^7.14.2",
46+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
47+
"@babel/plugin-proposal-object-rest-spread": "^7.14.2",
48+
"@babel/plugin-proposal-optional-chaining": "^7.14.2",
4849
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
49-
"@babel/plugin-transform-runtime": "^7.11.0",
50-
"@babel/preset-env": "^7.11.0",
51-
"@babel/preset-react": "^7.10.4",
52-
"@babel/runtime": "^7.11.2",
53-
"antd-dayjs-webpack-plugin": "^1.0.1",
54-
"autoprefixer": "^9.8.6",
50+
"@babel/plugin-transform-runtime": "^7.14.3",
51+
"@babel/preset-env": "^7.14.2",
52+
"@babel/preset-react": "^7.13.13",
53+
"@babel/runtime": "^7.0.0",
54+
"antd-dayjs-webpack-plugin": "^1.0.6",
55+
"autoprefixer": "^10.2.6",
5556
"babel-eslint": "^10.1.0",
56-
"babel-loader": "^8.1.0",
57-
"babel-plugin-import": "^1.13.0",
57+
"babel-loader": "^8.2.2",
58+
"babel-plugin-import": "^1.13.3",
5859
"body-parser": "^1.19.0",
5960
"clean-webpack-plugin": "^3.0.0",
60-
"copy-webpack-plugin": "^6.0.3",
61-
"css-loader": "^4.2.2",
62-
"eslint": "^7.7.0",
61+
"copy-webpack-plugin": "^9.0.0",
62+
"css-loader": "^5.2.6",
63+
"eslint": "^7.27.0",
6364
"eslint-loader": "^4.0.2",
64-
"eslint-plugin-prettier": "^3.1.4",
65-
"eslint-plugin-react": "^7.20.6",
66-
"eslint-plugin-react-hooks": "^4.1.0",
65+
"eslint-plugin-prettier": "^3.4.0",
66+
"eslint-plugin-react": "^7.23.2",
67+
"eslint-plugin-react-hooks": "^4.2.0",
6768
"express": "^4.17.1",
68-
"favicons-webpack-plugin": "4.2.0",
69-
"file-loader": "^6.0.0",
69+
"favicons-webpack-plugin": "5.0.2",
70+
"file-loader": "^6.2.0",
7071
"happypack": "^5.0.1",
71-
"html-webpack-plugin": "^4.3.0",
72-
"less": "^3.12.2",
73-
"less-loader": "^6.2.0",
74-
"mini-css-extract-plugin": "^0.10.0",
72+
"html-webpack-plugin": "^5.3.1",
73+
"less": "^4.1.1",
74+
"less-loader": "^9.0.0",
75+
"mini-css-extract-plugin": "^1.6.0",
7576
"mockjs": "^1.1.0",
76-
"optimize-css-assets-webpack-plugin": "^5.0.3",
77-
"postcss-loader": "^3.0.0",
78-
"prettier": "2.1.0",
79-
"style-loader": "1.2.1",
77+
"optimize-css-assets-webpack-plugin": "^6.0.0",
78+
"postcss-loader": "^5.3.0",
79+
"prettier": "2.3.0",
80+
"source-map-loader": "^3.0.0",
81+
"style-loader": "2.0.0",
8082
"sw-precache-webpack-plugin": "^1.0.0",
81-
"terser-webpack-plugin": "^4.1.0",
82-
"url-loader": "^4.1.0",
83-
"webpack": "^4.44.1",
84-
"webpack-cli": "^3.3.12",
85-
"webpack-dev-middleware": "^3.7.2",
83+
"terser-webpack-plugin": "^5.1.2",
84+
"url-loader": "^4.1.1",
85+
"webpack": "^5.37.1",
86+
"webpack-cli": "^4.7.0",
87+
"webpack-dev-middleware": "^4.3.0",
8688
"webpack-hot-middleware": "^2.25.0",
8789
"webpackbar": "^4.0.0",
8890
"xml-loader": "^1.2.1"

‎postcss.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/** postcss-loader 解析器所需的配置文件 **/
22
module.exports = {
3-
plugins: [require("autoprefixer")()]
3+
plugins: [require("autoprefixer")],
44
};

‎server.js‎

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,62 @@ const webpack = require("webpack"); // webpack核心
77
const webpackDevMiddleware = require("webpack-dev-middleware"); // webpack服务器
88
const webpackHotMiddleware = require("webpack-hot-middleware"); // HMR热更新中间件
99
const webpackConfig = require("./webpack.dev.config.js"); // webpack开发环境的配置文件
10-
1110
const mock = require("./mock/app-data"); // mock模拟数据,模拟后台业务
1211

12+
// const { createProxyMiddleware } = require("http-proxy-middleware"); // 跨域配置 需要跨域请打开注释即可
13+
1314
const app = express(); // 实例化express服务
14-
const DIST_DIR = webpackConfig.output.path; // webpack配置中设置的文件输出路径,所有文件存放在内存中
15-
const PORT = 8888; // 服务启动端口号
15+
let PORT = 8888; // 服务启动端口号
16+
17+
// 跨域设置 需要跨域请打开注释,自己设置对应的域名
18+
// app.use(
19+
// "/proxy",
20+
// createProxyMiddleware({
21+
// target: "https://example.com", // 目标域名
22+
// changeOrigin: true,
23+
// ws: false,
24+
// pathRewrite: {
25+
// "^/proxy": "/",
26+
// },
27+
// })
28+
// );
1629

30+
// bodyParser的配置需要放在Proxy代理的下面,否则post请求的代理参数无法处理
1731
app.use(bodyParser.urlencoded({ extended: false }));
1832
app.use(bodyParser.json());
1933

34+
/** 监听POST请求,返回MOCK模拟数据 **/
35+
app.post(/\/api.*/, (req, res, next) => {
36+
const result = mock.mockApi({ url: req.originalUrl, body: req.body });
37+
res.send(result);
38+
});
39+
app.get(/\/api.*/, (req, res, next) => {
40+
const result = mock.mockApi({ url: req.originalUrl, body: req.body });
41+
res.send(result);
42+
});
43+
2044
if (env === "production") {
2145
// 如果是生产环境,则运行build文件夹中的代码
46+
PORT = 8889;
2247
app.use(express.static("build"));
23-
app.get("*", function(req, res) {
48+
app.get("*", function(req, res) {
2449
res.sendFile(path.join(__dirname, "build", "index.html"));
2550
});
2651
} else {
2752
const compiler = webpack(webpackConfig); // 实例化webpack
28-
app.use(express.static("dll"));
2953
app.use(
54+
// 挂载webpack小型服务器
3055
webpackDevMiddleware(compiler, {
31-
// 挂载webpack小型服务器
3256
publicPath: webpackConfig.output.publicPath, // 对应webpack配置中的publicPath
33-
quiet: true, // 是否不输出启动时的相关信息
34-
stats: {
35-
colors: true, // 不同信息不同颜色
36-
timings: true, // 输出各步骤消耗的时间
37-
},
3857
}),
3958
);
4059
// 挂载HMR热更新中间件
4160
app.use(webpackHotMiddleware(compiler));
4261

43-
/** 监听POST请求,返回MOCK模拟数据 **/
44-
app.post(/\/api.*/, (req, res, next) => {
45-
const result = mock.mockApi({ url: req.originalUrl, body: req.body });
46-
res.send(result);
47-
});
48-
app.get(/\/api.*/, (req, res, next) => {
49-
const result = mock.mockApi({ url: req.originalUrl, body: req.body });
50-
res.send(result);
51-
});
52-
5362
// 所有请求都返回index.html
5463
app.get("*", (req, res, next) => {
55-
const filename = path.join(DIST_DIR, "index.html");
64+
// webpack配置中设置的文件输出路径,所有文件存放在内存中
65+
const filename = path.join(webpackConfig.output.path, "index.html");
5666

5767
// 由于index.html是由html-webpack-plugin生成到内存中的,所以使用下面的方式获取
5868
compiler.outputFileSystem.readFile(filename, (err, result) => {

‎src/a_component/Footer/index.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ export default class Com extends React.PureComponent {
1313
render() {
1414
return (
1515
<Footer className={`footer ${this.props.className}`}>
16-
© 2018-2020{" "}
17-
<a
18-
href="https://blog.isluo.com"
19-
target="_blank"
20-
rel="noopener noreferrer"
21-
>
16+
© 2018-{new Date().getFullYear()}{" "}
17+
<a href="https://blog.isluo.com" target="_blank" rel="noopener noreferrer">
2218
blog.isluo.com
2319
</a>
2420
, Inc.

‎src/a_container/home/index.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ export default class HomePageContainer extends React.Component {
2525
<div className="box">
2626
<img src={ImgLogo} />
2727
<div className="title">React-admin</div>
28-
<div className="info">
29-
标准React+Redux分层结构,react16、router4、antd4、webpack4、ES6+
30-
</div>
28+
<div className="info">标准React+Redux分层结构,react17、router4、antd4、webpack5、ES6+</div>
3129
<div className="info">动态菜单配置,权限精确到按钮</div>
3230
</div>
3331
</div>

‎src/layouts/BasicLayout.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ export default class AppContainer extends React.Component {
8484
if (this.props.userinfo.menus && this.props.userinfo.menus.length) {
8585
menus = this.props.userinfo.menus;
8686
} else if (sessionStorage.getItem("userinfo")) {
87-
menus = JSON.parse(tools.uncompile(sessionStorage.getItem("userinfo")))
88-
.menus;
87+
menus = JSON.parse(
88+
tools.uncompile(sessionStorage.getItem("userinfo"))
89+
).menus;
8990
}
9091
const m = menus.map((item) => item.url.replace(/^\//, "")); // 当前用户拥有的所有菜单
9192
const urls = pathname.split("/").filter((item) => !!item);

‎webpack.dev.config.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const AntdDayjsWebpackPlugin = require("antd-dayjs-webpack-plugin");
88
const HappyPack = require("happypack"); // 多线程编译
99
const webpackbar = require("webpackbar");
1010
const PUBLIC_PATH = "/"; // 基础路径
11+
1112
module.exports = {
1213
mode: "development",
1314
entry: [
@@ -17,7 +18,7 @@ module.exports = {
1718
output: {
1819
path: __dirname + "/", // 将打包好的文件放在此路径下,dev模式中,只会在内存中存在,不会真正的打包到此路径
1920
publicPath: PUBLIC_PATH, // 文件解析路径,index.html中引用的路径会被设置为相对于此路径
20-
filename: "bundle.js", // 编译后的文件名字
21+
filename: "bundle-[contenthash].js", // 编译后的文件名字
2122
},
2223
devtool: "eval-source-map", // 报错的时候在控制台输出哪一行报错
2324
optimization: {
@@ -31,7 +32,7 @@ module.exports = {
3132
// 编译前通过eslint检查代码 (注释掉即可取消eslint检测)
3233
test: /\.js?$/,
3334
enforce: "pre",
34-
use: ["eslint-loader"],
35+
use: ["source-map-loader","eslint-loader"],
3536
include: path.resolve(__dirname, "src"),
3637
},
3738
{
@@ -48,7 +49,7 @@ module.exports = {
4849
{
4950
// .less 解析
5051
test: /\.less$/,
51-
use: ["style-loader", "css-loader", "postcss-loader", { loader: "less-loader", options: { lessOptions: {javascriptEnabled: true} } }],
52+
use: ["style-loader", "css-loader", "postcss-loader", { loader: "less-loader", options: { lessOptions: {javascriptEnabled: true} } }],
5253
},
5354
{
5455
// 文件解析

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /