Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca1d182795 | ||
|
|
4042d5ba3a | ||
|
|
da4abc2293 | ||
|
|
13c13961c7 | ||
|
|
0d1c4f23e9 | ||
|
|
f3c6ccf7b2 | ||
|
|
a18c9bcb7e | ||
|
|
12eab5f5c7 | ||
|
|
1dbeb05005 | ||
|
|
a0000d7371 | ||
|
|
b0cb27712d | ||
|
|
0bb381f419 | ||
|
|
8c01bc1488 | ||
|
|
d8baaad3b1 | ||
|
|
e32a19fe3b | ||
|
|
c6382c6221 | ||
|
|
02280fbed9 | ||
|
|
d897eb205d | ||
|
|
b1f290ea32 | ||
|
|
0e36b6b7a0 | ||
|
|
d92f121cf4 | ||
|
|
0a73ba0f12 | ||
|
|
9e4e0efbab | ||
|
|
524dff07d2 | ||
|
|
8b3e5c08f7 | ||
|
|
c17444f5d6 | ||
|
|
df85ecdfff | ||
|
|
b8824141d6 | ||
|
|
aedd2ec3db | ||
|
|
5abad21082 | ||
|
|
1ae41c7ae5 | ||
|
|
e41671dbf9 | ||
|
|
eaeb9092e4 | ||
|
|
2f3ca0a006 | ||
|
|
1b65351be4 | ||
|
|
0422f6d51e | ||
|
|
8d050d4040 | ||
|
|
82b3a4b384 | ||
|
|
d2f391a881 | ||
|
|
9e778487d9 | ||
|
|
7938d71f2f | ||
|
|
422a6fed30 | ||
|
|
c6ea0454b3 | ||
|
|
467767a6c5 | ||
|
|
cf795c512a | ||
|
|
18b499030d | ||
|
|
d800d6f3ce | ||
|
|
185f706107 | ||
|
|
5a4661cdad | ||
|
|
7abdd94a0e | ||
|
|
22f0684ab0 | ||
|
|
80b2c63693 | ||
|
|
4b2a553bda | ||
|
|
ad30e73b10 | ||
|
|
15b62e302d | ||
|
|
9d5ec20f20 | ||
|
|
c878425fd0 | ||
|
|
90e80dda64 | ||
|
|
1db5bfeab5 | ||
|
|
b2b3fcd4a3 | ||
|
|
9cf97375c7 | ||
|
|
7839b6affb | ||
|
|
597064a07d | ||
|
|
0ea57d14c9 | ||
|
|
afd736d615 | ||
|
|
ce9b8c376f | ||
|
|
79776e6752 | ||
|
|
a2432022a1 | ||
|
|
ea5ee96bdc | ||
|
|
fe954092a4 | ||
|
|
5e148fec92 | ||
|
|
5daa2a9548 | ||
|
|
f1913f7b18 | ||
|
|
65a453553e | ||
|
|
29da8f24da | ||
|
|
3443ad9968 | ||
|
|
838dc93eff | ||
|
|
07ef68ec1f | ||
|
|
3cb7f86086 | ||
|
|
fc9565c157 | ||
|
|
557f6022f3 | ||
|
|
d0a56169e3 | ||
|
|
f7d6e2b4ed | ||
|
|
df82ee42fd | ||
|
|
a29d761483 | ||
|
|
713a86b9d6 | ||
|
|
d6250f16b0 | ||
|
|
1c5d5c3788 | ||
|
|
699e9d9ff1 | ||
|
|
fad0cb931a | ||
|
|
5d7ff55869 | ||
|
|
642ccb5b82 | ||
|
|
51a7ce0827 | ||
|
|
157a54b11d | ||
|
|
be083d81fc | ||
|
|
f6c869ad47 | ||
|
|
bef5b26509 | ||
|
|
59cfe24178 | ||
|
|
87d0d58ae8 | ||
|
|
de8b6c972d | ||
|
|
0ac4839e94 | ||
|
|
565bce6d8b | ||
|
|
b278b028cf | ||
|
|
33abd9369e | ||
|
|
e6b2f7f271 | ||
|
|
0bd1e9cf59 | ||
|
|
693625bf2c | ||
|
|
3a6c587569 | ||
|
|
bd85eaf0a0 | ||
|
|
29aa0f416e | ||
|
|
5b32607911 | ||
|
|
76e5359752 | ||
|
|
5ec4efbb6e | ||
|
|
f8bb7b421a | ||
|
|
887c169aa8 | ||
|
|
8c10dcc6c2 | ||
|
|
671da6b5fa | ||
|
|
7fdb2f4ea8 | ||
|
|
67388b31f5 | ||
|
|
2379cca765 | ||
|
|
34be6651e5 | ||
|
|
10f8e3e8ef | ||
|
|
0c6ea8eb5c | ||
|
|
6e69b06e61 | ||
|
|
98ba383a68 | ||
|
|
4e6d81a9bf | ||
|
|
0e2c206023 | ||
|
|
285f06d1e7 | ||
|
|
d03787a871 | ||
|
|
6aead03f3e | ||
|
|
0949a298c9 | ||
|
|
94c8e2168f | ||
|
|
358134f417 | ||
|
|
7eb9e06452 | ||
|
|
fab06d5005 | ||
|
|
7483572b1d | ||
|
|
d1ce8e0739 | ||
|
|
16860f93ad | ||
|
|
6ba45d5bc3 | ||
|
|
f230429ddd | ||
|
|
78c3b6d597 | ||
|
|
cdbc2782ff | ||
|
|
108aca99b9 | ||
|
|
7dd5dfb1bf | ||
|
|
ee7a0fffc2 | ||
|
|
6999871860 | ||
|
|
6742207c77 | ||
|
|
d71c29ee2e | ||
|
|
6917d6b89a | ||
|
|
c3f369f0b3 | ||
|
|
01abc5ca38 | ||
|
|
08a348090c | ||
|
|
63b1ecf79f | ||
|
|
efe7e74375 | ||
|
|
6d552d22d9 | ||
|
|
017af0ddfc | ||
|
|
c2161ceca9 | ||
|
|
140af31bec | ||
|
|
1199e7e618 | ||
|
|
3fa24d00fa | ||
|
|
5d23c77100 | ||
|
|
286178fc5e | ||
|
|
f6621572df | ||
|
|
d32b09d802 | ||
|
|
dbe86ec0a8 | ||
|
|
5f8141148a | ||
|
|
c7c24983cc | ||
|
|
f80b6d366f | ||
|
|
0b360eeebb | ||
|
|
c92a1e1342 | ||
|
|
c0963cbcd9 | ||
|
|
4979d5cbc4 | ||
|
|
ff85c1447b | ||
|
|
df608b2dc1 | ||
|
|
f38e0ce7e2 | ||
|
|
0499b70218 | ||
|
|
f654b277fa | ||
|
|
95eeebb09e | ||
|
|
bb61d7f7dc | ||
|
|
d821a7cf59 | ||
|
|
9db8827d4a | ||
|
|
0b17931c62 | ||
|
|
c1df88c25f | ||
|
|
f6454e71f0 | ||
|
|
66a6e55191 | ||
|
|
0a3fac2e72 | ||
|
|
2f928329d1 | ||
|
|
9a5ff4aa98 | ||
|
|
dd3c191139 | ||
|
|
9a702fb774 | ||
|
|
d0c2713f20 | ||
|
|
a6bf4286dc | ||
|
|
08f40efd2b | ||
|
|
4e7795ec7c | ||
|
|
5aa187334a | ||
|
|
abfcf2460e | ||
|
|
bcd6248833 | ||
|
|
baa5869fe5 | ||
|
|
58f62d8145 | ||
|
|
2044beb7f1 | ||
|
|
5f8a298ece | ||
|
|
487b39f97c | ||
|
|
c5724f208a | ||
|
|
03a23bab9a | ||
|
|
d58b6ce948 | ||
|
|
7c83c80d5d | ||
|
|
0801d83856 | ||
|
|
8aa55330b4 | ||
|
|
ee10965f43 | ||
|
|
755e19ed12 | ||
|
|
40d3914b3c | ||
|
|
47fd515944 | ||
|
|
ba426defdd | ||
|
|
a8bd1a587a | ||
|
|
237efb4e72 | ||
|
|
0de24b8251 | ||
|
|
7077ef15f3 | ||
|
|
b3d5d11539 | ||
|
|
2522b971f1 | ||
|
|
c6be37ca09 | ||
|
|
ae8ac62938 | ||
|
|
349eb3216d | ||
|
|
d1d559b1d6 | ||
|
|
7d5ad95cff | ||
|
|
e09c22fc18 | ||
|
|
a7e84edad3 | ||
|
|
0f466b2abe | ||
|
|
0ccdcdbc92 | ||
|
|
3d3f8e70dd | ||
|
|
417215cfcc | ||
|
|
ae8aba68f2 | ||
|
|
cd53b36e76 | ||
|
|
a44f5795fd | ||
|
|
556169871a | ||
|
|
261fbb8428 | ||
|
|
f02d39ace0 | ||
|
|
4d32829445 | ||
|
|
5438e04fc5 | ||
|
|
54bbe4d70a | ||
|
|
78ece0c9fb | ||
|
|
3407f9a0c1 | ||
|
|
f1b78e8d1f | ||
|
|
df2fc9c32e | ||
|
|
cc5c319332 | ||
|
|
43ef09dfed | ||
|
|
0c95751b8d | ||
|
|
843bd1a088 | ||
|
|
a0db71e571 | ||
|
|
7fc14eddd9 | ||
|
|
7f2fdc383b | ||
|
|
ff2caecb3a | ||
|
|
d01df1ef13 | ||
|
|
cd55df3a15 | ||
|
|
ce59f3e7b2 | ||
|
|
4d722f103a | ||
|
|
c1bc6f27b1 | ||
|
|
ed88c087bf | ||
|
|
4e337caa07 | ||
|
|
ea3929b4c2 | ||
|
|
9eff4ca129 | ||
|
|
d6d94e2121 | ||
|
|
737c0236d6 | ||
|
|
69571f2916 | ||
|
|
6dffa7378c | ||
|
|
c2a7bc7106 | ||
|
|
e752750c9e | ||
|
|
32bde8f69e | ||
|
|
b5f9ef51f1 | ||
|
|
8c10be6ee6 | ||
|
|
c1e3872792 | ||
|
|
c3eef53e4d | ||
|
|
a1b9c0c33d | ||
|
|
c49b0edbe9 | ||
|
|
0fd8824ad7 | ||
|
|
973199135f | ||
|
|
43b7b21ad3 | ||
|
|
ba96ebb874 | ||
|
|
c66f086f42 | ||
|
|
07b2175e92 | ||
|
|
d245a1eabc | ||
|
|
f1e2fd3b18 | ||
|
|
a6b3dba92e | ||
|
|
9fd0abe6ea | ||
|
|
d06ee20c47 | ||
|
|
2ef1fa0367 | ||
|
|
9d459106c1 | ||
|
|
cd5a52a8fc | ||
|
|
d89320f578 | ||
|
|
df5ce2991e | ||
|
|
668c9c7dfe | ||
|
|
9bd13055c0 | ||
|
|
9f3adda59d | ||
|
|
bfa7aaecb8 | ||
|
|
9d4310d8e0 | ||
|
|
b3555b01f3 | ||
|
|
74895fbb0d | ||
|
|
5f04d19d2d | ||
|
|
0fef06e0c6 | ||
|
|
89d22451c5 | ||
|
|
fb49056c73 | ||
|
|
a3071819c4 | ||
|
|
d4e10ad5c2 | ||
|
|
59e9a1053e | ||
|
|
308fc09b33 | ||
|
|
99ec9facd3 | ||
|
|
2a96d7a5f6 | ||
|
|
195e1d17f8 | ||
|
|
580ff59b3d | ||
|
|
cfa5aae5da | ||
|
|
761125735a | ||
|
|
d1b12ff0e1 | ||
|
|
a47176a4e5 | ||
|
|
bc3d7fb39a | ||
|
|
458548150c | ||
|
|
f6e11bb464 | ||
|
|
479fc647c3 | ||
|
|
9a4c63390d | ||
|
|
42cd1221fa | ||
|
|
98b773fdc3 | ||
|
|
cd54fcbf52 | ||
|
|
bd68f8c631 | ||
|
|
3fde5aaa3c | ||
|
|
2f34de5602 | ||
|
|
2de1e81661 | ||
|
|
cea60c5683 | ||
|
|
f16e104f73 | ||
|
|
c397f552c3 | ||
|
|
11c4ac803e | ||
|
|
09b9a100de | ||
|
|
0e59df39ee | ||
|
|
30254a2ec7 | ||
|
|
cd796a6db9 | ||
|
|
6ba75de576 | ||
|
|
a3637b3a99 | ||
|
|
85ec09ec9a | ||
|
|
eb683b98e7 | ||
|
|
9221173309 | ||
|
|
55a96f41c6 | ||
|
|
ce510e79c7 | ||
|
|
3d4f2a8814 | ||
|
|
38e24edd7b | ||
|
|
841c987a1a | ||
|
|
dc26f7d25e | ||
|
|
bc754e683e | ||
|
|
c7acc8db4b | ||
|
|
057acc514f | ||
|
|
53ce7d08fb | ||
|
|
8ffd68a4e2 | ||
|
|
766653ee7a | ||
|
|
9dedcc68c3 | ||
|
|
5ea2b3c9b8 | ||
|
|
d2ac91839a | ||
|
|
bfca2746d8 | ||
|
|
b417065ac3 | ||
|
|
abdc97f087 | ||
|
|
07016c6c26 | ||
|
|
b8162060cd | ||
|
|
36fb5d293c | ||
|
|
429280a97a | ||
|
|
7ac36c779e | ||
|
|
d2e7b464e3 | ||
|
|
25839ea99f | ||
|
|
9c99581aa6 | ||
|
|
e42c21f0eb | ||
|
|
782bf214e5 | ||
|
|
a8a4496c7a | ||
|
|
f5f013ff23 | ||
|
|
8cff3af897 | ||
|
|
322d5a6d0e | ||
|
|
2ee26f51a7 | ||
|
|
e670ed2f96 | ||
|
|
601a03b5b4 | ||
|
|
00582e70ff | ||
|
|
fa4385055b | ||
|
|
01f4de55df | ||
|
|
dedd34e8e8 | ||
|
|
d1b373201e | ||
|
|
dbcc90e7ad | ||
|
|
87fce74d5b | ||
|
|
5c51679ad7 | ||
|
|
6d17b5b876 | ||
|
|
1288853112 | ||
|
|
d3e7e17789 | ||
|
|
6077d74f10 | ||
|
|
7bf031699a | ||
|
|
a6eb693636 | ||
|
|
39c377e0e2 | ||
|
|
67b90c4df0 | ||
|
|
0e2727f9c8 | ||
|
|
68c9f2b65f | ||
|
|
38637ef167 | ||
|
|
fe8527e72e | ||
|
|
da64cac414 |
@@ -1,2 +1 @@
|
||||
src/**/*-test.js
|
||||
src/public
|
||||
docs/**/*.js
|
||||
|
||||
@@ -1,52 +1,9 @@
|
||||
{
|
||||
"extends": "airbnb",
|
||||
"extends": "react-app",
|
||||
"rules": {
|
||||
"semi": [2, "never"],
|
||||
"no-console": 0,
|
||||
"comma-dangle": [2, "always-multiline"],
|
||||
"max-len": 0,
|
||||
"react/jsx-first-prop-new-line": 0,
|
||||
"react/jsx-filename-extension": 0,
|
||||
"space-before-function-paren": [2, "always"],
|
||||
"no-unused-expressions": [0, {
|
||||
"allowShortCircuit": true,
|
||||
"allowTernary": true
|
||||
}],
|
||||
"arrow-body-style": [0, "never"],
|
||||
"func-names": 0,
|
||||
"prefer-const": 0,
|
||||
"no-extend-native": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-restricted-syntax": 0,
|
||||
"no-eval": 0,
|
||||
"no-continue": 0,
|
||||
"react/jsx-no-bind": 0,
|
||||
"no-unused-vars": [2, { "ignoreRestSiblings": true }],
|
||||
"no-underscore-dangle": 0,
|
||||
"global-require": 0,
|
||||
"import/no-unresolved": 0,
|
||||
"import/extensions": 0,
|
||||
"import/no-anonymous-default-export": 0,
|
||||
"jsx-a11y/href-no-hash": 0,
|
||||
"react/no-array-index-key": 0,
|
||||
"react/require-default-props": 0,
|
||||
"react/forbid-prop-types": 0,
|
||||
"react/no-string-refs": 0,
|
||||
"react/no-find-dom-node": 0,
|
||||
"import/no-extraneous-dependencies": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"react/no-danger": 0,
|
||||
"jsx-a11y/no-static-element-interactions": 0,
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 8,
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"experimentalObjectRestSpread": true
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": "node"
|
||||
}
|
||||
"no-console": "warn",
|
||||
"valid-jsdoc": "warn"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
> 请酌情提供细节,并保持issue精简便于查阅
|
||||
> 1. 功能需求 => 详细说明
|
||||
> 2. Bug反馈
|
||||
> 2.1 简单描述下报错
|
||||
> 2.2 你期望什么结果
|
||||
> 2.3 如何操作导致的
|
||||
> 2.4 可提供运行环境信息
|
||||
> 3. 代码求助 => 可以提,未必及时答复
|
||||
@@ -1,4 +1,26 @@
|
||||
dist
|
||||
node_modules
|
||||
yarn.lock
|
||||
npm-debug.log
|
||||
coverage
|
||||
dist
|
||||
node_modules
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
# ide
|
||||
.idea
|
||||
|
||||
# Mac General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# umi
|
||||
.umi
|
||||
.umi-production
|
||||
|
||||
# jslingui
|
||||
src/locales/_build
|
||||
src/locales/**/*.js
|
||||
|
||||
.vscode
|
||||
@@ -0,0 +1,6 @@
|
||||
*.svg
|
||||
*.ejs
|
||||
.DS_Store
|
||||
.umi
|
||||
.umi-production
|
||||
src/locales/**/*.json
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
const path = require('path')
|
||||
const { version } = require('./package.json')
|
||||
|
||||
const svgSpriteDirs = [
|
||||
path.resolve(__dirname, 'src/svg/'),
|
||||
require.resolve('antd').replace(/index\.js$/, '')
|
||||
]
|
||||
|
||||
export default {
|
||||
entry : 'src/index.js',
|
||||
svgSpriteLoaderDirs : svgSpriteDirs,
|
||||
theme : "./theme.config.js",
|
||||
publicPath : `/${version}/`,
|
||||
outputPath : `./dist/${version}`,
|
||||
// 接口代理示例
|
||||
proxy: {
|
||||
"/api/v1/weather": {
|
||||
"target": "https://api.seniverse.com/",
|
||||
"changeOrigin": true,
|
||||
"pathRewrite": { "^/api/v1/weather" : "/v3/weather" }
|
||||
},
|
||||
// "/api/v2": {
|
||||
// "target": "http://192.168.0.110",
|
||||
// "changeOrigin": true,
|
||||
// "pathRewrite": { "^/api/v2" : "/api/v2" }
|
||||
// }
|
||||
},
|
||||
env : {
|
||||
development: {
|
||||
extraBabelPlugins: [
|
||||
"dva-hmr",
|
||||
"transform-runtime",
|
||||
[
|
||||
"import", {
|
||||
"libraryName": "antd",
|
||||
"style": true
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
production: {
|
||||
extraBabelPlugins: [
|
||||
"transform-runtime",
|
||||
[
|
||||
"import", {
|
||||
"libraryName": "antd",
|
||||
"style": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
dllPlugin : {
|
||||
exclude: ["babel-runtime"],
|
||||
include: ["dva/router", "dva/saga", "dva/fetch"]
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
const mock = {}
|
||||
require('fs').readdirSync(require('path').join(__dirname + '/src/mock')).forEach(function(file) {
|
||||
Object.assign(mock, require('./src/mock/' + file))
|
||||
})
|
||||
module.exports = mock
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": ["stylelint-config-standard", "stylelint-config-prettier"],
|
||||
"rules": {
|
||||
"declaration-empty-line-before": null,
|
||||
"no-descending-specificity": null,
|
||||
"selector-pseudo-class-no-unknown": null,
|
||||
"selector-pseudo-element-colon-notation": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
script:
|
||||
- npm run build
|
||||
before_install:
|
||||
- yarn global add now
|
||||
after_script:
|
||||
- |
|
||||
if [[ $TRAVIS_BRANCH == 'master' ]]; then
|
||||
echo $PROD_SITE_NOW_CONFIG >> dist/vercel.json && echo $PROD_DOC_NOW_CONFIG >> docs/vercel.json;
|
||||
else
|
||||
echo $DEV_SITE_NOW_CONFIG >> dist/vercel.json && echo $DEV_DOC_NOW_CONFIG >> docs/vercel.json;
|
||||
fi
|
||||
- cd ./dist
|
||||
- now -A vercel.json -t $NOW_TOKEN --prod -c
|
||||
- cd ../docs
|
||||
- now -A vercel.json -t $NOW_TOKEN --prod -c
|
||||
@@ -0,0 +1,87 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="http://github.com/zuiidea/antd-admin">
|
||||
<img alt="antd-admin" height="64" src="./docs/_media/logo.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h1 align="center">AntD Admin</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
一套优秀的中后台前端解决方案
|
||||
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/umijs/umi)
|
||||
[](https://github.com/zuiidea/antd-admin/issues)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||

|
||||
[](https://github.com/zuiidea/antd-admin/pulls)
|
||||
[](https://gitter.im/antd-admin/antd-admin)
|
||||
|
||||
</div>
|
||||
|
||||
- 在线演示 - [https://antd-admin.zuiidea.com](https://antd-admin.zuiidea.com)
|
||||
- 使用文档 - [https://doc.antd-admin.zuiidea.com/#/zh-cn/](https://doc.antd-admin.zuiidea.com/#/zh-cn/)
|
||||
- 常见问题 - [https://doc.antd-admin.zuiidea.com/#/zh-cn/faq](https://doc.antd-admin.zuiidea.com/#/zh-cn/faq)
|
||||
- 更新日志 - [https://doc.antd-admin.zuiidea.com/#/zh-cn/change-log](https://doc.antd-admin.zuiidea.com/#/zh-cn/change-log)
|
||||
|
||||
[English](./README.md) | 简体中文
|
||||
|
||||
## 特性
|
||||
|
||||
- 国际化,源码中抽离翻译字段,按需加载语言包
|
||||
- 动态权限,不同权限对应不同菜单
|
||||
- 优雅美观,Ant Design 设计体系
|
||||
- Mock 数据,本地数据调试
|
||||
|
||||
|
||||
## 使用
|
||||
|
||||
1. 下载项目代码。
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
cd my-project
|
||||
```
|
||||
|
||||
2. 进入目录安装依赖,国内用户推荐使用 [cnpm](https://cnpmjs.org) 进行加速。
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. 启动本地服务器。
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
4. 启动完成后打开浏览器访问 [http://localhost:7000](http://localhost:7000),如果需要更改启动端口,可在 `.env` 文件中配置。
|
||||
|
||||
|
||||
> 更多信息请参考 [使用文档](https://doc.antd-admin.zuiidea.com/#/zh-cn/)。
|
||||
|
||||
|
||||
## 支持环境
|
||||
|
||||
现代浏览器。
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## 参与贡献
|
||||
|
||||
我们非常欢迎你的贡献,你可以通过以下方式和我们一起共建 :smiley:
|
||||
- 在你的公司或个人项目中使用 AntD Admin。
|
||||
- 通过 [Issue](http://github.com/zuiidea/antd-admin/issues) 报告 bug 或进行咨询。
|
||||
- 提交 [Pull Request](http://github.com/zuiidea/antd-admin/pulls) 改进代码。
|
||||
|
||||
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。
|
||||
@@ -1,175 +1,86 @@
|
||||
# Antd Admin
|
||||
|
||||
[](https://github.com/facebook/react)
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/dvajs/dva)
|
||||
<p align="center">
|
||||
<a href="http://github.com/zuiidea/antd-admin">
|
||||
<img alt="antd-admin" height="64" src="./docs/_media/logo.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[](https://github.com/zuiidea/antd-admin)
|
||||
[](https://github.com/zuiidea/antd-admin/pulls)
|
||||
<h1 align="center">AntD Admin</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
An excellent front-end solution for enterprise applications.
|
||||
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/umijs/umi)
|
||||
[](https://github.com/zuiidea/antd-admin/issues)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
[](http://standardjs.com)
|
||||

|
||||
[](https://github.com/zuiidea/antd-admin/pulls)
|
||||
[](https://gitter.im/antd-admin/antd-admin)
|
||||
|
||||
演示地址 <http://antd-admin.zuiidea.com>
|
||||
</div>
|
||||
|
||||
## 特性
|
||||
- Preview - [https://antd-admin.zuiidea.com](https://antd-admin.zuiidea.com)
|
||||
- Documentation - [https://doc.antd-admin.zuiidea.com](https://doc.antd-admin.zuiidea.com)
|
||||
- FAQ - [https://doc.antd-admin.zuiidea.com/#/faq](https://doc.antd-admin.zuiidea.com/#/faq)
|
||||
- ChangeLog - [https://doc.antd-admin.zuiidea.com/#/change-log](https://doc.antd-admin.zuiidea.com/#/change-log)
|
||||
|
||||
- 基于[react](https://github.com/facebook/react),[ant-design](https://github.com/ant-design/ant-design),[dva](https://github.com/dvajs/dva),[Mock](https://github.com/nuysoft/Mock) 企业级后台管理系统最佳实践。
|
||||
- 基于Antd UI 设计语言,提供后台管理系统常见使用场景。
|
||||
- 基于[dva](https://github.com/dvajs/dva)动态加载 Model 和路由,按需加载。
|
||||
- 使用[roadhog](https://github.com/sorrycc/roadhog)本地调试和构建,其中Mock功能实现脱离后端独立开发。
|
||||
- 浅度响应式设计。
|
||||
English | [简体中文](./README-zh_CN.md)
|
||||
|
||||
## 更新日志
|
||||
## Features
|
||||
|
||||
### 4.3.4
|
||||
- Internationalization, extracting translation fields from source code, loading language packs on demand
|
||||
- Dynamic permissions, different permissions for different menus
|
||||
- Elegant and beautiful, Ant Design system
|
||||
- Mock data, local data debugging
|
||||
|
||||
`2017-09-04`
|
||||
|
||||
- 更新[roadhog](https://github.com/sorrycc/roadhog)至`1.2.1`,修复闪屏问题。
|
||||
- 修复build css未压缩[#529](https://github.com/zuiidea/antd-admin/issues/529),classname未Hash[#477](https://github.com/zuiidea/antd-admin/issues/477)。
|
||||
- 更新登录成功使用router跳转[#479](https://github.com/zuiidea/antd-admin/issues/479)。
|
||||
## Usage
|
||||
|
||||
### 4.3.0
|
||||
|
||||
`2017-07-30`
|
||||
|
||||
- 更新[roadhog](https://github.com/sorrycc/roadhog)至`1.0.0-beta.7`,得益于`webpack@3.4`,编译速度不减。
|
||||
- 基于使用roadhog的dll插件,开发时编译耗时减半。
|
||||
- 新增打包时按项目版本号生成文件目录。[#449](https://github.com/zuiidea/antd-admin/issues/449)
|
||||
- 更新`eslint`,并适当修改了`.eslintrc`。
|
||||
|
||||
### 4.2.3
|
||||
|
||||
`2017-07-07`
|
||||
|
||||
- 新增用户按权限访问。[#384](https://github.com/zuiidea/antd-admin/issues/384)
|
||||
|
||||
### 4.2.2
|
||||
|
||||
`2017-06-01`
|
||||
|
||||
- 新增用户管理批量删除。[#320](https://github.com/zuiidea/antd-admin/issues/320)
|
||||
|
||||
### 4.2.1
|
||||
|
||||
`2017-05-12`
|
||||
|
||||
- 新增IconFont扩展方案,本地使用方案。[#270](https://github.com/zuiidea/antd-admin/issues/270) [Live](http://47.92.30.98:666/UIElement/iconfont)
|
||||
- 新增常见场景使用loading。 [dva-loading](https://github.com/dvajs/dva-loading)
|
||||
|
||||
### 4.2
|
||||
|
||||
`2017-04-28`
|
||||
|
||||
- 修改user相关API使用`Restful`风格。
|
||||
- 增加user页面多条件查询。[#266](https://github.com/zuiidea/antd-admin/issues/226)
|
||||
- 修复菜单默认高亮。[#201](https://github.com/zuiidea/antd-admin/issues/201)
|
||||
|
||||
[More Change Log](https://github.com/zuiidea/antd-admin/wiki/Change-Log)
|
||||
|
||||
## 开发构建
|
||||
|
||||
### 目录结构
|
||||
1. Clone project code.
|
||||
|
||||
```bash
|
||||
├── /dist/ # 项目输出目录
|
||||
├── /src/ # 项目源码目录
|
||||
│ ├── /public/ # 公共文件,编译时copy至dist目录
|
||||
│ ├── /components/ # UI组件及UI相关方法
|
||||
│ │ ├── skin.less # 全局样式
|
||||
│ │ └── vars.less # 全局样式变量
|
||||
│ ├── /routes/ # 路由组件
|
||||
│ │ └── app.js # 路由入口
|
||||
│ ├── /models/ # 数据模型
|
||||
│ ├── /services/ # 数据接口
|
||||
│ ├── /themes/ # 项目样式
|
||||
│ ├── /mock/ # 数据mock
|
||||
│ ├── /utils/ # 工具函数
|
||||
│ │ ├── config.js # 项目常规配置
|
||||
│ │ ├── menu.js # 菜单及面包屑配置
|
||||
│ │ ├── config.js # 项目常规配置
|
||||
│ │ ├── request.js # 异步请求函数
|
||||
│ │ └── theme.js # 项目需要在js中使用到样式变量
|
||||
│ ├── route.js # 路由配置
|
||||
│ ├── index.js # 入口文件
|
||||
│ └── index.html
|
||||
├── package.json # 项目信息
|
||||
├── .eslintrc # Eslint配置
|
||||
└── .roadhogrc.js # roadhog配置
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
cd my-project
|
||||
```
|
||||
|
||||
文件夹命名说明:
|
||||
|
||||
- components:组件(方法)为单位以文件夹保存,文件夹名组件首字母大写(如`DataTable`),方法首字母小写(如`layer`),文件夹内主文件与文件夹同名,多文件以`index.js`导出对象(如`./src/components/Layout`)。
|
||||
- routes:页面为单位以文件夹保存,文件夹名首字母小写(特殊除外,如`UIElement`),文件夹内主文件以`index.js`导出,多文件时可建立`components`文件夹(如`./src/routes/dashboard`),如果有子路由,依次按照路由层次建立文件夹(如`./src/routes/UIElement`)。
|
||||
|
||||
### 快速开始
|
||||
|
||||
克隆项目文件:
|
||||
2. Installation dependence.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git
|
||||
yarn install
|
||||
```
|
||||
|
||||
进入目录安装依赖:
|
||||
Or
|
||||
|
||||
```bash
|
||||
#开始前请确保没有安装roadhog、webpack到NPM全局目录
|
||||
npm i 或者 yarn install
|
||||
npm install
|
||||
```
|
||||
|
||||
开发:
|
||||
3. Start local server.
|
||||
|
||||
```bash
|
||||
npm run build:dll #第一次npm run dev时需运行此命令,使开发时编译更快
|
||||
npm run dev
|
||||
打开 http://localhost:8000
|
||||
npm run start
|
||||
```
|
||||
|
||||
构建:
|
||||
[详情](https://github.com/zuiidea/antd-admin/issues/269)
|
||||
4. After the startup is complete, open a browser and visit [http://localhost:7000](http://localhost:7000), If you need to change the startup port, you can configure it in the `.env` file.
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
|
||||
将会打包至dist/{version}目录 #package.json里version字段
|
||||
> More instructions at [documentation](https://doc.antd-admin.zuiidea.com)。
|
||||
|
||||
npm run build:new
|
||||
|
||||
将会打包至dist/{version增加1}目录 #package.json里version字段
|
||||
```
|
||||
## Browsers support
|
||||
|
||||
代码检测:
|
||||
Modern browsers.
|
||||
|
||||
```bash
|
||||
npm run lint
|
||||
```
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## FAQ
|
||||
## Contributing
|
||||
|
||||
- 项目打包后如何部署? [#269](https://github.com/zuiidea/antd-admin/issues/269)
|
||||
- 如何做权限管理? [#384](https://github.com/zuiidea/antd-admin/issues/384)
|
||||
- 如何使用mock.js模拟接口,怎么使用线上接口? [#348](https://github.com/zuiidea/antd-admin/issues/348)
|
||||
- 如何使用Iconfont,如何使用本地的svg图标? [#270](https://github.com/zuiidea/antd-admin/issues/270)
|
||||
- 怎么按版本打包,上线时不影响正在访问的用户? [#449](https://github.com/zuiidea/antd-admin/issues/449)
|
||||
- windows处理CRLF?[参考](http://blog.csdn.net/lysc_forever/article/details/42835203)
|
||||
We very much welcome your contribution, you can build together with us in the following ways :smiley:
|
||||
|
||||
```bash
|
||||
git config --global core.autocrlf false
|
||||
```
|
||||
|
||||
## 参考
|
||||
|
||||
用户列表:<https://github.com/dvajs/dva/tree/master/examples/user-dashboard>
|
||||
|
||||
dashboard设计稿:<https://dribbble.com/shots/3108122-Dashboard-Admin> (已征得作者同意)
|
||||
|
||||
## 截屏
|
||||
|
||||
web
|
||||
|
||||

|
||||
|
||||
移动
|
||||
|
||||

|
||||
- Use Ant Design Pro in your daily work.
|
||||
- Submit [GitHub issues](http://github.com/zuiidea/antd-admin/issues)s to report bugs or ask questions.
|
||||
- Propose [Pull Request](http://github.com/zuiidea/antd-admin/pulls) to improve our code.
|
||||
|
||||
|
Before Width: | Height: | Size: 3.7 MiB |
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 645 KiB |
@@ -0,0 +1,5 @@
|
||||
const config = {
|
||||
publicPath: 'https://cdn.antd-admin.zuiidea.com/',
|
||||
}
|
||||
|
||||
export default config
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* see more, https://umijs.org/config
|
||||
*/
|
||||
import lessToJs from 'less-vars-to-js'
|
||||
import fs from 'fs'
|
||||
import routes from './routes'
|
||||
import path from 'path'
|
||||
import proxy from './proxy'
|
||||
|
||||
const theme = lessToJs(
|
||||
fs.readFileSync(path.join(__dirname, '../src/themes/default.less'), 'utf8')
|
||||
)
|
||||
|
||||
const config = {
|
||||
hash: true,
|
||||
ignoreMomentLocale: true,
|
||||
targets: { ie: 11 },
|
||||
theme,
|
||||
proxy,
|
||||
routes,
|
||||
devtool: 'eval',
|
||||
mock: {
|
||||
exclude: ['utils/index'],
|
||||
},
|
||||
extraBabelPresets: ['@lingui/babel-preset-react'],
|
||||
extraBabelPlugins: [
|
||||
'macros',
|
||||
[
|
||||
'import',
|
||||
{
|
||||
libraryName: 'lodash',
|
||||
libraryDirectory: '',
|
||||
camel2DashComponentName: false,
|
||||
},
|
||||
'lodash',
|
||||
],
|
||||
[
|
||||
'import',
|
||||
{
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: 'css',
|
||||
},
|
||||
'antd',
|
||||
],
|
||||
[
|
||||
'import',
|
||||
{
|
||||
libraryName: '@ant-design',
|
||||
libraryDirectory: 'icons',
|
||||
camel2DashComponentName: false,
|
||||
},
|
||||
'ant-design-icons',
|
||||
],
|
||||
],
|
||||
chainWebpack: (memo) => {
|
||||
memo.module.rule('po').test(/\.po$/).use('po').loader('@lingui/loader')
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
@@ -0,0 +1,7 @@
|
||||
export default {
|
||||
'/api/v1/weather': {
|
||||
target: 'https://api.seniverse.com/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api/v1/weather': '/v3/weather' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
const routes = [
|
||||
{
|
||||
exact: false,
|
||||
path: '/',
|
||||
// component: '@/layouts/index', // comment due to double layout
|
||||
routes: [
|
||||
{ exact: true, path: '/login', component: '@/pages/login' },
|
||||
{ exact: true, path: '/user', component: '@/pages/user' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
export default routes
|
||||
@@ -0,0 +1,86 @@
|
||||
# API configuration
|
||||
|
||||
## Why
|
||||
|
||||
In the use of `redux` or `dva` projects, we often write functions like the following `service` layer to make the code structure clearer, but it is easy to see that we will write a lot of similar code in `antd -admin@5.0`, using the more concise configuration method to achieve the same function.
|
||||
|
||||
```javascript
|
||||
export async function login(data) {
|
||||
return request({
|
||||
url: '/api/v1/user/login',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration and use
|
||||
|
||||
In the `src/services/api.js` file, you will see the following configuration object, the object's key is used to call the function name, the object's value is the requested `url`, the default request method is `GET`, The format of the value of the other request mode object is `'method url'`.
|
||||
|
||||
```javascript
|
||||
export default {
|
||||
...
|
||||
queryUser: '/user/:id',
|
||||
queryUserList: '/users',
|
||||
updateUser: 'Patch /user/:id',
|
||||
createUser: 'POST /user/:id',
|
||||
removeUser: 'DELETE /user/:id',
|
||||
removeUserList: 'POST /users/delete',
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Used in other files
|
||||
|
||||
```javascript
|
||||
import { queryUser } from 'api'
|
||||
|
||||
// in the general file
|
||||
...
|
||||
queryUser(option).then(data => console.log(data))
|
||||
...
|
||||
|
||||
/ / Model file
|
||||
...
|
||||
yield call(queryUser, option)
|
||||
...
|
||||
```
|
||||
|
||||
## Method to realize
|
||||
|
||||
Refer to the `src/services/index.js` file to traverse the api configuration. Each property returns the corresponding encapsulated request function.
|
||||
|
||||
```javascript
|
||||
import request from 'utils/request'
|
||||
import { apiPrefix } from 'utils/config'
|
||||
|
||||
import api from './api'
|
||||
|
||||
const gen = params => {
|
||||
let url = apiPrefix + params
|
||||
let method = 'GET'
|
||||
|
||||
const paramsArray = params.split(' ')
|
||||
if (paramsArray.length === 2) {
|
||||
method = paramsArray[0]
|
||||
url = apiPrefix + paramsArray[1]
|
||||
}
|
||||
|
||||
return function(data) {
|
||||
return request({
|
||||
url,
|
||||
data,
|
||||
method,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const APIFunction = {}
|
||||
for (const key in api) {
|
||||
APIFunction[key] = gen(api[key])
|
||||
}
|
||||
|
||||
module.exports = APIFunction
|
||||
|
||||
```
|
||||
@@ -0,0 +1,83 @@
|
||||
<p align="center">
|
||||
<a href="http://github.com/zuiidea/antd-admin">
|
||||
<img alt="antd-admin" height="64" src="./_media/logo.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h1 align="center">AntD Admin</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
An excellent front-end solution for enterprise applications.
|
||||
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/umijs/umi)
|
||||
[](https://github.com/zuiidea/antd-admin/issues)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||

|
||||
[](https://github.com/zuiidea/antd-admin/pulls)
|
||||
[](https://gitter.im/antd-admin/antd-admin)
|
||||
|
||||
</div>
|
||||
|
||||
- Preview - [https://antd-admin.zuiidea.com](https://antd-admin.zuiidea.com)
|
||||
- Documentation - [https://doc.antd-admin.zuiidea.com](https://doc.antd-admin.zuiidea.com)
|
||||
- FAQ - [https://doc.antd-admin.zuiidea.com/#/faq](https://doc.antd-admin.zuiidea.com/#/faq)
|
||||
- ChangeLog - [https://doc.antd-admin.zuiidea.com/#/change-log](https://doc.antd-admin.zuiidea.com/#/change-log)
|
||||
|
||||
## Features
|
||||
|
||||
- Internationalization, extracting translation fields from source code, loading language packs on demand
|
||||
- Dynamic permissions, different permissions for different menus
|
||||
- Elegant and beautiful, Ant Design system
|
||||
- Mock data, local data debugging
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
1. Clone project code.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
cd my-project
|
||||
```
|
||||
|
||||
2. Installation dependence.
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Start local server.
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
4. After the startup is complete, open a browser and visit [http://localhost:7000](http://localhost:7000), If you need to change the startup port, you can configure it in the `.env` file.
|
||||
|
||||
|
||||
> More instructions at [documentation](https://doc.antd-admin.zuiidea.com)。
|
||||
|
||||
|
||||
## Browsers support
|
||||
|
||||
Modern browsers.
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## Contributing
|
||||
|
||||
We very much welcome your contribution, you can build together with us in the following ways :smiley:
|
||||
|
||||
- Use Ant Design Pro in your daily work.
|
||||
- Submit [GitHub issues](http://github.com/zuiidea/antd-admin/issues)s to report bugs or ask questions.
|
||||
- Propose [Pull Request](http://github.com/zuiidea/antd-admin/pulls) to improve our code.
|
||||
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,24 @@
|
||||
|
||||
<svg width="169px" height="141px" viewBox="0 0 169 141" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<linearGradient x1="54.0428975%" y1="4.39752391%" x2="54.0428975%" y2="108.456714%" id="linearGradient-1">
|
||||
<stop stop-color="#29CDFF" offset="0%"></stop>
|
||||
<stop stop-color="#148EFF" offset="62.3089445%"></stop>
|
||||
<stop stop-color="#0A60FF" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="50%" y1="14.2201464%" x2="50%" y2="113.263844%" id="linearGradient-2">
|
||||
<stop stop-color="#FA816E" offset="0%"></stop>
|
||||
<stop stop-color="#F74A5C" offset="65.9092442%"></stop>
|
||||
<stop stop-color="#F51D2C" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group" transform="translate(0.000000, -5.000000)">
|
||||
<rect id="Rectangle" fill="url(#linearGradient-1)" transform="translate(83.718923, 75.312358) rotate(-24.000000) translate(-83.718923, -75.312358) " x="68.7189234" y="0.312357954" width="30" height="150" rx="15"></rect>
|
||||
<rect id="Rectangle" fill="url(#linearGradient-1)" transform="translate(129.009910, 75.580213) rotate(-24.000000) translate(-129.009910, -75.580213) " x="114.00991" y="0.580212739" width="30" height="150" rx="15"></rect>
|
||||
<circle id="Oval" fill="url(#linearGradient-2)" cx="25" cy="120" r="25"></circle>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 194 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 199 KiB |
|
After Width: | Height: | Size: 124 KiB |
@@ -0,0 +1,12 @@
|
||||
- Getting started
|
||||
- [Quick Start](getting-started.md)
|
||||
- Customization
|
||||
- [Configuration](configuration.md)
|
||||
- [API Configuration](API-configuration.md)
|
||||
- [I18n](i18n.md)
|
||||
- [Layout](layout.md)
|
||||
- [Request](request.md)
|
||||
- Guide
|
||||
- [Deploy](deploy.md)
|
||||
- [Change Log](change-log.md)
|
||||
- [FAQ](faq.md)
|
||||
@@ -0,0 +1,50 @@
|
||||
## 5.0.0
|
||||
|
||||
#### Optimization
|
||||
|
||||
- Try to use decorators to simplify code writing and improve code readability.
|
||||
|
||||
- API configurization to simplify the way data is obtained.
|
||||
|
||||
- The files in `utils` are split and each has its own role.
|
||||
|
||||
- Simplify the `utils/request` file without special handling.
|
||||
|
||||
#### Specification
|
||||
|
||||
- Functions add comments, parameters, return values, etc., ambiguous code adds comments, canonical reference [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html#appendices-jsdoc-tag-reference).
|
||||
|
||||
- Semantic version number, specification participation [semantic version 2.0.0](https://semver.org/lang/zh-CN/).
|
||||
|
||||
- Static code checking, unified code style, will use `prettier`, `stylelint`, `eslint` specification code before code submission.
|
||||
|
||||
- Git submits information normalization, [git-commit-emoji-cn](https://github.com/liuchengxu/git-commit-emoji-cn).
|
||||
|
||||
- Based on the pre-defined routing of `Umi`, there is no need to write a routing configuration file.
|
||||
|
||||
- Use `React 16` new features such as `Fragment`, `Context`, `PureComponent`, etc.
|
||||
|
||||
#### Features
|
||||
|
||||
- Support internationalization, extract source fields from source code, load language packs on demand, and automatically translate online.
|
||||
|
||||
- Support for the introduction `lodash` functions on demand.
|
||||
|
||||
- Support multiple layouts, which rules can be used according to the rules.
|
||||
|
||||
- Support Antd Admin to automatically compile and deploy on Travis.
|
||||
|
||||
- Generate a documentation website using `Docsify`.
|
||||
|
||||
|
||||
#### Style
|
||||
|
||||
- Added Antd Admin standalone Logo.
|
||||
|
||||
- Rewrite the overall layout component, optimize the menu, automatic breadcrumb navigation, menu auto-expansion and other logic.
|
||||
|
||||
- The mobile menu is changed to drawer.
|
||||
|
||||
#### Other
|
||||
|
||||
- Discard components such as `IconFont`, `Search`, `DataTable` because they are well supported and replaceable in `Antd`.
|
||||
@@ -0,0 +1,102 @@
|
||||
# Configuration
|
||||
|
||||
You can do some custom configuration in `/src/utils/config.js`:
|
||||
|
||||
## siteName
|
||||
|
||||
- Type `String`
|
||||
|
||||
Configure the site name, apply it to the login box, and display the title text at the top of the sidebar.
|
||||
|
||||
## copyright
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Configure the copyright notice to apply to the login page, at the bottom of the `Primary` layout.
|
||||
|
||||
## logoPath
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Configure the site logo to apply to the login box and the Logo display at the top of the sidebar.
|
||||
|
||||
## apiPrefix
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Configure the prefix of the interface in the project. The interface related documents can be viewed [API configuration](API-configuration.md)
|
||||
|
||||
## fixedHeader
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Under the `Primary` layout, whether the top of the page is fixed when scrolling。
|
||||
|
||||
## layouts
|
||||
|
||||
- Type: `Array`
|
||||
|
||||
Configuration? Which routes use which layout, unspecified route uses the default layout `Public`, the project currently has `Primary` and `Public` layouts,
|
||||
The default configuration is as follows:
|
||||
|
||||
```javascript
|
||||
layouts: [
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exclude: [/(\/(en|zh))*\/login/],
|
||||
},
|
||||
],
|
||||
```
|
||||
|
||||
The object properties for each layout are as follows:
|
||||
|
||||
- `name` - The name of the layout;
|
||||
|
||||
- `include` - Specifies a list of routing rules that use this layout, which can be a regular expression or a string;
|
||||
|
||||
- `exclude` - Specifies a list of routing rules that do not use this layout, which can be a regular expression or a string.
|
||||
|
||||
> Note: `exclude` takes precedence over `include`, and the layout previous it has a higher priority than the behind layout. The development process may need to be combined with the layout in the `src/layouts` directory. For details, see [Using Layout](./layout.md).
|
||||
|
||||
## i18n
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
Configure internationalization, the default configuration is as follows:
|
||||
|
||||
```javascript
|
||||
i18n: {
|
||||
languages: [
|
||||
{
|
||||
key: 'en',
|
||||
title: 'English',
|
||||
flag: '/america.svg',
|
||||
},
|
||||
{
|
||||
key: 'zh',
|
||||
title: '中文',
|
||||
flag: '/china.svg',
|
||||
},
|
||||
],
|
||||
defaultLanguage: 'en',
|
||||
}
|
||||
```
|
||||
|
||||
### i18n.languages
|
||||
|
||||
- Type: `Array`
|
||||
|
||||
Specify which languages the app supports, and the object properties for each language are as follows:
|
||||
|
||||
- `key` - The `key` of the language is applied to the page url to distinguish the language, and also corresponds to the language package folder name in the `src/locales` directory;
|
||||
|
||||
- `title` - The name of the language, at the bottom of the login page, at the top of the `Primary` layout, the language switch is displayed;
|
||||
|
||||
- `flag` - The path of the flag icon of the language, the language switching display at the top of the `Primary` layout.
|
||||
|
||||
### i18n.defaultLanguage
|
||||
|
||||
- Type: `String`
|
||||
|
||||
Configure the default language.
|
||||
@@ -0,0 +1,113 @@
|
||||
# Deploy
|
||||
|
||||
After the development is completed and verified in the development environment, it needs to be deployed to our users.
|
||||
|
||||

|
||||
|
||||
## Build
|
||||
|
||||
First execute the following command,
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
After a few seconds, the output should look like this:
|
||||
|
||||
```bash
|
||||
> antd-admin@5.0.0-beta build /Users/zuiidea/web/antd-admin
|
||||
> umi build
|
||||
|
||||
[21:13:17] webpack compiled in 43s 868ms
|
||||
DONE Compiled successfully in 43877ms 21:13:17
|
||||
|
||||
File sizes after gzip:
|
||||
|
||||
1.3 MB dist/vendors.async.js
|
||||
308.21 KB dist/umi.js
|
||||
45.49 KB dist/vendors.chunk.css
|
||||
36.08 KB dist/p__chart__highCharts__index.async.js
|
||||
33.53 KB dist/p__user__index.async.js
|
||||
22.36 KB dist/p__chart__ECharts__index.async.js
|
||||
4.21 KB dist/p__dashboard__index.async.js
|
||||
4.06 KB dist/umi.css
|
||||
...
|
||||
```
|
||||
|
||||
The `build` command will package all resources, including JavaScript, CSS, web fonts, images, html, and more. You can find these files in the `dist/` directory.
|
||||
|
||||
> If you have requirements for using HashHistory , deploying html to non-root directories, statics, etc., check out [Umi Deployment] (https://umijs.org/en/guide/deploy.html).
|
||||
|
||||
## Local verification
|
||||
|
||||
|
||||
Local verification can be done via `serve` before publishing.
|
||||
|
||||
```
|
||||
$ yarn global add serve
|
||||
$ serve ./dist
|
||||
|
||||
Serving!
|
||||
|
||||
- Local: http://localhost:5000
|
||||
- On Your Network: http://{Your IP}:5000
|
||||
|
||||
Copied local address to clipboard!
|
||||
|
||||
```
|
||||
|
||||
Access [http://localhost:5000](http://localhost:5000), under normal circumstances, it should be consistent with `npm start` (The API may not get the correct data).
|
||||
|
||||
|
||||
## Deploy
|
||||
|
||||
Next, we can upload the static file to the server. If you use Nginx as the Web server, you can configure it in `ngnix.conf`:
|
||||
```
|
||||
server
|
||||
{
|
||||
listen 80;
|
||||
# Specify an accessible domain name
|
||||
server_name antd-admin.zuiidea.com;
|
||||
# The directory where the compiled files are stored
|
||||
root /home/www/antd-admin/dist;
|
||||
|
||||
# Proxy server interface to avoid cross-domain
|
||||
location /api {
|
||||
proxy_pass http://localhost:7000/api;
|
||||
}
|
||||
|
||||
Because the front end uses BrowserHistory, it will route backback to index.html
|
||||
location / {
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Restart the web server and access [http://antd-admin.zuiidea.com](http://antd-admin.zuiidea.com) , You will see the correct page.
|
||||
|
||||
```bash
|
||||
nginx -s reload
|
||||
```
|
||||
|
||||
Similarly, if you use Caddy as a web server, you can do this in `Caddyfile`:
|
||||
|
||||
```
|
||||
antd-admin.zuiidea.com {
|
||||
gzip
|
||||
root /home/www/antd-admin/dist
|
||||
proxy /api http://localhost:7000
|
||||
|
||||
rewrite {
|
||||
if {path} not_match ^/api
|
||||
to {path} {path}/ /
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
antd-admin.zuiidea.com/public {
|
||||
gzip
|
||||
root /home/www/antd-admin/dist/static/public
|
||||
}
|
||||
|
||||
```
|
||||
@@ -0,0 +1,9 @@
|
||||
# FAQ
|
||||
|
||||
Most asked
|
||||
|
||||
## create new page
|
||||
|
||||
1. just copy a page in /src/pages (route here auto generated by [umi](https://umijs.org/guide/router.html#basic-routing))
|
||||
2. modify namespace/pathToRegexp in model.js
|
||||
3. modify mock route.js to add a route
|
||||
@@ -0,0 +1,73 @@
|
||||
# Quick Start
|
||||
|
||||
> Before delving into Ant Design React, a good knowledge base of [React](http://facebook.github.io/react/) 、 [ES2015+](http://es6.ruanyifeng.com/) 、 [Antd Design](https://ant.design/docs/react/introduce-cn) . Learn about [UmiJS](https://umijs.org/) , [Dva](http://github.com/dvajs/dva) . And properly installed and configured [Node.js](https://nodejs.org/) v8 or above, [Git](https://git-scm.com/). It would be helpful if you have pre-existing knowledge on those.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
cd my-project
|
||||
```
|
||||
|
||||
## Scaffolding
|
||||
|
||||
The project layout is as follows:
|
||||
|
||||
```bash
|
||||
├── dist/ # Default build output directory
|
||||
├── mock/ # Mock files
|
||||
├── public/ # Static resource
|
||||
├── src/ # Source code
|
||||
│ ├── components/ # Components
|
||||
│ ├── e2e/ # Integrated Test Case
|
||||
│ ├── layouts/ # Common Layouts
|
||||
│ ├── locales/ # i18n resources
|
||||
│ ├── models/ # Global dva Model
|
||||
│ ├── pages/ # Sub-pages and templates
|
||||
│ ├── services/ # Backend Services
|
||||
│ │ ├── api.js # API configuration
|
||||
│ │ └── index.js # API export
|
||||
│ ├── themes/ # Themes
|
||||
│ │ ├── default.less # Less variable
|
||||
│ │ ├── index.less # Global style
|
||||
│ │ ├── mixin.less # Less mixin
|
||||
│ │ └── vars.less # Less variable and mixin
|
||||
│ ├── utils/ # Utility
|
||||
│ │ ├── config.js # Application configuration
|
||||
│ │ ├── constant.js # Static constant
|
||||
│ │ ├── index.js # Utility methods
|
||||
│ │ ├── request.js # Request function(axios)
|
||||
│ │ └── theme.js # Style variables used in js
|
||||
├── .editorconfig
|
||||
├── .env
|
||||
├── .eslintrc
|
||||
├── .gitignore
|
||||
├── .prettierignore
|
||||
├── .prettierrc
|
||||
├── .stylelintrc.json
|
||||
├── .travis.yml
|
||||
└── .umirc.js
|
||||
└── package.json
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
1. Install Dependencies.
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
2. Start local server.
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
3. After the startup is complete, open a browser and visit [http://localhost:7000](http://localhost:7000), If you need to change the startup port, you can configure it in the `.env` file.
|
||||
@@ -0,0 +1,75 @@
|
||||
# globalization
|
||||
|
||||
## Add language
|
||||
|
||||
Take Japanese as an example.
|
||||
|
||||

|
||||
|
||||
1. Add a language pack local file, `ja` is the Japanese language code, and a list of languages that support translation [有道智云](http://ai.youdao.com/docs/doc-trans-api.s#p05), the `src/locales/ja/messages.json` file will be generated after running the following command.
|
||||
|
||||
```bash
|
||||
npm run add-locale ja
|
||||
```
|
||||
|
||||
2. Extract the fields in the code that need to be translated, ie `<Trans>?message</Trans>`, `` t`message `` in the `message` field, run the following command after `src/locales/ja /messages.json` will appear after the extracted field configuration.
|
||||
|
||||
```bash
|
||||
npm run extract
|
||||
```
|
||||
|
||||
You will see the following information:
|
||||
|
||||
```bash
|
||||
Catalog statistics:
|
||||
┌─────────────┬─────────────┬─────────┐
|
||||
│ Language │ Total count │ Missing │
|
||||
├─────────────┼─────────────┼─────────┤
|
||||
│ en (source) │ 52 │ - │
|
||||
│ ja │ 52 │ 52 │
|
||||
│ zh │ 52 │ 0 │
|
||||
└─────────────┴─────────────┴─────────┘
|
||||
```
|
||||
|
||||
3. At the same time, we have added the relevant configuration in `src/utils/config.js`.
|
||||
|
||||
```javascript
|
||||
{
|
||||
...
|
||||
i18n: {
|
||||
languages: [
|
||||
...
|
||||
{
|
||||
key:'ja',
|
||||
title: '日本語',
|
||||
flag: '/japanese.svg',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
> Routing related effects, after the configuration `npm run start` takes effect after restart.
|
||||
|
||||
4. Use the built-in commands for automatic translation. You will see the translated configuration in `src/locales/ja/messages.json`.
|
||||
|
||||
```bash
|
||||
npm run trans:only
|
||||
```
|
||||
|
||||
You will see the following information:
|
||||
|
||||
```bash
|
||||
start: en -> ja
|
||||
...
|
||||
youdao: en -> ja: Unpublished -> 未発表
|
||||
youdao: en -> ja: Update -> 更新
|
||||
youdao: en -> ja: Update User -> ユーザーの更新
|
||||
youdao: en -> ja: Username -> 名
|
||||
...
|
||||
All translations have been completed.
|
||||
```
|
||||
|
||||
> `npm run trans` will execute `npm run extract` and `npm run trans:only` in order.
|
||||
|
||||
5. Finally, you can adjust the inaccurate fields in `src/locales/ja/messages.json`. Start the development mode `npm run start`, open [http://localhost:7000/ja/login](http://localhost:7000/ja/login) and you will see the Japanese version of the app.
|
||||
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>antd-admin - An admin dashboard application demo built upon Ant Design and UmiJS</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="description" content="An admin dashboard application demo built upon Ant Design and UmiJS">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
|
||||
<link rel="icon" href="/_media/favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav data-cloak class="app-nav">
|
||||
<a href="/">En</a>
|
||||
<a href="#/zh-cn/">中文</a>
|
||||
</nav>
|
||||
<div id="app">Loading...</div>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
name: 'AntD Admin',
|
||||
loadSidebar: true,
|
||||
maxLevel: 3,
|
||||
subMaxLevel: 3,
|
||||
auto2top: true,
|
||||
autoHeader: true,
|
||||
repo: 'zuiidea/antd-admin',
|
||||
themeColor: '#1890ff',
|
||||
search: {
|
||||
paths: 'auto',
|
||||
placeholder: {
|
||||
'/zh-cn/': '搜索',
|
||||
'/': 'Type to search'
|
||||
},
|
||||
|
||||
noData: {
|
||||
'/zh-cn/': '找不到结果',
|
||||
'/': 'No Results'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (typeof navigator.serviceWorker !== 'undefined') {
|
||||
// navigator.serviceWorker.register('sw.js')
|
||||
// }
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/emoji.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.min.js"></script>
|
||||
<script src="//unpkg.com/docsify-copy-code"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,60 @@
|
||||
# Layout
|
||||
|
||||
## Add a new layout
|
||||
|
||||
Take a new layout named `secondary` as an example to make the route starting with `secondary` use this layout.
|
||||
|
||||
1. Add related configuration in `src/utils/config.js`. For details, please refer to [layouts](/configuration?id=layouts).
|
||||
|
||||
```javascript
|
||||
layouts: [
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
{
|
||||
name: 'secondary',
|
||||
include: [/(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
],
|
||||
```
|
||||
|
||||
2. Add the `secondary` layout component to the `src/layouts/BaseLayout.js` file.
|
||||
|
||||
```javascript
|
||||
import SecondaryLayout from './SecondaryLayout'
|
||||
|
||||
const LayoutMap = {
|
||||
primary: PrimaryLayout,
|
||||
public: PublicLayout,
|
||||
secondary: SecondaryLayout,
|
||||
}
|
||||
```
|
||||
|
||||
3. Add the `SecondaryLayout.js` file to the `src/layouts/` directory.
|
||||
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Secondary</h1>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
4. Add a `secondary/index.js` file to the `src/pages/` directory.
|
||||
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
Return <div>Secondary page Content</div>
|
||||
}
|
||||
```
|
||||
|
||||
5. Finally, start the development mode `npm run start`, open [http://localhost:7000/secondary/](http://localhost:7000/secondary/) and you will see the page for the `secondary` layout.
|
||||
@@ -0,0 +1,22 @@
|
||||
# HTTP request
|
||||
|
||||
this project use axios for http service, file located in src/utils/request.js
|
||||
|
||||
## Custom Header
|
||||
|
||||
As for privilege access or modify cookie, you could add header param by yourself
|
||||
|
||||
```
|
||||
axios.defaults.headers.common['Authorization'] = 'token'
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```
|
||||
axios.interceptors.request.use(function (config) {
|
||||
config.headers.token = window.localStorage.getItem('token');
|
||||
return config;
|
||||
}, function (error) {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,83 @@
|
||||
/* ===========================================================
|
||||
* docsify sw.js
|
||||
* ===========================================================
|
||||
* Copyright 2016 @huxpro
|
||||
* Licensed under Apache 2.0
|
||||
* Register service worker.
|
||||
* ========================================================== */
|
||||
|
||||
const RUNTIME = 'docsify'
|
||||
const HOSTNAME_WHITELIST = [
|
||||
self.location.hostname,
|
||||
'fonts.gstatic.com',
|
||||
'fonts.googleapis.com',
|
||||
'unpkg.com'
|
||||
]
|
||||
|
||||
// The Util Function to hack URLs of intercepted requests
|
||||
const getFixedUrl = (req) => {
|
||||
var now = Date.now()
|
||||
var url = new URL(req.url)
|
||||
|
||||
// 1. fixed http URL
|
||||
// Just keep syncing with location.protocol
|
||||
// fetch(httpURL) belongs to active mixed content.
|
||||
// And fetch(httpRequest) is not supported yet.
|
||||
url.protocol = self.location.protocol
|
||||
|
||||
// 2. add query for caching-busting.
|
||||
// Github Pages served with Cache-Control: max-age=600
|
||||
// max-age on mutable content is error-prone, with SW life of bugs can even extend.
|
||||
// Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
|
||||
// Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
|
||||
if (url.hostname === self.location.hostname) {
|
||||
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now
|
||||
}
|
||||
return url.href
|
||||
}
|
||||
|
||||
/**
|
||||
* @Lifecycle Activate
|
||||
* New one activated when old isnt being used.
|
||||
*
|
||||
* waitUntil(): activating ====> activated
|
||||
*/
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(self.clients.claim())
|
||||
})
|
||||
|
||||
/**
|
||||
* @Functional Fetch
|
||||
* All network requests are being intercepted here.
|
||||
*
|
||||
* void respondWith(Promise<Response> r)
|
||||
*/
|
||||
self.addEventListener('fetch', event => {
|
||||
// Skip some of cross-origin requests, like those for Google Analytics.
|
||||
if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
|
||||
// Stale-while-revalidate
|
||||
// similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
|
||||
// Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
|
||||
const cached = caches.match(event.request)
|
||||
const fixedUrl = getFixedUrl(event.request)
|
||||
const fetched = fetch(fixedUrl, { cache: 'no-store' })
|
||||
const fetchedCopy = fetched.then(resp => resp.clone())
|
||||
|
||||
// Call respondWith() with whatever we get first.
|
||||
// If the fetch fails (e.g disconnected), wait for the cache.
|
||||
// If there’s nothing in cache, wait for the fetch.
|
||||
// If neither yields a response, return offline pages.
|
||||
event.respondWith(
|
||||
Promise.race([fetched.catch(_ => cached), cached])
|
||||
.then(resp => resp || fetched)
|
||||
.catch(_ => { /* eat any errors */ })
|
||||
)
|
||||
|
||||
// Update the cache with the version we fetched (only for ok status)
|
||||
event.waitUntil(
|
||||
Promise.all([fetchedCopy, caches.open(RUNTIME)])
|
||||
.then(([response, cache]) => response.ok && cache.put(event.request, response))
|
||||
.catch(_ => { /* eat any errors */ })
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,86 @@
|
||||
# 接口配置
|
||||
|
||||
## 为什么
|
||||
|
||||
在使用了`redux`或者`dva`项目中,我们经常会写类似下面的`service`层的函数,使代码结构更清晰,但是很容易看出,我们会写很多相似的代码,在`antd-admin@5.0`中,使用了更加简洁的配置方式实现了相同的功能。
|
||||
|
||||
```javascript
|
||||
export async function login(data) {
|
||||
return request({
|
||||
url: '/api/v1/user/login',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## 配置和使用
|
||||
|
||||
在`src/services/api.js`文件中,你会看到如下配置对象,对象的键用于调用时的函数名称,对象的值为请求的`url`,默认请求方式为`GET`,如果是其他请求方式对象的值的格式则为`'method url'`。
|
||||
|
||||
```javascript
|
||||
export default {
|
||||
...
|
||||
queryUser: '/user/:id',
|
||||
queryUserList: '/users',
|
||||
updateUser: 'Patch /user/:id',
|
||||
createUser: 'POST /user/:id',
|
||||
removeUser: 'DELETE /user/:id',
|
||||
removeUserList: 'POST /users/delete',
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
在其他文件中使用
|
||||
|
||||
```javascript
|
||||
import { queryUser } from 'api'
|
||||
|
||||
// 一般文件中
|
||||
...
|
||||
queryUser(option).then(data => console.log(data))
|
||||
...
|
||||
|
||||
// model文件中
|
||||
...
|
||||
yield call(queryUser, option)
|
||||
...
|
||||
```
|
||||
|
||||
## 实现方式
|
||||
|
||||
参考`src/services/index.js`文件,对api配置进行遍历,每个属性都返回对应的封装后的request函数。
|
||||
|
||||
```javascript
|
||||
import request from 'utils/request'
|
||||
import { apiPrefix } from 'utils/config'
|
||||
|
||||
import api from './api'
|
||||
|
||||
const gen = params => {
|
||||
let url = apiPrefix + params
|
||||
let method = 'GET'
|
||||
|
||||
const paramsArray = params.split(' ')
|
||||
if (paramsArray.length === 2) {
|
||||
method = paramsArray[0]
|
||||
url = apiPrefix + paramsArray[1]
|
||||
}
|
||||
|
||||
return function(data) {
|
||||
return request({
|
||||
url,
|
||||
data,
|
||||
method,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const APIFunction = {}
|
||||
for (const key in api) {
|
||||
APIFunction[key] = gen(api[key])
|
||||
}
|
||||
|
||||
module.exports = APIFunction
|
||||
|
||||
```
|
||||
@@ -0,0 +1,84 @@
|
||||
<p align="center">
|
||||
<a href="http://github.com/zuiidea/antd-admin">
|
||||
<img alt="antd-admin" height="64" src="../_media/logo.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h1 align="center">AntD Admin</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
一套优秀的中后台前端解决方案
|
||||
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/umijs/umi)
|
||||
[](https://github.com/zuiidea/antd-admin/issues)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||

|
||||
[](https://github.com/zuiidea/antd-admin/pulls)
|
||||
[](https://gitter.im/antd-admin/antd-admin)
|
||||
|
||||
</div>
|
||||
|
||||
- 在线演示 - [https://antd-admin.zuiidea.com](https://antd-admin.zuiidea.com)
|
||||
- 使用文档 - [https://doc.antd-admin.zuiidea.com/#/zh-cn/](https://doc.antd-admin.zuiidea.com/#/zh-cn/)
|
||||
- 常见问题 - [https://doc.antd-admin.zuiidea.com/#/zh-cn/faq](https://doc.antd-admin.zuiidea.com/#/zh-cn/faq)
|
||||
- 更新日志 - [https://doc.antd-admin.zuiidea.com/#/zh-cn/change-log](https://doc.antd-admin.zuiidea.com/#/zh-cn/change-log)
|
||||
|
||||
## 特性
|
||||
|
||||
- 国际化,源码中抽离翻译字段,按需加载语言包
|
||||
- 动态权限,不同权限对应不同菜单
|
||||
- 优雅美观,Ant Design 设计体系
|
||||
- Mock 数据,本地数据调试
|
||||
|
||||
|
||||
## 使用
|
||||
|
||||
1. 下载项目代码。
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
cd my-project
|
||||
```
|
||||
|
||||
2. 进入目录安装依赖,国内用户推荐使用 [cnpm](https://cnpmjs.org) 进行加速。
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. 启动本地服务器。
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
4. 启动完成后打开浏览器访问 [http://localhost:7000](http://localhost:7000),如果需要更改启动端口,可在 `.env` 文件中配置。
|
||||
|
||||
|
||||
> 更多信息请参考 [使用文档](https://doc.antd-admin.zuiidea.com/#/zh-cn/)。
|
||||
|
||||
|
||||
## 支持环境
|
||||
|
||||
现代浏览器。
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## 参与贡献
|
||||
|
||||
我们非常欢迎你的贡献,你可以通过以下方式和我们一起共建 :smiley:
|
||||
- 在你的公司或个人项目中使用 AntD Admin。
|
||||
- 通过 [Issue](http://github.com/zuiidea/antd-admin/issues) 报告 bug 或进行咨询。
|
||||
- 提交 [Pull Request](http://github.com/zuiidea/antd-admin/pulls) 改进代码。
|
||||
|
||||
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。
|
||||
@@ -0,0 +1,11 @@
|
||||
- 入门
|
||||
- [快速上手](zh-cn/getting-started.md)
|
||||
- 定制化
|
||||
- [配置项](zh-cn/configuration.md)
|
||||
- [接口配置](zh-cn/API-configuration.md)
|
||||
- [国际化](zh-cn/i18n.md)
|
||||
- [布局](zh-cn/layout.md)
|
||||
- [http 请求](zh-cn/request.md)
|
||||
- 指南
|
||||
- [部署](zh-cn/deploy.md)
|
||||
- [更新日志](zh-cn/change-log.md)
|
||||
@@ -0,0 +1,52 @@
|
||||
## 5.0.0
|
||||
|
||||
#### 优化
|
||||
|
||||
- 尽量使用修饰器,简化代码编写,提高代码可读性。
|
||||
|
||||
- API 配置化,简化获取数据方式。
|
||||
|
||||
- `utils` 内文件拆分,各司其职。
|
||||
|
||||
- 简化`utils/request`文件,不做特殊处理。
|
||||
|
||||
#### 规范
|
||||
|
||||
- 函数添加描述、参数、返回值等注释,含糊不清的代码增加注释,规范参考 [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html#appendices-jsdoc-tag-reference)。
|
||||
|
||||
- 语义化版本号,规范参加 [语义化版本 2.0.0](https://semver.org/lang/zh-CN/)。
|
||||
|
||||
- 静态代码检查,统一代码风格,代码提交前将会使用 `prettier`、`stylelint`、`eslint` 规范代码。
|
||||
|
||||
- Git 提交信息规范化,[git-commit-emoji-cn](https://github.com/liuchengxu/git-commit-emoji-cn)。
|
||||
|
||||
- 基于 `Umi` 的约定式路由,无需再写路由配置文件。
|
||||
|
||||
- 使用 `React 16` 新特性,如 `Fragment`、`Context`、 `PureComponent`等。
|
||||
|
||||
#### 功能
|
||||
|
||||
- 支持国际化,源码中抽离翻译字段,按需加载语言包,自动在线翻译。
|
||||
|
||||
- 支持按需引入 `lodash` 函数。
|
||||
|
||||
- 支持多布局,可根据规则规定哪些路由使用哪种布局。
|
||||
|
||||
- 支持 Antd Admin 在 Travis 上自动编译和部署。
|
||||
|
||||
- 使用 `Docsify` 生成文档网站。
|
||||
|
||||
|
||||
#### 样式
|
||||
|
||||
- 新增 Antd Admin 独立 Logo。
|
||||
|
||||
- 重写整体布局组件,优化菜单、面包屑导航自动高亮,菜单自动展开等逻辑。
|
||||
|
||||
- 移动端菜单更改为抽屉式。
|
||||
|
||||
#### 其他
|
||||
|
||||
- 废弃 `IconFont`、 `Search`、`DataTable`等组件,因为在 `Antd` 中有很好的支持和可替代的。
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# 配置项
|
||||
|
||||
你可以在 `/src/utils/config.js` 里做一些自定义配置:
|
||||
|
||||
## siteName
|
||||
|
||||
- 类型: `String`
|
||||
|
||||
配置站点名称,应用到登录框,侧边栏顶部的标题文字显示。
|
||||
|
||||
## copyright
|
||||
|
||||
- 类型: `String`
|
||||
|
||||
配置版权声明,应用到登录页、`Primay`布局底部。
|
||||
|
||||
## logoPath
|
||||
|
||||
- 类型: `String`
|
||||
|
||||
配置站点 Logo,应用到登录框,侧边栏顶部的 Logo 显示。
|
||||
|
||||
## apiPrefix
|
||||
|
||||
- 类型: `String`
|
||||
|
||||
配置项目中接口的前缀,接口相关文档可查看 [接口配置](API-configuration.md)
|
||||
|
||||
## fixedHeader
|
||||
|
||||
- 类型: `String`
|
||||
|
||||
在`Primary`布局下,页面滚动时是否固定顶部。
|
||||
|
||||
## layouts
|
||||
|
||||
- 类型: `Array`
|
||||
|
||||
配置哪些路由使用哪种布局,未指定路由使用默认布局 `Public`,项目中目前有 `Primary` 和 `Public` 两种布局,
|
||||
默认配置如下:
|
||||
|
||||
```javascript
|
||||
layouts: [
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exclude: [/(\/(en|zh))*\/login/],
|
||||
},
|
||||
],
|
||||
```
|
||||
|
||||
每种布局的对象属性如下:
|
||||
|
||||
- `name` - 布局的名称;
|
||||
|
||||
- `include` - 指定使用该布局的路由规则列表,规则可为正则表达式或者字符串;
|
||||
|
||||
- `exclude` - 指定不使用该布局的路由规则列表,规则可为正则表达式或者字符串。
|
||||
|
||||
> 注意:`exclude` 优先级高于 `include`,前面的布局优先级高于后面的布局。开发过程中可能需要结合`src/layouts`目录下的布局使用,具体方法可查看 [使用布局](./layout.md)。
|
||||
|
||||
## i18n
|
||||
|
||||
- 类型: `Object`
|
||||
|
||||
配置国际化,默认配置如下:
|
||||
|
||||
```javascript
|
||||
i18n: {
|
||||
languages: [
|
||||
{
|
||||
key: 'en',
|
||||
title: 'English',
|
||||
flag: '/america.svg',
|
||||
},
|
||||
{
|
||||
key: 'zh',
|
||||
title: '中文',
|
||||
flag: '/china.svg',
|
||||
},
|
||||
],
|
||||
defaultLanguage: 'en',
|
||||
}
|
||||
```
|
||||
|
||||
### i18n.languages
|
||||
|
||||
- 类型: `Array`
|
||||
|
||||
指定应用支持哪些语言,每种语言的对象属性如下:
|
||||
|
||||
- `key` - 语言的`key`,应用到页面 url 上以区分语言,也对应 `src/locales` 目录下的语言包文件夹名;
|
||||
|
||||
- `title` - 语言名称,在登录页底部、`Primay` 布局顶部语言切换显示;
|
||||
|
||||
- `flag` - 语言的国旗图标的路径,在 `Primay` 布局顶部语言切换显示。
|
||||
|
||||
### i18n.defaultLanguage
|
||||
|
||||
- 类型: `String`
|
||||
|
||||
配置默认语言。
|
||||
@@ -0,0 +1,114 @@
|
||||
# 部署
|
||||
|
||||
完成开发并且在开发环境验证之后,就需要部署给我们的用户了。
|
||||
|
||||

|
||||
|
||||
## 构建
|
||||
|
||||
先执行下面的命令,
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
几秒后,输出应该如下:
|
||||
|
||||
```bash
|
||||
> antd-admin@5.0.0-beta build /Users/zuiidea/web/antd-admin
|
||||
> umi build
|
||||
|
||||
[21:13:17] webpack compiled in 43s 868ms
|
||||
DONE Compiled successfully in 43877ms 21:13:17
|
||||
|
||||
File sizes after gzip:
|
||||
|
||||
1.3 MB dist/vendors.async.js
|
||||
308.21 KB dist/umi.js
|
||||
45.49 KB dist/vendors.chunk.css
|
||||
36.08 KB dist/p__chart__highCharts__index.async.js
|
||||
33.53 KB dist/p__user__index.async.js
|
||||
22.36 KB dist/p__chart__ECharts__index.async.js
|
||||
4.21 KB dist/p__dashboard__index.async.js
|
||||
4.06 KB dist/umi.css
|
||||
...
|
||||
```
|
||||
|
||||
`build` 命令会打包所有的资源,包含 JavaScript, CSS, web fonts, images, html 等。你可以在 `dist/` 目录下找到这些文件。
|
||||
|
||||
> 如果有使用 HashHistory 、 部署 html 到非根目录、静态化等需求,请查看[Umi 部署](https://umijs.org/zh/guide/deploy.html)。
|
||||
|
||||
## 本地验证
|
||||
|
||||
|
||||
发布之前,可以通过 `serve` 做本地验证,
|
||||
|
||||
```
|
||||
$ yarn global add serve
|
||||
$ serve ./dist
|
||||
|
||||
Serving!
|
||||
|
||||
- Local: http://localhost:5000
|
||||
- On Your Network: http://{Your IP}:5000
|
||||
|
||||
Copied local address to clipboard!
|
||||
|
||||
```
|
||||
|
||||
访问 [http://localhost:5000](http://localhost:5000),正常情况下法应该是和 `npm start` 一致的(接口可能无法获取到正确数据)。
|
||||
|
||||
|
||||
## 部署
|
||||
|
||||
接下来,我们可以把静态文件上传到服务器,如果使用 Nginx 作为 Web server,你可以在 `ngnix.conf` 中这样配置:
|
||||
|
||||
```
|
||||
server
|
||||
{
|
||||
listen 80;
|
||||
# 指定可访问的域名
|
||||
server_name antd-admin.zuiidea.com;
|
||||
# 编译后的文件存放的目录
|
||||
root /home/www/antd-admin/dist;
|
||||
|
||||
# 代理服务端接口,避免跨域
|
||||
location /api {
|
||||
proxy_pass http://localhost:7000/api;
|
||||
}
|
||||
|
||||
# 因为前端使用了BrowserHistory,所以将路由 fallback 到 index.html
|
||||
location / {
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
重启 Web server,访问 [http://antd-admin.zuiidea.com](http://antd-admin.zuiidea.com) ,你将看到正确的页面。
|
||||
|
||||
```bash
|
||||
nginx -s reload
|
||||
```
|
||||
|
||||
类似的,如果你使用 Caddy 作为 Web server,你可以在 `Caddyfile` 中这样配置:
|
||||
|
||||
```
|
||||
antd-admin.zuiidea.com {
|
||||
gzip
|
||||
root /home/www/antd-admin/dist
|
||||
proxy /api http://localhost:7000
|
||||
|
||||
rewrite {
|
||||
if {path} not_match ^/api
|
||||
to {path} {path}/ /
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
antd-admin.zuiidea.com/public {
|
||||
gzip
|
||||
root /home/www/antd-admin/dist/static/public
|
||||
}
|
||||
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
# 问题集锦
|
||||
|
||||
## 新建页面
|
||||
|
||||
1. 直接从/src/pages复制一个page (会自动创建路由[umi](https://umijs.org/zh/guide/router.html#%E7%BA%A6%E5%AE%9A%E5%BC%8F%E8%B7%AF%E7%94%B1))
|
||||
2. 修改 namespace/pathToRegexp 在 model.js
|
||||
3. 修改 mock中route.js增加一条route
|
||||
@@ -0,0 +1,73 @@
|
||||
# 快速上手
|
||||
|
||||
> 在开始之前,推荐先学习 [React](http://facebook.github.io/react/) 、 [ES2015+](http://es6.ruanyifeng.com/) 、 [Antd Design](https://ant.design/docs/react/introduce-cn) , 了解 [UmiJS](https://umijs.org/) 、[Dva](http://github.com/dvajs/dva) ,并正确安装和配置了 [Node.js](https://nodejs.org/) v8 或以上 、[Git](https://git-scm.com/)。提前了解和学习这些知识会非常有帮助。
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
cd my-project
|
||||
```
|
||||
|
||||
## 目录结构
|
||||
|
||||
应用的目录结构如下
|
||||
|
||||
```bash
|
||||
├── dist/ # 默认build输出目录
|
||||
├── mock/ # Mock文件目录
|
||||
├── public/ # 静态资源文件目录
|
||||
├── src/ # 源码目录
|
||||
│ ├── components/ # 组件目录
|
||||
│ ├── e2e/ # e2e目录
|
||||
│ ├── layouts/ # 布局目录
|
||||
│ ├── locales/ # 国际化文件目录
|
||||
│ ├── models/ # 数据模型目录
|
||||
│ ├── pages/ # 页面组件目录
|
||||
│ ├── services/ # 数据接口目录
|
||||
│ │ ├── api.js # 接口配置
|
||||
│ │ └── index.js # 接口输出
|
||||
│ ├── themes/ # 项目样式目录
|
||||
│ │ ├── default.less # 样式变量
|
||||
│ │ ├── index.less # 全局样式
|
||||
│ │ ├── mixin.less # 样式函数
|
||||
│ │ └── vars.less # 样式变量及函数
|
||||
│ ├── utils/ # 工具函数目录
|
||||
│ │ ├── config.js # 项目配置
|
||||
│ │ ├── constant.js # 静态常量
|
||||
│ │ ├── index.js # 工具函数
|
||||
│ │ ├── request.js # 异步请求函数(axios)
|
||||
│ │ └── theme.js # 项目需要在js中使用到样式变量
|
||||
├── .editorconfig # 编辑器配置
|
||||
├── .env # 环境变量
|
||||
├── .eslintrc # ESlint配置
|
||||
├── .gitignore # Git忽略文件配置
|
||||
├── .prettierignore # Prettier忽略文件配置
|
||||
├── .prettierrc # Prettier配置
|
||||
├── .stylelintrc.json # Stylelint配置
|
||||
├── .travis.yml # Travis配置
|
||||
└── .umirc.js # Umi配置
|
||||
└── package.json # 项目信息
|
||||
```
|
||||
|
||||
## 本地开发
|
||||
|
||||
1. 进入目录安装依赖,国内用户推荐使用 [cnpm](https://cnpmjs.org) 进行加速
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
2. 启动本地服务器
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
3. 启动完成后打开浏览器访问 [http://localhost:7000](http://localhost:7000),如果需要更改启动端口,可在 `.env` 文件中配置。
|
||||
@@ -0,0 +1,75 @@
|
||||
# 国际化
|
||||
|
||||
## 新增应用语言
|
||||
|
||||
以新增日语为例。
|
||||
|
||||

|
||||
|
||||
1. 添加语言包本地文件,`ja` 为日语的语言代码,支持翻译的语言列表参考 [有道智云](http://ai.youdao.com/docs/doc-trans-api.s#p05),运行下面命令后会生成 `src/locales/ja/messages.json` 文件。
|
||||
|
||||
```bash
|
||||
npm run add-locale ja
|
||||
```
|
||||
|
||||
2. 提取代码中需要翻译的字段,即 `<Trans>message</Trans>`、`` intl.formatMessage({ id: 'message `` 中 `message` 字段,运行下面命令后 `src/locales/ja/messages.json' }) 将会出现提取后的字段配置。
|
||||
|
||||
```bash
|
||||
npm run extract
|
||||
```
|
||||
|
||||
你将看到如下信息:
|
||||
|
||||
```bash
|
||||
Catalog statistics:
|
||||
┌─────────────┬─────────────┬─────────┐
|
||||
│ Language │ Total count │ Missing │
|
||||
├─────────────┼─────────────┼─────────┤
|
||||
│ en (source) │ 52 │ - │
|
||||
│ ja │ 52 │ 52 │
|
||||
│ zh │ 52 │ 0 │
|
||||
└─────────────┴─────────────┴─────────┘
|
||||
```
|
||||
|
||||
3. 与此同时,我们在 `src/utils/config.js` 新增相关配置。
|
||||
|
||||
```javascript
|
||||
{
|
||||
...
|
||||
i18n: {
|
||||
languages: [
|
||||
...
|
||||
{
|
||||
key:'ja',
|
||||
title: '日本語',
|
||||
flag: '/japanese.svg',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
> 路由相关效果,配置后 `npm run start` 重启后生效。
|
||||
|
||||
4. 使用内置的命令进行自动翻译,在 `src/locales/ja/messages.json` 中将会看到翻译后的配置。
|
||||
|
||||
```bash
|
||||
npm run trans:only
|
||||
```
|
||||
|
||||
你将看到如下信息:
|
||||
|
||||
```bash
|
||||
start: en -> ja
|
||||
...
|
||||
youdao: en -> ja: Unpublished -> 未発表
|
||||
youdao: en -> ja: Update -> 更新
|
||||
youdao: en -> ja: Update User -> ユーザーの更新
|
||||
youdao: en -> ja: Username -> 名
|
||||
...
|
||||
All translations have been completed.
|
||||
```
|
||||
|
||||
> `npm run trans` 将会依次执行 `npm run extract` 和 `npm run trans:only`
|
||||
|
||||
5. 最后,可以在 `src/locales/ja/messages.json` 中对翻译不准确的的字段进行调整。启动开发模式 `npm run start`,打开 [http://localhost:7000/ja/login](http://localhost:7000/ja/login),你将看到日语版本的应用。
|
||||
@@ -0,0 +1,60 @@
|
||||
# 布局
|
||||
|
||||
## 新增布局
|
||||
|
||||
以新增名为 `secondary` 的布局为例,使以 `secondary` 开头的路由都使用该布局。
|
||||
|
||||
1. 在 `src/utils/config.js` 新增相关配置,参数详细请查看 [layouts](/zh-cn/configuration?id=layouts)。
|
||||
|
||||
```javascript
|
||||
layouts: [
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
{
|
||||
name: 'secondary',
|
||||
include: [/(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
],
|
||||
```
|
||||
|
||||
2. 在`src/layouts/BaseLayout.js` 文件中新增 `secondary` 布局组件。
|
||||
|
||||
```javascript
|
||||
import SecondaryLayout from './SecondaryLayout'
|
||||
|
||||
const LayoutMap = {
|
||||
primary: PrimaryLayout,
|
||||
public: PublicLayout,
|
||||
secondary: SecondaryLayout,
|
||||
}
|
||||
```
|
||||
|
||||
3. 在`src/layouts/` 目录中新增 `SecondaryLayout.js` 文件。
|
||||
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Secondary</h1>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
4. 在`src/pages/` 目录中新增 `secondary/index.js` 文件。
|
||||
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
return <div>Secondary page Content</div>
|
||||
}
|
||||
```
|
||||
|
||||
5. 最后,启动开发模式 `npm run start`,打开 [http://localhost:7000/secondary/](http://localhost:7000/secondary/),你将看到 `secondary` 布局的页面。
|
||||
@@ -0,0 +1,24 @@
|
||||
# HTTP请求
|
||||
|
||||
本项目使用了axios提供http请求服务,文件在src/utils/request.js
|
||||
|
||||
## 自定义Header
|
||||
|
||||
为了提供鉴权、修改cookie等服务,可以手动修改Header
|
||||
|
||||
```
|
||||
axios.defaults.headers.common['Authorization'] = 'token'
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```
|
||||
// 添加请求拦截器
|
||||
axios.interceptors.request.use(function (config) {
|
||||
// 在发送请求之前做些什么
|
||||
config.headers.token = window.localStorage.getItem('token');
|
||||
return config;
|
||||
}, function (error) {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
# 路由
|
||||
|
||||
本项目中采用约定式路由
|
||||
|
||||
参考[umi 路由](https://umijs.org/zh/guide/router.html)
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
testURL: 'http://localhost:8000'
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "Antd-Admin",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"background_color": "#fff",
|
||||
"description": "A front-end solution for enterprise applications built upon Ant Design and UmiJS",
|
||||
"icons": [{
|
||||
"src": "logo/logo@96.png",
|
||||
"sizes": "72x72"
|
||||
},
|
||||
{
|
||||
"src": "logo/logo@128.png",
|
||||
"sizes": "128x128"
|
||||
},
|
||||
{
|
||||
"src": "logo/logo@144.png",
|
||||
"sizes": "144x144"
|
||||
},
|
||||
{
|
||||
"src": "logo/logo@152.png",
|
||||
"sizes": "152x152"
|
||||
},
|
||||
{
|
||||
"src": "logo/logo@192.png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo/logo@384.png",
|
||||
"sizes": "384x384"
|
||||
},
|
||||
{
|
||||
"src": "logo/logo@512.png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
import { color } from '../utils/theme'
|
||||
import Mock from 'mockjs'
|
||||
import { Constant } from './utils'
|
||||
|
||||
const Mock = require('mockjs')
|
||||
const config = require('../utils/config')
|
||||
|
||||
const { apiPrefix } = config
|
||||
const { ApiPrefix, Color } = Constant
|
||||
|
||||
const Dashboard = Mock.mock({
|
||||
'sales|8': [
|
||||
@@ -57,11 +55,9 @@ const Dashboard = Mock.mock({
|
||||
},
|
||||
],
|
||||
user: {
|
||||
name: 'zuiidea',
|
||||
email: 'zuiiidea@.gmail.com',
|
||||
name: 'github',
|
||||
sales: 3241,
|
||||
sold: 3556,
|
||||
avatar: 'http://tva4.sinaimg.cn/crop.0.0.996.996.180/6ee6a3a3jw8f0ks5pk7btj20ro0rodi0.jpg',
|
||||
},
|
||||
'completed|12': [
|
||||
{
|
||||
@@ -75,11 +71,19 @@ const Dashboard = Mock.mock({
|
||||
name: '@last',
|
||||
'status|1-3': 1,
|
||||
content: '@sentence',
|
||||
avatar () {
|
||||
return Mock.Random.image('48x48', Mock.Random.color(), '#757575', 'png', this.name.substr(0, 1))
|
||||
avatar() {
|
||||
return Mock.Random.image(
|
||||
'48x48',
|
||||
Mock.Random.color(),
|
||||
'#757575',
|
||||
'png',
|
||||
this.name.substr(0, 1)
|
||||
)
|
||||
},
|
||||
date () {
|
||||
return `2016-${Mock.Random.date('MM-dd')} ${Mock.Random.time('HH:mm:ss')}`
|
||||
date() {
|
||||
return `2016-${Mock.Random.date('MM-dd')} ${Mock.Random.time(
|
||||
'HH:mm:ss'
|
||||
)}`
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -88,8 +92,10 @@ const Dashboard = Mock.mock({
|
||||
'id|+1': 1,
|
||||
name: '@last',
|
||||
'status|1-4': 1,
|
||||
date () {
|
||||
return `${Mock.Random.integer(2015, 2016)}-${Mock.Random.date('MM-dd')} ${Mock.Random.time('HH:mm:ss')}`
|
||||
date() {
|
||||
return `${Mock.Random.integer(2015, 2016)}-${Mock.Random.date(
|
||||
'MM-dd'
|
||||
)} ${Mock.Random.time('HH:mm:ss')}`
|
||||
},
|
||||
'price|10-200.1-2': 1,
|
||||
},
|
||||
@@ -97,36 +103,41 @@ const Dashboard = Mock.mock({
|
||||
quote: {
|
||||
name: 'Joho Doe',
|
||||
title: 'Graphic Designer',
|
||||
content: 'I\'m selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can\'t handle me at my worst, then you sure as hell don\'t deserve me at my best.',
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
content:
|
||||
"I'm selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can't handle me at my worst, then you sure as hell don't deserve me at my best.",
|
||||
avatar:
|
||||
'//cdn.antd-admin.zuiidea.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
},
|
||||
numbers: [
|
||||
{
|
||||
icon: 'pay-circle-o',
|
||||
color: color.green,
|
||||
color: Color.green,
|
||||
title: 'Online Review',
|
||||
number: 2781,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
icon: 'team',
|
||||
color: color.blue,
|
||||
color: Color.blue,
|
||||
title: 'New Customers',
|
||||
number: 3241,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
icon: 'message',
|
||||
color: color.purple,
|
||||
color: Color.purple,
|
||||
title: 'Active Projects',
|
||||
number: 253,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
icon: 'shopping-cart',
|
||||
color: color.red,
|
||||
color: Color.red,
|
||||
title: 'Referrals',
|
||||
number: 4324,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
[`GET ${apiPrefix}/dashboard`] (req, res) {
|
||||
export default {
|
||||
[`GET ${ApiPrefix}/dashboard`](req, res) {
|
||||
res.json(Dashboard)
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
declare module 'mockjs'
|
||||
declare module 'qs'
|
||||
@@ -0,0 +1,155 @@
|
||||
import { Constant } from './utils'
|
||||
const { ApiPrefix } = Constant
|
||||
|
||||
const database = [
|
||||
{
|
||||
id: '1',
|
||||
icon: 'dashboard',
|
||||
name: 'Dashboard',
|
||||
zh: {
|
||||
name: '仪表盘',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Dashboard',
|
||||
},
|
||||
route: '/dashboard',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Users',
|
||||
zh: {
|
||||
name: '用户管理',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Usuário',
|
||||
},
|
||||
icon: 'user',
|
||||
route: '/user',
|
||||
},
|
||||
{
|
||||
id: '7',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Posts',
|
||||
zh: {
|
||||
name: '用户管理',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Posts',
|
||||
},
|
||||
icon: 'shopping-cart',
|
||||
route: '/post',
|
||||
},
|
||||
{
|
||||
id: '21',
|
||||
menuParentId: '-1',
|
||||
breadcrumbParentId: '2',
|
||||
name: 'User Detail',
|
||||
zh: {
|
||||
name: '用户详情',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Detalhes do usuário',
|
||||
},
|
||||
route: '/user/:id',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Request',
|
||||
zh: {
|
||||
name: 'Request',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Requisição',
|
||||
},
|
||||
icon: 'api',
|
||||
route: '/request',
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'UI Element',
|
||||
zh: {
|
||||
name: 'UI组件',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Elementos UI',
|
||||
},
|
||||
icon: 'camera-o',
|
||||
},
|
||||
{
|
||||
id: '45',
|
||||
breadcrumbParentId: '4',
|
||||
menuParentId: '4',
|
||||
name: 'Editor',
|
||||
zh: {
|
||||
name: 'Editor',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Editor',
|
||||
},
|
||||
icon: 'edit',
|
||||
route: '/editor',
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Charts',
|
||||
zh: {
|
||||
name: 'Charts',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Graficos',
|
||||
},
|
||||
icon: 'code-o',
|
||||
},
|
||||
{
|
||||
id: '51',
|
||||
breadcrumbParentId: '5',
|
||||
menuParentId: '5',
|
||||
name: 'ECharts',
|
||||
zh: {
|
||||
name: 'ECharts',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'ECharts',
|
||||
},
|
||||
icon: 'line-chart',
|
||||
route: '/chart/ECharts',
|
||||
},
|
||||
{
|
||||
id: '52',
|
||||
breadcrumbParentId: '5',
|
||||
menuParentId: '5',
|
||||
name: 'HighCharts',
|
||||
zh: {
|
||||
name: 'HighCharts',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'HighCharts',
|
||||
},
|
||||
icon: 'bar-chart',
|
||||
route: '/chart/highCharts',
|
||||
},
|
||||
{
|
||||
id: '53',
|
||||
breadcrumbParentId: '5',
|
||||
menuParentId: '5',
|
||||
name: 'Rechartst',
|
||||
zh: {
|
||||
name: 'Rechartst',
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Rechartst',
|
||||
},
|
||||
icon: 'area-chart',
|
||||
route: '/chart/Recharts',
|
||||
},
|
||||
]
|
||||
|
||||
export default {
|
||||
[`GET ${ApiPrefix}/routes`](req, res) {
|
||||
res.status(200).json(database)
|
||||
},
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
const qs = require('qs')
|
||||
const Mock = require('mockjs')
|
||||
const config = require('../utils/config')
|
||||
import Mock from 'mockjs'
|
||||
import qs from 'qs'
|
||||
import { Constant, randomAvatar, waitTime } from './utils'
|
||||
|
||||
const { apiPrefix } = config
|
||||
const { ApiPrefix } = Constant
|
||||
|
||||
let usersListData = Mock.mock({
|
||||
const usersListData = Mock.mock({
|
||||
'data|80-100': [
|
||||
{
|
||||
id: '@id',
|
||||
@@ -16,14 +16,13 @@ let usersListData = Mock.mock({
|
||||
isMale: '@boolean',
|
||||
email: '@email',
|
||||
createTime: '@datetime',
|
||||
avatar () {
|
||||
return Mock.Random.image('100x100', Mock.Random.color(), '#757575', 'png', this.nickName.substr(0, 1))
|
||||
avatar() {
|
||||
return randomAvatar()
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
let database = usersListData.data
|
||||
|
||||
const EnumRoleType = {
|
||||
@@ -51,16 +50,21 @@ const adminUsers = [
|
||||
username: 'admin',
|
||||
password: 'admin',
|
||||
permissions: userPermission.ADMIN,
|
||||
}, {
|
||||
avatar: randomAvatar(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
username: 'guest',
|
||||
password: 'guest',
|
||||
permissions: userPermission.DEFAULT,
|
||||
}, {
|
||||
avatar: randomAvatar(),
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: '吴彦祖',
|
||||
password: '123456',
|
||||
permissions: userPermission.DEVELOPER,
|
||||
avatar: randomAvatar(),
|
||||
},
|
||||
]
|
||||
|
||||
@@ -88,56 +92,70 @@ const NOTFOUND = {
|
||||
documentation_url: 'http://localhost:8000/request',
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
const authorized = (req, res) => {
|
||||
const cookie = req.headers.cookie || ''
|
||||
const cookies = qs.parse(cookie.replace(/\s/g, ''), { delimiter: ';' })
|
||||
if (!cookies.token) {
|
||||
res.status(401).send({ message: 'Not Login' })
|
||||
return false
|
||||
}
|
||||
|
||||
[`POST ${apiPrefix}/user/login`] (req, res) {
|
||||
const token = JSON.parse(cookies.token)
|
||||
if (cookies.token && token && token.deadline > new Date().getTime()) {
|
||||
return token
|
||||
}
|
||||
|
||||
res.status(401).send({ message: 'Not Login' })
|
||||
return false
|
||||
}
|
||||
|
||||
export default {
|
||||
async [`POST ${ApiPrefix}/user/login`](req, res) {
|
||||
await waitTime()
|
||||
const { username, password } = req.body
|
||||
const user = adminUsers.filter(item => item.username === username)
|
||||
const user = adminUsers.filter((item) => item.username === username)
|
||||
|
||||
if (user.length > 0 && user[0].password === password) {
|
||||
const now = new Date()
|
||||
now.setDate(now.getDate() + 1)
|
||||
res.cookie('token', JSON.stringify({ id: user[0].id, deadline: now.getTime() }), {
|
||||
maxAge: 900000,
|
||||
httpOnly: true,
|
||||
})
|
||||
res.cookie(
|
||||
'token',
|
||||
JSON.stringify({ id: user[0].id, deadline: now.getTime() }),
|
||||
{
|
||||
maxAge: 900000,
|
||||
httpOnly: true,
|
||||
}
|
||||
)
|
||||
res.json({ success: true, message: 'Ok' })
|
||||
} else {
|
||||
res.status(400).end()
|
||||
}
|
||||
},
|
||||
|
||||
[`GET ${apiPrefix}/user/logout`] (req, res) {
|
||||
async [`GET ${ApiPrefix}/user/logout`](req, res) {
|
||||
await waitTime()
|
||||
res.clearCookie('token')
|
||||
res.status(200).end()
|
||||
},
|
||||
|
||||
[`GET ${apiPrefix}/user`] (req, res) {
|
||||
const cookie = req.headers.cookie || ''
|
||||
const cookies = qs.parse(cookie.replace(/\s/g, ''), { delimiter: ';' })
|
||||
const response = {}
|
||||
const user = {}
|
||||
if (!cookies.token) {
|
||||
res.status(200).send({ message: 'Not Login' })
|
||||
async [`GET ${ApiPrefix}/user`](req, res) {
|
||||
await waitTime()
|
||||
|
||||
const token = authorized(req, res)
|
||||
if (!token) {
|
||||
return
|
||||
}
|
||||
const token = JSON.parse(cookies.token)
|
||||
if (token) {
|
||||
response.success = token.deadline > new Date().getTime()
|
||||
|
||||
const userItem = adminUsers.find((_) => _.id === token.id)
|
||||
if (userItem) {
|
||||
const { password, ...rest } = userItem
|
||||
res.json(rest)
|
||||
} else {
|
||||
res.status(401).send({ message: 'Not Login' })
|
||||
}
|
||||
if (response.success) {
|
||||
const userItem = adminUsers.filter(_ => _.id === token.id)
|
||||
if (userItem.length > 0) {
|
||||
user.permissions = userItem[0].permissions
|
||||
user.username = userItem[0].username
|
||||
user.id = userItem[0].id
|
||||
}
|
||||
}
|
||||
response.user = user
|
||||
res.json(response)
|
||||
},
|
||||
|
||||
[`GET ${apiPrefix}/users`] (req, res) {
|
||||
[`GET ${ApiPrefix}/users`](req, res) {
|
||||
const { query } = req
|
||||
let { pageSize, page, ...other } = query
|
||||
pageSize = pageSize || 10
|
||||
@@ -149,7 +167,7 @@ module.exports = {
|
||||
newData = newData.filter((item) => {
|
||||
if ({}.hasOwnProperty.call(item, key)) {
|
||||
if (key === 'address') {
|
||||
return other[key].every(iitem => item[key].indexOf(iitem) > -1)
|
||||
return other[key].every((iitem) => item[key].indexOf(iitem) > -1)
|
||||
} else if (key === 'createTime') {
|
||||
const start = new Date(other[key][0]).getTime()
|
||||
const end = new Date(other[key][1]).getTime()
|
||||
@@ -160,7 +178,10 @@ module.exports = {
|
||||
}
|
||||
return true
|
||||
}
|
||||
return String(item[key]).trim().indexOf(decodeURI(other[key]).trim()) > -1
|
||||
return (
|
||||
String(item[key]).trim().indexOf(decodeURI(other[key]).trim()) >
|
||||
-1
|
||||
)
|
||||
}
|
||||
return true
|
||||
})
|
||||
@@ -168,22 +189,29 @@ module.exports = {
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
data: newData.slice((page - 1) * pageSize, page * pageSize),
|
||||
list: newData.slice((page - 1) * pageSize, page * pageSize),
|
||||
total: newData.length,
|
||||
})
|
||||
},
|
||||
|
||||
[`DELETE ${apiPrefix}/users`] (req, res) {
|
||||
const { ids } = req.body
|
||||
database = database.filter(item => !ids.some(_ => _ === item.id))
|
||||
[`POST ${ApiPrefix}/users/delete`](req, res) {
|
||||
const { ids = [] } = req.body
|
||||
database = database.filter((item) => !ids.some((_) => _ === item.id))
|
||||
res.status(204).end()
|
||||
},
|
||||
|
||||
|
||||
[`POST ${apiPrefix}/user`] (req, res) {
|
||||
[`POST ${ApiPrefix}/user`](req, res) {
|
||||
const newData = req.body
|
||||
newData.createTime = Mock.mock('@now')
|
||||
newData.avatar = newData.avatar || Mock.Random.image('100x100', Mock.Random.color(), '#757575', 'png', newData.nickName.substr(0, 1))
|
||||
newData.avatar =
|
||||
newData.avatar ||
|
||||
Mock.Random.image(
|
||||
'100x100',
|
||||
Mock.Random.color(),
|
||||
'#757575',
|
||||
'png',
|
||||
newData.nickName.substr(0, 1)
|
||||
)
|
||||
newData.id = Mock.mock('@id')
|
||||
|
||||
database.unshift(newData)
|
||||
@@ -191,28 +219,28 @@ module.exports = {
|
||||
res.status(200).end()
|
||||
},
|
||||
|
||||
[`GET ${apiPrefix}/user/:id`] (req, res) {
|
||||
[`GET ${ApiPrefix}/user/:id`](req, res) {
|
||||
const { id } = req.params
|
||||
const data = queryArray(database, id, 'id')
|
||||
if (data) {
|
||||
res.status(200).json(data)
|
||||
} else {
|
||||
res.status(404).json(NOTFOUND)
|
||||
res.status(200).json(NOTFOUND)
|
||||
}
|
||||
},
|
||||
|
||||
[`DELETE ${apiPrefix}/user/:id`] (req, res) {
|
||||
[`DELETE ${ApiPrefix}/user/:id`](req, res) {
|
||||
const { id } = req.params
|
||||
const data = queryArray(database, id, 'id')
|
||||
if (data) {
|
||||
database = database.filter(item => item.id !== id)
|
||||
database = database.filter((item) => item.id !== id)
|
||||
res.status(204).end()
|
||||
} else {
|
||||
res.status(404).json(NOTFOUND)
|
||||
res.status(200).json(NOTFOUND)
|
||||
}
|
||||
},
|
||||
|
||||
[`PATCH ${apiPrefix}/user/:id`] (req, res) {
|
||||
[`PATCH ${ApiPrefix}/user/:id`](req, res) {
|
||||
const { id } = req.params
|
||||
const editItem = req.body
|
||||
let isExist = false
|
||||
@@ -228,7 +256,7 @@ module.exports = {
|
||||
if (isExist) {
|
||||
res.status(201).end()
|
||||
} else {
|
||||
res.status(404).json(NOTFOUND)
|
||||
res.status(200).json(NOTFOUND)
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Query objects that specify keys and values in an array where all values are objects.
|
||||
* @param {array} array An array where all values are objects, like [{key:1},{key:2}].
|
||||
* @param {string} key The key of the object that needs to be queried.
|
||||
* @param {string} value The value of the object that needs to be queried.
|
||||
* @return {object|undefined} Return frist object when query success.
|
||||
*/
|
||||
export function queryArray(array, key, value) {
|
||||
if (!Array.isArray(array)) {
|
||||
return
|
||||
}
|
||||
return array.filter((_) => _[key] === value)
|
||||
}
|
||||
|
||||
export function randomNumber(min, max) {
|
||||
return Math.floor(Math.random() * (max - min) + min)
|
||||
}
|
||||
|
||||
export function randomAvatar() {
|
||||
const avatarList = [
|
||||
'photo-1549492864-2ec7d66ffb04.jpeg',
|
||||
'photo-1480535339474-e083439a320d.jpeg',
|
||||
'photo-1523419409543-a5e549c1faa8.jpeg',
|
||||
'photo-1519648023493-d82b5f8d7b8a.jpeg',
|
||||
'photo-1523307730650-594bc63f9d67.jpeg',
|
||||
'photo-1522962506050-a2f0267e4895.jpeg',
|
||||
'photo-1489779162738-f81aed9b0a25.jpeg',
|
||||
'photo-1534308143481-c55f00be8bd7.jpeg',
|
||||
'photo-1519336555923-59661f41bb45.jpeg',
|
||||
'photo-1551438632-e8c7d9a5d1b7.jpeg',
|
||||
'photo-1525879000488-bff3b1c387cf.jpeg',
|
||||
'photo-1487412720507-e7ab37603c6f.jpeg',
|
||||
'photo-1510227272981-87123e259b17.jpeg',
|
||||
]
|
||||
return `//image.zuiidea.com/${
|
||||
avatarList[randomNumber(0, avatarList.length - 1)]
|
||||
}?imageView2/1/w/200/h/200/format/webp/q/75|imageslim`
|
||||
}
|
||||
|
||||
export const waitTime = (time: number = 300) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(true)
|
||||
}, time)
|
||||
})
|
||||
}
|
||||
|
||||
export const Constant = {
|
||||
ApiPrefix: '/api/v1',
|
||||
NotFound: {
|
||||
message: 'Not Found',
|
||||
documentation_url: '',
|
||||
},
|
||||
Color: {
|
||||
green: '#64ea91',
|
||||
blue: '#8fc9fb',
|
||||
purple: '#d897eb',
|
||||
red: '#f69899',
|
||||
yellow: '#f8c82e',
|
||||
peach: '#f797d6',
|
||||
borderBase: '#e5e5e5',
|
||||
borderSplit: '#f4f4f4',
|
||||
grass: '#d6fbb5',
|
||||
sky: '#c1e0fc',
|
||||
},
|
||||
}
|
||||
@@ -1,63 +1,126 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "antd-admin",
|
||||
"version": "4.3.4",
|
||||
"version": "6.0.0-a.1",
|
||||
"license": "MIT",
|
||||
"description": "An admin dashboard application demo built upon Ant Design and UmiJS",
|
||||
"dependencies": {
|
||||
"antd": "^2.11.2",
|
||||
"axios": "^0.16.2",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"classnames": "^2.2.5",
|
||||
"d3-shape": "^1.2.0",
|
||||
"draftjs-to-markdown": "^0.4.0",
|
||||
"dva": "^1.2.0",
|
||||
"dva-loading": "^0.2.0",
|
||||
"ejs-loader": "^0.3.0",
|
||||
"js-beautify": "^1.6.14",
|
||||
"jsonp": "^0.2.1",
|
||||
"less-vars-to-js": "^1.1.2",
|
||||
"lodash": "^4.17.4",
|
||||
"mockjs": "^1.0.1-beta3",
|
||||
"@ant-design/icons": "^4.7.0",
|
||||
"@ant-design/pro-layout": "^6.37.0",
|
||||
"@lingui/core": "^3.13.3",
|
||||
"@lingui/detect-locale": "^3.13.3",
|
||||
"@lingui/react": "^3.13.3",
|
||||
"antd": "^4.20.1",
|
||||
"axios": "^0.27.2",
|
||||
"classnames": "^2.3.1",
|
||||
"dva-model-extend": "^0.1.2",
|
||||
"echarts": "^5.3.2",
|
||||
"echarts-for-react": "^3.0.2",
|
||||
"echarts-gl": "^2.0.9",
|
||||
"echarts-liquidfill": "^3.1.0",
|
||||
"json-format": "^1.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
"make-plural": "^7.1.0",
|
||||
"md5": "^2.3.0",
|
||||
"nprogress": "^0.2.0",
|
||||
"path-to-regexp": "^1.7.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"qs": "^6.5.0",
|
||||
"rc-tween-one": "^1.3.1",
|
||||
"react": "^15.6.1",
|
||||
"react-countup": "^2.1.1",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-draft-wysiwyg": "^1.10.0",
|
||||
"react-helmet": "^5.1.3",
|
||||
"recharts": "^0.22.4",
|
||||
"roadhog": "^1.2.1"
|
||||
"path-to-regexp": "^6.2.0",
|
||||
"prop-types": "^15.8.1",
|
||||
"qs": "^6.10.3",
|
||||
"react": "^18.1.0",
|
||||
"react-countup": "^6.2.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-highcharts": "^16.1.0",
|
||||
"react-perfect-scrollbar": "^1.5.8",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"recharts": "^2.1.9",
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
"babel-plugin-dva-hmr": "^0.3.2",
|
||||
"babel-plugin-import": "^1.1.1",
|
||||
"babel-plugin-transform-runtime": "^6.9.0",
|
||||
"babel-runtime": "^6.9.2",
|
||||
"copy-webpack-plugin": "^4.0.1",
|
||||
"draftjs-to-html": "^0.7.0",
|
||||
"dva-model-extend": "^0.1.1",
|
||||
"eslint": "^4.1.1",
|
||||
"eslint-config-airbnb": "^15.0.2",
|
||||
"eslint-import-resolver-node": "^0.3.1",
|
||||
"eslint-loader": "^1.9.0",
|
||||
"eslint-plugin-import": "^2.6.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.2",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"html-webpack-plugin": "^2.29.0",
|
||||
"html-webpack-template": "^5.6.0",
|
||||
"redbox-react": "^1.2.10",
|
||||
"roadhog": "1.0.0-beta.7"
|
||||
"@babel/preset-react": "^7.16.7",
|
||||
"@lingui/babel-preset-react": "^2.9.2",
|
||||
"@lingui/cli": "^3.13.3",
|
||||
"@lingui/loader": "^3.13.3",
|
||||
"@lingui/macro": "^3.13.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
||||
"@typescript-eslint/parser": "^5.21.0",
|
||||
"babel-plugin-dev-expression": "^0.2.3",
|
||||
"babel-plugin-import": "^1.13.5",
|
||||
"babel-plugin-macros": "^3.1.0",
|
||||
"babel-plugin-module-resolver": "^4.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.14.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-config-react-app": "^7.0.1",
|
||||
"eslint-plugin-babel": "^5.3.1",
|
||||
"eslint-plugin-flowtype": "^8.0.3",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.5.1",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-react": "^7.29.4",
|
||||
"eslint-plugin-react-hooks": "^4.5.0",
|
||||
"husky": "^7.0.4",
|
||||
"less-vars-to-js": "^1.3.0",
|
||||
"lint-staged": "^12.4.1",
|
||||
"mockjs": "^1.1.0",
|
||||
"prettier": "^2.6.2",
|
||||
"stylelint": "^14.8.0",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-standard": "^25.0.0",
|
||||
"typescript": "^4.6.4",
|
||||
"umi": "4.0.0-canary.20220429.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js,jsx}": [
|
||||
"npm run eslint",
|
||||
"npm run prettier"
|
||||
],
|
||||
"*.less": [
|
||||
"npm run stylelint",
|
||||
"npm run prettier"
|
||||
]
|
||||
},
|
||||
"lingui": {
|
||||
"fallbackLocales": {
|
||||
"default": "en"
|
||||
},
|
||||
"sourceLocale": "en",
|
||||
"locales": [
|
||||
"en",
|
||||
"zh",
|
||||
"pt-br"
|
||||
],
|
||||
"catalogs": [
|
||||
{
|
||||
"path": "src/locales/{locale}/messages",
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"format": "minimal",
|
||||
"runtimeConfigModule": [
|
||||
"@/hooks/useIntlProvider",
|
||||
"i18n"
|
||||
]
|
||||
},
|
||||
"pre-commit": ["lint"],
|
||||
"scripts": {
|
||||
"dev": "set BROWSER=none&&set HOST=0.0.0.0&&roadhog server",
|
||||
"lint": "eslint --fix --ext .js src",
|
||||
"build": "roadhog build",
|
||||
"build:dll": "roadhog buildDll",
|
||||
"build:new": "node version && roadhog build"
|
||||
"start": "umi dev",
|
||||
"build": "cross-env UMI_ENV=prod umi build",
|
||||
"test": "umi test",
|
||||
"analyze": "cross-env ANALYZE=1 umi dev",
|
||||
"eslint": "eslint --fix 'src/**/*.{ts,tsx,js.jsx}'",
|
||||
"stylelint": "stylelint src/**/*.less --syntax less",
|
||||
"prettier": "prettier --write 'src/**/*.{ts,tsx,js.jsx,less}'",
|
||||
"precommit": "lint-staged",
|
||||
"add-locale": "lingui add-locale",
|
||||
"extract": "lingui extract",
|
||||
"trans": "lingui extract --clean && node ./scripts/translate.js",
|
||||
"doc": "docsify serve docs"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<rect style="fill:#F0F0F0;" width="512" height="512"/>
|
||||
<g>
|
||||
<rect y="64" style="fill:#D80027;" width="512" height="64"/>
|
||||
<rect y="192" style="fill:#D80027;" width="512" height="64"/>
|
||||
<rect y="320" style="fill:#D80027;" width="512" height="64"/>
|
||||
<rect y="448" style="fill:#D80027;" width="512" height="64"/>
|
||||
</g>
|
||||
<rect style="fill:#2E52B2;" width="256" height="275.69"/>
|
||||
<g>
|
||||
<polygon style="fill:#F0F0F0;" points="51.518,115.318 45.924,132.529 27.826,132.529 42.469,143.163 36.875,160.375
|
||||
51.518,149.741 66.155,160.375 60.56,143.163 75.203,132.529 57.106,132.529 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="57.106,194.645 51.518,177.434 45.924,194.645 27.826,194.645 42.469,205.279
|
||||
36.875,222.49 51.518,211.857 66.155,222.49 60.56,205.279 75.203,194.645 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="51.518,53.202 45.924,70.414 27.826,70.414 42.469,81.047 36.875,98.259 51.518,87.625
|
||||
66.155,98.259 60.56,81.047 75.203,70.414 57.106,70.414 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="128.003,115.318 122.409,132.529 104.311,132.529 118.954,143.163 113.36,160.375
|
||||
128.003,149.741 142.64,160.375 137.045,143.163 151.689,132.529 133.591,132.529 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="133.591,194.645 128.003,177.434 122.409,194.645 104.311,194.645 118.954,205.279
|
||||
113.36,222.49 128.003,211.857 142.64,222.49 137.045,205.279 151.689,194.645 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="210.076,194.645 204.489,177.434 198.894,194.645 180.797,194.645 195.44,205.279
|
||||
189.845,222.49 204.489,211.857 219.125,222.49 213.531,205.279 228.174,194.645 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="204.489,115.318 198.894,132.529 180.797,132.529 195.44,143.163 189.845,160.375
|
||||
204.489,149.741 219.125,160.375 213.531,143.163 228.174,132.529 210.076,132.529 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="128.003,53.202 122.409,70.414 104.311,70.414 118.954,81.047 113.36,98.259
|
||||
128.003,87.625 142.64,98.259 137.045,81.047 151.689,70.414 133.591,70.414 "/>
|
||||
<polygon style="fill:#F0F0F0;" points="204.489,53.202 198.894,70.414 180.797,70.414 195.44,81.047 189.845,98.259
|
||||
204.489,87.625 219.125,98.259 213.531,81.047 228.174,70.414 210.076,70.414 "/>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="-49 141 512 512" style="enable-background:new -49 141 512 512;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#D80027;}
|
||||
.st1{fill:#FFDA44;}
|
||||
</style>
|
||||
<rect x="-49" y="141" class="st0" width="512" height="512"/>
|
||||
|
||||
<g>
|
||||
<polygon class="st1" points="91.1,296.8 113.2,364.8 184.7,364.8 126.9,406.9 149,474.9 91.1,432.9 33.2,474.9 55.4,406.9
|
||||
-2.5,364.8 69,364.8 "/>
|
||||
<polygon class="st1" points="254.5,537.5 237.6,516.7 212.6,526.4 227.1,503.9 210.2,483 236.1,489.9 250.7,467.4 252.1,494.2
|
||||
278.1,501.1 253,510.7 "/>
|
||||
<polygon class="st1" points="288.1,476.5 296.1,450.9 274.2,435.4 301,435 308.9,409.4 317.6,434.8 344.4,434.5 322.9,450.5
|
||||
331.5,475.9 309.6,460.4 "/>
|
||||
<polygon class="st1" points="333.4,328.9 321.6,353 340.8,371.7 314.3,367.9 302.5,391.9 297.9,365.5 271.3,361.7 295.1,349.2
|
||||
290.5,322.7 309.7,341.4 "/>
|
||||
<polygon class="st1" points="255.2,255.9 253.2,282.6 278.1,292.7 252,299.1 250.1,325.9 236,303.1 209.9,309.5 227.2,289
|
||||
213,266.3 237.9,276.4 "/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,24 @@
|
||||
|
||||
<svg width="169px" height="141px" viewBox="0 0 169 141" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<linearGradient x1="54.0428975%" y1="4.39752391%" x2="54.0428975%" y2="108.456714%" id="linearGradient-1">
|
||||
<stop stop-color="#29CDFF" offset="0%"></stop>
|
||||
<stop stop-color="#148EFF" offset="62.3089445%"></stop>
|
||||
<stop stop-color="#0A60FF" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="50%" y1="14.2201464%" x2="50%" y2="113.263844%" id="linearGradient-2">
|
||||
<stop stop-color="#FA816E" offset="0%"></stop>
|
||||
<stop stop-color="#F74A5C" offset="65.9092442%"></stop>
|
||||
<stop stop-color="#F51D2C" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group" transform="translate(0.000000, -5.000000)">
|
||||
<rect id="Rectangle" fill="url(#linearGradient-1)" transform="translate(83.718923, 75.312358) rotate(-24.000000) translate(-83.718923, -75.312358) " x="68.7189234" y="0.312357954" width="30" height="150" rx="15"></rect>
|
||||
<rect id="Rectangle" fill="url(#linearGradient-1)" transform="translate(129.009910, 75.580213) rotate(-24.000000) translate(-129.009910, -75.580213) " x="114.00991" y="0.580212739" width="30" height="150" rx="15"></rect>
|
||||
<circle id="Oval" fill="url(#linearGradient-2)" cx="25" cy="120" r="25"></circle>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<rect style="fill:#D80027;" width="512" height="512"/>
|
||||
<polygon style="fill:#6DA544;" points="196.641,0 196.641,264.348 196.641,512 0,512 0,0 "/>
|
||||
<circle style="fill:#FFDA44;" cx="196.641" cy="256" r="96"/>
|
||||
<path style="fill:#D80027;" d="M142.638,208v60c0,29.823,24.178,54,54,54s54-24.178,54-54v-60H142.638z"/>
|
||||
<path style="fill:#F0F0F0;" d="M196.638,286c-9.925,0-18-8.075-18-18v-24.001h36V268C214.638,277.925,206.563,286,196.638,286z"/>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 973 B |
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Youdao Translate, My private account is for testing purposes only.
|
||||
* Please go to the official account to apply for an account. Thank you for your cooperation.
|
||||
* APP ID:055c2d71f9a05214
|
||||
* Secret key:ZcpuQxQW3NkQeKVkqrXIKQYXH57g2KuN
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
const md5 = require('md5')
|
||||
const qs = require('qs')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const axios = require('axios')
|
||||
const jsonFormat = require('json-format')
|
||||
const { i18n } = require('../src/utils/config')
|
||||
const { languages, defaultLanguage } = i18n
|
||||
|
||||
const locales = {}
|
||||
|
||||
languages.forEach(item => {
|
||||
locales[item.key] = require(`../src/locales/${item.key}/messages.json`)
|
||||
})
|
||||
|
||||
const youdao = ({ q, from, to }) =>
|
||||
new Promise((resolve, reject) => {
|
||||
{
|
||||
const appid = '055c2d71f9a05214'
|
||||
const appse = 'ZcpuQxQW3NkQeKVkqrXIKQYXH57g2KuN'
|
||||
const salt = Date.now()
|
||||
|
||||
const sign = md5(appid + q + salt + appse)
|
||||
const query = qs.stringify({
|
||||
q,
|
||||
from,
|
||||
to,
|
||||
appKey: appid,
|
||||
salt,
|
||||
sign,
|
||||
})
|
||||
|
||||
axios.get(`http://openapi.youdao.com/api?${query}`).then(({ data }) => {
|
||||
if (data.query && data.translation[0]) {
|
||||
resolve(data.translation[0])
|
||||
} else {
|
||||
resolve(q)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const transform = async ({ from, to, locales, outputPath }) => {
|
||||
for (const key in locales[from]) {
|
||||
if (locales[to][key]) {
|
||||
console.log(`add to skip: ${key}`)
|
||||
} else {
|
||||
let res = key
|
||||
let way = 'youdao'
|
||||
if (key.indexOf('/') !== 0) {
|
||||
const reg = '{([^{}]*)}'
|
||||
const tasks = key
|
||||
.match(new RegExp(`${reg}|((?<=(${reg}|^)).*?(?=(${reg}|$)))`, 'g'))
|
||||
.map(item => {
|
||||
if (new RegExp(reg).test(item)) {
|
||||
return Promise.resolve(item)
|
||||
}
|
||||
return youdao({
|
||||
q: item,
|
||||
from,
|
||||
to,
|
||||
})
|
||||
})
|
||||
|
||||
res = (await Promise.all(tasks)).join('')
|
||||
} else {
|
||||
res = `/${to + key}`
|
||||
way = 'link'
|
||||
}
|
||||
if (res !== key) {
|
||||
locales[to][key] = res
|
||||
console.log(`${way}: ${from} -> ${to}: ${key} -> ${res}`)
|
||||
} else {
|
||||
console.log(`same: ${from} -> ${to}: ${key}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
await fs.writeFileSync(
|
||||
path.resolve(__dirname, outputPath),
|
||||
jsonFormat(locales[to], {
|
||||
type: 'space',
|
||||
size: 2,
|
||||
})
|
||||
)
|
||||
}
|
||||
;(async () => {
|
||||
const tasks = languages
|
||||
.map(item => ({
|
||||
from: defaultLanguage,
|
||||
to: item.key,
|
||||
}))
|
||||
.filter(item => item.from !== item.to)
|
||||
|
||||
for (const item of tasks) {
|
||||
console.log(`start: ${item.from} -> ${item.to}`)
|
||||
await transform({
|
||||
from: item.from,
|
||||
to: item.to,
|
||||
locales,
|
||||
outputPath: `../src/locales/${item.to}/messages.json`,
|
||||
})
|
||||
console.log(`completed: ${item.from} -> ${item.to}`)
|
||||
}
|
||||
|
||||
console.log('All translations have been completed.')
|
||||
})()
|
||||
@@ -1,67 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { TweenOneGroup } from 'rc-tween-one'
|
||||
|
||||
const enterAnim = [
|
||||
{
|
||||
opacity: 0,
|
||||
x: 30,
|
||||
backgroundColor: '#fffeee',
|
||||
duration: 0,
|
||||
}, {
|
||||
height: 0,
|
||||
duration: 200,
|
||||
type: 'from',
|
||||
delay: 250,
|
||||
ease: 'easeOutQuad',
|
||||
onComplete: (e) => {
|
||||
e.target.style.height = 'auto'
|
||||
},
|
||||
}, {
|
||||
opacity: 1,
|
||||
x: 0,
|
||||
duration: 250,
|
||||
ease: 'easeOutQuad',
|
||||
}, {
|
||||
delay: 1000,
|
||||
backgroundColor: '#fff',
|
||||
},
|
||||
]
|
||||
|
||||
const leaveAnim = [
|
||||
{
|
||||
duration: 250,
|
||||
x: -30,
|
||||
opacity: 0,
|
||||
}, {
|
||||
height: 0,
|
||||
duration: 200,
|
||||
ease: 'easeOutQuad',
|
||||
},
|
||||
]
|
||||
|
||||
const AnimTableBody = ({ body, page = 1, current }) => {
|
||||
if (current !== +page) {
|
||||
return body
|
||||
}
|
||||
|
||||
return (
|
||||
<TweenOneGroup
|
||||
component="tbody"
|
||||
className={body.props.className}
|
||||
enter={enterAnim}
|
||||
leave={leaveAnim}
|
||||
appear={false}
|
||||
>
|
||||
{body.props.children}
|
||||
</TweenOneGroup>
|
||||
)
|
||||
}
|
||||
|
||||
AnimTableBody.propTypes = {
|
||||
body: PropTypes.element,
|
||||
page: PropTypes.any,
|
||||
current: PropTypes.number.isRequired,
|
||||
}
|
||||
|
||||
export default AnimTableBody
|
||||
@@ -1,112 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Table } from 'antd'
|
||||
import { request } from 'utils'
|
||||
import lodash from 'lodash'
|
||||
import './DataTable.less'
|
||||
|
||||
class DataTable extends React.Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
const { dataSource, pagination = {
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: total => `共 ${total} 条`,
|
||||
current: 1,
|
||||
total: 100 },
|
||||
} = props
|
||||
this.state = {
|
||||
loading: false,
|
||||
dataSource,
|
||||
fetchData: {},
|
||||
pagination,
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
if (this.props.fetch) {
|
||||
this.fetch()
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
const staticNextProps = lodash.cloneDeep(nextProps)
|
||||
delete staticNextProps.columns
|
||||
const { columns, ...otherProps } = this.props
|
||||
|
||||
if (!lodash.isEqual(staticNextProps, otherProps)) {
|
||||
this.props = nextProps
|
||||
this.fetch()
|
||||
}
|
||||
}
|
||||
|
||||
handleTableChange = (pagination, filters, sorter) => {
|
||||
const pager = this.state.pagination
|
||||
pager.current = pagination.current
|
||||
this.setState({
|
||||
pagination: pager,
|
||||
fetchData: {
|
||||
results: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
sortField: sorter.field,
|
||||
sortOrder: sorter.order,
|
||||
...filters,
|
||||
},
|
||||
}, () => {
|
||||
this.fetch()
|
||||
})
|
||||
}
|
||||
|
||||
fetch = () => {
|
||||
const { fetch: { url, data, dataKey } } = this.props
|
||||
const { fetchData } = this.state
|
||||
this.setState({ loading: true })
|
||||
this.promise = request({
|
||||
url,
|
||||
data: {
|
||||
...data,
|
||||
...fetchData,
|
||||
},
|
||||
}).then((result) => {
|
||||
if (!this.refs.DataTable) {
|
||||
return
|
||||
}
|
||||
const { pagination } = this.state
|
||||
pagination.total = result.total || pagination.total
|
||||
this.setState({
|
||||
loading: false,
|
||||
dataSource: dataKey ? result[dataKey] : result.data,
|
||||
pagination,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const { fetch, ...tableProps } = this.props
|
||||
const { loading, dataSource, pagination } = this.state
|
||||
|
||||
return (<Table
|
||||
ref="DataTable"
|
||||
bordered
|
||||
loading={loading}
|
||||
onChange={this.handleTableChange}
|
||||
{...tableProps}
|
||||
pagination={pagination}
|
||||
dataSource={dataSource}
|
||||
/>)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DataTable.propTypes = {
|
||||
fetch: PropTypes.object,
|
||||
rowKey: PropTypes.string,
|
||||
pagination: React.PropTypes.oneOfType([
|
||||
React.PropTypes.bool,
|
||||
React.PropTypes.object,
|
||||
]),
|
||||
columns: PropTypes.array,
|
||||
dataSource: PropTypes.array,
|
||||
}
|
||||
|
||||
export default DataTable
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "DataTable",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "./DataTable.js"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Dropdown, Button, Icon, Menu } from 'antd'
|
||||
|
||||
const DropOption = ({ onMenuClick, menuOptions = [], buttonStyle, dropdownProps }) => {
|
||||
const menu = menuOptions.map(item => <Menu.Item key={item.key}>{item.name}</Menu.Item>)
|
||||
return (<Dropdown
|
||||
overlay={<Menu onClick={onMenuClick}>{menu}</Menu>}
|
||||
{...dropdownProps}
|
||||
>
|
||||
<Button style={{ border: 'none', ...buttonStyle }}>
|
||||
<Icon style={{ marginRight: 2 }} type="bars" />
|
||||
<Icon type="down" />
|
||||
</Button>
|
||||
</Dropdown>)
|
||||
}
|
||||
|
||||
DropOption.propTypes = {
|
||||
onMenuClick: PropTypes.func,
|
||||
menuOptions: PropTypes.array.isRequired,
|
||||
buttonStyle: PropTypes.object,
|
||||
dropdownProps: PropTypes.object,
|
||||
}
|
||||
|
||||
export default DropOption
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "DropOption",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "./DropOption.js"
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import React from 'react'
|
||||
import { Editor } from 'react-draft-wysiwyg'
|
||||
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css'
|
||||
import styles from './Editor.less'
|
||||
|
||||
|
||||
const DraftEditor = (props) => {
|
||||
return (<Editor toolbarClassName={styles.toolbar} wrapperClassName={styles.wrapper} editorClassName={styles.editor} {...props} />)
|
||||
}
|
||||
|
||||
export default DraftEditor
|
||||
@@ -1,111 +0,0 @@
|
||||
.wrapper {
|
||||
height: 500px;
|
||||
|
||||
:global {
|
||||
.rdw-dropdownoption-default {
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.rdw-dropdown-optionwrapper {
|
||||
box-sizing: content-box;
|
||||
width: 100%;
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
|
||||
.rdw-inline-wrapper {
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 0;
|
||||
|
||||
.rdw-option-wrapper {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.rdw-option-active {
|
||||
box-shadow: 1px 1px 0 #e8e8e8 inset;
|
||||
}
|
||||
|
||||
.rdw-dropdown-optionwrapper {
|
||||
&:hover {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.rdw-colorpicker-option {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.rdw-colorpicker-modal,
|
||||
.rdw-embedded-modal,
|
||||
.rdw-emoji-modal,
|
||||
.rdw-image-modal,
|
||||
.rdw-link-modal {
|
||||
box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.rdw-colorpicker-modal,
|
||||
.rdw-embedded-modal,
|
||||
.rdw-link-modal {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.rdw-emoji-modal {
|
||||
width: 214px;
|
||||
}
|
||||
|
||||
.rdw-colorpicker-modal {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.rdw-embedded-modal-btn,
|
||||
.rdw-image-modal-btn,
|
||||
.rdw-link-modal-btn {
|
||||
height: 32px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.rdw-embedded-modal-input,
|
||||
.rdw-embedded-modal-size-input,
|
||||
.rdw-link-modal-input {
|
||||
padding: 2px 6px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.rdw-dropdown-selectedtext {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.rdw-dropdown-wrapper,
|
||||
.rdw-option-wrapper {
|
||||
min-width: 36px;
|
||||
transition: all 0.2s ease;
|
||||
height: 30px;
|
||||
|
||||
&:active {
|
||||
box-shadow: 1px 1px 0 #e8e8e8 inset;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
box-shadow: 1px 1px 0 #e8e8e8;
|
||||
}
|
||||
}
|
||||
|
||||
.rdw-dropdown-wrapper {
|
||||
min-width: 60px;
|
||||
}
|
||||
|
||||
.rdw-editor-main {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.editor {
|
||||
border: 1px solid #F1F1F1;
|
||||
padding: 5px;
|
||||
border-radius: 2px;
|
||||
height: auto;
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.toolbar {}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "Editor",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "./Editor.js"
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import styles from './FilterItem.less'
|
||||
|
||||
const FilterItem = ({
|
||||
label = '',
|
||||
children,
|
||||
}) => {
|
||||
const labelArray = label.split('')
|
||||
return (
|
||||
<div className={styles.filterItem}>
|
||||
{labelArray.length > 0
|
||||
? <div className={styles.labelWrap}>
|
||||
{labelArray.map((item, index) => <span className="labelText" key={index}>{item}</span>)}
|
||||
</div>
|
||||
: ''}
|
||||
<div className={styles.item}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
FilterItem.propTypes = {
|
||||
label: PropTypes.string,
|
||||
children: PropTypes.element.isRequired,
|
||||
}
|
||||
|
||||
export default FilterItem
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from 'react'
|
||||
import styles from './index.less'
|
||||
|
||||
interface FilterItemProps {
|
||||
label: string
|
||||
}
|
||||
const FilterItem: React.FC<FilterItemProps> = ({ label = '', children }) => {
|
||||
const labelArray = label.split('')
|
||||
return (
|
||||
<div className={styles.filterItem}>
|
||||
{labelArray.length > 0 && (
|
||||
<div className={styles.labelWrap}>
|
||||
{labelArray.map((item, index) => (
|
||||
<span className="labelText" key={index}>
|
||||
{item}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.item}>{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default FilterItem
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "FilterItem",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "./FilterItem.js"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@import '~antd/lib/style/themes/default.less';
|
||||
|
||||
.globalFooter {
|
||||
margin: 48px 0 24px 0;
|
||||
padding: 0 16px;
|
||||
text-align: center;
|
||||
|
||||
.links {
|
||||
margin-bottom: 8px;
|
||||
|
||||
a {
|
||||
color: @text-color-secondary;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: @text-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copyright {
|
||||
color: @text-color-secondary;
|
||||
font-size: @font-size-base;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import React from 'react'
|
||||
import styles from './index.less'
|
||||
|
||||
interface LinkItem {
|
||||
key: string
|
||||
title: React.ReactNode
|
||||
href?: string
|
||||
blankTarget?: boolean
|
||||
}
|
||||
|
||||
interface GlobalFooterProps {
|
||||
links?: LinkItem[]
|
||||
copyright?: React.ReactNode
|
||||
}
|
||||
|
||||
const GlobalFooter: React.FC<GlobalFooterProps> = ({
|
||||
links = [],
|
||||
copyright,
|
||||
}) => {
|
||||
return (
|
||||
<footer className={styles.globalFooter}>
|
||||
<div className={styles.links}>
|
||||
{links.map((link) => (
|
||||
<a
|
||||
key={link.key}
|
||||
title={link.key}
|
||||
target={link.blankTarget ? '_blank' : '_self'}
|
||||
href={link.href}
|
||||
rel="noreferrer"
|
||||
>
|
||||
{link.title}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
{copyright && <div className={styles.copyright}>{copyright}</div>}
|
||||
</footer>
|
||||
)
|
||||
}
|
||||
|
||||
export default GlobalFooter
|
||||
@@ -1,21 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import './iconfont.less'
|
||||
|
||||
const Iconfont = ({ type, colorful }) => {
|
||||
if (colorful) {
|
||||
return (<span
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `<svg class="colorful-icon" aria-hidden="true"><use xlink:href="#${type.startsWith('#') ? type.replace(/#/, '') : type}"></use></svg>`,
|
||||
}}
|
||||
/>)
|
||||
}
|
||||
return <i className={`antdadmin icon-${type}`} />
|
||||
}
|
||||
|
||||
Iconfont.propTypes = {
|
||||
type: PropTypes.string,
|
||||
colorful: PropTypes.bool,
|
||||
}
|
||||
|
||||
export default Iconfont
|
||||
@@ -1,8 +0,0 @@
|
||||
:global .colorful-icon {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
vertical-align: -0.15em;
|
||||
fill: currentColor;
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "Iconfont",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "./Iconfont.js"
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Breadcrumb, Icon } from 'antd'
|
||||
import { Link } from 'dva/router'
|
||||
import pathToRegexp from 'path-to-regexp'
|
||||
import { queryArray } from 'utils'
|
||||
import styles from './Bread.less'
|
||||
|
||||
const Bread = ({ menu, location }) => {
|
||||
// 匹配当前路由
|
||||
let pathArray = []
|
||||
let current
|
||||
for (let index in menu) {
|
||||
if (menu[index].route && pathToRegexp(menu[index].route).exec(location.pathname)) {
|
||||
current = menu[index]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const getPathArray = (item) => {
|
||||
pathArray.unshift(item)
|
||||
if (item.bpid) {
|
||||
getPathArray(queryArray(menu, item.bpid, 'id'))
|
||||
}
|
||||
}
|
||||
|
||||
if (!current) {
|
||||
pathArray.push(menu[0] || {
|
||||
id: 1,
|
||||
icon: 'laptop',
|
||||
name: 'Dashboard',
|
||||
})
|
||||
pathArray.push({
|
||||
id: 404,
|
||||
name: 'Not Found',
|
||||
})
|
||||
} else {
|
||||
getPathArray(current)
|
||||
}
|
||||
|
||||
// 递归查找父级
|
||||
const breads = pathArray.map((item, key) => {
|
||||
const content = (
|
||||
<span>{item.icon
|
||||
? <Icon type={item.icon} style={{ marginRight: 4 }} />
|
||||
: ''}{item.name}</span>
|
||||
)
|
||||
return (
|
||||
<Breadcrumb.Item key={key}>
|
||||
{((pathArray.length - 1) !== key)
|
||||
? <Link to={item.route}>
|
||||
{content}
|
||||
</Link>
|
||||
: content}
|
||||
</Breadcrumb.Item>
|
||||
)
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={styles.bread}>
|
||||
<Breadcrumb>
|
||||
{breads}
|
||||
</Breadcrumb>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Bread.propTypes = {
|
||||
menu: PropTypes.array,
|
||||
location: PropTypes.object,
|
||||
}
|
||||
|
||||
export default Bread
|
||||
@@ -1,8 +0,0 @@
|
||||
@import "~themes/vars";
|
||||
|
||||
.bread {
|
||||
height: 64px;
|
||||
line-height: 64px;
|
||||
padding: 0 24px;
|
||||
margin-bottom: -24px;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import React from 'react'
|
||||
import { config } from 'utils'
|
||||
import styles from './Footer.less'
|
||||
|
||||
const Footer = () => (<div className={styles.footer}>
|
||||
{config.footerText}
|
||||
</div>)
|
||||
|
||||
export default Footer
|
||||
@@ -1,12 +0,0 @@
|
||||
@import "~themes/vars";
|
||||
|
||||
.footer {
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
background: #fff;
|
||||
box-shadow: @shadow-2;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Menu, Icon, Popover } from 'antd'
|
||||
import classnames from 'classnames'
|
||||
import styles from './Header.less'
|
||||
import Menus from './Menu'
|
||||
|
||||
const SubMenu = Menu.SubMenu
|
||||
|
||||
const Header = ({ user, logout, switchSider, siderFold, isNavbar, menuPopoverVisible, location, switchMenuPopover, navOpenKeys, changeOpenKeys, menu }) => {
|
||||
let handleClickMenu = e => e.key === 'logout' && logout()
|
||||
const menusProps = {
|
||||
menu,
|
||||
siderFold: false,
|
||||
darkTheme: false,
|
||||
isNavbar,
|
||||
handleClickNavMenu: switchMenuPopover,
|
||||
location,
|
||||
navOpenKeys,
|
||||
changeOpenKeys,
|
||||
}
|
||||
return (
|
||||
<div className={styles.header}>
|
||||
{isNavbar
|
||||
? <Popover placement="bottomLeft" onVisibleChange={switchMenuPopover} visible={menuPopoverVisible} overlayClassName={styles.popovermenu} trigger="click" content={<Menus {...menusProps} />}>
|
||||
<div className={styles.button}>
|
||||
<Icon type="bars" />
|
||||
</div>
|
||||
</Popover>
|
||||
: <div
|
||||
className={styles.button}
|
||||
onClick={switchSider}
|
||||
>
|
||||
<Icon type={classnames({ 'menu-unfold': siderFold, 'menu-fold': !siderFold })} />
|
||||
</div>}
|
||||
<div className={styles.rightWarpper}>
|
||||
<div className={styles.button}>
|
||||
<Icon type="mail" />
|
||||
</div>
|
||||
<Menu mode="horizontal" onClick={handleClickMenu}>
|
||||
<SubMenu
|
||||
style={{
|
||||
float: 'right',
|
||||
}}
|
||||
title={<span>
|
||||
<Icon type="user" />
|
||||
{user.username}
|
||||
</span>}
|
||||
>
|
||||
<Menu.Item key="logout">
|
||||
Sign out
|
||||
</Menu.Item>
|
||||
</SubMenu>
|
||||
</Menu>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Header.propTypes = {
|
||||
menu: PropTypes.array,
|
||||
user: PropTypes.object,
|
||||
logout: PropTypes.func,
|
||||
switchSider: PropTypes.func,
|
||||
siderFold: PropTypes.bool,
|
||||
isNavbar: PropTypes.bool,
|
||||
menuPopoverVisible: PropTypes.bool,
|
||||
location: PropTypes.object,
|
||||
switchMenuPopover: PropTypes.func,
|
||||
navOpenKeys: PropTypes.array,
|
||||
changeOpenKeys: PropTypes.func,
|
||||
}
|
||||
|
||||
export default Header
|
||||
@@ -1,59 +0,0 @@
|
||||
@import "~themes/vars";
|
||||
|
||||
.header {
|
||||
:global .ant-menu-horizontal {
|
||||
& > .ant-menu-submenu {
|
||||
float: right;
|
||||
}
|
||||
border: none;
|
||||
display: inline-block;
|
||||
}
|
||||
box-shadow: @shadow-2;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
height: 47px;
|
||||
background-color: #fff;
|
||||
z-index: 999;
|
||||
|
||||
.rightWarpper {
|
||||
display: flex;
|
||||
padding-right: 16px;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 47px;
|
||||
height: 47px;
|
||||
line-height: 47px;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
transition: @transition-ease-in;
|
||||
|
||||
&:hover {
|
||||
color: @primary-color;
|
||||
background-color: fade(@primary-color, 15%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.popovermenu {
|
||||
width: 280px;
|
||||
margin-left: 6px;
|
||||
|
||||
:global .ant-popover-inner-content {
|
||||
padding: 0;
|
||||
|
||||
.ant-menu-inline .ant-menu-item,
|
||||
.ant-menu-vertical .ant-menu-item {
|
||||
border-right: 0;
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
}
|
||||
|
||||
.ant-menu-inline .ant-menu-item-selected,
|
||||
.ant-menu-inline .ant-menu-selected {
|
||||
border-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
@import "~themes/vars";
|
||||
|
||||
.layout {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
|
||||
&.withnavbar {
|
||||
.main {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.fold {
|
||||
.sider {
|
||||
width: 42px;
|
||||
|
||||
.logo {
|
||||
img {
|
||||
width: 28px;
|
||||
margin: 6px 7px;
|
||||
}
|
||||
}
|
||||
|
||||
:global {
|
||||
.ant-menu-root {
|
||||
width: 100%;
|
||||
overflow: visible;
|
||||
|
||||
& > .ant-menu-item {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
|
||||
.anticon {
|
||||
font-size: 14px;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
& > .ant-menu-submenu {
|
||||
& > .ant-menu-submenu-title {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
|
||||
.anticon {
|
||||
font-size: 14px;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
margin-left: 42px;
|
||||
}
|
||||
}
|
||||
|
||||
.sider {
|
||||
width: 224px;
|
||||
background: #3e3e3e;
|
||||
position: absolute;
|
||||
overflow: visible;
|
||||
padding-bottom: 24px;
|
||||
height: 100vh;
|
||||
transition: @transition-ease-out;
|
||||
box-shadow: @shadow-1;
|
||||
color: #999;
|
||||
|
||||
&.light {
|
||||
background: #fff;
|
||||
|
||||
.switchtheme {
|
||||
background: #fff;
|
||||
border-top: solid 1px #f8f8f8;
|
||||
}
|
||||
}
|
||||
|
||||
.logo {
|
||||
text-align: center;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
cursor: pointer;
|
||||
margin: 28px 0;
|
||||
transition: @transition-ease-out;
|
||||
overflow: hidden;
|
||||
|
||||
img {
|
||||
width: 40px;
|
||||
margin-right: 8px;
|
||||
transition: @transition-ease-out;
|
||||
}
|
||||
|
||||
span {
|
||||
vertical-align: text-bottom;
|
||||
font-size: 16px;
|
||||
text-transform: uppercase;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.anticon {
|
||||
transition: @transition-ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
.switchtheme {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
height: 48px;
|
||||
background-color: @dark-half;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 16px 0 24px;
|
||||
overflow: hidden;
|
||||
z-index: 1000;
|
||||
|
||||
span {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:global {
|
||||
.anticon {
|
||||
min-width: 14px;
|
||||
margin-right: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global {
|
||||
.ant-menu-dark,
|
||||
.ant-menu-dark .ant-menu-sub {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ant-menu-root {
|
||||
height: ~"calc(100vh - 144px)";
|
||||
overflow-x: hidden;
|
||||
border-right: none;
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
&.ant-menu-vertical {
|
||||
.ant-menu-sub {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.ant-menu-submenu-active {
|
||||
.ant-menu-sub {
|
||||
height: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-menu {
|
||||
transition: @transition-ease-out;
|
||||
|
||||
.ant-menu-item,
|
||||
.ant-menu-submenu-title {
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
margin-left: 224px;
|
||||
overflow: auto;
|
||||
height: 100vh;
|
||||
transition: @transition-ease-out;
|
||||
|
||||
:global {
|
||||
.content-inner {
|
||||
background: #fff;
|
||||
padding: 24px;
|
||||
box-shadow: @shadow-1;
|
||||
min-height: e("calc(100vh - 184px)");
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 24px;
|
||||
}
|
||||
|
||||
.content {
|
||||
min-height: e("calc(100vh - 184px)");
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global .ant-menu-dark {
|
||||
color: #999;
|
||||
background-color: #3e3e3e;
|
||||
|
||||
.ant-menu-submenu-title:hover,
|
||||
.ant-menu-submenu:hover {
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
.ant-menu-sub {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ant-menu-submenu-selected {
|
||||
color: @primary-color;
|
||||
|
||||
&:not(.ant-menu-submenu-open) {
|
||||
background-color: @dark-half;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-menu-item,
|
||||
.ant-menu-submenu-title {
|
||||
& > a {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
&:hover > a {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&.ant-menu-inline {
|
||||
.ant-menu-item-selected {
|
||||
background-color: @dark-half;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-menu-item-selected {
|
||||
color: @primary-color;
|
||||
background-color: @dark-half;
|
||||
|
||||
& > a {
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: @dark-half;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.spin {
|
||||
:global .ant-spin-container {
|
||||
height: 100vh;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.layout {
|
||||
.main {
|
||||
.container {
|
||||
margin: 12px;
|
||||
}
|
||||
|
||||
.bread {
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.content {
|
||||
min-height: e("calc(100vh - 160px)");
|
||||
}
|
||||
|
||||
:global {
|
||||
.content-inner {
|
||||
padding: 12px;
|
||||
min-height: e("calc(100vh - 160px)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||