andrew 4 年之前
父節點
當前提交
8ab5fe1334

+ 153
- 0
estateagents-admin-manager/config/config.js 查看文件

@@ -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
estateagents-admin-manager/config/defaultSettings.js 查看文件

@@ -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
estateagents-admin-manager/config/plugin.config.js 查看文件

@@ -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
estateagents-admin-manager/config/routes.js
文件差異過大導致無法顯示
查看文件


+ 103
- 0
estateagents-admin-manager/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
estateagents-admin-manager/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
estateagents-admin-manager/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
+};

+ 34
- 0
estateagents-admin-manager/tsconfig.json 查看文件

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