Skip to content

Commit fd39e2e

Browse files
committed
add playground
1 parent b34402e commit fd39e2e

27 files changed

+643
-0
lines changed

playground/.gitignore

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

playground/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# playground
2+
3+
4+
## 运行步骤
5+
### 编译form-pc
6+
```
7+
yarn build
8+
```
9+
在form-pc目录下执行编译命令,编译完成后会在dist目录下生成form-pc的代码包。
10+
11+
12+
### 运行实例
13+
14+
```
15+
# 开发模式
16+
yarn start
17+
# 调试模式
18+
yarn dev
19+
# 生产模式
20+
yarn build
21+
```

playground/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
4+
moduleNameMapper: {
5+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
6+
},
7+
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
8+
};

playground/jest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom';

playground/mocks/product.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Mock from "mockjs";
2+
import webpackMockServer from "webpack-mock-server";
3+
4+
export default webpackMockServer.add((app, helper) => {
5+
app.get('/api/products', (req, res) => {
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({
15+
success: true,
16+
data:{
17+
list:products,
18+
total: products.length
19+
},
20+
});
21+
});
22+
});

playground/mocks/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": [
4+
"../mocks/*",
5+
"*.mock.ts",
6+
"**/global.d.ts"
7+
],
8+
"files": [],
9+
"exclude": [
10+
"*test.mock.ts"
11+
]
12+
}

playground/mocks/user.ts

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

playground/package.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"name": "playground",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@codingapi/ui-framework": "file:../dist",
7+
"@types/node": "^16.18.108",
8+
"@types/react": "^18.3.5",
9+
"@types/react-dom": "^18.3.0",
10+
"react": "^18.3.1",
11+
"react-dom": "^18.3.1",
12+
"sass": "^1.78.0",
13+
"sass-loader": "^16.0.1",
14+
"typescript": "^5.6.2",
15+
"web-vitals": "^2.1.4"
16+
},
17+
"resolutions": {
18+
"react": "18.3.1",
19+
"react-dom": "18.3.1"
20+
},
21+
"scripts": {
22+
"start": "webpack serve --config webpack.config.mock.js --open",
23+
"dev": "webpack serve --config webpack.config.dev.js --open",
24+
"build": "webpack --mode production --config webpack.config.prod.js"
25+
},
26+
"devDependencies": {
27+
"@testing-library/dom": "^10.4.0",
28+
"@testing-library/jest-dom": "^6.6.3",
29+
"@testing-library/react": "^16.3.0",
30+
"@testing-library/user-event": "^13.5.0",
31+
"@types/jest": "^29.5.14",
32+
"clean-webpack-plugin": "^4.0.0",
33+
"copy-webpack-plugin": "^12.0.2",
34+
"css-loader": "^7.1.2",
35+
"express": "^4.21.0",
36+
"html-webpack-plugin": "^5.6.0",
37+
"identity-obj-proxy": "^3.0.0",
38+
"jest": "^29.7.0",
39+
"jest-environment-jsdom": "^29.7.0",
40+
"mockjs": "^1.1.0",
41+
"monaco-editor-webpack-plugin": "^7.1.0",
42+
"sass": "^1.78.0",
43+
"sass-loader": "^16.0.1",
44+
"style-loader": "^4.0.0",
45+
"ts-jest": "^29.3.2",
46+
"ts-loader": "^9.5.1",
47+
"ts-node": "^10.9.2",
48+
"webpack": "^5.94.0",
49+
"webpack-cli": "^5.1.4",
50+
"webpack-dev-server": "^5.1.0",
51+
"webpack-merge": "^6.0.1",
52+
"webpack-mock-server": "^1.0.23"
53+
},
54+
"eslintConfig": {
55+
"extends": [
56+
"react-app",
57+
"react-app/jest"
58+
]
59+
},
60+
"browserslist": {
61+
"production": [
62+
">0.2%",
63+
"not dead",
64+
"not op_mini all"
65+
],
66+
"development": [
67+
"last 1 chrome version",
68+
"last 1 firefox version",
69+
"last 1 safari version"
70+
]
71+
}
72+
}

playground/public/captcha.jpeg

548 Bytes
Loading

playground/public/favicon.ico

3.78 KB
Binary file not shown.

playground/public/index.html

Lines changed: 36 additions & 0 deletions
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>

playground/public/logo192.png

5.22 KB
Loading

playground/public/logo512.png

9.44 KB
Loading

playground/public/manifest.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

playground/public/robots.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

0 commit comments

Comments
 (0)