张延森 4 年前
当前提交
d7b5d3cab2
共有 100 个文件被更改,包括 4377 次插入0 次删除
  1. 16
    0
      .editorconfig
  2. 4
    0
      .eslintignore
  3. 8
    0
      .eslintrc.js
  4. 40
    0
      .gitignore
  5. 21
    0
      .prettierignore
  6. 5
    0
      .prettierrc.js
  7. 5
    0
      .stylelintrc.js
  8. 57
    0
      README.md
  9. 184
    0
      config/config.js
  10. 17
    0
      config/defaultSettings.js
  11. 68
    0
      config/plugin.config.js
  12. 36
    0
      config/proxy.js
  13. 114
    0
      config/themePluginConfig.js
  14. 12
    0
      jest-puppeteer.config.js
  15. 9
    0
      jest.config.js
  16. 10
    0
      jsconfig.json
  17. 103
    0
      mock/notices.js
  18. 7
    0
      mock/route.js
  19. 148
    0
      mock/user.js
  20. 120
    0
      package.json
  21. 二进制
      public/favicon.png
  22. 二进制
      public/home_bg.png
  23. 二进制
      public/icons/icon-128x128.png
  24. 二进制
      public/icons/icon-192x192.png
  25. 二进制
      public/icons/icon-512x512.png
  26. 1
    0
      public/pro_icon.svg
  27. 1
    0
      src/assets/logo.svg
  28. 21
    0
      src/components/Authorized/Authorized.jsx
  29. 25
    0
      src/components/Authorized/AuthorizedRoute.jsx
  30. 76
    0
      src/components/Authorized/CheckPermissions.jsx
  31. 78
    0
      src/components/Authorized/PromiseRender.jsx
  32. 70
    0
      src/components/Authorized/Secured.jsx
  33. 8
    0
      src/components/Authorized/index.jsx
  34. 30
    0
      src/components/Authorized/renderAuthorize.js
  35. 79
    0
      src/components/GlobalHeader/AvatarDropdown.jsx
  36. 174
    0
      src/components/GlobalHeader/NoticeIconView.jsx
  37. 69
    0
      src/components/GlobalHeader/RightContent.jsx
  38. 103
    0
      src/components/GlobalHeader/index.less
  39. 10
    0
      src/components/HeaderDropdown/index.jsx
  40. 16
    0
      src/components/HeaderDropdown/index.less
  41. 131
    0
      src/components/HeaderSearch/index.jsx
  42. 32
    0
      src/components/HeaderSearch/index.less
  43. 95
    0
      src/components/NoticeIcon/NoticeList.jsx
  44. 103
    0
      src/components/NoticeIcon/NoticeList.less
  45. 156
    0
      src/components/NoticeIcon/index.jsx
  46. 31
    0
      src/components/NoticeIcon/index.less
  47. 4
    0
      src/components/PageLoading/index.jsx
  48. 53
    0
      src/components/SelectLang/index.jsx
  49. 24
    0
      src/components/SelectLang/index.less
  50. 1
    0
      src/e2e/__mocks__/antd-pro-merge-less.js
  51. 45
    0
      src/e2e/baseLayout.e2e.js
  52. 15
    0
      src/e2e/topMenu.e2e.js
  53. 101
    0
      src/global.jsx
  54. 54
    0
      src/global.less
  55. 178
    0
      src/layouts/BasicLayout.jsx
  56. 5
    0
      src/layouts/BlankLayout.jsx
  57. 50
    0
      src/layouts/SecurityLayout.jsx
  58. 60
    0
      src/layouts/UserLayout.jsx
  59. 71
    0
      src/layouts/UserLayout.less
  60. 21
    0
      src/locales/en-US.js
  61. 5
    0
      src/locales/en-US/component.js
  62. 17
    0
      src/locales/en-US/globalHeader.js
  63. 52
    0
      src/locales/en-US/menu.js
  64. 6
    0
      src/locales/en-US/pwa.js
  65. 31
    0
      src/locales/en-US/settingDrawer.js
  66. 60
    0
      src/locales/en-US/settings.js
  67. 19
    0
      src/locales/pt-BR.js
  68. 5
    0
      src/locales/pt-BR/component.js
  69. 18
    0
      src/locales/pt-BR/globalHeader.js
  70. 52
    0
      src/locales/pt-BR/menu.js
  71. 7
    0
      src/locales/pt-BR/pwa.js
  72. 32
    0
      src/locales/pt-BR/settingDrawer.js
  73. 60
    0
      src/locales/pt-BR/settings.js
  74. 21
    0
      src/locales/zh-CN.js
  75. 5
    0
      src/locales/zh-CN/component.js
  76. 17
    0
      src/locales/zh-CN/globalHeader.js
  77. 52
    0
      src/locales/zh-CN/menu.js
  78. 6
    0
      src/locales/zh-CN/pwa.js
  79. 31
    0
      src/locales/zh-CN/settingDrawer.js
  80. 55
    0
      src/locales/zh-CN/settings.js
  81. 19
    0
      src/locales/zh-TW.js
  82. 5
    0
      src/locales/zh-TW/component.js
  83. 17
    0
      src/locales/zh-TW/globalHeader.js
  84. 52
    0
      src/locales/zh-TW/menu.js
  85. 6
    0
      src/locales/zh-TW/pwa.js
  86. 31
    0
      src/locales/zh-TW/settingDrawer.js
  87. 55
    0
      src/locales/zh-TW/settings.js
  88. 22
    0
      src/manifest.json
  89. 22
    0
      src/models/building.js
  90. 114
    0
      src/models/global.js
  91. 73
    0
      src/models/login.js
  92. 27
    0
      src/models/setting.js
  93. 50
    0
      src/models/user.js
  94. 19
    0
      src/pages/404.jsx
  95. 40
    0
      src/pages/Admin.jsx
  96. 32
    0
      src/pages/Authorized.jsx
  97. 66
    0
      src/pages/Welcome.jsx
  98. 8
    0
      src/pages/Welcome.less
  99. 193
    0
      src/pages/document.ejs
  100. 0
    0
      src/pages/user/login/components/Login/LoginContext.jsx

+ 16
- 0
.editorconfig 查看文件

@@ -0,0 +1,16 @@
1
+# http://editorconfig.org
2
+root = true
3
+
4
+[*]
5
+indent_style = space
6
+indent_size = 2
7
+end_of_line = lf
8
+charset = utf-8
9
+trim_trailing_whitespace = true
10
+insert_final_newline = true
11
+
12
+[*.md]
13
+trim_trailing_whitespace = false
14
+
15
+[Makefile]
16
+indent_style = tab

+ 4
- 0
.eslintignore 查看文件

@@ -0,0 +1,4 @@
1
+/lambda/
2
+/scripts
3
+/config
4
+.history

+ 8
- 0
.eslintrc.js 查看文件

@@ -0,0 +1,8 @@
1
+module.exports = {
2
+  extends: [require.resolve('@umijs/fabric/dist/eslint')],
3
+  globals: {
4
+    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
5
+    page: true,
6
+    REACT_APP_ENV: true,
7
+  },
8
+};

+ 40
- 0
.gitignore 查看文件

@@ -0,0 +1,40 @@
1
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+# dependencies
4
+**/node_modules
5
+# roadhog-api-doc ignore
6
+/src/utils/request-temp.js
7
+_roadhog-api-doc
8
+
9
+# production
10
+/dist
11
+/.vscode
12
+
13
+# misc
14
+.DS_Store
15
+npm-debug.log*
16
+yarn-error.log
17
+
18
+/coverage
19
+.idea
20
+yarn.lock
21
+package-lock.json
22
+*bak
23
+.vscode
24
+
25
+# visual studio code
26
+.history
27
+*.log
28
+functions/*
29
+.temp/**
30
+
31
+# umi
32
+.umi
33
+.umi-production
34
+
35
+# screenshot
36
+screenshot
37
+.firebase
38
+.eslintcache
39
+
40
+build

+ 21
- 0
.prettierignore 查看文件

@@ -0,0 +1,21 @@
1
+**/*.svg
2
+package.json
3
+.umi
4
+.umi-production
5
+/dist
6
+.dockerignore
7
+.DS_Store
8
+.eslintignore
9
+*.png
10
+*.toml
11
+docker
12
+.editorconfig
13
+Dockerfile*
14
+.gitignore
15
+.prettierignore
16
+LICENSE
17
+.eslintcache
18
+*.lock
19
+yarn-error.log
20
+.history
21
+CNAME

+ 5
- 0
.prettierrc.js 查看文件

@@ -0,0 +1,5 @@
1
+const fabric = require('@umijs/fabric');
2
+
3
+module.exports = {
4
+  ...fabric.prettier,
5
+};

+ 5
- 0
.stylelintrc.js 查看文件

@@ -0,0 +1,5 @@
1
+const fabric = require('@umijs/fabric');
2
+
3
+module.exports = {
4
+  ...fabric.stylelint,
5
+};

+ 57
- 0
README.md 查看文件

@@ -0,0 +1,57 @@
1
+# Ant Design Pro
2
+
3
+This project is initialized with [Ant Design Pro](https://pro.ant.design). Follow is the quick guide for how to use.
4
+
5
+## Environment Prepare
6
+
7
+Install `node_modules`:
8
+
9
+```bash
10
+npm install
11
+```
12
+
13
+or
14
+
15
+```bash
16
+yarn
17
+```
18
+
19
+## Provided Scripts
20
+
21
+Ant Design Pro provides some useful script to help you quick start and build with web project, code style check and test.
22
+
23
+Scripts provided in `package.json`. It's safe to modify or add additional script:
24
+
25
+### Start project
26
+
27
+```bash
28
+npm start
29
+```
30
+
31
+### Build project
32
+
33
+```bash
34
+npm run build
35
+```
36
+
37
+### Check code style
38
+
39
+```bash
40
+npm run lint
41
+```
42
+
43
+You can also use script to auto fix some lint error:
44
+
45
+```bash
46
+npm run lint:fix
47
+```
48
+
49
+### Test code
50
+
51
+```bash
52
+npm test
53
+```
54
+
55
+## More
56
+
57
+You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro).

+ 184
- 0
config/config.js 查看文件

@@ -0,0 +1,184 @@
1
+import defaultSettings from './defaultSettings'; // https://umijs.org/config/
2
+
3
+import slash from 'slash2';
4
+import themePluginConfig from './themePluginConfig';
5
+import proxy from './proxy';
6
+import webpackPlugin from './plugin.config';
7
+const { pwa } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
8
+// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
9
+
10
+const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, REACT_APP_ENV } = process.env;
11
+const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
12
+const plugins = [
13
+  ['umi-plugin-antd-icon-config', {}],
14
+  [
15
+    'umi-plugin-react',
16
+    {
17
+      antd: true,
18
+      dva: {
19
+        hmr: true,
20
+      },
21
+      locale: {
22
+        // default false
23
+        enable: true,
24
+        // default zh-CN
25
+        default: 'zh-CN',
26
+        // default true, when it is true, will use `navigator.language` overwrite default
27
+        baseNavigator: true,
28
+      },
29
+      dynamicImport: {
30
+        loadingComponent: './components/PageLoading/index',
31
+        webpackChunkName: true,
32
+        level: 3,
33
+      },
34
+      pwa: pwa
35
+        ? {
36
+            workboxPluginMode: 'InjectManifest',
37
+            workboxOptions: {
38
+              importWorkboxFrom: 'local',
39
+            },
40
+          }
41
+        : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
42
+      // dll features https://webpack.js.org/plugins/dll-plugin/
43
+      // dll: {
44
+      //   include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
45
+      //   exclude: ['@babel/runtime', 'netlify-lambda'],
46
+      // },
47
+    },
48
+  ],
49
+  [
50
+    'umi-plugin-pro-block',
51
+    {
52
+      moveMock: false,
53
+      moveService: false,
54
+      modifyRequest: true,
55
+      autoAddMenu: true,
56
+    },
57
+  ],
58
+];
59
+
60
+if (isAntDesignProPreview) {
61
+  // 针对 preview.pro.ant.design 的 GA 统计代码
62
+  plugins.push([
63
+    'umi-plugin-ga',
64
+    {
65
+      code: 'UA-72788897-6',
66
+    },
67
+  ]);
68
+  plugins.push(['umi-plugin-antd-theme', themePluginConfig]);
69
+}
70
+
71
+export default {
72
+  plugins,
73
+  hash: true,
74
+  targets: {
75
+    ie: 11,
76
+  },
77
+  // umi routes: https://umijs.org/zh/guide/router.html
78
+  routes: [
79
+    {
80
+      path: '/user',
81
+      component: '../layouts/UserLayout',
82
+      routes: [
83
+        {
84
+          name: 'login',
85
+          path: '/user/login',
86
+          component: './user/login',
87
+        },
88
+      ],
89
+    },
90
+    {
91
+      path: '/',
92
+      component: '../layouts/SecurityLayout',
93
+      routes: [
94
+        {
95
+          path: '/',
96
+          component: '../layouts/BasicLayout',
97
+          authority: ['admin', 'user'],
98
+          routes: [
99
+            {
100
+              path: '/',
101
+              redirect: '/welcome',
102
+            },
103
+            {
104
+              path: '/welcome',
105
+              name: 'welcome',
106
+              icon: 'smile',
107
+              component: './Welcome',
108
+            },
109
+            {
110
+              path: '/admin',
111
+              name: 'admin',
112
+              icon: 'crown',
113
+              component: './Admin',
114
+              authority: ['admin'],
115
+              routes: [
116
+                {
117
+                  path: '/admin/sub-page',
118
+                  name: 'sub-page',
119
+                  icon: 'smile',
120
+                  component: './Welcome',
121
+                  authority: ['admin'],
122
+                },
123
+              ],
124
+            },
125
+            {
126
+              component: './404',
127
+            },
128
+          ],
129
+        },
130
+        {
131
+          component: './404',
132
+        },
133
+      ],
134
+    },
135
+    {
136
+      component: './404',
137
+    },
138
+  ],
139
+  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
140
+  theme: {
141
+    // ...darkTheme,
142
+    'primary-color': defaultSettings.primaryColor,
143
+  },
144
+  define: {
145
+    REACT_APP_ENV: REACT_APP_ENV || false,
146
+    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
147
+      ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
148
+  },
149
+  ignoreMomentLocale: true,
150
+  lessLoaderOptions: {
151
+    javascriptEnabled: true,
152
+  },
153
+  disableRedirectHoist: true,
154
+  cssLoaderOptions: {
155
+    modules: true,
156
+    getLocalIdent: (context, _, localName) => {
157
+      if (
158
+        context.resourcePath.includes('node_modules') ||
159
+        context.resourcePath.includes('ant.design.pro.less') ||
160
+        context.resourcePath.includes('global.less')
161
+      ) {
162
+        return localName;
163
+      }
164
+
165
+      const match = context.resourcePath.match(/src(.*)/);
166
+
167
+      if (match && match[1]) {
168
+        const antdProPath = match[1].replace('.less', '');
169
+        const arr = slash(antdProPath)
170
+          .split('/')
171
+          .map((a) => a.replace(/([A-Z])/g, '-$1'))
172
+          .map((a) => a.toLowerCase());
173
+        return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
174
+      }
175
+
176
+      return localName;
177
+    },
178
+  },
179
+  manifest: {
180
+    basePath: '/',
181
+  },
182
+  proxy: proxy[REACT_APP_ENV || 'dev'],
183
+  chainWebpack: webpackPlugin,
184
+};

+ 17
- 0
config/defaultSettings.js 查看文件

@@ -0,0 +1,17 @@
1
+export default {
2
+  navTheme: 'dark',
3
+  // 拂晓蓝
4
+  primaryColor: '#1890ff',
5
+  layout: 'sidemenu',
6
+  contentWidth: 'Fluid',
7
+  fixedHeader: false,
8
+  autoHideHeader: false,
9
+  fixSiderbar: false,
10
+  colorWeak: false,
11
+  menu: {
12
+    locale: true,
13
+  },
14
+  title: 'Ant Design Pro',
15
+  pwa: false,
16
+  iconfontUrl: '',
17
+};

+ 68
- 0
config/plugin.config.js 查看文件

@@ -0,0 +1,68 @@
1
+import path from 'path';
2
+
3
+function getModulePackageName(module) {
4
+  if (!module.context) return null;
5
+  const nodeModulesPath = path.join(__dirname, '../node_modules/');
6
+
7
+  if (module.context.substring(0, nodeModulesPath.length) !== nodeModulesPath) {
8
+    return null;
9
+  }
10
+
11
+  const moduleRelativePath = module.context.substring(nodeModulesPath.length);
12
+  const [moduleDirName] = moduleRelativePath.split(path.sep);
13
+  let packageName = moduleDirName; // handle tree shaking
14
+
15
+  if (packageName && packageName.match('^_')) {
16
+    // eslint-disable-next-line prefer-destructuring
17
+    packageName = packageName.match(/^_(@?[^@]+)/)[1];
18
+  }
19
+
20
+  return packageName;
21
+}
22
+
23
+const webpackPlugin = (config) => {
24
+  // optimize chunks
25
+  config.optimization // share the same chunks across different modules
26
+    .runtimeChunk(false)
27
+    .splitChunks({
28
+      chunks: 'async',
29
+      name: 'vendors',
30
+      maxInitialRequests: Infinity,
31
+      minSize: 0,
32
+      cacheGroups: {
33
+        vendors: {
34
+          test: (module) => {
35
+            const packageName = getModulePackageName(module) || '';
36
+
37
+            if (packageName) {
38
+              return [
39
+                'bizcharts',
40
+                'gg-editor',
41
+                'g6',
42
+                '@antv',
43
+                'l7',
44
+                'gg-editor-core',
45
+                'bizcharts-plugin-slider',
46
+              ].includes(packageName);
47
+            }
48
+
49
+            return false;
50
+          },
51
+
52
+          name(module) {
53
+            const packageName = getModulePackageName(module);
54
+
55
+            if (packageName) {
56
+              if (['bizcharts', '@antv_data-set'].indexOf(packageName) >= 0) {
57
+                return 'viz'; // visualization package
58
+              }
59
+            }
60
+
61
+            return 'misc';
62
+          },
63
+        },
64
+      },
65
+    });
66
+};
67
+
68
+export default webpackPlugin;

+ 36
- 0
config/proxy.js 查看文件

@@ -0,0 +1,36 @@
1
+/**
2
+ * 在生产环境 代理是无法生效的,所以这里没有生产环境的配置
3
+ * The agent cannot take effect in the production environment
4
+ * so there is no configuration of the production environment
5
+ * For details, please see
6
+ * https://pro.ant.design/docs/deploy
7
+ */
8
+export default {
9
+  dev: {
10
+    '/api/': {
11
+      target: 'https://preview.pro.ant.design',
12
+      changeOrigin: true,
13
+      pathRewrite: {
14
+        '^': '',
15
+      },
16
+    },
17
+  },
18
+  test: {
19
+    '/api/': {
20
+      target: 'https://preview.pro.ant.design',
21
+      changeOrigin: true,
22
+      pathRewrite: {
23
+        '^': '',
24
+      },
25
+    },
26
+  },
27
+  pre: {
28
+    '/api/': {
29
+      target: 'your pre url',
30
+      changeOrigin: true,
31
+      pathRewrite: {
32
+        '^': '',
33
+      },
34
+    },
35
+  },
36
+};

+ 114
- 0
config/themePluginConfig.js 查看文件

@@ -0,0 +1,114 @@
1
+export default {
2
+  theme: [
3
+    {
4
+      key: 'dark',
5
+      fileName: 'dark.css',
6
+      theme: 'dark',
7
+    },
8
+    {
9
+      key: 'dust',
10
+      fileName: 'dust.css',
11
+      modifyVars: {
12
+        '@primary-color': '#F5222D',
13
+      },
14
+    },
15
+    {
16
+      key: 'volcano',
17
+      fileName: 'volcano.css',
18
+      modifyVars: {
19
+        '@primary-color': '#FA541C',
20
+      },
21
+    },
22
+    {
23
+      key: 'sunset',
24
+      fileName: 'sunset.css',
25
+      modifyVars: {
26
+        '@primary-color': '#FAAD14',
27
+      },
28
+    },
29
+    {
30
+      key: 'cyan',
31
+      fileName: 'cyan.css',
32
+      modifyVars: {
33
+        '@primary-color': '#13C2C2',
34
+      },
35
+    },
36
+    {
37
+      key: 'green',
38
+      fileName: 'green.css',
39
+      modifyVars: {
40
+        '@primary-color': '#52C41A',
41
+      },
42
+    },
43
+    {
44
+      key: 'geekblue',
45
+      fileName: 'geekblue.css',
46
+      modifyVars: {
47
+        '@primary-color': '#2F54EB',
48
+      },
49
+    },
50
+    {
51
+      key: 'purple',
52
+      fileName: 'purple.css',
53
+      modifyVars: {
54
+        '@primary-color': '#722ED1',
55
+      },
56
+    },
57
+    {
58
+      key: 'dust',
59
+      theme: 'dark',
60
+      fileName: 'dark-dust.css',
61
+      modifyVars: {
62
+        '@primary-color': '#F5222D',
63
+      },
64
+    },
65
+    {
66
+      key: 'volcano',
67
+      theme: 'dark',
68
+      fileName: 'dark-volcano.css',
69
+      modifyVars: {
70
+        '@primary-color': '#FA541C',
71
+      },
72
+    },
73
+    {
74
+      key: 'sunset',
75
+      theme: 'dark',
76
+      fileName: 'dark-sunset.css',
77
+      modifyVars: {
78
+        '@primary-color': '#FAAD14',
79
+      },
80
+    },
81
+    {
82
+      key: 'cyan',
83
+      theme: 'dark',
84
+      fileName: 'dark-cyan.css',
85
+      modifyVars: {
86
+        '@primary-color': '#13C2C2',
87
+      },
88
+    },
89
+    {
90
+      key: 'green',
91
+      theme: 'dark',
92
+      fileName: 'dark-green.css',
93
+      modifyVars: {
94
+        '@primary-color': '#52C41A',
95
+      },
96
+    },
97
+    {
98
+      key: 'geekblue',
99
+      theme: 'dark',
100
+      fileName: 'dark-geekblue.css',
101
+      modifyVars: {
102
+        '@primary-color': '#2F54EB',
103
+      },
104
+    },
105
+    {
106
+      key: 'purple',
107
+      theme: 'dark',
108
+      fileName: 'dark-purple.css',
109
+      modifyVars: {
110
+        '@primary-color': '#722ED1',
111
+      },
112
+    },
113
+  ],
114
+};

+ 12
- 0
jest-puppeteer.config.js 查看文件

@@ -0,0 +1,12 @@
1
+// ps https://github.com/GoogleChrome/puppeteer/issues/3120
2
+module.exports = {
3
+  launch: {
4
+    args: [
5
+      '--disable-gpu',
6
+      '--disable-dev-shm-usage',
7
+      '--no-first-run',
8
+      '--no-zygote',
9
+      '--no-sandbox',
10
+    ],
11
+  },
12
+};

+ 9
- 0
jest.config.js 查看文件

@@ -0,0 +1,9 @@
1
+module.exports = {
2
+  testURL: 'http://localhost:8000',
3
+  preset: 'jest-puppeteer',
4
+  extraSetupFiles: ['./tests/setupTests.js'],
5
+  globals: {
6
+    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false,
7
+    localStorage: null,
8
+  },
9
+};

+ 10
- 0
jsconfig.json 查看文件

@@ -0,0 +1,10 @@
1
+{
2
+  "compilerOptions": {
3
+    "emitDecoratorMetadata": true,
4
+    "experimentalDecorators": true,
5
+    "baseUrl": ".",
6
+    "paths": {
7
+      "@/*": ["./src/*"]
8
+    }
9
+  }
10
+}

+ 103
- 0
mock/notices.js 查看文件

@@ -0,0 +1,103 @@
1
+const getNotices = (req, res) => {
2
+  res.json([
3
+    {
4
+      id: '000000001',
5
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
6
+      title: '你收到了 14 份新周报',
7
+      datetime: '2017-08-09',
8
+      type: 'notification',
9
+    },
10
+    {
11
+      id: '000000002',
12
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
13
+      title: '你推荐的 曲妮妮 已通过第三轮面试',
14
+      datetime: '2017-08-08',
15
+      type: 'notification',
16
+    },
17
+    {
18
+      id: '000000003',
19
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
20
+      title: '这种模板可以区分多种通知类型',
21
+      datetime: '2017-08-07',
22
+      read: true,
23
+      type: 'notification',
24
+    },
25
+    {
26
+      id: '000000004',
27
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
28
+      title: '左侧图标用于区分不同的类型',
29
+      datetime: '2017-08-07',
30
+      type: 'notification',
31
+    },
32
+    {
33
+      id: '000000005',
34
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
35
+      title: '内容不要超过两行字,超出时自动截断',
36
+      datetime: '2017-08-07',
37
+      type: 'notification',
38
+    },
39
+    {
40
+      id: '000000006',
41
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
42
+      title: '曲丽丽 评论了你',
43
+      description: '描述信息描述信息描述信息',
44
+      datetime: '2017-08-07',
45
+      type: 'message',
46
+      clickClose: true,
47
+    },
48
+    {
49
+      id: '000000007',
50
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
51
+      title: '朱偏右 回复了你',
52
+      description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
53
+      datetime: '2017-08-07',
54
+      type: 'message',
55
+      clickClose: true,
56
+    },
57
+    {
58
+      id: '000000008',
59
+      avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
60
+      title: '标题',
61
+      description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
62
+      datetime: '2017-08-07',
63
+      type: 'message',
64
+      clickClose: true,
65
+    },
66
+    {
67
+      id: '000000009',
68
+      title: '任务名称',
69
+      description: '任务需要在 2017-01-12 20:00 前启动',
70
+      extra: '未开始',
71
+      status: 'todo',
72
+      type: 'event',
73
+    },
74
+    {
75
+      id: '000000010',
76
+      title: '第三方紧急代码变更',
77
+      description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
78
+      extra: '马上到期',
79
+      status: 'urgent',
80
+      type: 'event',
81
+    },
82
+    {
83
+      id: '000000011',
84
+      title: '信息安全考试',
85
+      description: '指派竹尔于 2017-01-09 前完成更新并发布',
86
+      extra: '已耗时 8 天',
87
+      status: 'doing',
88
+      type: 'event',
89
+    },
90
+    {
91
+      id: '000000012',
92
+      title: 'ABCD 版本发布',
93
+      description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
94
+      extra: '进行中',
95
+      status: 'processing',
96
+      type: 'event',
97
+    },
98
+  ]);
99
+};
100
+
101
+export default {
102
+  'GET /api/notices': getNotices,
103
+};

+ 7
- 0
mock/route.js 查看文件

@@ -0,0 +1,7 @@
1
+export default {
2
+  '/api/auth_routes': {
3
+    '/form/advanced-form': {
4
+      authority: ['admin', 'user'],
5
+    },
6
+  },
7
+};

+ 148
- 0
mock/user.js 查看文件

@@ -0,0 +1,148 @@
1
+function getFakeCaptcha(req, res) {
2
+  return res.json('captcha-xxx');
3
+} // 代码中会兼容本地 service mock 以及部署站点的静态数据
4
+
5
+export default {
6
+  // 支持值为 Object 和 Array
7
+  'GET /api/currentUser': {
8
+    name: 'Serati Ma',
9
+    avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
10
+    userid: '00000001',
11
+    email: 'antdesign@alipay.com',
12
+    signature: '海纳百川,有容乃大',
13
+    title: '交互专家',
14
+    group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
15
+    tags: [
16
+      {
17
+        key: '0',
18
+        label: '很有想法的',
19
+      },
20
+      {
21
+        key: '1',
22
+        label: '专注设计',
23
+      },
24
+      {
25
+        key: '2',
26
+        label: '辣~',
27
+      },
28
+      {
29
+        key: '3',
30
+        label: '大长腿',
31
+      },
32
+      {
33
+        key: '4',
34
+        label: '川妹子',
35
+      },
36
+      {
37
+        key: '5',
38
+        label: '海纳百川',
39
+      },
40
+    ],
41
+    notifyCount: 12,
42
+    unreadCount: 11,
43
+    country: 'China',
44
+    geographic: {
45
+      province: {
46
+        label: '浙江省',
47
+        key: '330000',
48
+      },
49
+      city: {
50
+        label: '杭州市',
51
+        key: '330100',
52
+      },
53
+    },
54
+    address: '西湖区工专路 77 号',
55
+    phone: '0752-268888888',
56
+  },
57
+  // GET POST 可省略
58
+  'GET /api/users': [
59
+    {
60
+      key: '1',
61
+      name: 'John Brown',
62
+      age: 32,
63
+      address: 'New York No. 1 Lake Park',
64
+    },
65
+    {
66
+      key: '2',
67
+      name: 'Jim Green',
68
+      age: 42,
69
+      address: 'London No. 1 Lake Park',
70
+    },
71
+    {
72
+      key: '3',
73
+      name: 'Joe Black',
74
+      age: 32,
75
+      address: 'Sidney No. 1 Lake Park',
76
+    },
77
+  ],
78
+  'POST /api/login/account': (req, res) => {
79
+    const { password, userName, type } = req.body;
80
+
81
+    if (password === 'ant.design' && userName === 'admin') {
82
+      res.send({
83
+        status: 'ok',
84
+        type,
85
+        currentAuthority: 'admin',
86
+      });
87
+      return;
88
+    }
89
+
90
+    if (password === 'ant.design' && userName === 'user') {
91
+      res.send({
92
+        status: 'ok',
93
+        type,
94
+        currentAuthority: 'user',
95
+      });
96
+      return;
97
+    }
98
+
99
+    res.send({
100
+      status: 'error',
101
+      type,
102
+      currentAuthority: 'guest',
103
+    });
104
+  },
105
+  'POST /api/register': (req, res) => {
106
+    res.send({
107
+      status: 'ok',
108
+      currentAuthority: 'user',
109
+    });
110
+  },
111
+  'GET /api/500': (req, res) => {
112
+    res.status(500).send({
113
+      timestamp: 1513932555104,
114
+      status: 500,
115
+      error: 'error',
116
+      message: 'error',
117
+      path: '/base/category/list',
118
+    });
119
+  },
120
+  'GET /api/404': (req, res) => {
121
+    res.status(404).send({
122
+      timestamp: 1513932643431,
123
+      status: 404,
124
+      error: 'Not Found',
125
+      message: 'No message available',
126
+      path: '/base/category/list/2121212',
127
+    });
128
+  },
129
+  'GET /api/403': (req, res) => {
130
+    res.status(403).send({
131
+      timestamp: 1513932555104,
132
+      status: 403,
133
+      error: 'Unauthorized',
134
+      message: 'Unauthorized',
135
+      path: '/base/category/list',
136
+    });
137
+  },
138
+  'GET /api/401': (req, res) => {
139
+    res.status(401).send({
140
+      timestamp: 1513932555104,
141
+      status: 401,
142
+      error: 'Unauthorized',
143
+      message: 'Unauthorized',
144
+      path: '/base/category/list',
145
+    });
146
+  },
147
+  'GET  /api/login/captcha': getFakeCaptcha,
148
+};

+ 120
- 0
package.json 查看文件

@@ -0,0 +1,120 @@
1
+{
2
+  "name": "ant-design-pro",
3
+  "version": "4.0.0",
4
+  "private": true,
5
+  "description": "An out-of-box UI solution for enterprise applications",
6
+  "scripts": {
7
+    "analyze": "cross-env ANALYZE=1 umi build",
8
+    "build": "umi build",
9
+    "deploy": "npm run site && npm run gh-pages",
10
+    "fetch:blocks": "pro fetch-blocks && npm run prettier",
11
+    "gh-pages": "cp CNAME ./dist/ && gh-pages -d dist",
12
+    "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
13
+    "lint": "npm run lint:js && npm run lint:style && npm run lint:prettier",
14
+    "lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
15
+    "lint-staged": "lint-staged",
16
+    "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
17
+    "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
18
+    "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
19
+    "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
20
+    "prettier": "prettier -c --write \"**/*\"",
21
+    "start": "umi dev",
22
+    "dev": "npm run start:dev",
23
+    "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none umi dev",
24
+    "start:no-mock": "cross-env MOCK=none umi dev",
25
+    "start:no-ui": "cross-env UMI_UI=none umi dev",
26
+    "start:pre": "cross-env REACT_APP_ENV=pre MOCK=none umi dev",
27
+    "start:test": "cross-env REACT_APP_ENV=test MOCK=none umi dev",
28
+    "test": "umi test",
29
+    "test:all": "node ./tests/run-tests.js",
30
+    "test:component": "umi test ./src/components",
31
+    "tsc": "tsc",
32
+    "ui": "umi ui"
33
+  },
34
+  "husky": {
35
+    "hooks": {
36
+      "pre-commit": "npm run lint-staged"
37
+    }
38
+  },
39
+  "lint-staged": {
40
+    "**/*.less": "stylelint --syntax less",
41
+    "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
42
+    "**/*.{js,jsx,tsx,ts,less,md,json}": [
43
+      "prettier --write"
44
+    ]
45
+  },
46
+  "browserslist": [
47
+    "> 1%",
48
+    "last 2 versions",
49
+    "not ie <= 10"
50
+  ],
51
+  "dependencies": {
52
+    "@ant-design/pro-layout": "^4.10.13",
53
+    "@antv/data-set": "^0.11.0",
54
+    "@zjxpcyc/xrc-form2": "2.2.2",
55
+    "antd": "^3.23.6",
56
+    "classnames": "^2.2.6",
57
+    "dva": "^2.6.0-beta.16",
58
+    "lodash": "^4.17.11",
59
+    "md5": "^2.3.0",
60
+    "moment": "^2.24.0",
61
+    "omit.js": "^1.0.2",
62
+    "path-to-regexp": "2.4.0",
63
+    "qs": "^6.9.0",
64
+    "react": "^16.8.6",
65
+    "react-copy-to-clipboard": "^5.0.1",
66
+    "react-dom": "^16.8.6",
67
+    "react-helmet": "^5.2.1",
68
+    "redux": "^4.0.1",
69
+    "umi": "^2.13.0",
70
+    "umi-plugin-antd-theme": "^1.0.1",
71
+    "umi-plugin-pro-block": "^1.3.2",
72
+    "umi-plugin-react": "^1.9.5",
73
+    "umi-request": "^1.0.8"
74
+  },
75
+  "devDependencies": {
76
+    "@ant-design/pro-cli": "^1.0.18",
77
+    "@types/classnames": "^2.2.7",
78
+    "@types/express": "^4.17.0",
79
+    "@types/history": "^4.7.2",
80
+    "@types/jest": "^25.1.0",
81
+    "@types/lodash": "^4.14.144",
82
+    "@types/qs": "^6.5.3",
83
+    "@types/react": "^16.8.19",
84
+    "@types/react-dom": "^16.8.4",
85
+    "@types/react-helmet": "^5.0.13",
86
+    "@umijs/fabric": "^2.0.2",
87
+    "chalk": "^3.0.0",
88
+    "cross-env": "^7.0.0",
89
+    "cross-port-killer": "^1.1.1",
90
+    "enzyme": "^3.9.0",
91
+    "express": "^4.17.1",
92
+    "gh-pages": "^2.0.1",
93
+    "husky": "^4.0.7",
94
+    "jest-puppeteer": "^4.2.0",
95
+    "jsdom-global": "^3.0.2",
96
+    "lint-staged": "^10.0.0",
97
+    "mockjs": "^1.0.1-beta3",
98
+    "node-fetch": "^2.6.0",
99
+    "prettier": "^1.19.1",
100
+    "pro-download": "1.0.1",
101
+    "stylelint": "^13.0.0",
102
+    "umi-plugin-antd-icon-config": "^1.0.2",
103
+    "umi-plugin-ga": "^1.1.3",
104
+    "umi-plugin-pro": "^1.0.2",
105
+    "umi-types": "^0.5.0"
106
+  },
107
+  "optionalDependencies": {
108
+    "puppeteer": "^2.0.0"
109
+  },
110
+  "engines": {
111
+    "node": ">=10.0.0"
112
+  },
113
+  "checkFiles": [
114
+    "src/**/*.js*",
115
+    "src/**/*.ts*",
116
+    "src/**/*.less",
117
+    "config/**/*.js*",
118
+    "scripts/**/*.js"
119
+  ]
120
+}

二进制
public/favicon.png 查看文件


二进制
public/home_bg.png 查看文件


二进制
public/icons/icon-128x128.png 查看文件


二进制
public/icons/icon-192x192.png 查看文件


二进制
public/icons/icon-512x512.png 查看文件


+ 1
- 0
public/pro_icon.svg 查看文件

@@ -0,0 +1 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="图层_1" width="512" height="512" x="0" y="0" enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve"><path fill-rule="evenodd" d="M259.119,233.588c0-3.644,0.041-7.289-0.008-10.932	c-0.111-8.558-4.697-13.308-13.231-13.486c-6.658-0.139-13.326,0.12-19.98-0.096c-3.292-0.107-4.247,0.995-4.24,4.266	c0.094,44.794,0.101,89.589-0.008,134.383c-0.009,3.492,1.346,4.154,4.407,4.113c9.99-0.135,19.985-0.18,29.972,0.019	c3.52,0.069,4.561-1.136,4.534-4.575c-0.138-16.817-0.124-33.637-0.037-50.455c0.053-10.153-0.512-20.322,0.426-30.457	c1.339-14.5,10.473-23.758,24.802-25.619c4.382-0.569,8.652-0.143,12.92,0.505c4.367,0.663,6.274-1.139,6.266-5.396	c-0.015-7.494-0.048-14.987,0.015-22.48c0.029-3.358-1.322-5.272-4.784-5.789c-13.2-1.97-24.368,1.438-32.905,12.103	C263.914,223.876,262.08,228.86,259.119,233.588z" clip-rule="evenodd"/><g><defs><path id="SVGID_1_" d="M56.964,256.003c0-30.332,0.092-60.665-0.105-90.996c-0.028-4.252,1.185-5.176,5.265-5.141 c25.497,0.221,51.007-0.295,76.491,0.323c20.853,0.505,39.051,8.125,50.951,25.966c14.972,22.448,16.14,46.757,4.473,70.786 c-11.114,22.892-31.459,32.606-56.012,33.989c-12.13,0.683-24.326,0.327-36.489,0.176c-3.462-0.043-4.55,0.903-4.514,4.451 c0.174,17.164-0.026,34.333,0.161,51.496c0.04,3.676-0.859,4.918-4.695,4.82c-10.326-0.262-20.668-0.277-30.994,0.006 c-3.947,0.109-4.622-1.318-4.606-4.882C57.021,316.668,56.964,286.335,56.964,256.003z M115.378,191.878 c-4.832,0-9.666,0.105-14.493-0.042c-2.639-0.08-3.862,0.506-3.844,3.544c0.121,20.324,0.09,40.65,0.026,60.975 c-0.007,2.423,0.494,3.632,3.281,3.58c9.16-0.174,18.349,0.301,27.481-0.248c20.562-1.234,31.673-12.484,32.665-32.392 c0.974-19.536-9.987-32.905-29.141-35.031C126.09,191.681,115.378,191.978,115.378,191.878z"/></defs><use fill-rule="evenodd" clip-rule="evenodd" overflow="visible" xlink:href="#SVGID_1_"/><clipPath id="SVGID_2_"><use overflow="visible" xlink:href="#SVGID_1_"/></clipPath><path fill-rule="evenodd" d="M56.964,256.003c0,30.332,0.056,60.665-0.075,90.996 c-0.016,3.563,0.659,4.991,4.606,4.882c10.325-0.283,20.667-0.268,30.994-0.006c3.836,0.098,4.735-1.145,4.695-4.82 c-0.188-17.163,0.013-34.332-0.161-51.496c-0.036-3.548,1.052-4.494,4.514-4.451c12.163,0.151,24.359,0.507,36.489-0.176 c24.552-1.383,44.897-11.097,56.012-33.989c11.667-24.029,10.5-48.338-4.473-70.786c-11.9-17.841-30.098-25.461-50.951-25.966 c-25.484-0.618-50.995-0.103-76.491-0.323c-4.08-0.035-5.292,0.889-5.265,5.141C57.056,195.339,56.964,225.671,56.964,256.003z" clip-path="url(#SVGID_2_)" clip-rule="evenodd"/></g><g><defs><path id="SVGID_3_" d="M315.446,281.626c0.099-19.011,3.621-36.469,15.474-51.155c15.867-19.659,37.477-25.831,61.573-23.923 c38.108,3.018,61.858,28.28,63.712,66.526c0.692,14.277-0.41,28.252-5.881,41.65c-7.521,18.418-20.696,30.726-39.764,36.411 c-18.27,5.447-36.605,5.267-54.348-1.839c-25.895-10.371-37.139-31.363-40.178-57.816 C315.637,288.012,315.61,284.501,315.446,281.626z M417.02,280.467c-0.092-9.835-1.27-19.53-5.888-28.481 c-5.233-10.144-13.333-15.962-25.039-16.006c-11.688-0.044-20.367,5.439-25.118,15.79c-8.715,18.984-8.698,38.444-0.095,57.46 c4.719,10.431,13.509,15.761,25.142,15.739c11.655-0.021,19.883-5.677,25.127-15.869 C415.757,300.142,416.912,290.442,417.02,280.467z"/></defs><use fill-rule="evenodd" clip-rule="evenodd" overflow="visible" xlink:href="#SVGID_3_"/><clipPath id="SVGID_4_"><use overflow="visible" xlink:href="#SVGID_3_"/></clipPath><path fill-rule="evenodd" d="M315.446,281.626c0.164,2.875,0.19,6.386,0.589,9.854 c3.039,26.453,14.283,47.445,40.178,57.816c17.742,7.105,36.078,7.286,54.348,1.839c19.067-5.686,32.242-17.993,39.764-36.411 c5.471-13.398,6.573-27.373,5.881-41.65c-1.854-38.247-25.604-63.509-63.712-66.526c-24.097-1.908-45.706,4.264-61.573,23.923 C319.067,245.157,315.545,262.615,315.446,281.626z" clip-path="url(#SVGID_4_)" clip-rule="evenodd"/></g><path fill-rule="evenodd" d="M259.119,233.588c2.961-4.728,4.795-9.712,8.146-13.899	c8.537-10.664,19.705-14.072,32.905-12.103c3.462,0.517,4.813,2.431,4.784,5.789c-0.063,7.493-0.029,14.987-0.015,22.48	c0.009,4.258-1.898,6.06-6.266,5.396c-4.268-0.648-8.538-1.074-12.92-0.505c-14.329,1.861-23.463,11.119-24.802,25.619	c-0.938,10.135-0.373,20.304-0.426,30.457c-0.087,16.818-0.101,33.638,0.037,50.455c0.027,3.439-1.014,4.645-4.534,4.575	c-9.987-0.198-19.982-0.153-29.972-0.019c-3.061,0.041-4.416-0.621-4.407-4.113c0.109-44.794,0.103-89.589,0.008-134.383	c-0.007-3.271,0.948-4.373,4.24-4.266c6.654,0.216,13.322-0.042,19.98,0.096c8.535,0.178,13.12,4.928,13.231,13.486	C259.16,226.3,259.119,229.944,259.119,233.588z" clip-rule="evenodd"/></svg>

+ 1
- 0
src/assets/logo.svg 查看文件

@@ -0,0 +1 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" version="1.1" viewBox="0 0 200 200"><title>Group 28 Copy 5</title><desc>Created with Sketch.</desc><defs><linearGradient id="linearGradient-1" x1="62.102%" x2="108.197%" y1="0%" y2="37.864%"><stop offset="0%" stop-color="#4285EB"/><stop offset="100%" stop-color="#2EC7FF"/></linearGradient><linearGradient id="linearGradient-2" x1="69.644%" x2="54.043%" y1="0%" y2="108.457%"><stop offset="0%" stop-color="#29CDFF"/><stop offset="37.86%" stop-color="#148EFF"/><stop offset="100%" stop-color="#0A60FF"/></linearGradient><linearGradient id="linearGradient-3" x1="69.691%" x2="16.723%" y1="-12.974%" y2="117.391%"><stop offset="0%" stop-color="#FA816E"/><stop offset="41.473%" stop-color="#F74A5C"/><stop offset="100%" stop-color="#F51D2C"/></linearGradient><linearGradient id="linearGradient-4" x1="68.128%" x2="30.44%" y1="-35.691%" y2="114.943%"><stop offset="0%" stop-color="#FA8E7D"/><stop offset="51.264%" stop-color="#F74A5C"/><stop offset="100%" stop-color="#F51D2C"/></linearGradient></defs><g id="Page-1" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="logo" transform="translate(-20.000000, -20.000000)"><g id="Group-28-Copy-5" transform="translate(20.000000, 20.000000)"><g id="Group-27-Copy-3"><g id="Group-25" fill-rule="nonzero"><g id="2"><path id="Shape" fill="url(#linearGradient-1)" d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C99.2571609,26.9692191 101.032305,26.9692191 102.20193,28.1378823 L129.985225,55.8983314 C134.193707,60.1033528 141.017005,60.1033528 145.225487,55.8983314 C149.433969,51.69331 149.433969,44.8756232 145.225487,40.6706018 L108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z"/><path id="Shape" fill="url(#linearGradient-2)" d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C100.999864,25.6271836 105.751642,20.541824 112.729652,19.3524487 C117.915585,18.4685261 123.585219,20.4140239 129.738554,25.1889424 C125.624663,21.0784292 118.571995,14.0340304 108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z"/></g><path id="Shape" fill="url(#linearGradient-3)" d="M153.685633,135.854579 C157.894115,140.0596 164.717412,140.0596 168.925894,135.854579 L195.959977,108.842726 C200.659183,104.147384 200.659183,96.5636133 195.960527,91.8688194 L168.690777,64.7181159 C164.472332,60.5180858 157.646868,60.5241425 153.435895,64.7316526 C149.227413,68.936674 149.227413,75.7543607 153.435895,79.9593821 L171.854035,98.3623765 C173.02366,99.5310396 173.02366,101.304724 171.854035,102.473387 L153.685633,120.626849 C149.47715,124.83187 149.47715,131.649557 153.685633,135.854579 Z"/></g><ellipse id="Combined-Shape" cx="100.519" cy="100.437" fill="url(#linearGradient-4)" rx="23.6" ry="23.581"/></g></g></g></g></svg>

+ 21
- 0
src/components/Authorized/Authorized.jsx 查看文件

@@ -0,0 +1,21 @@
1
+import React from 'react';
2
+import { Result } from 'antd';
3
+import check from './CheckPermissions';
4
+
5
+const Authorized = ({
6
+  children,
7
+  authority,
8
+  noMatch = (
9
+    <Result
10
+      status={403}
11
+      title="403"
12
+      subTitle="Sorry, you are not authorized to access this page."
13
+    />
14
+  ),
15
+}) => {
16
+  const childrenRender = typeof children === 'undefined' ? null : children;
17
+  const dom = check(authority, childrenRender, noMatch);
18
+  return <>{dom}</>;
19
+};
20
+
21
+export default Authorized;

+ 25
- 0
src/components/Authorized/AuthorizedRoute.jsx 查看文件

@@ -0,0 +1,25 @@
1
+import { Redirect, Route } from 'umi';
2
+import React from 'react';
3
+import Authorized from './Authorized';
4
+
5
+const AuthorizedRoute = ({ component: Component, render, authority, redirectPath, ...rest }) => (
6
+  <Authorized
7
+    authority={authority}
8
+    noMatch={
9
+      <Route
10
+        {...rest}
11
+        render={() => (
12
+          <Redirect
13
+            to={{
14
+              pathname: redirectPath,
15
+            }}
16
+          />
17
+        )}
18
+      />
19
+    }
20
+  >
21
+    <Route {...rest} render={(props) => (Component ? <Component {...props} /> : render(props))} />
22
+  </Authorized>
23
+);
24
+
25
+export default AuthorizedRoute;

+ 76
- 0
src/components/Authorized/CheckPermissions.jsx 查看文件

@@ -0,0 +1,76 @@
1
+import React from 'react';
2
+import { CURRENT } from './renderAuthorize'; // eslint-disable-next-line import/no-cycle
3
+
4
+import PromiseRender from './PromiseRender';
5
+
6
+/**
7
+ * 通用权限检查方法
8
+ * Common check permissions method
9
+ * @param { 权限判定 | Permission judgment } authority
10
+ * @param { 你的权限 | Your permission description } currentAuthority
11
+ * @param { 通过的组件 | Passing components } target
12
+ * @param { 未通过的组件 | no pass components } Exception
13
+ */
14
+const checkPermissions = (authority, currentAuthority, target, Exception) => {
15
+  // 没有判定权限.默认查看所有
16
+  // Retirement authority, return target;
17
+  if (!authority) {
18
+    return target;
19
+  } // 数组处理
20
+
21
+  if (Array.isArray(authority)) {
22
+    if (Array.isArray(currentAuthority)) {
23
+      if (currentAuthority.some((item) => authority.includes(item))) {
24
+        return target;
25
+      }
26
+    } else if (authority.includes(currentAuthority)) {
27
+      return target;
28
+    }
29
+
30
+    return Exception;
31
+  } // string 处理
32
+
33
+  if (typeof authority === 'string') {
34
+    if (Array.isArray(currentAuthority)) {
35
+      if (currentAuthority.some((item) => authority === item)) {
36
+        return target;
37
+      }
38
+    } else if (authority === currentAuthority) {
39
+      return target;
40
+    }
41
+
42
+    return Exception;
43
+  } // Promise 处理
44
+
45
+  if (authority instanceof Promise) {
46
+    return <PromiseRender ok={target} error={Exception} promise={authority} />;
47
+  } // Function 处理
48
+
49
+  if (typeof authority === 'function') {
50
+    try {
51
+      const bool = authority(currentAuthority); // 函数执行后返回值是 Promise
52
+
53
+      if (bool instanceof Promise) {
54
+        return <PromiseRender ok={target} error={Exception} promise={bool} />;
55
+      }
56
+
57
+      if (bool) {
58
+        return target;
59
+      }
60
+
61
+      return Exception;
62
+    } catch (error) {
63
+      throw error;
64
+    }
65
+  }
66
+
67
+  throw new Error('unsupported parameters');
68
+};
69
+
70
+export { checkPermissions };
71
+
72
+function check(authority, target, Exception) {
73
+  return checkPermissions(authority, CURRENT, target, Exception);
74
+}
75
+
76
+export default check;

+ 78
- 0
src/components/Authorized/PromiseRender.jsx 查看文件

@@ -0,0 +1,78 @@
1
+import React from 'react';
2
+import { Spin } from 'antd';
3
+import isEqual from 'lodash/isEqual';
4
+import { isComponentClass } from './Secured'; // eslint-disable-next-line import/no-cycle
5
+
6
+export default class PromiseRender extends React.Component {
7
+  state = {
8
+    component: () => null,
9
+  };
10
+
11
+  componentDidMount() {
12
+    this.setRenderComponent(this.props);
13
+  }
14
+
15
+  shouldComponentUpdate = (nextProps, nextState) => {
16
+    const { component } = this.state;
17
+
18
+    if (!isEqual(nextProps, this.props)) {
19
+      this.setRenderComponent(nextProps);
20
+    }
21
+
22
+    if (nextState.component !== component) return true;
23
+    return false;
24
+  }; // set render Component : ok or error
25
+
26
+  setRenderComponent(props) {
27
+    const ok = this.checkIsInstantiation(props.ok);
28
+    const error = this.checkIsInstantiation(props.error);
29
+    props.promise
30
+      .then(() => {
31
+        this.setState({
32
+          component: ok,
33
+        });
34
+        return true;
35
+      })
36
+      .catch(() => {
37
+        this.setState({
38
+          component: error,
39
+        });
40
+      });
41
+  } // Determine whether the incoming component has been instantiated
42
+  // AuthorizedRoute is already instantiated
43
+  // Authorized  render is already instantiated, children is no instantiated
44
+  // Secured is not instantiated
45
+
46
+  checkIsInstantiation = (target) => {
47
+    if (isComponentClass(target)) {
48
+      const Target = target;
49
+      return (props) => <Target {...props} />;
50
+    }
51
+
52
+    if (React.isValidElement(target)) {
53
+      return (props) => React.cloneElement(target, props);
54
+    }
55
+
56
+    return () => target;
57
+  };
58
+
59
+  render() {
60
+    const { component: Component } = this.state;
61
+    const { ok, error, promise, ...rest } = this.props;
62
+    return Component ? (
63
+      <Component {...rest} />
64
+    ) : (
65
+      <div
66
+        style={{
67
+          width: '100%',
68
+          height: '100%',
69
+          margin: 'auto',
70
+          paddingTop: 50,
71
+          textAlign: 'center',
72
+        }}
73
+      >
74
+        <Spin size="large" />
75
+      </div>
76
+    );
77
+  }
78
+}

+ 70
- 0
src/components/Authorized/Secured.jsx 查看文件

@@ -0,0 +1,70 @@
1
+import React from 'react';
2
+import CheckPermissions from './CheckPermissions';
3
+/**
4
+ * 默认不能访问任何页面
5
+ * default is "NULL"
6
+ */
7
+
8
+const Exception403 = () => 403;
9
+
10
+export const isComponentClass = (component) => {
11
+  if (!component) return false;
12
+  const proto = Object.getPrototypeOf(component);
13
+  if (proto === React.Component || proto === Function.prototype) return true;
14
+  return isComponentClass(proto);
15
+}; // Determine whether the incoming component has been instantiated
16
+// AuthorizedRoute is already instantiated
17
+// Authorized  render is already instantiated, children is no instantiated
18
+// Secured is not instantiated
19
+
20
+const checkIsInstantiation = (target) => {
21
+  if (isComponentClass(target)) {
22
+    const Target = target;
23
+    return (props) => <Target {...props} />;
24
+  }
25
+
26
+  if (React.isValidElement(target)) {
27
+    return (props) => React.cloneElement(target, props);
28
+  }
29
+
30
+  return () => target;
31
+};
32
+/**
33
+ * 用于判断是否拥有权限访问此 view 权限
34
+ * authority 支持传入 string, () => boolean | Promise
35
+ * e.g. 'user' 只有 user 用户能访问
36
+ * e.g. 'user,admin' user 和 admin 都能访问
37
+ * e.g. ()=>boolean 返回true能访问,返回false不能访问
38
+ * e.g. Promise  then 能访问   catch不能访问
39
+ * e.g. authority support incoming string, () => boolean | Promise
40
+ * e.g. 'user' only user user can access
41
+ * e.g. 'user, admin' user and admin can access
42
+ * e.g. () => boolean true to be able to visit, return false can not be accessed
43
+ * e.g. Promise then can not access the visit to catch
44
+ * @param {string | function | Promise} authority
45
+ * @param {ReactNode} error 非必需参数
46
+ */
47
+
48
+const authorize = (authority, error) => {
49
+  /**
50
+   * conversion into a class
51
+   * 防止传入字符串时找不到staticContext造成报错
52
+   * String parameters can cause staticContext not found error
53
+   */
54
+  let classError = false;
55
+
56
+  if (error) {
57
+    classError = () => error;
58
+  }
59
+
60
+  if (!authority) {
61
+    throw new Error('authority is required');
62
+  }
63
+
64
+  return function decideAuthority(target) {
65
+    const component = CheckPermissions(authority, target, classError || Exception403);
66
+    return checkIsInstantiation(component);
67
+  };
68
+};
69
+
70
+export default authorize;

+ 8
- 0
src/components/Authorized/index.jsx 查看文件

@@ -0,0 +1,8 @@
1
+import Authorized from './Authorized';
2
+import Secured from './Secured';
3
+import check from './CheckPermissions';
4
+import renderAuthorize from './renderAuthorize';
5
+Authorized.Secured = Secured;
6
+Authorized.check = check;
7
+const RenderAuthorize = renderAuthorize(Authorized);
8
+export default RenderAuthorize;

+ 30
- 0
src/components/Authorized/renderAuthorize.js 查看文件

@@ -0,0 +1,30 @@
1
+/* eslint-disable eslint-comments/disable-enable-pair */
2
+
3
+/* eslint-disable import/no-mutable-exports */
4
+let CURRENT = 'NULL';
5
+
6
+/**
7
+ * use  authority or getAuthority
8
+ * @param {string|()=>String} currentAuthority
9
+ */
10
+const renderAuthorize = (Authorized) => (currentAuthority) => {
11
+  if (currentAuthority) {
12
+    if (typeof currentAuthority === 'function') {
13
+      CURRENT = currentAuthority();
14
+    }
15
+
16
+    if (
17
+      Object.prototype.toString.call(currentAuthority) === '[object String]' ||
18
+      Array.isArray(currentAuthority)
19
+    ) {
20
+      CURRENT = currentAuthority;
21
+    }
22
+  } else {
23
+    CURRENT = 'NULL';
24
+  }
25
+
26
+  return Authorized;
27
+};
28
+
29
+export { CURRENT };
30
+export default (Authorized) => renderAuthorize(Authorized);

+ 79
- 0
src/components/GlobalHeader/AvatarDropdown.jsx 查看文件

@@ -0,0 +1,79 @@
1
+import { Avatar, Icon, Menu, Spin } from 'antd';
2
+import { FormattedMessage } from 'umi-plugin-react/locale';
3
+import React from 'react';
4
+import { connect } from 'dva';
5
+import { router } from 'umi';
6
+import HeaderDropdown from '../HeaderDropdown';
7
+import styles from './index.less';
8
+
9
+class AvatarDropdown extends React.Component {
10
+  onMenuClick = (event) => {
11
+    const { key } = event;
12
+
13
+    if (key === 'logout') {
14
+      const { dispatch } = this.props;
15
+
16
+      if (dispatch) {
17
+        dispatch({
18
+          type: 'login/logout',
19
+        });
20
+      }
21
+
22
+      return;
23
+    }
24
+
25
+    router.push(`/account/${key}`);
26
+  };
27
+
28
+  render() {
29
+    const {
30
+      currentUser = {
31
+        avatar: '',
32
+        name: '',
33
+      },
34
+      menu,
35
+    } = this.props;
36
+    const menuHeaderDropdown = (
37
+      <Menu className={styles.menu} selectedKeys={[]} onClick={this.onMenuClick}>
38
+        {menu && (
39
+          <Menu.Item key="center">
40
+            <Icon type="user" />
41
+            <FormattedMessage id="menu.account.center" defaultMessage="account center" />
42
+          </Menu.Item>
43
+        )}
44
+        {menu && (
45
+          <Menu.Item key="settings">
46
+            <Icon type="setting" />
47
+            <FormattedMessage id="menu.account.settings" defaultMessage="account settings" />
48
+          </Menu.Item>
49
+        )}
50
+        {menu && <Menu.Divider />}
51
+
52
+        <Menu.Item key="logout">
53
+          <Icon type="logout" />
54
+          <FormattedMessage id="menu.account.logout" defaultMessage="logout" />
55
+        </Menu.Item>
56
+      </Menu>
57
+    );
58
+    return currentUser && currentUser.name ? (
59
+      <HeaderDropdown overlay={menuHeaderDropdown}>
60
+        <span className={`${styles.action} ${styles.account}`}>
61
+          <Avatar size="small" className={styles.avatar} src={currentUser.avatar} alt="avatar" />
62
+          <span className={styles.name}>{currentUser.name}</span>
63
+        </span>
64
+      </HeaderDropdown>
65
+    ) : (
66
+      <Spin
67
+        size="small"
68
+        style={{
69
+          marginLeft: 8,
70
+          marginRight: 8,
71
+        }}
72
+      />
73
+    );
74
+  }
75
+}
76
+
77
+export default connect(({ user }) => ({
78
+  currentUser: user.currentUser,
79
+}))(AvatarDropdown);

+ 174
- 0
src/components/GlobalHeader/NoticeIconView.jsx 查看文件

@@ -0,0 +1,174 @@
1
+import React, { Component } from 'react';
2
+import { Tag, message } from 'antd';
3
+import { connect } from 'dva';
4
+import { formatMessage } from 'umi-plugin-react/locale';
5
+import groupBy from 'lodash/groupBy';
6
+import moment from 'moment';
7
+import NoticeIcon from '../NoticeIcon';
8
+import styles from './index.less';
9
+
10
+class GlobalHeaderRight extends Component {
11
+  componentDidMount() {
12
+    const { dispatch } = this.props;
13
+
14
+    if (dispatch) {
15
+      dispatch({
16
+        type: 'global/fetchNotices',
17
+      });
18
+    }
19
+  }
20
+
21
+  changeReadState = (clickedItem) => {
22
+    const { id } = clickedItem;
23
+    const { dispatch } = this.props;
24
+
25
+    if (dispatch) {
26
+      dispatch({
27
+        type: 'global/changeNoticeReadState',
28
+        payload: id,
29
+      });
30
+    }
31
+  };
32
+  handleNoticeClear = (title, key) => {
33
+    const { dispatch } = this.props;
34
+    message.success(
35
+      `${formatMessage({
36
+        id: 'component.noticeIcon.cleared',
37
+      })} ${title}`,
38
+    );
39
+
40
+    if (dispatch) {
41
+      dispatch({
42
+        type: 'global/clearNotices',
43
+        payload: key,
44
+      });
45
+    }
46
+  };
47
+  getNoticeData = () => {
48
+    const { notices = [] } = this.props;
49
+
50
+    if (notices.length === 0) {
51
+      return {};
52
+    }
53
+
54
+    const newNotices = notices.map((notice) => {
55
+      const newNotice = { ...notice };
56
+
57
+      if (newNotice.datetime) {
58
+        newNotice.datetime = moment(notice.datetime).fromNow();
59
+      }
60
+
61
+      if (newNotice.id) {
62
+        newNotice.key = newNotice.id;
63
+      }
64
+
65
+      if (newNotice.extra && newNotice.status) {
66
+        const color = {
67
+          todo: '',
68
+          processing: 'blue',
69
+          urgent: 'red',
70
+          doing: 'gold',
71
+        }[newNotice.status];
72
+        newNotice.extra = (
73
+          <Tag
74
+            color={color}
75
+            style={{
76
+              marginRight: 0,
77
+            }}
78
+          >
79
+            {newNotice.extra}
80
+          </Tag>
81
+        );
82
+      }
83
+
84
+      return newNotice;
85
+    });
86
+    return groupBy(newNotices, 'type');
87
+  };
88
+  getUnreadData = (noticeData) => {
89
+    const unreadMsg = {};
90
+    Object.keys(noticeData).forEach((key) => {
91
+      const value = noticeData[key];
92
+
93
+      if (!unreadMsg[key]) {
94
+        unreadMsg[key] = 0;
95
+      }
96
+
97
+      if (Array.isArray(value)) {
98
+        unreadMsg[key] = value.filter((item) => !item.read).length;
99
+      }
100
+    });
101
+    return unreadMsg;
102
+  };
103
+
104
+  render() {
105
+    const { currentUser, fetchingNotices, onNoticeVisibleChange } = this.props;
106
+    const noticeData = this.getNoticeData();
107
+    const unreadMsg = this.getUnreadData(noticeData);
108
+    return (
109
+      <NoticeIcon
110
+        className={styles.action}
111
+        count={currentUser && currentUser.unreadCount}
112
+        onItemClick={(item) => {
113
+          this.changeReadState(item);
114
+        }}
115
+        loading={fetchingNotices}
116
+        clearText={formatMessage({
117
+          id: 'component.noticeIcon.clear',
118
+        })}
119
+        viewMoreText={formatMessage({
120
+          id: 'component.noticeIcon.view-more',
121
+        })}
122
+        onClear={this.handleNoticeClear}
123
+        onPopupVisibleChange={onNoticeVisibleChange}
124
+        onViewMore={() => message.info('Click on view more')}
125
+        clearClose
126
+      >
127
+        <NoticeIcon.Tab
128
+          tabKey="notification"
129
+          count={unreadMsg.notification}
130
+          list={noticeData.notification}
131
+          title={formatMessage({
132
+            id: 'component.globalHeader.notification',
133
+          })}
134
+          emptyText={formatMessage({
135
+            id: 'component.globalHeader.notification.empty',
136
+          })}
137
+          showViewMore
138
+        />
139
+        <NoticeIcon.Tab
140
+          tabKey="message"
141
+          count={unreadMsg.message}
142
+          list={noticeData.message}
143
+          title={formatMessage({
144
+            id: 'component.globalHeader.message',
145
+          })}
146
+          emptyText={formatMessage({
147
+            id: 'component.globalHeader.message.empty',
148
+          })}
149
+          showViewMore
150
+        />
151
+        <NoticeIcon.Tab
152
+          tabKey="event"
153
+          title={formatMessage({
154
+            id: 'component.globalHeader.event',
155
+          })}
156
+          emptyText={formatMessage({
157
+            id: 'component.globalHeader.event.empty',
158
+          })}
159
+          count={unreadMsg.event}
160
+          list={noticeData.event}
161
+          showViewMore
162
+        />
163
+      </NoticeIcon>
164
+    );
165
+  }
166
+}
167
+
168
+export default connect(({ user, global, loading }) => ({
169
+  currentUser: user.currentUser,
170
+  collapsed: global.collapsed,
171
+  fetchingMoreNotices: loading.effects['global/fetchMoreNotices'],
172
+  fetchingNotices: loading.effects['global/fetchNotices'],
173
+  notices: global.notices,
174
+}))(GlobalHeaderRight);

+ 69
- 0
src/components/GlobalHeader/RightContent.jsx 查看文件

@@ -0,0 +1,69 @@
1
+import { Icon, Tooltip, Tag } from 'antd';
2
+import React from 'react';
3
+import { connect } from 'dva';
4
+import { formatMessage } from 'umi-plugin-react/locale';
5
+import Avatar from './AvatarDropdown';
6
+import HeaderSearch from '../HeaderSearch';
7
+import SelectLang from '../SelectLang';
8
+import styles from './index.less';
9
+const ENVTagColor = {
10
+  dev: 'orange',
11
+  test: 'green',
12
+  pre: '#87d068',
13
+};
14
+
15
+const GlobalHeaderRight = (props) => {
16
+  const { theme, layout } = props;
17
+  let className = styles.right;
18
+
19
+  if (theme === 'dark' && layout === 'topmenu') {
20
+    className = `${styles.right}  ${styles.dark}`;
21
+  }
22
+
23
+  return (
24
+    <div className={className}>
25
+      <HeaderSearch
26
+        className={`${styles.action} ${styles.search}`}
27
+        placeholder={formatMessage({
28
+          id: 'component.globalHeader.search',
29
+        })}
30
+        defaultValue="umi ui"
31
+        dataSource={[
32
+          formatMessage({
33
+            id: 'component.globalHeader.search.example1',
34
+          }),
35
+          formatMessage({
36
+            id: 'component.globalHeader.search.example2',
37
+          }),
38
+          formatMessage({
39
+            id: 'component.globalHeader.search.example3',
40
+          }),
41
+        ]}
42
+        onSearch={() => {}}
43
+        onPressEnter={() => {}}
44
+      />
45
+      <Tooltip
46
+        title={formatMessage({
47
+          id: 'component.globalHeader.help',
48
+        })}
49
+      >
50
+        <a
51
+          target="_blank"
52
+          href="https://pro.ant.design/docs/getting-started"
53
+          rel="noopener noreferrer"
54
+          className={styles.action}
55
+        >
56
+          <Icon type="question-circle-o" />
57
+        </a>
58
+      </Tooltip>
59
+      <Avatar />
60
+      {REACT_APP_ENV && <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>}
61
+      <SelectLang className={styles.action} />
62
+    </div>
63
+  );
64
+};
65
+
66
+export default connect(({ settings }) => ({
67
+  theme: settings.navTheme,
68
+  layout: settings.layout,
69
+}))(GlobalHeaderRight);

+ 103
- 0
src/components/GlobalHeader/index.less 查看文件

@@ -0,0 +1,103 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+@pro-header-hover-bg: rgba(0, 0, 0, 0.025);
4
+
5
+.menu {
6
+  :global(.anticon) {
7
+    margin-right: 8px;
8
+  }
9
+  :global(.ant-dropdown-menu-item) {
10
+    min-width: 160px;
11
+  }
12
+}
13
+
14
+.right {
15
+  float: right;
16
+  height: @layout-header-height;
17
+  margin-left: auto;
18
+  overflow: hidden;
19
+  .action {
20
+    display: inline-block;
21
+    height: 100%;
22
+    padding: 0 12px;
23
+    cursor: pointer;
24
+    transition: all 0.3s;
25
+    > i {
26
+      color: @text-color;
27
+      vertical-align: middle;
28
+    }
29
+    &:hover {
30
+      background: @pro-header-hover-bg;
31
+    }
32
+    &:global(.opened) {
33
+      background: @pro-header-hover-bg;
34
+    }
35
+  }
36
+  .search {
37
+    padding: 0 12px;
38
+    &:hover {
39
+      background: transparent;
40
+    }
41
+  }
42
+  .account {
43
+    .avatar {
44
+      margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0;
45
+      margin-right: 8px;
46
+      color: @primary-color;
47
+      vertical-align: top;
48
+      background: rgba(255, 255, 255, 0.85);
49
+    }
50
+  }
51
+}
52
+
53
+.dark {
54
+  .action {
55
+    color: rgba(255, 255, 255, 0.85);
56
+    > i {
57
+      color: rgba(255, 255, 255, 0.85);
58
+    }
59
+    &:hover,
60
+    &:global(.opened) {
61
+      background: @primary-color;
62
+    }
63
+  }
64
+}
65
+
66
+:global(.ant-pro-global-header) {
67
+  .dark {
68
+    .action {
69
+      color: @text-color;
70
+      > i {
71
+        color: @text-color;
72
+      }
73
+      &:hover {
74
+        color: rgba(255, 255, 255, 0.85);
75
+        > i {
76
+          color: rgba(255, 255, 255, 0.85);
77
+        }
78
+      }
79
+    }
80
+  }
81
+}
82
+
83
+@media only screen and (max-width: @screen-md) {
84
+  :global(.ant-divider-vertical) {
85
+    vertical-align: unset;
86
+  }
87
+  .name {
88
+    display: none;
89
+  }
90
+  .right {
91
+    position: absolute;
92
+    top: 0;
93
+    right: 12px;
94
+    .account {
95
+      .avatar {
96
+        margin-right: 0;
97
+      }
98
+    }
99
+    .search {
100
+      display: none;
101
+    }
102
+  }
103
+}

+ 10
- 0
src/components/HeaderDropdown/index.jsx 查看文件

@@ -0,0 +1,10 @@
1
+import { Dropdown } from 'antd';
2
+import React from 'react';
3
+import classNames from 'classnames';
4
+import styles from './index.less';
5
+
6
+const HeaderDropdown = ({ overlayClassName: cls, ...restProps }) => (
7
+  <Dropdown overlayClassName={classNames(styles.container, cls)} {...restProps} />
8
+);
9
+
10
+export default HeaderDropdown;

+ 16
- 0
src/components/HeaderDropdown/index.less 查看文件

@@ -0,0 +1,16 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+.container > * {
4
+  background-color: @popover-bg;
5
+  border-radius: 4px;
6
+  box-shadow: @shadow-1-down;
7
+}
8
+
9
+@media screen and (max-width: @screen-xs) {
10
+  .container {
11
+    width: 100% !important;
12
+  }
13
+  .container > * {
14
+    border-radius: 0 !important;
15
+  }
16
+}

+ 131
- 0
src/components/HeaderSearch/index.jsx 查看文件

@@ -0,0 +1,131 @@
1
+import { AutoComplete, Icon, Input } from 'antd';
2
+import React, { Component } from 'react';
3
+import classNames from 'classnames';
4
+import debounce from 'lodash/debounce';
5
+import styles from './index.less';
6
+export default class HeaderSearch extends Component {
7
+  inputRef = null;
8
+  static defaultProps = {
9
+    defaultActiveFirstOption: false,
10
+    onPressEnter: () => {},
11
+    onSearch: () => {},
12
+    onChange: () => {},
13
+    className: '',
14
+    placeholder: '',
15
+    dataSource: [],
16
+    defaultOpen: false,
17
+    onVisibleChange: () => {},
18
+  };
19
+
20
+  static getDerivedStateFromProps(props) {
21
+    if ('open' in props) {
22
+      return {
23
+        searchMode: props.open,
24
+      };
25
+    }
26
+
27
+    return null;
28
+  }
29
+
30
+  constructor(props) {
31
+    super(props);
32
+    this.state = {
33
+      searchMode: props.defaultOpen,
34
+      value: props.defaultValue,
35
+    };
36
+    this.debouncePressEnter = debounce(this.debouncePressEnter, 500, {
37
+      leading: true,
38
+      trailing: false,
39
+    });
40
+  }
41
+
42
+  onKeyDown = (e) => {
43
+    if (e.key === 'Enter') {
44
+      this.debouncePressEnter();
45
+    }
46
+  };
47
+  onChange = (value) => {
48
+    if (typeof value === 'string') {
49
+      const { onSearch, onChange } = this.props;
50
+      this.setState({
51
+        value,
52
+      });
53
+
54
+      if (onSearch) {
55
+        onSearch(value);
56
+      }
57
+
58
+      if (onChange) {
59
+        onChange(value);
60
+      }
61
+    }
62
+  };
63
+  enterSearchMode = () => {
64
+    const { onVisibleChange } = this.props;
65
+    onVisibleChange(true);
66
+    this.setState(
67
+      {
68
+        searchMode: true,
69
+      },
70
+      () => {
71
+        const { searchMode } = this.state;
72
+
73
+        if (searchMode && this.inputRef) {
74
+          this.inputRef.focus();
75
+        }
76
+      },
77
+    );
78
+  };
79
+  leaveSearchMode = () => {
80
+    this.setState({
81
+      searchMode: false,
82
+    });
83
+  };
84
+  debouncePressEnter = () => {
85
+    const { onPressEnter } = this.props;
86
+    const { value } = this.state;
87
+    onPressEnter(value || '');
88
+  };
89
+
90
+  render() {
91
+    const { className, defaultValue, placeholder, open, ...restProps } = this.props;
92
+    const { searchMode, value } = this.state;
93
+    delete restProps.defaultOpen; // for rc-select not affected
94
+
95
+    const inputClass = classNames(styles.input, {
96
+      [styles.show]: searchMode,
97
+    });
98
+    return (
99
+      <span
100
+        className={classNames(className, styles.headerSearch)}
101
+        onClick={this.enterSearchMode}
102
+        onTransitionEnd={({ propertyName }) => {
103
+          if (propertyName === 'width' && !searchMode) {
104
+            const { onVisibleChange } = this.props;
105
+            onVisibleChange(searchMode);
106
+          }
107
+        }}
108
+      >
109
+        <Icon type="search" key="Icon" />
110
+        <AutoComplete
111
+          key="AutoComplete"
112
+          {...restProps}
113
+          className={inputClass}
114
+          value={value}
115
+          onChange={this.onChange}
116
+        >
117
+          <Input
118
+            ref={(node) => {
119
+              this.inputRef = node;
120
+            }}
121
+            defaultValue={defaultValue}
122
+            aria-label={placeholder}
123
+            placeholder={placeholder}
124
+            onKeyDown={this.onKeyDown}
125
+            onBlur={this.leaveSearchMode}
126
+          />
127
+        </AutoComplete>
128
+      </span>
129
+    );
130
+  }
131
+}

+ 32
- 0
src/components/HeaderSearch/index.less 查看文件

@@ -0,0 +1,32 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+.headerSearch {
4
+  :global(.anticon-search) {
5
+    font-size: 16px;
6
+    cursor: pointer;
7
+  }
8
+  .input {
9
+    width: 0;
10
+    background: transparent;
11
+    border-radius: 0;
12
+    transition: width 0.3s, margin-left 0.3s;
13
+    :global(.ant-select-selection) {
14
+      background: transparent;
15
+    }
16
+    input {
17
+      padding-right: 0;
18
+      padding-left: 0;
19
+      border: 0;
20
+      box-shadow: none !important;
21
+    }
22
+    &,
23
+    &:hover,
24
+    &:focus {
25
+      border-bottom: 1px solid @border-color-base;
26
+    }
27
+    &.show {
28
+      width: 210px;
29
+      margin-left: 8px;
30
+    }
31
+  }
32
+}

+ 95
- 0
src/components/NoticeIcon/NoticeList.jsx 查看文件

@@ -0,0 +1,95 @@
1
+import { Avatar, List } from 'antd';
2
+import React from 'react';
3
+import classNames from 'classnames';
4
+import styles from './NoticeList.less';
5
+
6
+const NoticeList = ({
7
+  data = [],
8
+  onClick,
9
+  onClear,
10
+  title,
11
+  onViewMore,
12
+  emptyText,
13
+  showClear = true,
14
+  clearText,
15
+  viewMoreText,
16
+  showViewMore = false,
17
+}) => {
18
+  if (data.length === 0) {
19
+    return (
20
+      <div className={styles.notFound}>
21
+        <img
22
+          src="https://gw.alipayobjects.com/zos/rmsportal/sAuJeJzSKbUmHfBQRzmZ.svg"
23
+          alt="not found"
24
+        />
25
+        <div>{emptyText}</div>
26
+      </div>
27
+    );
28
+  }
29
+
30
+  return (
31
+    <div>
32
+      <List
33
+        className={styles.list}
34
+        dataSource={data}
35
+        renderItem={(item, i) => {
36
+          const itemCls = classNames(styles.item, {
37
+            [styles.read]: item.read,
38
+          }); // eslint-disable-next-line no-nested-ternary
39
+
40
+          const leftIcon = item.avatar ? (
41
+            typeof item.avatar === 'string' ? (
42
+              <Avatar className={styles.avatar} src={item.avatar} />
43
+            ) : (
44
+              <span className={styles.iconElement}>{item.avatar}</span>
45
+            )
46
+          ) : null;
47
+          return (
48
+            <List.Item
49
+              className={itemCls}
50
+              key={item.key || i}
51
+              onClick={() => onClick && onClick(item)}
52
+            >
53
+              <List.Item.Meta
54
+                className={styles.meta}
55
+                avatar={leftIcon}
56
+                title={
57
+                  <div className={styles.title}>
58
+                    {item.title}
59
+                    <div className={styles.extra}>{item.extra}</div>
60
+                  </div>
61
+                }
62
+                description={
63
+                  <div>
64
+                    <div className={styles.description}>{item.description}</div>
65
+                    <div className={styles.datetime}>{item.datetime}</div>
66
+                  </div>
67
+                }
68
+              />
69
+            </List.Item>
70
+          );
71
+        }}
72
+      />
73
+      <div className={styles.bottomBar}>
74
+        {showClear ? (
75
+          <div onClick={onClear}>
76
+            {clearText} {title}
77
+          </div>
78
+        ) : null}
79
+        {showViewMore ? (
80
+          <div
81
+            onClick={(e) => {
82
+              if (onViewMore) {
83
+                onViewMore(e);
84
+              }
85
+            }}
86
+          >
87
+            {viewMoreText}
88
+          </div>
89
+        ) : null}
90
+      </div>
91
+    </div>
92
+  );
93
+};
94
+
95
+export default NoticeList;

+ 103
- 0
src/components/NoticeIcon/NoticeList.less 查看文件

@@ -0,0 +1,103 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+.list {
4
+  max-height: 400px;
5
+  overflow: auto;
6
+  &::-webkit-scrollbar {
7
+    display: none;
8
+  }
9
+  .item {
10
+    padding-right: 24px;
11
+    padding-left: 24px;
12
+    overflow: hidden;
13
+    cursor: pointer;
14
+    transition: all 0.3s;
15
+
16
+    .meta {
17
+      width: 100%;
18
+    }
19
+
20
+    .avatar {
21
+      margin-top: 4px;
22
+      background: #fff;
23
+    }
24
+    .iconElement {
25
+      font-size: 32px;
26
+    }
27
+
28
+    &.read {
29
+      opacity: 0.4;
30
+    }
31
+    &:last-child {
32
+      border-bottom: 0;
33
+    }
34
+    &:hover {
35
+      background: @primary-1;
36
+    }
37
+    .title {
38
+      margin-bottom: 8px;
39
+      font-weight: normal;
40
+    }
41
+    .description {
42
+      font-size: 12px;
43
+      line-height: @line-height-base;
44
+    }
45
+    .datetime {
46
+      margin-top: 4px;
47
+      font-size: 12px;
48
+      line-height: @line-height-base;
49
+    }
50
+    .extra {
51
+      float: right;
52
+      margin-top: -1.5px;
53
+      margin-right: 0;
54
+      color: @text-color-secondary;
55
+      font-weight: normal;
56
+    }
57
+  }
58
+  .loadMore {
59
+    padding: 8px 0;
60
+    color: @primary-6;
61
+    text-align: center;
62
+    cursor: pointer;
63
+    &.loadedAll {
64
+      color: rgba(0, 0, 0, 0.25);
65
+      cursor: unset;
66
+    }
67
+  }
68
+}
69
+
70
+.notFound {
71
+  padding: 73px 0 88px;
72
+  color: @text-color-secondary;
73
+  text-align: center;
74
+  img {
75
+    display: inline-block;
76
+    height: 76px;
77
+    margin-bottom: 16px;
78
+  }
79
+}
80
+
81
+.bottomBar {
82
+  height: 46px;
83
+  color: @text-color;
84
+  line-height: 46px;
85
+  text-align: center;
86
+  border-top: 1px solid @border-color-split;
87
+  border-radius: 0 0 @border-radius-base @border-radius-base;
88
+  transition: all 0.3s;
89
+  div {
90
+    display: inline-block;
91
+    width: 50%;
92
+    cursor: pointer;
93
+    transition: all 0.3s;
94
+    user-select: none;
95
+
96
+    &:only-child {
97
+      width: 100%;
98
+    }
99
+    &:not(:only-child):last-child {
100
+      border-left: 1px solid @border-color-split;
101
+    }
102
+  }
103
+}

+ 156
- 0
src/components/NoticeIcon/index.jsx 查看文件

@@ -0,0 +1,156 @@
1
+import { Badge, Icon, Spin, Tabs } from 'antd';
2
+import React, { Component } from 'react';
3
+import classNames from 'classnames';
4
+import NoticeList from './NoticeList';
5
+import HeaderDropdown from '../HeaderDropdown';
6
+import styles from './index.less';
7
+const { TabPane } = Tabs;
8
+export default class NoticeIcon extends Component {
9
+  static Tab = NoticeList;
10
+  static defaultProps = {
11
+    onItemClick: () => {},
12
+    onPopupVisibleChange: () => {},
13
+    onTabChange: () => {},
14
+    onClear: () => {},
15
+    onViewMore: () => {},
16
+    loading: false,
17
+    clearClose: false,
18
+    emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg',
19
+  };
20
+  state = {
21
+    visible: false,
22
+  };
23
+  onItemClick = (item, tabProps) => {
24
+    const { onItemClick } = this.props;
25
+
26
+    if (onItemClick) {
27
+      onItemClick(item, tabProps);
28
+    }
29
+  };
30
+  onClear = (name, key) => {
31
+    const { onClear } = this.props;
32
+
33
+    if (onClear) {
34
+      onClear(name, key);
35
+    }
36
+  };
37
+  onTabChange = (tabType) => {
38
+    const { onTabChange } = this.props;
39
+
40
+    if (onTabChange) {
41
+      onTabChange(tabType);
42
+    }
43
+  };
44
+  onViewMore = (tabProps, event) => {
45
+    const { onViewMore } = this.props;
46
+
47
+    if (onViewMore) {
48
+      onViewMore(tabProps, event);
49
+    }
50
+  };
51
+
52
+  getNotificationBox() {
53
+    const { children, loading, clearText, viewMoreText } = this.props;
54
+
55
+    if (!children) {
56
+      return null;
57
+    }
58
+
59
+    const panes = [];
60
+    React.Children.forEach(children, (child) => {
61
+      if (!child) {
62
+        return;
63
+      }
64
+
65
+      const { list, title, count, tabKey, showClear, showViewMore } = child.props;
66
+      const len = list && list.length ? list.length : 0;
67
+      const msgCount = count || count === 0 ? count : len;
68
+      const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title;
69
+      panes.push(
70
+        <TabPane tab={tabTitle} key={tabKey}>
71
+          <NoticeList
72
+            clearText={clearText}
73
+            viewMoreText={viewMoreText}
74
+            data={list}
75
+            onClear={() => this.onClear(title, tabKey)}
76
+            onClick={(item) => this.onItemClick(item, child.props)}
77
+            onViewMore={(event) => this.onViewMore(child.props, event)}
78
+            showClear={showClear}
79
+            showViewMore={showViewMore}
80
+            title={title}
81
+            {...child.props}
82
+          />
83
+        </TabPane>,
84
+      );
85
+    });
86
+    return (
87
+      <>
88
+        <Spin spinning={loading} delay={300}>
89
+          <Tabs className={styles.tabs} onChange={this.onTabChange}>
90
+            {panes}
91
+          </Tabs>
92
+        </Spin>
93
+      </>
94
+    );
95
+  }
96
+
97
+  handleVisibleChange = (visible) => {
98
+    const { onPopupVisibleChange } = this.props;
99
+    this.setState({
100
+      visible,
101
+    });
102
+
103
+    if (onPopupVisibleChange) {
104
+      onPopupVisibleChange(visible);
105
+    }
106
+  };
107
+
108
+  render() {
109
+    const { className, count, popupVisible, bell } = this.props;
110
+    const { visible } = this.state;
111
+    const noticeButtonClass = classNames(className, styles.noticeButton);
112
+    const notificationBox = this.getNotificationBox();
113
+    const NoticeBellIcon = bell || <Icon type="bell" className={styles.icon} />;
114
+    const trigger = (
115
+      <span
116
+        className={classNames(noticeButtonClass, {
117
+          opened: visible,
118
+        })}
119
+      >
120
+        <Badge
121
+          count={count}
122
+          style={{
123
+            boxShadow: 'none',
124
+          }}
125
+          className={styles.badge}
126
+        >
127
+          {NoticeBellIcon}
128
+        </Badge>
129
+      </span>
130
+    );
131
+
132
+    if (!notificationBox) {
133
+      return trigger;
134
+    }
135
+
136
+    const popoverProps = {};
137
+
138
+    if ('popupVisible' in this.props) {
139
+      popoverProps.visible = popupVisible;
140
+    }
141
+
142
+    return (
143
+      <HeaderDropdown
144
+        placement="bottomRight"
145
+        overlay={notificationBox}
146
+        overlayClassName={styles.popover}
147
+        trigger={['click']}
148
+        visible={visible}
149
+        onVisibleChange={this.handleVisibleChange}
150
+        {...popoverProps}
151
+      >
152
+        {trigger}
153
+      </HeaderDropdown>
154
+    );
155
+  }
156
+}

+ 31
- 0
src/components/NoticeIcon/index.less 查看文件

@@ -0,0 +1,31 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+.popover {
4
+  position: relative;
5
+  width: 336px;
6
+}
7
+
8
+.noticeButton {
9
+  display: inline-block;
10
+  cursor: pointer;
11
+  transition: all 0.3s;
12
+}
13
+.icon {
14
+  padding: 4px;
15
+  vertical-align: middle;
16
+}
17
+
18
+.badge {
19
+  font-size: 16px;
20
+}
21
+
22
+.tabs {
23
+  :global {
24
+    .ant-tabs-nav-scroll {
25
+      text-align: center;
26
+    }
27
+    .ant-tabs-bar {
28
+      margin-bottom: 0;
29
+    }
30
+  }
31
+}

+ 4
- 0
src/components/PageLoading/index.jsx 查看文件

@@ -0,0 +1,4 @@
1
+import { PageLoading } from '@ant-design/pro-layout'; // loading components from code split
2
+// https://umijs.org/plugin/umi-plugin-react.html#dynamicimport
3
+
4
+export default PageLoading;

+ 53
- 0
src/components/SelectLang/index.jsx 查看文件

@@ -0,0 +1,53 @@
1
+import { Icon, Menu } from 'antd';
2
+import { formatMessage, getLocale, setLocale } from 'umi-plugin-react/locale';
3
+import React from 'react';
4
+import classNames from 'classnames';
5
+import HeaderDropdown from '../HeaderDropdown';
6
+import styles from './index.less';
7
+
8
+const SelectLang = (props) => {
9
+  const { className } = props;
10
+  const selectedLang = getLocale();
11
+
12
+  const changeLang = ({ key }) => setLocale(key);
13
+
14
+  const locales = ['zh-CN', 'zh-TW', 'en-US', 'pt-BR'];
15
+  const languageLabels = {
16
+    'zh-CN': '简体中文',
17
+    'zh-TW': '繁体中文',
18
+    'en-US': 'English',
19
+    'pt-BR': 'Português',
20
+  };
21
+  const languageIcons = {
22
+    'zh-CN': '🇨🇳',
23
+    'zh-TW': '🇭🇰',
24
+    'en-US': '🇺🇸',
25
+    'pt-BR': '🇧🇷',
26
+  };
27
+  const langMenu = (
28
+    <Menu className={styles.menu} selectedKeys={[selectedLang]} onClick={changeLang}>
29
+      {locales.map((locale) => (
30
+        <Menu.Item key={locale}>
31
+          <span role="img" aria-label={languageLabels[locale]}>
32
+            {languageIcons[locale]}
33
+          </span>{' '}
34
+          {languageLabels[locale]}
35
+        </Menu.Item>
36
+      ))}
37
+    </Menu>
38
+  );
39
+  return (
40
+    <HeaderDropdown overlay={langMenu} placement="bottomRight">
41
+      <span className={classNames(styles.dropDown, className)}>
42
+        <Icon
43
+          type="global"
44
+          title={formatMessage({
45
+            id: 'navBar.lang',
46
+          })}
47
+        />
48
+      </span>
49
+    </HeaderDropdown>
50
+  );
51
+};
52
+
53
+export default SelectLang;

+ 24
- 0
src/components/SelectLang/index.less 查看文件

@@ -0,0 +1,24 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+.menu {
4
+  :global(.anticon) {
5
+    margin-right: 8px;
6
+  }
7
+  :global(.ant-dropdown-menu-item) {
8
+    min-width: 160px;
9
+  }
10
+}
11
+
12
+.dropDown {
13
+  line-height: @layout-header-height;
14
+  vertical-align: top;
15
+  cursor: pointer;
16
+  > i {
17
+    font-size: 16px !important;
18
+    transform: none !important;
19
+    svg {
20
+      position: relative;
21
+      top: -1px;
22
+    }
23
+  }
24
+}

+ 1
- 0
src/e2e/__mocks__/antd-pro-merge-less.js 查看文件

@@ -0,0 +1 @@
1
+export default undefined;

+ 45
- 0
src/e2e/baseLayout.e2e.js 查看文件

@@ -0,0 +1,45 @@
1
+const { uniq } = require('lodash');
2
+const RouterConfig = require('../../config/config').default.routes;
3
+
4
+const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
5
+
6
+function formatter(routes, parentPath = '') {
7
+  const fixedParentPath = parentPath.replace(/\/{1,}/g, '/');
8
+  let result = [];
9
+  routes.forEach(item => {
10
+    if (item.path) {
11
+      result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/'));
12
+    }
13
+    if (item.routes) {
14
+      result = result.concat(
15
+        formatter(item.routes, item.path ? `${fixedParentPath}/${item.path}` : parentPath),
16
+      );
17
+    }
18
+  });
19
+  return uniq(result.filter(item => !!item));
20
+}
21
+
22
+beforeAll(async () => {
23
+  await page.goto(`${BASE_URL}`);
24
+  await page.evaluate(() => {
25
+    localStorage.setItem('antd-pro-authority', '["admin"]');
26
+  });
27
+});
28
+
29
+describe('Ant Design Pro E2E test', () => {
30
+  const testPage = path => async () => {
31
+    await page.goto(`${BASE_URL}${path}`);
32
+    await page.waitForSelector('footer', {
33
+      timeout: 2000,
34
+    });
35
+    const haveFooter = await page.evaluate(
36
+      () => document.getElementsByTagName('footer').length > 0,
37
+    );
38
+    expect(haveFooter).toBeTruthy();
39
+  };
40
+
41
+  const routers = formatter(RouterConfig);
42
+  routers.forEach(route => {
43
+    it(`test pages ${route}`, testPage(route));
44
+  });
45
+});

+ 15
- 0
src/e2e/topMenu.e2e.js 查看文件

@@ -0,0 +1,15 @@
1
+const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
2
+
3
+describe('Homepage', () => {
4
+  it('topmenu should have footer', async () => {
5
+    const params = '?navTheme=light&layout=topmenu';
6
+    await page.goto(`${BASE_URL}${params}`);
7
+    await page.waitForSelector('footer', {
8
+      timeout: 2000,
9
+    });
10
+    const haveFooter = await page.evaluate(
11
+      () => document.getElementsByTagName('footer').length > 0,
12
+    );
13
+    expect(haveFooter).toBeTruthy();
14
+  });
15
+});

+ 101
- 0
src/global.jsx 查看文件

@@ -0,0 +1,101 @@
1
+import { Button, message, notification } from 'antd';
2
+import React from 'react';
3
+import { formatMessage } from 'umi-plugin-react/locale';
4
+import defaultSettings from '../config/defaultSettings';
5
+const { pwa } = defaultSettings; // if pwa is true
6
+
7
+if (pwa) {
8
+  // Notify user if offline now
9
+  window.addEventListener('sw.offline', () => {
10
+    message.warning(
11
+      formatMessage({
12
+        id: 'app.pwa.offline',
13
+      }),
14
+    );
15
+  }); // Pop up a prompt on the page asking the user if they want to use the latest version
16
+
17
+  window.addEventListener('sw.updated', (event) => {
18
+    const e = event;
19
+
20
+    const reloadSW = async () => {
21
+      // Check if there is sw whose state is waiting in ServiceWorkerRegistration
22
+      // https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
23
+      const worker = e.detail && e.detail.waiting;
24
+
25
+      if (!worker) {
26
+        return true;
27
+      } // Send skip-waiting event to waiting SW with MessageChannel
28
+
29
+      await new Promise((resolve, reject) => {
30
+        const channel = new MessageChannel();
31
+
32
+        channel.port1.onmessage = (msgEvent) => {
33
+          if (msgEvent.data.error) {
34
+            reject(msgEvent.data.error);
35
+          } else {
36
+            resolve(msgEvent.data);
37
+          }
38
+        };
39
+
40
+        worker.postMessage(
41
+          {
42
+            type: 'skip-waiting',
43
+          },
44
+          [channel.port2],
45
+        );
46
+      }); // Refresh current page to use the updated HTML and other assets after SW has skiped waiting
47
+
48
+      window.location.reload(true);
49
+      return true;
50
+    };
51
+
52
+    const key = `open${Date.now()}`;
53
+    const btn = (
54
+      <Button
55
+        type="primary"
56
+        onClick={() => {
57
+          notification.close(key);
58
+          reloadSW();
59
+        }}
60
+      >
61
+        {formatMessage({
62
+          id: 'app.pwa.serviceworker.updated.ok',
63
+        })}
64
+      </Button>
65
+    );
66
+    notification.open({
67
+      message: formatMessage({
68
+        id: 'app.pwa.serviceworker.updated',
69
+      }),
70
+      description: formatMessage({
71
+        id: 'app.pwa.serviceworker.updated.hint',
72
+      }),
73
+      btn,
74
+      key,
75
+      onClose: async () => {},
76
+    });
77
+  });
78
+} else if ('serviceWorker' in navigator) {
79
+  // unregister service worker
80
+  const { serviceWorker } = navigator;
81
+
82
+  if (serviceWorker.getRegistrations) {
83
+    serviceWorker.getRegistrations().then((sws) => {
84
+      sws.forEach((sw) => {
85
+        sw.unregister();
86
+      });
87
+    });
88
+  }
89
+
90
+  serviceWorker.getRegistration().then((sw) => {
91
+    if (sw) sw.unregister();
92
+  }); // remove all caches
93
+
94
+  if (window.caches && window.caches.keys) {
95
+    caches.keys().then((keys) => {
96
+      keys.forEach((key) => {
97
+        caches.delete(key);
98
+      });
99
+    });
100
+  }
101
+}

+ 54
- 0
src/global.less 查看文件

@@ -0,0 +1,54 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+html,
4
+body,
5
+#root {
6
+  height: 100%;
7
+}
8
+
9
+.colorWeak {
10
+  filter: invert(80%);
11
+}
12
+
13
+.ant-layout {
14
+  min-height: 100vh;
15
+}
16
+
17
+canvas {
18
+  display: block;
19
+}
20
+
21
+body {
22
+  text-rendering: optimizeLegibility;
23
+  -webkit-font-smoothing: antialiased;
24
+  -moz-osx-font-smoothing: grayscale;
25
+}
26
+
27
+ul,
28
+ol {
29
+  list-style: none;
30
+}
31
+
32
+@media (max-width: @screen-xs) {
33
+  .ant-table {
34
+    width: 100%;
35
+    overflow-x: auto;
36
+    &-thead > tr,
37
+    &-tbody > tr {
38
+      > th,
39
+      > td {
40
+        white-space: pre;
41
+        > span {
42
+          display: block;
43
+        }
44
+      }
45
+    }
46
+  }
47
+}
48
+
49
+// 兼容IE11
50
+@media screen and(-ms-high-contrast: active), (-ms-high-contrast: none) {
51
+  body .ant-design-pro > .ant-layout {
52
+    min-height: 100vh;
53
+  }
54
+}

+ 178
- 0
src/layouts/BasicLayout.jsx 查看文件

@@ -0,0 +1,178 @@
1
+/**
2
+ * Ant Design Pro v4 use `@ant-design/pro-layout` to handle Layout.
3
+ * You can view component api by:
4
+ * https://github.com/ant-design/ant-design-pro-layout
5
+ */
6
+import ProLayout, { DefaultFooter } from '@ant-design/pro-layout';
7
+import React, { useEffect } from 'react';
8
+import { Link } from 'umi';
9
+import { connect } from 'dva';
10
+import { Icon, Result, Button } from 'antd';
11
+import { formatMessage } from 'umi-plugin-react/locale';
12
+import Authorized from '@/utils/Authorized';
13
+import RightContent from '@/components/GlobalHeader/RightContent';
14
+import { isAntDesignPro, getAuthorityFromRouter } from '@/utils/utils';
15
+import logo from '../assets/logo.svg';
16
+const noMatch = (
17
+  <Result
18
+    status={403}
19
+    title="403"
20
+    subTitle="Sorry, you are not authorized to access this page."
21
+    extra={
22
+      <Button type="primary">
23
+        <Link to="/user/login">Go Login</Link>
24
+      </Button>
25
+    }
26
+  />
27
+);
28
+
29
+/**
30
+ * use Authorized check all menu item
31
+ */
32
+const menuDataRender = (menuList) =>
33
+  menuList.map((item) => {
34
+    const localItem = { ...item, children: item.children ? menuDataRender(item.children) : [] };
35
+    return Authorized.check(item.authority, localItem, null);
36
+  });
37
+
38
+const defaultFooterDom = (
39
+  <DefaultFooter
40
+    copyright="2019 蚂蚁金服体验技术部出品"
41
+    links={[
42
+      {
43
+        key: 'Ant Design Pro',
44
+        title: 'Ant Design Pro',
45
+        href: 'https://pro.ant.design',
46
+        blankTarget: true,
47
+      },
48
+      {
49
+        key: 'github',
50
+        title: <Icon type="github" />,
51
+        href: 'https://github.com/ant-design/ant-design-pro',
52
+        blankTarget: true,
53
+      },
54
+      {
55
+        key: 'Ant Design',
56
+        title: 'Ant Design',
57
+        href: 'https://ant.design',
58
+        blankTarget: true,
59
+      },
60
+    ]}
61
+  />
62
+);
63
+
64
+const footerRender = () => {
65
+  if (!isAntDesignPro()) {
66
+    return defaultFooterDom;
67
+  }
68
+
69
+  return (
70
+    <>
71
+      {defaultFooterDom}
72
+      <div
73
+        style={{
74
+          padding: '0px 24px 24px',
75
+          textAlign: 'center',
76
+        }}
77
+      >
78
+        <a href="https://www.netlify.com" target="_blank" rel="noopener noreferrer">
79
+          <img
80
+            src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"
81
+            width="82px"
82
+            alt="netlify logo"
83
+          />
84
+        </a>
85
+      </div>
86
+    </>
87
+  );
88
+};
89
+
90
+const BasicLayout = (props) => {
91
+  const {
92
+    dispatch,
93
+    children,
94
+    settings,
95
+    location = {
96
+      pathname: '/',
97
+    },
98
+  } = props;
99
+  /**
100
+   * constructor
101
+   */
102
+
103
+  useEffect(() => {
104
+    if (dispatch) {
105
+      dispatch({
106
+        type: 'user/fetchCurrent',
107
+      });
108
+    }
109
+  }, []);
110
+  /**
111
+   * init variables
112
+   */
113
+
114
+  const handleMenuCollapse = (payload) => {
115
+    if (dispatch) {
116
+      dispatch({
117
+        type: 'global/changeLayoutCollapsed',
118
+        payload,
119
+      });
120
+    }
121
+  }; // get children authority
122
+
123
+  const authorized = getAuthorityFromRouter(props.route.routes, location.pathname || '/') || {
124
+    authority: undefined,
125
+  };
126
+  return (
127
+    <ProLayout
128
+      logo={logo}
129
+      menuHeaderRender={(logoDom, titleDom) => (
130
+        <Link to="/">
131
+          {logoDom}
132
+          {titleDom}
133
+        </Link>
134
+      )}
135
+      onCollapse={handleMenuCollapse}
136
+      menuItemRender={(menuItemProps, defaultDom) => {
137
+        if (menuItemProps.isUrl || menuItemProps.children || !menuItemProps.path) {
138
+          return defaultDom;
139
+        }
140
+
141
+        return <Link to={menuItemProps.path}>{defaultDom}</Link>;
142
+      }}
143
+      breadcrumbRender={(routers = []) => [
144
+        {
145
+          path: '/',
146
+          breadcrumbName: formatMessage({
147
+            id: 'menu.home',
148
+            defaultMessage: 'Home',
149
+          }),
150
+        },
151
+        ...routers,
152
+      ]}
153
+      itemRender={(route, params, routes, paths) => {
154
+        const first = routes.indexOf(route) === 0;
155
+        return first ? (
156
+          <Link to={paths.join('/')}>{route.breadcrumbName}</Link>
157
+        ) : (
158
+          <span>{route.breadcrumbName}</span>
159
+        );
160
+      }}
161
+      footerRender={footerRender}
162
+      menuDataRender={menuDataRender}
163
+      formatMessage={formatMessage}
164
+      rightContentRender={() => <RightContent />}
165
+      {...props}
166
+      {...settings}
167
+    >
168
+      <Authorized authority={authorized.authority} noMatch={noMatch}>
169
+        {children}
170
+      </Authorized>
171
+    </ProLayout>
172
+  );
173
+};
174
+
175
+export default connect(({ global, settings }) => ({
176
+  collapsed: global.collapsed,
177
+  settings,
178
+}))(BasicLayout);

+ 5
- 0
src/layouts/BlankLayout.jsx 查看文件

@@ -0,0 +1,5 @@
1
+import React from 'react';
2
+
3
+const Layout = ({ children }) => <>{children}</>;
4
+
5
+export default Layout;

+ 50
- 0
src/layouts/SecurityLayout.jsx 查看文件

@@ -0,0 +1,50 @@
1
+import React from 'react';
2
+import { connect } from 'dva';
3
+import { PageLoading } from '@ant-design/pro-layout';
4
+import { Redirect } from 'umi';
5
+import { stringify } from 'querystring';
6
+
7
+class SecurityLayout extends React.Component {
8
+  state = {
9
+    isReady: false,
10
+  };
11
+
12
+  componentDidMount() {
13
+    this.setState({
14
+      isReady: true,
15
+    });
16
+    const { dispatch } = this.props;
17
+
18
+    if (dispatch) {
19
+      dispatch({
20
+        type: 'user/fetchCurrent',
21
+      });
22
+    }
23
+  }
24
+
25
+  render() {
26
+    const { isReady } = this.state;
27
+    const { children, loading, currentUser } = this.props; // You can replace it to your authentication rule (such as check token exists)
28
+    // 你可以把它替换成你自己的登录认证规则(比如判断 token 是否存在)
29
+
30
+    const isLogin = currentUser && currentUser.userid;
31
+    const queryString = stringify({
32
+      redirect: window.location.href,
33
+    });
34
+
35
+    if ((!isLogin && loading) || !isReady) {
36
+      return <PageLoading />;
37
+    }
38
+
39
+    if (!isLogin && window.location.pathname !== '/user/login') {
40
+      return <Redirect to={`/user/login?${queryString}`} />;
41
+    }
42
+
43
+    return children;
44
+  }
45
+}
46
+
47
+export default connect(({ user, loading }) => ({
48
+  currentUser: user.currentUser,
49
+  loading: loading.models.user,
50
+}))(SecurityLayout);

+ 60
- 0
src/layouts/UserLayout.jsx 查看文件

@@ -0,0 +1,60 @@
1
+import { DefaultFooter, getMenuData, getPageTitle } from '@ant-design/pro-layout';
2
+import { Helmet } from 'react-helmet';
3
+import { Link } from 'umi';
4
+import React from 'react';
5
+import { connect } from 'dva';
6
+import { formatMessage } from 'umi-plugin-react/locale';
7
+import SelectLang from '@/components/SelectLang';
8
+import logo from '../assets/logo.svg';
9
+import styles from './UserLayout.less';
10
+
11
+const UserLayout = (props) => {
12
+  const {
13
+    route = {
14
+      routes: [],
15
+    },
16
+  } = props;
17
+  const { routes = [] } = route;
18
+  const {
19
+    children,
20
+    location = {
21
+      pathname: '',
22
+    },
23
+  } = props;
24
+  const { breadcrumb } = getMenuData(routes);
25
+  const title = getPageTitle({
26
+    pathname: location.pathname,
27
+    breadcrumb,
28
+    formatMessage,
29
+    ...props,
30
+  });
31
+  return (
32
+    <>
33
+      <Helmet>
34
+        <title>{title}</title>
35
+        <meta name="description" content={title} />
36
+      </Helmet>
37
+
38
+      <div className={styles.container}>
39
+        <div className={styles.lang}>
40
+          <SelectLang />
41
+        </div>
42
+        <div className={styles.content}>
43
+          <div className={styles.top}>
44
+            <div className={styles.header}>
45
+              <Link to="/">
46
+                <img alt="logo" className={styles.logo} src={logo} />
47
+                <span className={styles.title}>Ant Design</span>
48
+              </Link>
49
+            </div>
50
+            <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
51
+          </div>
52
+          {children}
53
+        </div>
54
+        <DefaultFooter />
55
+      </div>
56
+    </>
57
+  );
58
+};
59
+
60
+export default connect(({ settings }) => ({ ...settings }))(UserLayout);

+ 71
- 0
src/layouts/UserLayout.less 查看文件

@@ -0,0 +1,71 @@
1
+@import '~antd/es/style/themes/default.less';
2
+
3
+.container {
4
+  display: flex;
5
+  flex-direction: column;
6
+  height: 100vh;
7
+  overflow: auto;
8
+  background: @layout-body-background;
9
+}
10
+
11
+.lang {
12
+  width: 100%;
13
+  height: 40px;
14
+  line-height: 44px;
15
+  text-align: right;
16
+  :global(.ant-dropdown-trigger) {
17
+    margin-right: 24px;
18
+  }
19
+}
20
+
21
+.content {
22
+  flex: 1;
23
+  padding: 32px 0;
24
+}
25
+
26
+@media (min-width: @screen-md-min) {
27
+  .container {
28
+    background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg');
29
+    background-repeat: no-repeat;
30
+    background-position: center 110px;
31
+    background-size: 100%;
32
+  }
33
+
34
+  .content {
35
+    padding: 32px 0 24px;
36
+  }
37
+}
38
+
39
+.top {
40
+  text-align: center;
41
+}
42
+
43
+.header {
44
+  height: 44px;
45
+  line-height: 44px;
46
+  a {
47
+    text-decoration: none;
48
+  }
49
+}
50
+
51
+.logo {
52
+  height: 44px;
53
+  margin-right: 16px;
54
+  vertical-align: top;
55
+}
56
+
57
+.title {
58
+  position: relative;
59
+  top: 2px;
60
+  color: @heading-color;
61
+  font-weight: 600;
62
+  font-size: 33px;
63
+  font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif;
64
+}
65
+
66
+.desc {
67
+  margin-top: 12px;
68
+  margin-bottom: 40px;
69
+  color: @text-color-secondary;
70
+  font-size: @font-size-base;
71
+}

+ 21
- 0
src/locales/en-US.js 查看文件

@@ -0,0 +1,21 @@
1
+import component from './en-US/component';
2
+import globalHeader from './en-US/globalHeader';
3
+import menu from './en-US/menu';
4
+import pwa from './en-US/pwa';
5
+import settingDrawer from './en-US/settingDrawer';
6
+import settings from './en-US/settings';
7
+export default {
8
+  'navBar.lang': 'Languages',
9
+  'layout.user.link.help': 'Help',
10
+  'layout.user.link.privacy': 'Privacy',
11
+  'layout.user.link.terms': 'Terms',
12
+  'app.preview.down.block': 'Download this page to your local project',
13
+  'app.welcome.link.fetch-blocks': 'Get all block',
14
+  'app.welcome.link.block-list': 'Quickly build standard, pages based on `block` development',
15
+  ...globalHeader,
16
+  ...menu,
17
+  ...settingDrawer,
18
+  ...settings,
19
+  ...pwa,
20
+  ...component,
21
+};

+ 5
- 0
src/locales/en-US/component.js 查看文件

@@ -0,0 +1,5 @@
1
+export default {
2
+  'component.tagSelect.expand': 'Expand',
3
+  'component.tagSelect.collapse': 'Collapse',
4
+  'component.tagSelect.all': 'All',
5
+};

+ 17
- 0
src/locales/en-US/globalHeader.js 查看文件

@@ -0,0 +1,17 @@
1
+export default {
2
+  'component.globalHeader.search': 'Search',
3
+  'component.globalHeader.search.example1': 'Search example 1',
4
+  'component.globalHeader.search.example2': 'Search example 2',
5
+  'component.globalHeader.search.example3': 'Search example 3',
6
+  'component.globalHeader.help': 'Help',
7
+  'component.globalHeader.notification': 'Notification',
8
+  'component.globalHeader.notification.empty': 'You have viewed all notifications.',
9
+  'component.globalHeader.message': 'Message',
10
+  'component.globalHeader.message.empty': 'You have viewed all messsages.',
11
+  'component.globalHeader.event': 'Event',
12
+  'component.globalHeader.event.empty': 'You have viewed all events.',
13
+  'component.noticeIcon.clear': 'Clear',
14
+  'component.noticeIcon.cleared': 'Cleared',
15
+  'component.noticeIcon.empty': 'No notifications',
16
+  'component.noticeIcon.view-more': 'View more',
17
+};

+ 52
- 0
src/locales/en-US/menu.js 查看文件

@@ -0,0 +1,52 @@
1
+export default {
2
+  'menu.welcome': 'Welcome',
3
+  'menu.more-blocks': 'More Blocks',
4
+  'menu.home': 'Home',
5
+  'menu.admin': 'Admin',
6
+  'menu.admin.sub-page': 'Sub-Page',
7
+  'menu.login': 'Login',
8
+  'menu.register': 'Register',
9
+  'menu.register.result': 'Register Result',
10
+  'menu.dashboard': 'Dashboard',
11
+  'menu.dashboard.analysis': 'Analysis',
12
+  'menu.dashboard.monitor': 'Monitor',
13
+  'menu.dashboard.workplace': 'Workplace',
14
+  'menu.exception.403': '403',
15
+  'menu.exception.404': '404',
16
+  'menu.exception.500': '500',
17
+  'menu.form': 'Form',
18
+  'menu.form.basic-form': 'Basic Form',
19
+  'menu.form.step-form': 'Step Form',
20
+  'menu.form.step-form.info': 'Step Form(write transfer information)',
21
+  'menu.form.step-form.confirm': 'Step Form(confirm transfer information)',
22
+  'menu.form.step-form.result': 'Step Form(finished)',
23
+  'menu.form.advanced-form': 'Advanced Form',
24
+  'menu.list': 'List',
25
+  'menu.list.table-list': 'Search Table',
26
+  'menu.list.basic-list': 'Basic List',
27
+  'menu.list.card-list': 'Card List',
28
+  'menu.list.search-list': 'Search List',
29
+  'menu.list.search-list.articles': 'Search List(articles)',
30
+  'menu.list.search-list.projects': 'Search List(projects)',
31
+  'menu.list.search-list.applications': 'Search List(applications)',
32
+  'menu.profile': 'Profile',
33
+  'menu.profile.basic': 'Basic Profile',
34
+  'menu.profile.advanced': 'Advanced Profile',
35
+  'menu.result': 'Result',
36
+  'menu.result.success': 'Success',
37
+  'menu.result.fail': 'Fail',
38
+  'menu.exception': 'Exception',
39
+  'menu.exception.not-permission': '403',
40
+  'menu.exception.not-find': '404',
41
+  'menu.exception.server-error': '500',
42
+  'menu.exception.trigger': 'Trigger',
43
+  'menu.account': 'Account',
44
+  'menu.account.center': 'Account Center',
45
+  'menu.account.settings': 'Account Settings',
46
+  'menu.account.trigger': 'Trigger Error',
47
+  'menu.account.logout': 'Logout',
48
+  'menu.editor': 'Graphic Editor',
49
+  'menu.editor.flow': 'Flow Editor',
50
+  'menu.editor.mind': 'Mind Editor',
51
+  'menu.editor.koni': 'Koni Editor',
52
+};

+ 6
- 0
src/locales/en-US/pwa.js 查看文件

@@ -0,0 +1,6 @@
1
+export default {
2
+  'app.pwa.offline': 'You are offline now',
3
+  'app.pwa.serviceworker.updated': 'New content is available',
4
+  'app.pwa.serviceworker.updated.hint': 'Please press the "Refresh" button to reload current page',
5
+  'app.pwa.serviceworker.updated.ok': 'Refresh',
6
+};

+ 31
- 0
src/locales/en-US/settingDrawer.js 查看文件

@@ -0,0 +1,31 @@
1
+export default {
2
+  'app.setting.pagestyle': 'Page style setting',
3
+  'app.setting.pagestyle.dark': 'Dark style',
4
+  'app.setting.pagestyle.light': 'Light style',
5
+  'app.setting.content-width': 'Content Width',
6
+  'app.setting.content-width.fixed': 'Fixed',
7
+  'app.setting.content-width.fluid': 'Fluid',
8
+  'app.setting.themecolor': 'Theme Color',
9
+  'app.setting.themecolor.dust': 'Dust Red',
10
+  'app.setting.themecolor.volcano': 'Volcano',
11
+  'app.setting.themecolor.sunset': 'Sunset Orange',
12
+  'app.setting.themecolor.cyan': 'Cyan',
13
+  'app.setting.themecolor.green': 'Polar Green',
14
+  'app.setting.themecolor.daybreak': 'Daybreak Blue (default)',
15
+  'app.setting.themecolor.geekblue': 'Geek Glue',
16
+  'app.setting.themecolor.purple': 'Golden Purple',
17
+  'app.setting.navigationmode': 'Navigation Mode',
18
+  'app.setting.sidemenu': 'Side Menu Layout',
19
+  'app.setting.topmenu': 'Top Menu Layout',
20
+  'app.setting.fixedheader': 'Fixed Header',
21
+  'app.setting.fixedsidebar': 'Fixed Sidebar',
22
+  'app.setting.fixedsidebar.hint': 'Works on Side Menu Layout',
23
+  'app.setting.hideheader': 'Hidden Header when scrolling',
24
+  'app.setting.hideheader.hint': 'Works when Hidden Header is enabled',
25
+  'app.setting.othersettings': 'Other Settings',
26
+  'app.setting.weakmode': 'Weak Mode',
27
+  'app.setting.copy': 'Copy Setting',
28
+  'app.setting.copyinfo': 'copy success,please replace defaultSettings in src/models/setting.js',
29
+  'app.setting.production.hint':
30
+    'Setting panel shows in development environment only, please manually modify',
31
+};

+ 60
- 0
src/locales/en-US/settings.js 查看文件

@@ -0,0 +1,60 @@
1
+export default {
2
+  'app.settings.menuMap.basic': 'Basic Settings',
3
+  'app.settings.menuMap.security': 'Security Settings',
4
+  'app.settings.menuMap.binding': 'Account Binding',
5
+  'app.settings.menuMap.notification': 'New Message Notification',
6
+  'app.settings.basic.avatar': 'Avatar',
7
+  'app.settings.basic.change-avatar': 'Change avatar',
8
+  'app.settings.basic.email': 'Email',
9
+  'app.settings.basic.email-message': 'Please input your email!',
10
+  'app.settings.basic.nickname': 'Nickname',
11
+  'app.settings.basic.nickname-message': 'Please input your Nickname!',
12
+  'app.settings.basic.profile': 'Personal profile',
13
+  'app.settings.basic.profile-message': 'Please input your personal profile!',
14
+  'app.settings.basic.profile-placeholder': 'Brief introduction to yourself',
15
+  'app.settings.basic.country': 'Country/Region',
16
+  'app.settings.basic.country-message': 'Please input your country!',
17
+  'app.settings.basic.geographic': 'Province or city',
18
+  'app.settings.basic.geographic-message': 'Please input your geographic info!',
19
+  'app.settings.basic.address': 'Street Address',
20
+  'app.settings.basic.address-message': 'Please input your address!',
21
+  'app.settings.basic.phone': 'Phone Number',
22
+  'app.settings.basic.phone-message': 'Please input your phone!',
23
+  'app.settings.basic.update': 'Update Information',
24
+  'app.settings.security.strong': 'Strong',
25
+  'app.settings.security.medium': 'Medium',
26
+  'app.settings.security.weak': 'Weak',
27
+  'app.settings.security.password': 'Account Password',
28
+  'app.settings.security.password-description': 'Current password strength',
29
+  'app.settings.security.phone': 'Security Phone',
30
+  'app.settings.security.phone-description': 'Bound phone',
31
+  'app.settings.security.question': 'Security Question',
32
+  'app.settings.security.question-description':
33
+    'The security question is not set, and the security policy can effectively protect the account security',
34
+  'app.settings.security.email': 'Backup Email',
35
+  'app.settings.security.email-description': 'Bound Email',
36
+  'app.settings.security.mfa': 'MFA Device',
37
+  'app.settings.security.mfa-description':
38
+    'Unbound MFA device, after binding, can be confirmed twice',
39
+  'app.settings.security.modify': 'Modify',
40
+  'app.settings.security.set': 'Set',
41
+  'app.settings.security.bind': 'Bind',
42
+  'app.settings.binding.taobao': 'Binding Taobao',
43
+  'app.settings.binding.taobao-description': 'Currently unbound Taobao account',
44
+  'app.settings.binding.alipay': 'Binding Alipay',
45
+  'app.settings.binding.alipay-description': 'Currently unbound Alipay account',
46
+  'app.settings.binding.dingding': 'Binding DingTalk',
47
+  'app.settings.binding.dingding-description': 'Currently unbound DingTalk account',
48
+  'app.settings.binding.bind': 'Bind',
49
+  'app.settings.notification.password': 'Account Password',
50
+  'app.settings.notification.password-description':
51
+    'Messages from other users will be notified in the form of a station letter',
52
+  'app.settings.notification.messages': 'System Messages',
53
+  'app.settings.notification.messages-description':
54
+    'System messages will be notified in the form of a station letter',
55
+  'app.settings.notification.todo': 'To-do Notification',
56
+  'app.settings.notification.todo-description':
57
+    'The to-do list will be notified in the form of a letter from the station',
58
+  'app.settings.open': 'Open',
59
+  'app.settings.close': 'Close',
60
+};

+ 19
- 0
src/locales/pt-BR.js 查看文件

@@ -0,0 +1,19 @@
1
+import component from './pt-BR/component';
2
+import globalHeader from './pt-BR/globalHeader';
3
+import menu from './pt-BR/menu';
4
+import pwa from './pt-BR/pwa';
5
+import settingDrawer from './pt-BR/settingDrawer';
6
+import settings from './pt-BR/settings';
7
+export default {
8
+  'navBar.lang': 'Idiomas',
9
+  'layout.user.link.help': 'ajuda',
10
+  'layout.user.link.privacy': 'política de privacidade',
11
+  'layout.user.link.terms': 'termos de serviços',
12
+  'app.preview.down.block': 'Download this page to your local project',
13
+  ...globalHeader,
14
+  ...menu,
15
+  ...settingDrawer,
16
+  ...settings,
17
+  ...pwa,
18
+  ...component,
19
+};

+ 5
- 0
src/locales/pt-BR/component.js 查看文件

@@ -0,0 +1,5 @@
1
+export default {
2
+  'component.tagSelect.expand': 'Expandir',
3
+  'component.tagSelect.collapse': 'Diminuir',
4
+  'component.tagSelect.all': 'Todas',
5
+};

+ 18
- 0
src/locales/pt-BR/globalHeader.js 查看文件

@@ -0,0 +1,18 @@
1
+export default {
2
+  'component.globalHeader.search': 'Busca',
3
+  'component.globalHeader.search.example1': 'Exemplo de busca 1',
4
+  'component.globalHeader.search.example2': 'Exemplo de busca 2',
5
+  'component.globalHeader.search.example3': 'Exemplo de busca 3',
6
+  'component.globalHeader.help': 'Ajuda',
7
+  'component.globalHeader.notification': 'Notificação',
8
+  'component.globalHeader.notification.empty': 'Você visualizou todas as notificações.',
9
+  'component.globalHeader.message': 'Mensagem',
10
+  'component.globalHeader.message.empty': 'Você visualizou todas as mensagens.',
11
+  'component.globalHeader.event': 'Evento',
12
+  'component.globalHeader.event.empty': 'Você visualizou todos os eventos.',
13
+  'component.noticeIcon.clear': 'Limpar',
14
+  'component.noticeIcon.cleared': 'Limpo',
15
+  'component.noticeIcon.empty': 'Sem notificações',
16
+  'component.noticeIcon.loaded': 'Carregado',
17
+  'component.noticeIcon.view-more': 'Veja mais',
18
+};

+ 52
- 0
src/locales/pt-BR/menu.js 查看文件

@@ -0,0 +1,52 @@
1
+export default {
2
+  'menu.welcome': 'Welcome',
3
+  'menu.more-blocks': 'More Blocks',
4
+  'menu.home': 'Início',
5
+  'menu.login': 'Login',
6
+  'menu.admin': 'Admin',
7
+  'menu.admin.sub-page': 'Sub-Page',
8
+  'menu.register': 'Registro',
9
+  'menu.register.result': 'Resultado de registro',
10
+  'menu.dashboard': 'Dashboard',
11
+  'menu.dashboard.analysis': 'Análise',
12
+  'menu.dashboard.monitor': 'Monitor',
13
+  'menu.dashboard.workplace': 'Ambiente de Trabalho',
14
+  'menu.exception.403': '403',
15
+  'menu.exception.404': '404',
16
+  'menu.exception.500': '500',
17
+  'menu.form': 'Formulário',
18
+  'menu.form.basic-form': 'Formulário Básico',
19
+  'menu.form.step-form': 'Formulário Assistido',
20
+  'menu.form.step-form.info': 'Formulário Assistido(gravar informações de transferência)',
21
+  'menu.form.step-form.confirm': 'Formulário Assistido(confirmar informações de transferência)',
22
+  'menu.form.step-form.result': 'Formulário Assistido(finalizado)',
23
+  'menu.form.advanced-form': 'Formulário Avançado',
24
+  'menu.list': 'Lista',
25
+  'menu.list.table-list': 'Tabela de Busca',
26
+  'menu.list.basic-list': 'Lista Básica',
27
+  'menu.list.card-list': 'Lista de Card',
28
+  'menu.list.search-list': 'Lista de Busca',
29
+  'menu.list.search-list.articles': 'Lista de Busca(artigos)',
30
+  'menu.list.search-list.projects': 'Lista de Busca(projetos)',
31
+  'menu.list.search-list.applications': 'Lista de Busca(aplicações)',
32
+  'menu.profile': 'Perfil',
33
+  'menu.profile.basic': 'Perfil Básico',
34
+  'menu.profile.advanced': 'Perfil Avançado',
35
+  'menu.result': 'Resultado',
36
+  'menu.result.success': 'Sucesso',
37
+  'menu.result.fail': 'Falha',
38
+  'menu.exception': 'Exceção',
39
+  'menu.exception.not-permission': '403',
40
+  'menu.exception.not-find': '404',
41
+  'menu.exception.server-error': '500',
42
+  'menu.exception.trigger': 'Disparar',
43
+  'menu.account': 'Conta',
44
+  'menu.account.center': 'Central da Conta',
45
+  'menu.account.settings': 'Configurar Conta',
46
+  'menu.account.trigger': 'Disparar Erro',
47
+  'menu.account.logout': 'Sair',
48
+  'menu.editor': 'Graphic Editor',
49
+  'menu.editor.flow': 'Flow Editor',
50
+  'menu.editor.mind': 'Mind Editor',
51
+  'menu.editor.koni': 'Koni Editor',
52
+};

+ 7
- 0
src/locales/pt-BR/pwa.js 查看文件

@@ -0,0 +1,7 @@
1
+export default {
2
+  'app.pwa.offline': 'Você está offline agora',
3
+  'app.pwa.serviceworker.updated': 'Novo conteúdo está disponível',
4
+  'app.pwa.serviceworker.updated.hint':
5
+    'Por favor, pressione o botão "Atualizar" para recarregar a página atual',
6
+  'app.pwa.serviceworker.updated.ok': 'Atualizar',
7
+};

+ 32
- 0
src/locales/pt-BR/settingDrawer.js 查看文件

@@ -0,0 +1,32 @@
1
+export default {
2
+  'app.setting.pagestyle': 'Configuração de estilo da página',
3
+  'app.setting.pagestyle.dark': 'Dark style',
4
+  'app.setting.pagestyle.light': 'Light style',
5
+  'app.setting.content-width': 'Largura do conteúdo',
6
+  'app.setting.content-width.fixed': 'Fixo',
7
+  'app.setting.content-width.fluid': 'Fluido',
8
+  'app.setting.themecolor': 'Cor do Tema',
9
+  'app.setting.themecolor.dust': 'Dust Red',
10
+  'app.setting.themecolor.volcano': 'Volcano',
11
+  'app.setting.themecolor.sunset': 'Sunset Orange',
12
+  'app.setting.themecolor.cyan': 'Cyan',
13
+  'app.setting.themecolor.green': 'Polar Green',
14
+  'app.setting.themecolor.daybreak': 'Daybreak Blue (default)',
15
+  'app.setting.themecolor.geekblue': 'Geek Glue',
16
+  'app.setting.themecolor.purple': 'Golden Purple',
17
+  'app.setting.navigationmode': 'Modo de Navegação',
18
+  'app.setting.sidemenu': 'Layout do Menu Lateral',
19
+  'app.setting.topmenu': 'Layout do Menu Superior',
20
+  'app.setting.fixedheader': 'Cabeçalho fixo',
21
+  'app.setting.fixedsidebar': 'Barra lateral fixa',
22
+  'app.setting.fixedsidebar.hint': 'Funciona no layout do menu lateral',
23
+  'app.setting.hideheader': 'Esconder o cabeçalho quando rolar',
24
+  'app.setting.hideheader.hint': 'Funciona quando o esconder cabeçalho está abilitado',
25
+  'app.setting.othersettings': 'Outras configurações',
26
+  'app.setting.weakmode': 'Weak Mode',
27
+  'app.setting.copy': 'Copiar Configuração',
28
+  'app.setting.copyinfo':
29
+    'copiado com sucesso,por favor trocar o defaultSettings em src/models/setting.js',
30
+  'app.setting.production.hint':
31
+    'O painel de configuração apenas é exibido no ambiente de desenvolvimento, por favor modifique manualmente o',
32
+};

+ 60
- 0
src/locales/pt-BR/settings.js 查看文件

@@ -0,0 +1,60 @@
1
+export default {
2
+  'app.settings.menuMap.basic': 'Configurações Básicas',
3
+  'app.settings.menuMap.security': 'Configurações de Segurança',
4
+  'app.settings.menuMap.binding': 'Vinculação de Conta',
5
+  'app.settings.menuMap.notification': 'Mensagens de Notificação',
6
+  'app.settings.basic.avatar': 'Avatar',
7
+  'app.settings.basic.change-avatar': 'Alterar avatar',
8
+  'app.settings.basic.email': 'Email',
9
+  'app.settings.basic.email-message': 'Por favor insira seu email!',
10
+  'app.settings.basic.nickname': 'Nome de usuário',
11
+  'app.settings.basic.nickname-message': 'Por favor insira seu nome de usuário!',
12
+  'app.settings.basic.profile': 'Perfil pessoal',
13
+  'app.settings.basic.profile-message': 'Por favor insira seu perfil pessoal!',
14
+  'app.settings.basic.profile-placeholder': 'Breve introdução sua',
15
+  'app.settings.basic.country': 'País/Região',
16
+  'app.settings.basic.country-message': 'Por favor insira país!',
17
+  'app.settings.basic.geographic': 'Província, estado ou cidade',
18
+  'app.settings.basic.geographic-message': 'Por favor insira suas informações geográficas!',
19
+  'app.settings.basic.address': 'Endereço',
20
+  'app.settings.basic.address-message': 'Por favor insira seu endereço!',
21
+  'app.settings.basic.phone': 'Número de telefone',
22
+  'app.settings.basic.phone-message': 'Por favor insira seu número de telefone!',
23
+  'app.settings.basic.update': 'Atualizar Informações',
24
+  'app.settings.security.strong': 'Forte',
25
+  'app.settings.security.medium': 'Média',
26
+  'app.settings.security.weak': 'Fraca',
27
+  'app.settings.security.password': 'Senha da Conta',
28
+  'app.settings.security.password-description': 'Força da senha',
29
+  'app.settings.security.phone': 'Telefone de Seguraça',
30
+  'app.settings.security.phone-description': 'Telefone vinculado',
31
+  'app.settings.security.question': 'Pergunta de Segurança',
32
+  'app.settings.security.question-description':
33
+    'A pergunta de segurança não está definida e a política de segurança pode proteger efetivamente a segurança da conta',
34
+  'app.settings.security.email': 'Email de Backup',
35
+  'app.settings.security.email-description': 'Email vinculado',
36
+  'app.settings.security.mfa': 'Dispositivo MFA',
37
+  'app.settings.security.mfa-description':
38
+    'O dispositivo MFA não vinculado, após a vinculação, pode ser confirmado duas vezes',
39
+  'app.settings.security.modify': 'Modificar',
40
+  'app.settings.security.set': 'Atribuir',
41
+  'app.settings.security.bind': 'Vincular',
42
+  'app.settings.binding.taobao': 'Vincular Taobao',
43
+  'app.settings.binding.taobao-description': 'Atualmente não vinculado à conta Taobao',
44
+  'app.settings.binding.alipay': 'Vincular Alipay',
45
+  'app.settings.binding.alipay-description': 'Atualmente não vinculado à conta Alipay',
46
+  'app.settings.binding.dingding': 'Vincular DingTalk',
47
+  'app.settings.binding.dingding-description': 'Atualmente não vinculado à conta DingTalk',
48
+  'app.settings.binding.bind': 'Vincular',
49
+  'app.settings.notification.password': 'Senha da Conta',
50
+  'app.settings.notification.password-description':
51
+    'Mensagens de outros usuários serão notificadas na forma de uma estação de letra',
52
+  'app.settings.notification.messages': 'Mensagens de Sistema',
53
+  'app.settings.notification.messages-description':
54
+    'Mensagens de sistema serão notificadas na forma de uma estação de letra',
55
+  'app.settings.notification.todo': 'Notificação de To-do',
56
+  'app.settings.notification.todo-description':
57
+    'A lista de to-do será notificada na forma de uma estação de letra',
58
+  'app.settings.open': 'Aberto',
59
+  'app.settings.close': 'Fechado',
60
+};

+ 21
- 0
src/locales/zh-CN.js 查看文件

@@ -0,0 +1,21 @@
1
+import component from './zh-CN/component';
2
+import globalHeader from './zh-CN/globalHeader';
3
+import menu from './zh-CN/menu';
4
+import pwa from './zh-CN/pwa';
5
+import settingDrawer from './zh-CN/settingDrawer';
6
+import settings from './zh-CN/settings';
7
+export default {
8
+  'navBar.lang': '语言',
9
+  'layout.user.link.help': '帮助',
10
+  'layout.user.link.privacy': '隐私',
11
+  'layout.user.link.terms': '条款',
12
+  'app.preview.down.block': '下载此页面到本地项目',
13
+  'app.welcome.link.fetch-blocks': '获取全部区块',
14
+  'app.welcome.link.block-list': '基于 block 开发,快速构建标准页面',
15
+  ...globalHeader,
16
+  ...menu,
17
+  ...settingDrawer,
18
+  ...settings,
19
+  ...pwa,
20
+  ...component,
21
+};

+ 5
- 0
src/locales/zh-CN/component.js 查看文件

@@ -0,0 +1,5 @@
1
+export default {
2
+  'component.tagSelect.expand': '展开',
3
+  'component.tagSelect.collapse': '收起',
4
+  'component.tagSelect.all': '全部',
5
+};

+ 17
- 0
src/locales/zh-CN/globalHeader.js 查看文件

@@ -0,0 +1,17 @@
1
+export default {
2
+  'component.globalHeader.search': '站内搜索',
3
+  'component.globalHeader.search.example1': '搜索提示一',
4
+  'component.globalHeader.search.example2': '搜索提示二',
5
+  'component.globalHeader.search.example3': '搜索提示三',
6
+  'component.globalHeader.help': '使用文档',
7
+  'component.globalHeader.notification': '通知',
8
+  'component.globalHeader.notification.empty': '你已查看所有通知',
9
+  'component.globalHeader.message': '消息',
10
+  'component.globalHeader.message.empty': '您已读完所有消息',
11
+  'component.globalHeader.event': '待办',
12
+  'component.globalHeader.event.empty': '你已完成所有待办',
13
+  'component.noticeIcon.clear': '清空',
14
+  'component.noticeIcon.cleared': '清空了',
15
+  'component.noticeIcon.empty': '暂无数据',
16
+  'component.noticeIcon.view-more': '查看更多',
17
+};

+ 52
- 0
src/locales/zh-CN/menu.js 查看文件

@@ -0,0 +1,52 @@
1
+export default {
2
+  'menu.welcome': '欢迎',
3
+  'menu.more-blocks': '更多区块',
4
+  'menu.home': '首页',
5
+  'menu.admin': '管理页',
6
+  'menu.admin.sub-page': '二级管理页',
7
+  'menu.login': '登录',
8
+  'menu.register': '注册',
9
+  'menu.register.result': '注册结果',
10
+  'menu.dashboard': 'Dashboard',
11
+  'menu.dashboard.analysis': '分析页',
12
+  'menu.dashboard.monitor': '监控页',
13
+  'menu.dashboard.workplace': '工作台',
14
+  'menu.exception.403': '403',
15
+  'menu.exception.404': '404',
16
+  'menu.exception.500': '500',
17
+  'menu.form': '表单页',
18
+  'menu.form.basic-form': '基础表单',
19
+  'menu.form.step-form': '分步表单',
20
+  'menu.form.step-form.info': '分步表单(填写转账信息)',
21
+  'menu.form.step-form.confirm': '分步表单(确认转账信息)',
22
+  'menu.form.step-form.result': '分步表单(完成)',
23
+  'menu.form.advanced-form': '高级表单',
24
+  'menu.list': '列表页',
25
+  'menu.list.table-list': '查询表格',
26
+  'menu.list.basic-list': '标准列表',
27
+  'menu.list.card-list': '卡片列表',
28
+  'menu.list.search-list': '搜索列表',
29
+  'menu.list.search-list.articles': '搜索列表(文章)',
30
+  'menu.list.search-list.projects': '搜索列表(项目)',
31
+  'menu.list.search-list.applications': '搜索列表(应用)',
32
+  'menu.profile': '详情页',
33
+  'menu.profile.basic': '基础详情页',
34
+  'menu.profile.advanced': '高级详情页',
35
+  'menu.result': '结果页',
36
+  'menu.result.success': '成功页',
37
+  'menu.result.fail': '失败页',
38
+  'menu.exception': '异常页',
39
+  'menu.exception.not-permission': '403',
40
+  'menu.exception.not-find': '404',
41
+  'menu.exception.server-error': '500',
42
+  'menu.exception.trigger': '触发错误',
43
+  'menu.account': '个人页',
44
+  'menu.account.center': '个人中心',
45
+  'menu.account.settings': '个人设置',
46
+  'menu.account.trigger': '触发报错',
47
+  'menu.account.logout': '退出登录',
48
+  'menu.editor': '图形编辑器',
49
+  'menu.editor.flow': '流程编辑器',
50
+  'menu.editor.mind': '脑图编辑器',
51
+  'menu.editor.koni': '拓扑编辑器',
52
+};

+ 6
- 0
src/locales/zh-CN/pwa.js 查看文件

@@ -0,0 +1,6 @@
1
+export default {
2
+  'app.pwa.offline': '当前处于离线状态',
3
+  'app.pwa.serviceworker.updated': '有新内容',
4
+  'app.pwa.serviceworker.updated.hint': '请点击“刷新”按钮或者手动刷新页面',
5
+  'app.pwa.serviceworker.updated.ok': '刷新',
6
+};

+ 31
- 0
src/locales/zh-CN/settingDrawer.js 查看文件

@@ -0,0 +1,31 @@
1
+export default {
2
+  'app.setting.pagestyle': '整体风格设置',
3
+  'app.setting.pagestyle.dark': '暗色菜单风格',
4
+  'app.setting.pagestyle.light': '亮色菜单风格',
5
+  'app.setting.content-width': '内容区域宽度',
6
+  'app.setting.content-width.fixed': '定宽',
7
+  'app.setting.content-width.fluid': '流式',
8
+  'app.setting.themecolor': '主题色',
9
+  'app.setting.themecolor.dust': '薄暮',
10
+  'app.setting.themecolor.volcano': '火山',
11
+  'app.setting.themecolor.sunset': '日暮',
12
+  'app.setting.themecolor.cyan': '明青',
13
+  'app.setting.themecolor.green': '极光绿',
14
+  'app.setting.themecolor.daybreak': '拂晓蓝(默认)',
15
+  'app.setting.themecolor.geekblue': '极客蓝',
16
+  'app.setting.themecolor.purple': '酱紫',
17
+  'app.setting.navigationmode': '导航模式',
18
+  'app.setting.sidemenu': '侧边菜单布局',
19
+  'app.setting.topmenu': '顶部菜单布局',
20
+  'app.setting.fixedheader': '固定 Header',
21
+  'app.setting.fixedsidebar': '固定侧边菜单',
22
+  'app.setting.fixedsidebar.hint': '侧边菜单布局时可配置',
23
+  'app.setting.hideheader': '下滑时隐藏 Header',
24
+  'app.setting.hideheader.hint': '固定 Header 时可配置',
25
+  'app.setting.othersettings': '其他设置',
26
+  'app.setting.weakmode': '色弱模式',
27
+  'app.setting.copy': '拷贝设置',
28
+  'app.setting.copyinfo': '拷贝成功,请到 src/defaultSettings.js 中替换默认配置',
29
+  'app.setting.production.hint':
30
+    '配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件',
31
+};

+ 55
- 0
src/locales/zh-CN/settings.js 查看文件

@@ -0,0 +1,55 @@
1
+export default {
2
+  'app.settings.menuMap.basic': '基本设置',
3
+  'app.settings.menuMap.security': '安全设置',
4
+  'app.settings.menuMap.binding': '账号绑定',
5
+  'app.settings.menuMap.notification': '新消息通知',
6
+  'app.settings.basic.avatar': '头像',
7
+  'app.settings.basic.change-avatar': '更换头像',
8
+  'app.settings.basic.email': '邮箱',
9
+  'app.settings.basic.email-message': '请输入您的邮箱!',
10
+  'app.settings.basic.nickname': '昵称',
11
+  'app.settings.basic.nickname-message': '请输入您的昵称!',
12
+  'app.settings.basic.profile': '个人简介',
13
+  'app.settings.basic.profile-message': '请输入个人简介!',
14
+  'app.settings.basic.profile-placeholder': '个人简介',
15
+  'app.settings.basic.country': '国家/地区',
16
+  'app.settings.basic.country-message': '请输入您的国家或地区!',
17
+  'app.settings.basic.geographic': '所在省市',
18
+  'app.settings.basic.geographic-message': '请输入您的所在省市!',
19
+  'app.settings.basic.address': '街道地址',
20
+  'app.settings.basic.address-message': '请输入您的街道地址!',
21
+  'app.settings.basic.phone': '联系电话',
22
+  'app.settings.basic.phone-message': '请输入您的联系电话!',
23
+  'app.settings.basic.update': '更新基本信息',
24
+  'app.settings.security.strong': '强',
25
+  'app.settings.security.medium': '中',
26
+  'app.settings.security.weak': '弱',
27
+  'app.settings.security.password': '账户密码',
28
+  'app.settings.security.password-description': '当前密码强度',
29
+  'app.settings.security.phone': '密保手机',
30
+  'app.settings.security.phone-description': '已绑定手机',
31
+  'app.settings.security.question': '密保问题',
32
+  'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全',
33
+  'app.settings.security.email': '备用邮箱',
34
+  'app.settings.security.email-description': '已绑定邮箱',
35
+  'app.settings.security.mfa': 'MFA 设备',
36
+  'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认',
37
+  'app.settings.security.modify': '修改',
38
+  'app.settings.security.set': '设置',
39
+  'app.settings.security.bind': '绑定',
40
+  'app.settings.binding.taobao': '绑定淘宝',
41
+  'app.settings.binding.taobao-description': '当前未绑定淘宝账号',
42
+  'app.settings.binding.alipay': '绑定支付宝',
43
+  'app.settings.binding.alipay-description': '当前未绑定支付宝账号',
44
+  'app.settings.binding.dingding': '绑定钉钉',
45
+  'app.settings.binding.dingding-description': '当前未绑定钉钉账号',
46
+  'app.settings.binding.bind': '绑定',
47
+  'app.settings.notification.password': '账户密码',
48
+  'app.settings.notification.password-description': '其他用户的消息将以站内信的形式通知',
49
+  'app.settings.notification.messages': '系统消息',
50
+  'app.settings.notification.messages-description': '系统消息将以站内信的形式通知',
51
+  'app.settings.notification.todo': '待办任务',
52
+  'app.settings.notification.todo-description': '待办任务将以站内信的形式通知',
53
+  'app.settings.open': '开',
54
+  'app.settings.close': '关',
55
+};

+ 19
- 0
src/locales/zh-TW.js 查看文件

@@ -0,0 +1,19 @@
1
+import component from './zh-TW/component';
2
+import globalHeader from './zh-TW/globalHeader';
3
+import menu from './zh-TW/menu';
4
+import pwa from './zh-TW/pwa';
5
+import settingDrawer from './zh-TW/settingDrawer';
6
+import settings from './zh-TW/settings';
7
+export default {
8
+  'navBar.lang': '語言',
9
+  'layout.user.link.help': '幫助',
10
+  'layout.user.link.privacy': '隱私',
11
+  'layout.user.link.terms': '條款',
12
+  'app.preview.down.block': '下載此頁面到本地項目',
13
+  ...globalHeader,
14
+  ...menu,
15
+  ...settingDrawer,
16
+  ...settings,
17
+  ...pwa,
18
+  ...component,
19
+};

+ 5
- 0
src/locales/zh-TW/component.js 查看文件

@@ -0,0 +1,5 @@
1
+export default {
2
+  'component.tagSelect.expand': '展開',
3
+  'component.tagSelect.collapse': '收起',
4
+  'component.tagSelect.all': '全部',
5
+};

+ 17
- 0
src/locales/zh-TW/globalHeader.js 查看文件

@@ -0,0 +1,17 @@
1
+export default {
2
+  'component.globalHeader.search': '站內搜索',
3
+  'component.globalHeader.search.example1': '搜索提示壹',
4
+  'component.globalHeader.search.example2': '搜索提示二',
5
+  'component.globalHeader.search.example3': '搜索提示三',
6
+  'component.globalHeader.help': '使用手冊',
7
+  'component.globalHeader.notification': '通知',
8
+  'component.globalHeader.notification.empty': '妳已查看所有通知',
9
+  'component.globalHeader.message': '消息',
10
+  'component.globalHeader.message.empty': '您已讀完所有消息',
11
+  'component.globalHeader.event': '待辦',
12
+  'component.globalHeader.event.empty': '妳已完成所有待辦',
13
+  'component.noticeIcon.clear': '清空',
14
+  'component.noticeIcon.cleared': '清空了',
15
+  'component.noticeIcon.empty': '暫無資料',
16
+  'component.noticeIcon.view-more': '查看更多',
17
+};

+ 52
- 0
src/locales/zh-TW/menu.js 查看文件

@@ -0,0 +1,52 @@
1
+export default {
2
+  'menu.welcome': '歡迎',
3
+  'menu.more-blocks': '更多區塊',
4
+  'menu.home': '首頁',
5
+  'menu.login': '登錄',
6
+  'menu.admin': '权限',
7
+  'menu.admin.sub-page': '二级管理页',
8
+  'menu.exception.403': '403',
9
+  'menu.exception.404': '404',
10
+  'menu.exception.500': '500',
11
+  'menu.register': '註冊',
12
+  'menu.register.result': '註冊結果',
13
+  'menu.dashboard': 'Dashboard',
14
+  'menu.dashboard.analysis': '分析頁',
15
+  'menu.dashboard.monitor': '監控頁',
16
+  'menu.dashboard.workplace': '工作臺',
17
+  'menu.form': '表單頁',
18
+  'menu.form.basic-form': '基礎表單',
19
+  'menu.form.step-form': '分步表單',
20
+  'menu.form.step-form.info': '分步表單(填寫轉賬信息)',
21
+  'menu.form.step-form.confirm': '分步表單(確認轉賬信息)',
22
+  'menu.form.step-form.result': '分步表單(完成)',
23
+  'menu.form.advanced-form': '高級表單',
24
+  'menu.list': '列表頁',
25
+  'menu.list.table-list': '查詢表格',
26
+  'menu.list.basic-list': '標淮列表',
27
+  'menu.list.card-list': '卡片列表',
28
+  'menu.list.search-list': '搜索列表',
29
+  'menu.list.search-list.articles': '搜索列表(文章)',
30
+  'menu.list.search-list.projects': '搜索列表(項目)',
31
+  'menu.list.search-list.applications': '搜索列表(應用)',
32
+  'menu.profile': '詳情頁',
33
+  'menu.profile.basic': '基礎詳情頁',
34
+  'menu.profile.advanced': '高級詳情頁',
35
+  'menu.result': '結果頁',
36
+  'menu.result.success': '成功頁',
37
+  'menu.result.fail': '失敗頁',
38
+  'menu.account': '個人頁',
39
+  'menu.account.center': '個人中心',
40
+  'menu.account.settings': '個人設置',
41
+  'menu.account.trigger': '觸發報錯',
42
+  'menu.account.logout': '退出登錄',
43
+  'menu.exception': '异常页',
44
+  'menu.exception.not-permission': '403',
45
+  'menu.exception.not-find': '404',
46
+  'menu.exception.server-error': '500',
47
+  'menu.exception.trigger': '触发错误',
48
+  'menu.editor': '圖形編輯器',
49
+  'menu.editor.flow': '流程編輯器',
50
+  'menu.editor.mind': '腦圖編輯器',
51
+  'menu.editor.koni': '拓撲編輯器',
52
+};

+ 6
- 0
src/locales/zh-TW/pwa.js 查看文件

@@ -0,0 +1,6 @@
1
+export default {
2
+  'app.pwa.offline': '當前處於離線狀態',
3
+  'app.pwa.serviceworker.updated': '有新內容',
4
+  'app.pwa.serviceworker.updated.hint': '請點擊“刷新”按鈕或者手動刷新頁面',
5
+  'app.pwa.serviceworker.updated.ok': '刷新',
6
+};

+ 31
- 0
src/locales/zh-TW/settingDrawer.js 查看文件

@@ -0,0 +1,31 @@
1
+export default {
2
+  'app.setting.pagestyle': '整體風格設置',
3
+  'app.setting.pagestyle.dark': '暗色菜單風格',
4
+  'app.setting.pagestyle.light': '亮色菜單風格',
5
+  'app.setting.content-width': '內容區域寬度',
6
+  'app.setting.content-width.fixed': '定寬',
7
+  'app.setting.content-width.fluid': '流式',
8
+  'app.setting.themecolor': '主題色',
9
+  'app.setting.themecolor.dust': '薄暮',
10
+  'app.setting.themecolor.volcano': '火山',
11
+  'app.setting.themecolor.sunset': '日暮',
12
+  'app.setting.themecolor.cyan': '明青',
13
+  'app.setting.themecolor.green': '極光綠',
14
+  'app.setting.themecolor.daybreak': '拂曉藍(默認)',
15
+  'app.setting.themecolor.geekblue': '極客藍',
16
+  'app.setting.themecolor.purple': '醬紫',
17
+  'app.setting.navigationmode': '導航模式',
18
+  'app.setting.sidemenu': '側邊菜單布局',
19
+  'app.setting.topmenu': '頂部菜單布局',
20
+  'app.setting.fixedheader': '固定 Header',
21
+  'app.setting.fixedsidebar': '固定側邊菜單',
22
+  'app.setting.fixedsidebar.hint': '側邊菜單布局時可配置',
23
+  'app.setting.hideheader': '下滑時隱藏 Header',
24
+  'app.setting.hideheader.hint': '固定 Header 時可配置',
25
+  'app.setting.othersettings': '其他設置',
26
+  'app.setting.weakmode': '色弱模式',
27
+  'app.setting.copy': '拷貝設置',
28
+  'app.setting.copyinfo': '拷貝成功,請到 src/defaultSettings.js 中替換默認配置',
29
+  'app.setting.production.hint':
30
+    '配置欄只在開發環境用於預覽,生產環境不會展現,請拷貝後手動修改配置文件',
31
+};

+ 55
- 0
src/locales/zh-TW/settings.js 查看文件

@@ -0,0 +1,55 @@
1
+export default {
2
+  'app.settings.menuMap.basic': '基本設置',
3
+  'app.settings.menuMap.security': '安全設置',
4
+  'app.settings.menuMap.binding': '賬號綁定',
5
+  'app.settings.menuMap.notification': '新消息通知',
6
+  'app.settings.basic.avatar': '頭像',
7
+  'app.settings.basic.change-avatar': '更換頭像',
8
+  'app.settings.basic.email': '郵箱',
9
+  'app.settings.basic.email-message': '請輸入您的郵箱!',
10
+  'app.settings.basic.nickname': '昵稱',
11
+  'app.settings.basic.nickname-message': '請輸入您的昵稱!',
12
+  'app.settings.basic.profile': '個人簡介',
13
+  'app.settings.basic.profile-message': '請輸入個人簡介!',
14
+  'app.settings.basic.profile-placeholder': '個人簡介',
15
+  'app.settings.basic.country': '國家/地區',
16
+  'app.settings.basic.country-message': '請輸入您的國家或地區!',
17
+  'app.settings.basic.geographic': '所在省市',
18
+  'app.settings.basic.geographic-message': '請輸入您的所在省市!',
19
+  'app.settings.basic.address': '街道地址',
20
+  'app.settings.basic.address-message': '請輸入您的街道地址!',
21
+  'app.settings.basic.phone': '聯系電話',
22
+  'app.settings.basic.phone-message': '請輸入您的聯系電話!',
23
+  'app.settings.basic.update': '更新基本信息',
24
+  'app.settings.security.strong': '強',
25
+  'app.settings.security.medium': '中',
26
+  'app.settings.security.weak': '弱',
27
+  'app.settings.security.password': '賬戶密碼',
28
+  'app.settings.security.password-description': '當前密碼強度',
29
+  'app.settings.security.phone': '密保手機',
30
+  'app.settings.security.phone-description': '已綁定手機',
31
+  'app.settings.security.question': '密保問題',
32
+  'app.settings.security.question-description': '未設置密保問題,密保問題可有效保護賬戶安全',
33
+  'app.settings.security.email': '備用郵箱',
34
+  'app.settings.security.email-description': '已綁定郵箱',
35
+  'app.settings.security.mfa': 'MFA 設備',
36
+  'app.settings.security.mfa-description': '未綁定 MFA 設備,綁定後,可以進行二次確認',
37
+  'app.settings.security.modify': '修改',
38
+  'app.settings.security.set': '設置',
39
+  'app.settings.security.bind': '綁定',
40
+  'app.settings.binding.taobao': '綁定淘寶',
41
+  'app.settings.binding.taobao-description': '當前未綁定淘寶賬號',
42
+  'app.settings.binding.alipay': '綁定支付寶',
43
+  'app.settings.binding.alipay-description': '當前未綁定支付寶賬號',
44
+  'app.settings.binding.dingding': '綁定釘釘',
45
+  'app.settings.binding.dingding-description': '當前未綁定釘釘賬號',
46
+  'app.settings.binding.bind': '綁定',
47
+  'app.settings.notification.password': '賬戶密碼',
48
+  'app.settings.notification.password-description': '其他用戶的消息將以站內信的形式通知',
49
+  'app.settings.notification.messages': '系統消息',
50
+  'app.settings.notification.messages-description': '系統消息將以站內信的形式通知',
51
+  'app.settings.notification.todo': '待辦任務',
52
+  'app.settings.notification.todo-description': '待辦任務將以站內信的形式通知',
53
+  'app.settings.open': '開',
54
+  'app.settings.close': '關',
55
+};

+ 22
- 0
src/manifest.json 查看文件

@@ -0,0 +1,22 @@
1
+{
2
+  "name": "Ant Design Pro",
3
+  "short_name": "Ant Design Pro",
4
+  "display": "standalone",
5
+  "start_url": "./?utm_source=homescreen",
6
+  "theme_color": "#002140",
7
+  "background_color": "#001529",
8
+  "icons": [
9
+    {
10
+      "src": "icons/icon-192x192.png",
11
+      "sizes": "192x192"
12
+    },
13
+    {
14
+      "src": "icons/icon-128x128.png",
15
+      "sizes": "128x128"
16
+    },
17
+    {
18
+      "src": "icons/icon-512x512.png",
19
+      "sizes": "512x512"
20
+    }
21
+  ]
22
+}

+ 22
- 0
src/models/building.js 查看文件

@@ -0,0 +1,22 @@
1
+import { getList } from '@/services/building';
2
+
3
+const buildingModel = {
4
+  namespaced: 'building',
5
+  state: {
6
+
7
+  },
8
+  effect: {
9
+    *fetch(_, { call, put }) {
10
+      const response = yield call(getList);
11
+      yield put({
12
+        type: 'get',
13
+        payload: response,
14
+      });
15
+    },
16
+  },
17
+  reducers: {
18
+
19
+  },
20
+}
21
+
22
+export default buildingModel

+ 114
- 0
src/models/global.js 查看文件

@@ -0,0 +1,114 @@
1
+import { queryNotices } from '@/services/user';
2
+const GlobalModel = {
3
+  namespace: 'global',
4
+  state: {
5
+    collapsed: false,
6
+    notices: [],
7
+  },
8
+  effects: {
9
+    *fetchNotices(_, { call, put, select }) {
10
+      const data = yield call(queryNotices);
11
+      yield put({
12
+        type: 'saveNotices',
13
+        payload: data,
14
+      });
15
+      const unreadCount = yield select(
16
+        (state) => state.global.notices.filter((item) => !item.read).length,
17
+      );
18
+      yield put({
19
+        type: 'user/changeNotifyCount',
20
+        payload: {
21
+          totalCount: data.length,
22
+          unreadCount,
23
+        },
24
+      });
25
+    },
26
+
27
+    *clearNotices({ payload }, { put, select }) {
28
+      yield put({
29
+        type: 'saveClearedNotices',
30
+        payload,
31
+      });
32
+      const count = yield select((state) => state.global.notices.length);
33
+      const unreadCount = yield select(
34
+        (state) => state.global.notices.filter((item) => !item.read).length,
35
+      );
36
+      yield put({
37
+        type: 'user/changeNotifyCount',
38
+        payload: {
39
+          totalCount: count,
40
+          unreadCount,
41
+        },
42
+      });
43
+    },
44
+
45
+    *changeNoticeReadState({ payload }, { put, select }) {
46
+      const notices = yield select((state) =>
47
+        state.global.notices.map((item) => {
48
+          const notice = { ...item };
49
+
50
+          if (notice.id === payload) {
51
+            notice.read = true;
52
+          }
53
+
54
+          return notice;
55
+        }),
56
+      );
57
+      yield put({
58
+        type: 'saveNotices',
59
+        payload: notices,
60
+      });
61
+      yield put({
62
+        type: 'user/changeNotifyCount',
63
+        payload: {
64
+          totalCount: notices.length,
65
+          unreadCount: notices.filter((item) => !item.read).length,
66
+        },
67
+      });
68
+    },
69
+  },
70
+  reducers: {
71
+    changeLayoutCollapsed(
72
+      state = {
73
+        notices: [],
74
+        collapsed: true,
75
+      },
76
+      { payload },
77
+    ) {
78
+      return { ...state, collapsed: payload };
79
+    },
80
+
81
+    saveNotices(state, { payload }) {
82
+      return {
83
+        collapsed: false,
84
+        ...state,
85
+        notices: payload,
86
+      };
87
+    },
88
+
89
+    saveClearedNotices(
90
+      state = {
91
+        notices: [],
92
+        collapsed: true,
93
+      },
94
+      { payload },
95
+    ) {
96
+      return {
97
+        collapsed: false,
98
+        ...state,
99
+        notices: state.notices.filter((item) => item.type !== payload),
100
+      };
101
+    },
102
+  },
103
+  subscriptions: {
104
+    setup({ history }) {
105
+      // Subscribe history(url) change, trigger `load` action if pathname is `/`
106
+      history.listen(({ pathname, search }) => {
107
+        if (typeof window.ga !== 'undefined') {
108
+          window.ga('send', 'pageview', pathname + search);
109
+        }
110
+      });
111
+    },
112
+  },
113
+};
114
+export default GlobalModel;

+ 73
- 0
src/models/login.js 查看文件

@@ -0,0 +1,73 @@
1
+import { routerRedux } from 'dva/router';
2
+import { stringify } from 'querystring';
3
+// import { fakeAccountLogin, getFakeCaptcha } from '@/services/login';
4
+// import { setAuthority } from '@/utils/authority';
5
+import { getPageQuery } from '@/utils/utils';
6
+import { fetch, apis } from '@/utils/request';
7
+
8
+const signin = fetch(apis.user.signin);
9
+const signout = fetch(apis.user.signout);
10
+
11
+const Model = {
12
+  namespace: 'login',
13
+  state: {
14
+    status: undefined,
15
+  },
16
+  effects: {
17
+    *login({ payload }, { call, put }) {
18
+      const response = yield call(signin, { data: payload });
19
+      yield put({
20
+        type: 'changeLoginStatus',
21
+        payload: response,
22
+      }); // Login successfully
23
+
24
+      window.localStorage.setItem('showSwiperIndex', 1)
25
+
26
+      const urlParams = new URL(window.location.href);
27
+      const params = getPageQuery();
28
+      let { redirect } = params;
29
+
30
+      if (redirect) {
31
+        const redirectUrlParams = new URL(redirect);
32
+
33
+        if (redirectUrlParams.origin === urlParams.origin) {
34
+          redirect = redirect.substr(urlParams.origin.length);
35
+
36
+          if (redirect.match(/^\/.*#/)) {
37
+            redirect = redirect.substr(redirect.indexOf('#') + 1);
38
+          }
39
+        } else {
40
+          window.location.href = redirect;
41
+          return;
42
+        }
43
+      }
44
+
45
+      // yield put(routerRedux.replace(redirect || '/'));
46
+      yield put(routerRedux.replace('/'));
47
+    },
48
+
49
+    *logout(_, { put, call }) {
50
+      const { redirect } = getPageQuery(); // redirect
51
+
52
+      yield call(signout);
53
+
54
+      if (window.location.pathname !== '/user/login' && !redirect) {
55
+        yield put(
56
+          routerRedux.replace({
57
+            pathname: '/user/login',
58
+            search: stringify({
59
+              redirect: window.location.href,
60
+            }),
61
+          }),
62
+        );
63
+      }
64
+    },
65
+  },
66
+  reducers: {
67
+    changeLoginStatus(state, { payload }) {
68
+      // setAuthority((payload.user.roles || []).map(x => x.roleId));
69
+      return { ...state, status: 'ok', type: payload.type };
70
+    },
71
+  },
72
+};
73
+export default Model;

+ 27
- 0
src/models/setting.js 查看文件

@@ -0,0 +1,27 @@
1
+import defaultSettings from '../../config/defaultSettings';
2
+
3
+const updateColorWeak = (colorWeak) => {
4
+  const root = document.getElementById('root');
5
+
6
+  if (root) {
7
+    root.className = colorWeak ? 'colorWeak' : '';
8
+  }
9
+};
10
+
11
+const SettingModel = {
12
+  namespace: 'settings',
13
+  state: defaultSettings,
14
+  reducers: {
15
+    changeSetting(state = defaultSettings, { payload }) {
16
+      const { colorWeak, contentWidth } = payload;
17
+
18
+      if (state.contentWidth !== contentWidth && window.dispatchEvent) {
19
+        window.dispatchEvent(new Event('resize'));
20
+      }
21
+
22
+      updateColorWeak(!!colorWeak);
23
+      return { ...state, ...payload };
24
+    },
25
+  },
26
+};
27
+export default SettingModel;

+ 50
- 0
src/models/user.js 查看文件

@@ -0,0 +1,50 @@
1
+import { fetch, apis } from '@/utils/request';
2
+// import { setAllBtnAuth, setUserBtnAuth } from '@/components/AuthButton';
3
+
4
+const getCurrentUser = fetch(apis.user.current)
5
+
6
+const UserModel = {
7
+  namespace: 'user',
8
+  state: {
9
+    currentUser: {},
10
+    menuList: [],
11
+    buttonList: [],
12
+  },
13
+  effects: {
14
+    *fetchCurrent(_, { call, put }) {
15
+      const response = yield call(getCurrentUser);
16
+
17
+      yield put({
18
+        type: 'saveCurrentUser',
19
+        payload: response,
20
+      });
21
+    },
22
+  },
23
+  reducers: {
24
+    saveCurrentUser(state, { payload }) {
25
+      const { taUser = {} , menuList = [], buttonList = [] } = payload || {}
26
+      const currentUser = { ...taUser, roles: (taUser.roles || []).map(x => x.roleId) }
27
+
28
+      // setAllBtnAuth(buttonList)
29
+      // setUserBtnAuth(currentUser.buttons)
30
+
31
+      return { ...state, currentUser, menuList, buttonList };
32
+    },
33
+    changeNotifyCount(
34
+      state = {
35
+        currentUser: {},
36
+      },
37
+      action,
38
+    ) {
39
+      return {
40
+        ...state,
41
+        currentUser: {
42
+          ...state.currentUser,
43
+          notifyCount: action.payload.totalCount,
44
+          unreadCount: action.payload.unreadCount,
45
+        },
46
+      };
47
+    },
48
+  },
49
+};
50
+export default UserModel;

+ 19
- 0
src/pages/404.jsx 查看文件

@@ -0,0 +1,19 @@
1
+import { Button, Result } from 'antd';
2
+import React from 'react';
3
+import { router } from 'umi'; // 这里应该使用 antd 的 404 result 组件,
4
+// 但是还没发布,先来个简单的。
5
+
6
+const NoFoundPage = () => (
7
+  <Result
8
+    status={404}
9
+    title="404"
10
+    subTitle="Sorry, the page you visited does not exist."
11
+    extra={
12
+      <Button type="primary" onClick={() => router.push('/')}>
13
+        Back Home
14
+      </Button>
15
+    }
16
+  />
17
+);
18
+
19
+export default NoFoundPage;

+ 40
- 0
src/pages/Admin.jsx 查看文件

@@ -0,0 +1,40 @@
1
+import React from 'react';
2
+import { Card, Typography, Alert, Icon } from 'antd';
3
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
+export default () => (
5
+  <PageHeaderWrapper content=" 这个页面只有 admin 权限才能查看">
6
+    <Card>
7
+      <Alert
8
+        message="umi ui 现已发布,欢迎使用 npm run ui 启动体验。"
9
+        type="success"
10
+        showIcon
11
+        banner
12
+        style={{
13
+          margin: -12,
14
+          marginBottom: 48,
15
+        }}
16
+      />
17
+      <Typography.Title
18
+        level={2}
19
+        style={{
20
+          textAlign: 'center',
21
+        }}
22
+      >
23
+        <Icon type="smile" theme="twoTone" /> Ant Design Pro{' '}
24
+        <Icon type="heart" theme="twoTone" twoToneColor="#eb2f96" /> You
25
+      </Typography.Title>
26
+    </Card>
27
+    <p
28
+      style={{
29
+        textAlign: 'center',
30
+        marginTop: 24,
31
+      }}
32
+    >
33
+      Want to add more pages? Please refer to{' '}
34
+      <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
35
+        use block
36
+      </a>
37
+      。
38
+    </p>
39
+  </PageHeaderWrapper>
40
+);

+ 32
- 0
src/pages/Authorized.jsx 查看文件

@@ -0,0 +1,32 @@
1
+import React from 'react';
2
+import { Redirect } from 'umi';
3
+import { connect } from 'dva';
4
+import Authorized from '@/utils/Authorized';
5
+import { getRouteAuthority } from '@/utils/utils';
6
+
7
+const AuthComponent = ({
8
+  children,
9
+  route = {
10
+    routes: [],
11
+  },
12
+  location = {
13
+    pathname: '',
14
+  },
15
+  user,
16
+}) => {
17
+  const { currentUser } = user;
18
+  const { routes = [] } = route;
19
+  const isLogin = currentUser && currentUser.name;
20
+  return (
21
+    <Authorized
22
+      authority={getRouteAuthority(location.pathname, routes) || ''}
23
+      noMatch={isLogin ? <Redirect to="/exception/403" /> : <Redirect to="/user/login" />}
24
+    >
25
+      {children}
26
+    </Authorized>
27
+  );
28
+};
29
+
30
+export default connect(({ user }) => ({
31
+  user,
32
+}))(AuthComponent);

+ 66
- 0
src/pages/Welcome.jsx 查看文件

@@ -0,0 +1,66 @@
1
+import React from 'react';
2
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import { Card, Typography, Alert } from 'antd';
5
+import styles from './Welcome.less';
6
+
7
+const CodePreview = ({ children }) => (
8
+  <pre className={styles.pre}>
9
+    <code>
10
+      <Typography.Text copyable>{children}</Typography.Text>
11
+    </code>
12
+  </pre>
13
+);
14
+
15
+export default () => (
16
+  <PageHeaderWrapper>
17
+    <Card>
18
+      <Alert
19
+        message="umi ui 现已发布,点击右下角 umi 图标即可使用"
20
+        type="success"
21
+        showIcon
22
+        banner
23
+        style={{
24
+          margin: -12,
25
+          marginBottom: 24,
26
+        }}
27
+      />
28
+      <Typography.Text strong>
29
+        <a target="_blank" rel="noopener noreferrer" href="https://pro.ant.design/docs/block">
30
+          <FormattedMessage
31
+            id="app.welcome.link.block-list"
32
+            defaultMessage="基于 block 开发,快速构建标准页面"
33
+          />
34
+        </a>
35
+      </Typography.Text>
36
+      <CodePreview> npm run ui</CodePreview>
37
+      <Typography.Text
38
+        strong
39
+        style={{
40
+          marginBottom: 12,
41
+        }}
42
+      >
43
+        <a
44
+          target="_blank"
45
+          rel="noopener noreferrer"
46
+          href="https://pro.ant.design/docs/available-script#npm-run-fetchblocks"
47
+        >
48
+          <FormattedMessage id="app.welcome.link.fetch-blocks" defaultMessage="获取全部区块" />
49
+        </a>
50
+      </Typography.Text>
51
+      <CodePreview> npm run fetch:blocks</CodePreview>
52
+    </Card>
53
+    <p
54
+      style={{
55
+        textAlign: 'center',
56
+        marginTop: 24,
57
+      }}
58
+    >
59
+      Want to add more pages? Please refer to{' '}
60
+      <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
61
+        use block
62
+      </a>
63
+      。
64
+    </p>
65
+  </PageHeaderWrapper>
66
+);

+ 8
- 0
src/pages/Welcome.less 查看文件

@@ -0,0 +1,8 @@
1
+@import '~antd/lib/style/themes/default.less';
2
+
3
+.pre {
4
+  margin: 12px 0;
5
+  padding: 12px 20px;
6
+  background: @input-bg;
7
+  box-shadow: @card-shadow;
8
+}

+ 193
- 0
src/pages/document.ejs 查看文件

@@ -0,0 +1,193 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+  <head>
4
+    <meta charset="UTF-8" />
5
+    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+    <meta
7
+      name="viewport"
8
+      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
9
+    />
10
+    <title>Ant Design Pro</title>
11
+    <link rel="icon" href="/favicon.png" type="image/x-icon" />
12
+  </head>
13
+  <body>
14
+    <noscript>Out-of-the-box mid-stage front/design solution!</noscript>
15
+    <div id="root">
16
+      <style>
17
+        html,
18
+        body,
19
+        #root {
20
+          height: 100%;
21
+          margin: 0;
22
+          padding: 0;
23
+        }
24
+        #root {
25
+          background-image: url('/home_bg.png');
26
+          background-repeat: no-repeat;
27
+          background-size: 100% auto;
28
+        }
29
+        .page-loading-warp {
30
+          padding: 98px;
31
+          display: flex;
32
+          justify-content: center;
33
+          align-items: center;
34
+        }
35
+        .ant-spin {
36
+          -webkit-box-sizing: border-box;
37
+          box-sizing: border-box;
38
+          margin: 0;
39
+          padding: 0;
40
+          color: rgba(0, 0, 0, 0.65);
41
+          font-size: 14px;
42
+          font-variant: tabular-nums;
43
+          line-height: 1.5;
44
+          list-style: none;
45
+          -webkit-font-feature-settings: 'tnum';
46
+          font-feature-settings: 'tnum';
47
+          position: absolute;
48
+          display: none;
49
+          color: #1890ff;
50
+          text-align: center;
51
+          vertical-align: middle;
52
+          opacity: 0;
53
+          -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
54
+          transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
55
+          transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
56
+          transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
57
+            -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
58
+        }
59
+
60
+        .ant-spin-spinning {
61
+          position: static;
62
+          display: inline-block;
63
+          opacity: 1;
64
+        }
65
+
66
+        .ant-spin-dot {
67
+          position: relative;
68
+          display: inline-block;
69
+          font-size: 20px;
70
+          width: 20px;
71
+          height: 20px;
72
+        }
73
+
74
+        .ant-spin-dot-item {
75
+          position: absolute;
76
+          display: block;
77
+          width: 9px;
78
+          height: 9px;
79
+          background-color: #1890ff;
80
+          border-radius: 100%;
81
+          -webkit-transform: scale(0.75);
82
+          -ms-transform: scale(0.75);
83
+          transform: scale(0.75);
84
+          -webkit-transform-origin: 50% 50%;
85
+          -ms-transform-origin: 50% 50%;
86
+          transform-origin: 50% 50%;
87
+          opacity: 0.3;
88
+          -webkit-animation: antSpinMove 1s infinite linear alternate;
89
+          animation: antSpinMove 1s infinite linear alternate;
90
+        }
91
+
92
+        .ant-spin-dot-item:nth-child(1) {
93
+          top: 0;
94
+          left: 0;
95
+        }
96
+
97
+        .ant-spin-dot-item:nth-child(2) {
98
+          top: 0;
99
+          right: 0;
100
+          -webkit-animation-delay: 0.4s;
101
+          animation-delay: 0.4s;
102
+        }
103
+
104
+        .ant-spin-dot-item:nth-child(3) {
105
+          right: 0;
106
+          bottom: 0;
107
+          -webkit-animation-delay: 0.8s;
108
+          animation-delay: 0.8s;
109
+        }
110
+
111
+        .ant-spin-dot-item:nth-child(4) {
112
+          bottom: 0;
113
+          left: 0;
114
+          -webkit-animation-delay: 1.2s;
115
+          animation-delay: 1.2s;
116
+        }
117
+
118
+        .ant-spin-dot-spin {
119
+          -webkit-transform: rotate(45deg);
120
+          -ms-transform: rotate(45deg);
121
+          transform: rotate(45deg);
122
+          -webkit-animation: antRotate 1.2s infinite linear;
123
+          animation: antRotate 1.2s infinite linear;
124
+        }
125
+
126
+        .ant-spin-lg .ant-spin-dot {
127
+          font-size: 32px;
128
+          width: 32px;
129
+          height: 32px;
130
+        }
131
+
132
+        .ant-spin-lg .ant-spin-dot i {
133
+          width: 14px;
134
+          height: 14px;
135
+        }
136
+
137
+        @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
138
+          .ant-spin-blur {
139
+            background: #fff;
140
+            opacity: 0.5;
141
+          }
142
+        }
143
+
144
+        @-webkit-keyframes antSpinMove {
145
+          to {
146
+            opacity: 1;
147
+          }
148
+        }
149
+
150
+        @keyframes antSpinMove {
151
+          to {
152
+            opacity: 1;
153
+          }
154
+        }
155
+
156
+        @-webkit-keyframes antRotate {
157
+          to {
158
+            -webkit-transform: rotate(405deg);
159
+            transform: rotate(405deg);
160
+          }
161
+        }
162
+
163
+        @keyframes antRotate {
164
+          to {
165
+            -webkit-transform: rotate(405deg);
166
+            transform: rotate(405deg);
167
+          }
168
+        }
169
+      </style>
170
+      <div
171
+        style="display: flex;justify-content: center;align-items: center;flex-direction: column;min-height: 420px;height: 100%;"
172
+      >
173
+        <img src="/pro_icon.svg" alt="logo" width="256" />
174
+        <div class="page-loading-warp">
175
+          <div class="ant-spin ant-spin-lg ant-spin-spinning">
176
+            <span class="ant-spin-dot ant-spin-dot-spin"
177
+              ><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i
178
+              ><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i
179
+            ></span>
180
+          </div>
181
+        </div>
182
+        <div style="display: flex;justify-content: center;align-items: center;">
183
+          <img
184
+            src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
185
+            width="32"
186
+            style="margin-right: 8px;"
187
+          />
188
+          Ant Design
189
+        </div>
190
+      </div>
191
+    </div>
192
+  </body>
193
+</html>

+ 0
- 0
src/pages/user/login/components/Login/LoginContext.jsx 查看文件


部分文件因为文件数量过多而无法显示