Skip to content

Commit a7f177e

Browse files
authored
Merge pull request #73 from codingapi/flow
Flow
2 parents bd6b10a + d04e848 commit a7f177e

File tree

280 files changed

+17404
-1881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+17404
-1881
lines changed

.DS_Store

8 KB
Binary file not shown.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ build/
3333
.vscode/
3434
*.db
3535
*.trace.db
36+
37+
### jars ###
38+
/jars/

admin-ui/.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
/.idea
4+
5+
# dependencies
6+
/node_modules
7+
/.pnp
8+
.pnp.js
9+
10+
# testing
11+
/coverage
12+
13+
# production
14+
/build
15+
/dist
16+
17+
# misc
18+
.DS_Store
19+
.env.local
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
yarn.lock
28+

admin-ui/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Admin-ui with Antd For Micro Frontends
2+
3+
This is a simple React App with Webpack5 & Typescript.
4+
5+
## Features
6+
1. Support Webpack 5 ModuleFederationPlugin for Micro Frontends
7+
2. Support Dynamic zip component loading
8+
3. Support Dynamic Routing & Dynamic Menu
9+
4. Support Axios for API calls
10+
5. Support Antd & Pro-Components UI Library
11+
6. Support Redux for State Management
12+
7. Support Mock Server for API Mocking
13+
8. Support Monaco Editor for Code Editor
14+
9. Support Access ControlPanel for Menu & Page Components
15+
16+
## Running
17+
```shell
18+
yarn
19+
20+
yarn start
21+
```
22+
## Build
23+
```shell
24+
yarn build
25+
```
26+
27+
## Deploy
28+
```shell
29+
cd scripts
30+
sh package.sh
31+
sh deploy.sh
32+
```
33+

admin-ui/mocks/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const userMock = require('./user');
2+
const productMock = require('./product');
3+
4+
module.exports = (app, helper) => {
5+
userMock(app);
6+
productMock(app);
7+
};

admin-ui/mocks/product.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const Mock = require('mockjs');
2+
3+
module.exports = (app, helper) => {
4+
app.get('/api/products', (req, res) => {
5+
6+
const products = Mock.mock({
7+
'list|100': [{
8+
'id|+1': 1,
9+
'name': '@name',
10+
'price|100-1000': 1,
11+
}]
12+
}).list;
13+
14+
res.json(products);
15+
});
16+
};

admin-ui/mocks/user.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = (app, helper) => {
2+
app.post('/user/login', (req, res) => {
3+
const username = req.body.username;
4+
5+
if(username==='admin'){
6+
res.json({
7+
success:true,
8+
data:{
9+
'username': username,
10+
'token':'test token',
11+
'avatar':'/logo.png',
12+
'authorities': ['ROLE_ADMIN','ROLE_DEVELOPER'],
13+
}
14+
});
15+
return;
16+
}
17+
18+
res.json({
19+
success:true,
20+
data:{
21+
'username': username,
22+
'token':'test token',
23+
'avatar':'/logo.png',
24+
'authorities': ['ROLE_USER'],
25+
}
26+
});
27+
});
28+
};

admin-ui/package.json

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "admin-ui",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@ant-design/icons": "^5.4.0",
7+
"@ant-design/pro-components": "^2.7.19",
8+
"@babel/standalone": "^7.25.6",
9+
"@logicflow/core": "^2.0.5",
10+
"@logicflow/extension": "^2.0.9",
11+
"@reduxjs/toolkit": "^2.2.7",
12+
"@types/babel__standalone": "^7.1.7",
13+
"@types/node": "^16.18.108",
14+
"@types/react": "^18.3.5",
15+
"@types/react-dom": "^18.3.0",
16+
"antd": "^5.20.6",
17+
"axios": "^1.7.7",
18+
"base64-js": "^1.5.1",
19+
"jszip": "^3.10.1",
20+
"lodash": "^4.17.21",
21+
"moment": "^2.30.1",
22+
"monaco-editor": "^0.51.0",
23+
"react": "^18.3.1",
24+
"react-dom": "^18.3.1",
25+
"react-redux": "^9.1.2",
26+
"react-router": "^6.26.2",
27+
"react-router-dom": "^6.26.2",
28+
"typescript": "^5.6.2",
29+
"web-vitals": "^2.1.4"
30+
},
31+
"scripts": {
32+
"start": "webpack serve --config webpack.config.mock.js --open",
33+
"dev": "webpack serve --config webpack.config.dev.js --open",
34+
"build": "webpack --mode production --config webpack.config.prod.js"
35+
},
36+
"eslintConfig": {
37+
"extends": [
38+
"react-app"
39+
]
40+
},
41+
"browserslist": {
42+
"production": [
43+
">0.2%",
44+
"not dead",
45+
"not op_mini all"
46+
],
47+
"development": [
48+
"last 1 chrome version",
49+
"last 1 firefox version",
50+
"last 1 safari version"
51+
]
52+
},
53+
"devDependencies": {
54+
"@types/lodash": "^4.17.7",
55+
"@types/lodash-es": "^4.17.12",
56+
"clean-webpack-plugin": "^4.0.0",
57+
"copy-webpack-plugin": "^12.0.2",
58+
"css-loader": "^7.1.2",
59+
"express": "^4.21.0",
60+
"html-webpack-plugin": "^5.6.0",
61+
"mockjs": "^1.1.0",
62+
"monaco-editor-webpack-plugin": "^7.1.0",
63+
"sass": "^1.78.0",
64+
"sass-loader": "^16.0.1",
65+
"style-loader": "^4.0.0",
66+
"ts-loader": "^9.5.1",
67+
"webpack": "^5.94.0",
68+
"webpack-cli": "^5.1.4",
69+
"webpack-dev-server": "^5.1.0",
70+
"webpack-merge": "^6.0.1",
71+
"webpack-mock-server": "^1.0.21"
72+
}
73+
}

admin-ui/public/favicon.ico

3.78 KB
Binary file not shown.

admin-ui/public/index.html

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta
8+
name="description"
9+
content="Web site created using create-react-app"
10+
/>
11+
<!--
12+
Notice the use of %PUBLIC_URL% in the tags above.
13+
It will be replaced with the URL of the `public` folder during the build.
14+
Only files inside the `public` folder can be referenced from the HTML.
15+
16+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
17+
work correctly both with client-side routing and a non-root public URL.
18+
Learn how to configure a non-root public URL by running `npm run build`.
19+
-->
20+
<title>Admin UI</title>
21+
</head>
22+
<body>
23+
<noscript>You need to enable JavaScript to run this app.</noscript>
24+
<div id="root"></div>
25+
<!--
26+
This HTML file is a template.
27+
If you open it directly in the browser, you will see an empty page.
28+
29+
You can add webfonts, meta tags, or analytics to this file.
30+
The build step will place the bundled scripts into the <body> tag.
31+
32+
To begin the development, run `npm start` or `yarn start`.
33+
To create a production bundle, use `npm run build` or `yarn build`.
34+
-->
35+
</body>
36+
</html>

admin-ui/public/logo.png

5.22 KB
Loading

admin-ui/scripts/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/admin

admin-ui/scripts/deploy.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
serverHost=server
2+
serverAccount=root
3+
serverPort=22
4+
serverPath=/opt/test/
5+
6+
7+
scp -o ConnectTimeout=30 -P $serverPort -r * $serverAccount@$serverHost:$serverPath
8+
ssh -p $serverPort $serverAccount@$serverHost "cd $serverPath && sed -i 's/\r//g' *.sh && sh install.sh"

admin-ui/scripts/docker-compose.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "3"
2+
3+
services:
4+
admin-nginx:
5+
image: nginx:latest
6+
volumes:
7+
- "./admin:/usr/share/nginx/html"
8+
environment:
9+
TZ: "Asia/Shanghai"
10+
restart: always
11+
ports:
12+
- "13000:80"

admin-ui/scripts/install.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docker-compose build --no-cache
2+
docker-compose up -d
3+
docker ps -a

admin-ui/scripts/package.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rm -rf admin
2+
3+
cd ..
4+
yarn
5+
yarn run build
6+
7+
8+
cp -r ./dist/ ./scripts/admin/

admin-ui/src/api/account.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {post} from "@/api/index";
2+
3+
export async function login(body: Account.LoginRequest) {
4+
return post('/user/login', body);
5+
}
6+
7+
export function clearUser() {
8+
localStorage.removeItem('username');
9+
localStorage.removeItem('token');
10+
localStorage.removeItem('authorities');
11+
localStorage.removeItem('avatar');
12+
}
13+
14+
export function initUser(user: {
15+
username: string;
16+
token: string;
17+
authorities: string[];
18+
avatar: string;
19+
}) {
20+
const {username, token, authorities, avatar} = user;
21+
localStorage.setItem('username', username);
22+
localStorage.setItem('token', token);
23+
if(authorities) {
24+
localStorage.setItem('authorities', JSON.stringify(authorities));
25+
}
26+
localStorage.setItem('avatar', avatar || "/logo.png");
27+
}

0 commit comments

Comments
 (0)