andrew il y a 4 ans
Parent
révision
d5d2cec9c2
16 fichiers modifiés avec 1592 ajouts et 0 suppressions
  1. 16
    0
      .editorconfig
  2. 3
    0
      .eslintignore
  3. 10
    0
      .eslintrc.js
  4. 1
    0
      .npmrc
  5. 19
    0
      .prettierignore
  6. 5
    0
      .prettierrc.js
  7. 5
    0
      .stylelintrc.js
  8. 153
    0
      config/config.js
  9. 17
    0
      config/defaultSettings.js
  10. 112
    0
      config/plugin.config.js
  11. 1057
    0
      config/routes.js
  12. 12
    0
      jest-puppeteer.config.js
  13. 7
    0
      jest.config.js
  14. 10
    0
      jsconfig.json
  15. 131
    0
      package.json
  16. 34
    0
      tsconfig.json

+ 16
- 0
.editorconfig Voir le fichier

@@ -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

+ 3
- 0
.eslintignore Voir le fichier

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

+ 10
- 0
.eslintrc.js Voir le fichier

@@ -0,0 +1,10 @@
1
+const { strictEslint } = require('@umijs/fabric');
2
+
3
+module.exports = {
4
+  ...strictEslint,
5
+  globals: {
6
+    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
7
+    page: true,
8
+    AMap: true,
9
+  },
10
+};

+ 1
- 0
.npmrc Voir le fichier

@@ -0,0 +1 @@
1
+registry=https://registry.npm.taobao.org

+ 19
- 0
.prettierignore Voir le fichier

@@ -0,0 +1,19 @@
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

+ 5
- 0
.prettierrc.js Voir le fichier

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

+ 5
- 0
.stylelintrc.js Voir le fichier

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

+ 153
- 0
config/config.js Voir le fichier

@@ -0,0 +1,153 @@
1
+import defaultSettings from './defaultSettings'; // https://umijs.org/config/
2
+
3
+import slash from 'slash2';
4
+import webpackPlugin from './plugin.config';
5
+import routes from './routes';
6
+import proxy from './proxy';
7
+
8
+const path = require('path');
9
+
10
+const { pwa, primaryColor } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
11
+// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
12
+
13
+const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
14
+const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
15
+const plugins = [
16
+  [
17
+    'umi-plugin-react',
18
+    {
19
+      antd: true,
20
+      dva: {
21
+        hmr: true,
22
+      },
23
+      locale: {
24
+        // default false
25
+        enable: true,
26
+        // default zh-CN
27
+        default: 'zh-CN',
28
+        // default true, when it is true, will use `navigator.language` overwrite default
29
+        baseNavigator: true,
30
+      },
31
+      dynamicImport: {
32
+        loadingComponent: './components/PageLoading/index',
33
+        webpackChunkName: true,
34
+        level: 3,
35
+      },
36
+      pwa: pwa
37
+        ? {
38
+          workboxPluginMode: 'InjectManifest',
39
+          workboxOptions: {
40
+            importWorkboxFrom: 'local',
41
+          },
42
+        }
43
+        : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
44
+      // dll features https://webpack.js.org/plugins/dll-plugin/
45
+      // dll: {
46
+      //   include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
47
+      //   exclude: ['@babel/runtime', 'netlify-lambda'],
48
+      // },
49
+    },
50
+  ],
51
+  [
52
+    'umi-plugin-pro-block',
53
+    {
54
+      moveMock: false,
55
+      moveService: false,
56
+      modifyRequest: true,
57
+      autoAddMenu: true,
58
+    },
59
+  ],
60
+]; // 针对 preview.pro.ant.design 的 GA 统计代码
61
+
62
+if (isAntDesignProPreview) {
63
+  plugins.push([
64
+    'umi-plugin-ga',
65
+    {
66
+      code: 'UA-72788897-6',
67
+    },
68
+  ]);
69
+  plugins.push([
70
+    'umi-plugin-pro',
71
+    {
72
+      serverUrl: 'https://ant-design-pro.netlify.com',
73
+    },
74
+  ]);
75
+}
76
+
77
+export default {
78
+  plugins,
79
+  block: {
80
+    // 国内用户可以使用码云
81
+    // defaultGitUrl: 'https://gitee.com/ant-design/pro-blocks',
82
+    defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
83
+  },
84
+  hash: true,
85
+  targets: {
86
+    ie: 11,
87
+  },
88
+  publicPath: './',
89
+    // process.env.PROD_ENV == 1 ? 'https://estateagents.oss-accelerate.aliyuncs.com/zhiyun/admin/' : './',
90
+  // publicPath: 'https://njcjweb.oss-accelerate.aliyuncs.com/admin/',
91
+  history: 'hash',
92
+  devtool: isAntDesignProPreview ? 'source-map' : false,
93
+  // umi routes: https://umijs.org/zh/guide/router.html
94
+  routes,
95
+  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
96
+  theme: {
97
+    'primary-color': primaryColor,
98
+    'btn-primary-bg': '#EF273A',
99
+    'table-row-hover-bg': '#eee',
100
+    'btn-danger-bg': '#FF7E48',
101
+    'radio-button-hover-color': '#FF7E48',
102
+    'radio-button-active-color': 'red',
103
+    'checkbox-color': '#EF273A',
104
+    // 'checkbox-check-color': '#EF273A',
105
+    'checkbox-check-bg': '#EF273A',
106
+    // @checkbox-check-bg: @checkbox-check-color;
107
+    'primary-1': '#eee'
108
+  },
109
+  define: {
110
+    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
111
+      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 专用环境变量,请不要在你的项目中使用它。
112
+  },
113
+  ignoreMomentLocale: true,
114
+  lessLoaderOptions: {
115
+    javascriptEnabled: true,
116
+  },
117
+  disableRedirectHoist: true,
118
+  cssLoaderOptions: {
119
+    modules: true,
120
+    getLocalIdent: (context, _, localName) => {
121
+      if (
122
+        context.resourcePath.includes('node_modules') ||
123
+        context.resourcePath.includes('ant.design.pro.less') ||
124
+        context.resourcePath.includes('global.less')
125
+      ) {
126
+        return localName;
127
+      }
128
+
129
+      const match = context.resourcePath.match(/src(.*)/);
130
+
131
+      if (match && match[1]) {
132
+        const antdProPath = match[1].replace('.less', '');
133
+        const arr = slash(antdProPath)
134
+          .split('/')
135
+          .map(a => a.replace(/([A-Z])/g, '-$1'))
136
+          .map(a => a.toLowerCase());
137
+        return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
138
+      }
139
+
140
+      return localName;
141
+    },
142
+  },
143
+  manifest: {
144
+    basePath: '/',
145
+  },
146
+  chainWebpack: webpackPlugin,
147
+
148
+  alias: {
149
+    '@/': path.resolve(__dirname, 'src/')
150
+  },
151
+
152
+  proxy,
153
+};

+ 17
- 0
config/defaultSettings.js Voir le fichier

@@ -0,0 +1,17 @@
1
+export default {
2
+  navTheme: 'light',
3
+  primaryColor: '#333',
4
+  layout: 'sidemenu',
5
+  contentWidth: 'Fluid',
6
+  fixedHeader: false,
7
+  autoHideHeader: false,
8
+  fixSiderbar: false,
9
+  colorWeak: false,
10
+  menu: {
11
+    locale: false,
12
+  },
13
+  // title: '致云系统',
14
+  title: undefined,
15
+  pwa: false,
16
+  iconfontUrl: '',
17
+};

+ 112
- 0
config/plugin.config.js Voir le fichier

@@ -0,0 +1,112 @@
1
+// Change theme plugin
2
+// eslint-disable-next-line eslint-comments/abdeils - enable - pair;
3
+
4
+/* eslint-disable import/no-extraneous-dependencies */
5
+import ThemeColorReplacer from 'webpack-theme-color-replacer';
6
+import generate from '@ant-design/colors/lib/generate';
7
+import path from 'path';
8
+
9
+function getModulePackageName(module) {
10
+  if (!module.context) return null;
11
+  const nodeModulesPath = path.join(__dirname, '../node_modules/');
12
+
13
+  if (module.context.substring(0, nodeModulesPath.length) !== nodeModulesPath) {
14
+    return null;
15
+  }
16
+
17
+  const moduleRelativePath = module.context.substring(nodeModulesPath.length);
18
+  const [moduleDirName] = moduleRelativePath.split(path.sep);
19
+  let packageName = moduleDirName; // handle tree shaking
20
+
21
+  if (packageName && packageName.match('^_')) {
22
+    // eslint-disable-next-line prefer-destructuring
23
+    packageName = packageName.match(/^_(@?[^@]+)/)[1];
24
+  }
25
+
26
+  return packageName;
27
+}
28
+
29
+export default config => {
30
+  // preview.pro.ant.design only do not use in your production;
31
+  if (
32
+    process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ||
33
+    process.env.NODE_ENV !== 'production'
34
+  ) {
35
+    config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [
36
+      {
37
+        fileName: 'css/theme-colors-[contenthash:8].css',
38
+        matchColors: getAntdSerials('#1890ff'),
39
+
40
+        // 主色系列
41
+        // 改变样式选择器,解决样式覆盖问题
42
+        changeSelector(selector) {
43
+          switch (selector) {
44
+            case '.ant-calendar-today .ant-calendar-date':
45
+              return ':not(.ant-calendar-selected-date)' + selector;
46
+
47
+            case '.ant-btn:focus,.ant-btn:hover':
48
+              return '.ant-btn:focus:not(.ant-btn-primary),.ant-btn:hover:not(.ant-btn-primary)';
49
+
50
+            case '.ant-btn.active,.ant-btn:active':
51
+              return '.ant-btn.active:not(.ant-btn-primary),.ant-btn:active:not(.ant-btn-primary)';
52
+
53
+            default:
54
+              return selector;
55
+          }
56
+        }, // isJsUgly: true,
57
+      },
58
+    ]);
59
+  } // optimize chunks
60
+
61
+  config.optimization // share the same chunks across different modules
62
+    .runtimeChunk(false)
63
+    .splitChunks({
64
+      chunks: 'async',
65
+      name: 'vendors',
66
+      maxInitialRequests: Infinity,
67
+      minSize: 0,
68
+      cacheGroups: {
69
+        vendors: {
70
+          test: module => {
71
+            const packageName = getModulePackageName(module) || '';
72
+
73
+            if (packageName) {
74
+              return [
75
+                'bizcharts',
76
+                'gg-editor',
77
+                'g6',
78
+                '@antv',
79
+                'gg-editor-core',
80
+                'bizcharts-plugin-slider',
81
+              ].includes(packageName);
82
+            }
83
+
84
+            return false;
85
+          },
86
+
87
+          name(module) {
88
+            const packageName = getModulePackageName(module);
89
+
90
+            if (packageName) {
91
+              if (['bizcharts', '@antv_data-set'].indexOf(packageName) >= 0) {
92
+                return 'viz'; // visualization package
93
+              }
94
+            }
95
+
96
+            return 'misc';
97
+          },
98
+        },
99
+      },
100
+    });
101
+};
102
+
103
+const getAntdSerials = color => {
104
+  const lightNum = 9;
105
+  const devide10 = 10; // 淡化(即less的tint)
106
+
107
+  const lightens = new Array(lightNum).fill(undefined).map((_, i) => {
108
+    return ThemeColorReplacer.varyColor.lighten(color, i / devide10);
109
+  });
110
+  const colorPalettes = generate(color);
111
+  return lightens.concat(colorPalettes);
112
+};

+ 1057
- 0
config/routes.js
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 12
- 0
jest-puppeteer.config.js Voir le fichier

@@ -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
+};

+ 7
- 0
jest.config.js Voir le fichier

@@ -0,0 +1,7 @@
1
+module.exports = {
2
+  testURL: 'http://localhost:8000',
3
+  preset: 'jest-puppeteer',
4
+  globals: {
5
+    ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false,
6
+  },
7
+};

+ 10
- 0
jsconfig.json Voir le fichier

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

+ 131
- 0
package.json Voir le fichier

@@ -0,0 +1,131 @@
1
+{
2
+  "name": "ant-design-pro",
3
+  "version": "1.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:prod": "cross-env PROD_ENV=1 umi build",
9
+    "build": "cross-env PROD_ENV=2 umi build",
10
+    "deploy": "cross-env ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION=site npm run site && npm run gh-pages",
11
+    "fetch:blocks": "pro fetch-blocks",
12
+    "format-imports": "import-sort --write '**/*.{js,jsx,ts,tsx}'",
13
+    "gh-pages": "cp CNAME ./dist/ && gh-pages -d dist",
14
+    "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
15
+    "lint": "npm run lint:js && npm run lint:style && npm run lint:prettier",
16
+    "lint-staged": "lint-staged",
17
+    "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
18
+    "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
19
+    "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
20
+    "lint:prettier": "check-prettier lint",
21
+    "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
22
+    "prettier": "prettier -c --write \"**/*\"",
23
+    "start": "umi dev",
24
+    "start:no-mock": "cross-env MOCK=none umi dev",
25
+    "test": "umi test",
26
+    "test:all": "node ./tests/run-tests.js",
27
+    "test:component": "umi test ./src/components",
28
+    "ui": "umi ui"
29
+  },
30
+  "lint-staged": {
31
+    "**/*.less": "stylelint --syntax less",
32
+    "**/*.{js,jsx,tsx,ts,less,md,json}": [
33
+      "prettier --write",
34
+      "git add"
35
+    ],
36
+    "**/*.{js,jsx}": "npm run lint-staged:js",
37
+    "**/*.{js,ts,tsx}": "npm run lint-staged:js"
38
+  },
39
+  "browserslist": [
40
+    "> 1%",
41
+    "last 2 versions",
42
+    "not ie <= 10"
43
+  ],
44
+  "dependencies": {
45
+    "@ant-design/pro-layout": "^4.5.9",
46
+    "@antv/data-set": "^0.10.2",
47
+    "@zjxpcyc/xrc-form2": "^2.2.2",
48
+    "ant": "^0.2.0",
49
+    "antd": "^3.26.0",
50
+    "classnames": "^2.2.6",
51
+    "dayjs": "^1.8.16",
52
+    "dva": "^2.4.1",
53
+    "echarts": "^4.3.0",
54
+    "lodash": "^4.17.11",
55
+    "md5": "^2.2.1",
56
+    "moment": "^2.24.0",
57
+    "omit.js": "^1.0.2",
58
+    "path-to-regexp": "^3.0.0",
59
+    "qrcode.react": "^1.0.0",
60
+    "qs": "^6.7.0",
61
+    "react": "^16.8.6",
62
+    "react-amap": "^1.2.8",
63
+    "react-amap-plugin-autocomplete": "0.0.4",
64
+    "react-copy-to-clipboard": "^5.0.1",
65
+    "react-document-title": "^2.0.3",
66
+    "react-dom": "^16.8.6",
67
+    "react-slick": "^0.25.2",
68
+    "react-zmage": "^0.8.5",
69
+    "redux": "^4.0.1",
70
+    "swiper": "^5.3.6",
71
+    "umi": "^2.13.16",
72
+    "umi-plugin-pro-block": "^1.3.6",
73
+    "umi-plugin-react": "^1.15.8",
74
+    "umi-request": "^1.0.8",
75
+    "wangeditor": "^3.1.1"
76
+  },
77
+  "devDependencies": {
78
+    "@ant-design/colors": "^3.1.0",
79
+    "@ant-design/pro-cli": "^1.0.0",
80
+    "@types/classnames": "^2.2.7",
81
+    "@types/echarts": "^4.1.14",
82
+    "@types/express": "^4.17.0",
83
+    "@types/history": "^4.7.2",
84
+    "@types/jest": "^24.0.13",
85
+    "@types/lodash": "^4.14.133",
86
+    "@types/qrcode.react": "^0.9.0",
87
+    "@types/qs": "^6.5.3",
88
+    "@types/react": "^16.8.19",
89
+    "@types/react-document-title": "^2.0.3",
90
+    "@types/react-dom": "^16.8.4",
91
+    "@umijs/fabric": "^1.1.0",
92
+    "chalk": "^2.4.2",
93
+    "check-prettier": "^1.0.3",
94
+    "cross-env": "^5.2.0",
95
+    "cross-port-killer": "^1.1.1",
96
+    "enzyme": "^3.9.0",
97
+    "eslint": "^5.16.0",
98
+    "express": "^4.17.1",
99
+    "gh-pages": "^2.0.1",
100
+    "husky": "^3.0.0",
101
+    "import-sort-cli": "^6.0.0",
102
+    "import-sort-parser-babylon": "^6.0.0",
103
+    "import-sort-parser-typescript": "^6.0.0",
104
+    "import-sort-style-module": "^6.0.0",
105
+    "jest-puppeteer": "^4.2.0",
106
+    "lint-staged": "^9.0.0",
107
+    "mockjs": "^1.0.1-beta3",
108
+    "node-fetch": "^2.6.0",
109
+    "prettier": "^1.17.1",
110
+    "pro-download": "1.0.1",
111
+    "slash2": "^2.0.0",
112
+    "stylelint": "^10.1.0",
113
+    "umi-plugin-ga": "^1.1.6",
114
+    "umi-plugin-pro": "^1.0.3",
115
+    "umi-types": "^0.3.8",
116
+    "webpack-theme-color-replacer": "^1.3.12"
117
+  },
118
+  "optionalDependencies": {
119
+    "puppeteer": "^1.17.0"
120
+  },
121
+  "engines": {
122
+    "node": ">=10.0.0"
123
+  },
124
+  "checkFiles": [
125
+    "src/**/*.js*",
126
+    "src/**/*.ts*",
127
+    "src/**/*.less",
128
+    "config/**/*.js*",
129
+    "scripts/**/*.js"
130
+  ]
131
+}

+ 34
- 0
tsconfig.json Voir le fichier

@@ -0,0 +1,34 @@
1
+{
2
+  "compilerOptions": {
3
+    "outDir": "build/dist",
4
+    "module": "esnext",
5
+    "target": "esnext",
6
+    "lib": ["esnext", "dom"],
7
+    "sourceMap": true,
8
+    "baseUrl": ".",
9
+    "jsx": "react",
10
+    "allowSyntheticDefaultImports": true,
11
+    "moduleResolution": "node",
12
+    "forceConsistentCasingInFileNames": true,
13
+    "noImplicitReturns": true,
14
+    "suppressImplicitAnyIndexErrors": true,
15
+    "noUnusedLocals": true,
16
+    "allowJs": true,
17
+    "experimentalDecorators": true,
18
+    "strict": true,
19
+    "paths": {
20
+      "@/*": ["./src/*"]
21
+    }
22
+  },
23
+  "exclude": [
24
+    "node_modules",
25
+    "build",
26
+    "scripts",
27
+    "acceptance-tests",
28
+    "webpack",
29
+    "jest",
30
+    "src/setupTests.ts",
31
+    "tslint:latest",
32
+    "tslint-config-prettier"
33
+  ]
34
+}