Skip to content

Commit 9e129d1

Browse files
authored
Merge pull request #89 from codingapi/dev
Dev
2 parents 8bd31be + bbd21d8 commit 9e129d1

File tree

190 files changed

+10971
-101
lines changed

Some content is hidden

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

190 files changed

+10971
-101
lines changed

.DS_Store

10 KB
Binary file not shown.

admin-pro-ui/.gitignore

Lines changed: 28 additions & 0 deletions
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-pro-ui/README.md

Lines changed: 33 additions & 0 deletions
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-pro-ui/__mocks__/axios.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// __mocks__/axios.ts
2+
const mockAxios = {
3+
create: jest.fn(() => ({
4+
interceptors: {
5+
request: {
6+
use: jest.fn(),
7+
eject: jest.fn()
8+
},
9+
response: {
10+
use: jest.fn(),
11+
eject: jest.fn()
12+
}
13+
},
14+
get: jest.fn(),
15+
post: jest.fn(),
16+
put: jest.fn(),
17+
delete: jest.fn(),
18+
patch: jest.fn()
19+
})),
20+
interceptors: {
21+
request: {
22+
use: jest.fn(),
23+
eject: jest.fn()
24+
},
25+
response: {
26+
use: jest.fn(),
27+
eject: jest.fn()
28+
}
29+
},
30+
get: jest.fn(),
31+
post: jest.fn(),
32+
put: jest.fn(),
33+
delete: jest.fn(),
34+
patch: jest.fn()
35+
};
36+
37+
export default mockAxios;

admin-pro-ui/__mocks__/fileMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'test-file-stub';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
editor: {
3+
create: jest.fn(() => ({
4+
dispose: jest.fn(),
5+
getValue: jest.fn(() => ''),
6+
setValue: jest.fn(),
7+
})),
8+
},
9+
};

admin-pro-ui/jest.config.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { Config } from 'jest';
2+
3+
const config: Config = {
4+
preset: 'ts-jest',
5+
testEnvironment: 'jsdom',
6+
transform: {
7+
'^.+\\.(ts|tsx)$': ['ts-jest', {
8+
useESM: true,
9+
}],
10+
'^.+\\.(js|jsx|mjs)$': ['babel-jest', {
11+
presets: [
12+
['@babel/preset-env', {
13+
targets: {
14+
node: 'current',
15+
},
16+
}],
17+
'@babel/preset-react',
18+
'@babel/preset-typescript'
19+
],
20+
}],
21+
},
22+
moduleNameMapper: {
23+
'^monaco-editor$': '<rootDir>/__mocks__/monaco-editor.js',
24+
"@logicflow": "<rootDir>/node_modules/@logicflow/core/dist/index.min.js",
25+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
26+
'\\.(jpg|jpeg|png|gif|webp|svg)$': '<rootDir>/__mocks__/fileMock.js',
27+
'^@/(.*)$': '<rootDir>/src/$1'
28+
},
29+
setupFilesAfterEnv: ['<rootDir>/src/jest.setup.ts'],
30+
testMatch: [
31+
"**/__test__/**/*.[jt]s?(x)",
32+
"**/__tests__/**/*.[jt]s?(x)",
33+
"**/?(*.)+(spec|test).[jt]s?(x)"
34+
],
35+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
36+
transformIgnorePatterns: [
37+
'node_modules/(?!(lodash-es|@ant-design|@logicflow|other-esm-modules)/)'
38+
],
39+
};
40+
41+
export default config;

admin-pro-ui/mocks/index.js

Lines changed: 7 additions & 0 deletions
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-pro-ui/mocks/product.js

Lines changed: 16 additions & 0 deletions
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-pro-ui/mocks/user.js

Lines changed: 28 additions & 0 deletions
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+
};

0 commit comments

Comments
 (0)