陈帅 6 лет назад
Родитель
Сommit
4c91d0bad0

+ 1 - 1
.eslintignore

@@ -1,3 +1,3 @@
-/functions/mock/**
+/lambda/mock/**
 /scripts
 /config

+ 1 - 1
.eslintrc.js

@@ -34,8 +34,8 @@ module.exports = {
     'linebreak-style': 0,
   },
   settings: {
-    polyfills: ['fetch', 'promises', 'url'],
     // support import modules from TypeScript files in JavaScript files
     'import/resolver': { node: { extensions: ['.js', '.ts', '.tsx'] } },
+    polyfills: ['fetch', 'promises', 'url', 'object-assign'],
   },
 };

+ 0 - 5
.firebaserc

@@ -1,5 +0,0 @@
-{
-  "projects": {
-    "default": "antd-pro"
-  }
-}

+ 2 - 2
.gitignore

@@ -25,8 +25,8 @@ package-lock.json
 # visual studio code
 .history
 *.log
-
-functions/mock
+functions/*
+lambda/mock/index.js
 .temp/**
 
 # umi

Разница между файлами не показана из-за своего большого размера
+ 2 - 2
README.md


Разница между файлами не показана из-за своего большого размера
+ 2 - 2
README.ru-RU.md


Разница между файлами не показана из-за своего большого размера
+ 130 - 0
README.tr-TR.md


Разница между файлами не показана из-за своего большого размера
+ 2 - 2
README.zh-CN.md


+ 18 - 11
config/config.ts

@@ -1,5 +1,5 @@
 // https://umijs.org/config/
-// import os from 'os';
+import os from 'os';
 import slash from 'slash2';
 import { IPlugin, IConfig } from 'umi-types';
 import defaultSettings from './defaultSettings';
@@ -26,12 +26,23 @@ const plugins: IPlugin[] = [
         webpackChunkName: true,
         level: 3,
       },
-      pwa: {
-        workboxPluginMode: 'InjectManifest',
-        workboxOptions: {
-          importWorkboxFrom: 'local',
-        },
-      },
+      pwa: pwa
+        ? {
+            workboxPluginMode: 'InjectManifest',
+            workboxOptions: {
+              importWorkboxFrom: 'local',
+            },
+          }
+        : false,
+      ...(!TEST && os.platform() === 'darwin'
+        ? {
+            dll: {
+              include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
+              exclude: ['@babel/runtime'],
+            },
+            hardSource: false,
+          }
+        : {}),
     },
   ],
   [
@@ -103,10 +114,6 @@ export default {
   theme: {
     'primary-color': primaryColor,
   },
-  externals: {
-    '@antv/data-set': 'DataSet',
-    bizcharts: 'BizCharts',
-  },
   // proxy: {
   //   '/server/api/': {
   //     target: 'https://preview.pro.ant.design/',

+ 4 - 5
config/defaultSettings.ts

@@ -34,11 +34,10 @@ export interface DefaultSettings {
   menu: { disableLocal: boolean };
   title: string;
   pwa: boolean;
-  /**
-   * your iconfont Symbol Scrip Url
-   * eg:`//at.alicdn.com/t/font_1039637_btcrd5co4w.js`
-   * 注意:如果需要图标多色,Iconfont图标项目里要进行批量去色处理
-   */
+  // Your custom iconfont Symbol script Url
+  // eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js
+  // 注意:如果需要图标多色,Iconfont 图标项目里要进行批量去色处理
+  // Usage: https://github.com/ant-design/ant-design-pro/pull/3517
   iconfontUrl: string;
   colorWeak: boolean;
 }

+ 47 - 0
config/plugin.config.ts

@@ -4,6 +4,25 @@ import MergeLessPlugin from 'antd-pro-merge-less';
 import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
 import path from 'path';
 
+function getModulePackageName(module) {
+  if (!module.context) return null;
+
+  const nodeModulesPath = path.join(__dirname, '../node_modules/');
+  if (module.context.substring(0, nodeModulesPath.length) !== nodeModulesPath) {
+    return null;
+  }
+
+  const moduleRelativePath = module.context.substring(nodeModulesPath.length);
+  const [moduleDirName] = moduleRelativePath.split(path.sep);
+  let packageName = moduleDirName;
+  // handle tree shaking
+  if (packageName.match('^_')) {
+    // eslint-disable-next-line prefer-destructuring
+    packageName = packageName.match(/^_(@?[^@]+)/)[1];
+  }
+  return packageName;
+}
+
 export default config => {
   // pro 和 开发环境再添加这个插件
   if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
@@ -30,4 +49,32 @@ export default config => {
       },
     ]);
   }
+  // optimize chunks
+  config.optimization
+    .runtimeChunk(false) // share the same chunks across different modules
+    .splitChunks({
+      chunks: 'async',
+      name: 'vendors',
+      maxInitialRequests: Infinity,
+      minSize: 0,
+      cacheGroups: {
+        vendors: {
+          test: module => {
+            const packageName = getModulePackageName(module);
+            if (packageName) {
+              return ['bizcharts', '@antv_data-set'].indexOf(packageName) >= 0;
+            }
+            return false;
+          },
+          name(module) {
+            const packageName = getModulePackageName(module);
+
+            if (['bizcharts', '@antv_data-set'].indexOf(packageName) >= 0) {
+              return 'viz'; // visualization package
+            }
+            return 'misc';
+          },
+        },
+      },
+    });
 };

+ 0 - 13
firebase.json

@@ -1,13 +0,0 @@
-{
-  "hosting": {
-    "public": "dist",
-    "rewrites": [
-      { "source": "/api/**", "function": "api" },
-      {
-        "source": "**",
-        "destination": "/index.html"
-      }
-    ],
-    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
-  }
-}

+ 0 - 10
functions/index.js

@@ -1,10 +0,0 @@
-// [START functionsimport]
-const functions = require('firebase-functions');
-const express = require('express');
-
-const matchMock = require('./matchMock');
-
-const app = express();
-
-app.use(matchMock);
-exports.api = functions.https.onRequest(app);

+ 11 - 0
lambda/api.js

@@ -0,0 +1,11 @@
+// [START functions import]
+const express = require('express');
+const serverLess = require('serverless-http');
+
+const matchMock = require('./mock/matchMock');
+
+const app = express();
+
+app.use(matchMock);
+
+exports.handler = serverLess(app);

+ 6 - 5
functions/matchMock.js

@@ -1,7 +1,7 @@
 const pathToRegexp = require('path-to-regexp');
 const bodyParser = require('body-parser');
 
-const mockFile = require('./mock/index');
+const mockFile = require('./index');
 
 const BODY_PARSED_METHODS = ['post', 'put', 'patch'];
 
@@ -10,13 +10,14 @@ function parseKey(key) {
   let method = 'get';
   let path = key;
   if (key.indexOf(' ') > -1) {
-    const splited = key.split(' ');
-    method = splited[0].toLowerCase();
-    path = splited[1]; // eslint-disable-line
+    const spliced = key.split(' ');
+    method = spliced[0].toLowerCase();
+    path = spliced[1]; // eslint-disable-line
   }
+  const routerBasePath = process.env.NODE_ENV === 'dev' ? `${path}` : `/.netlify/functions${path}`;
   return {
     method,
-    path,
+    path: routerBasePath,
   };
 }
 

+ 5 - 2
netlify.toml

@@ -1,12 +1,15 @@
+[build]
+  functions = "./functions"
+
 [[redirects]]
   from = "/api/*"
-  to = "https://us-central1-antd-pro.cloudfunctions.net/api/api/:splat"
+  to = "/.netlify/functions/api/:splat"
   status = 200
   force = true
   [redirects.headers]
     X-From = "Netlify"
     X-Api-Key = "some-api-key-string"
-
+    
 [[redirects]]
   from = "/*"
   to = "/index.html"

+ 59 - 53
package.json

@@ -1,48 +1,77 @@
 {
   "name": "ant-design-pro",
-  "version": "2.2.1",
-  "description": "An out-of-box UI solution for enterprise applications",
+  "version": "2.3.1",
   "private": true,
+  "description": "An out-of-box UI solution for enterprise applications",
   "scripts": {
-    "presite": "cd functions && npm install",
-    "start": "cross-env APP_TYPE=site umi dev",
-    "start:no-mock": "cross-env MOCK=none umi dev",
+    "analyze": "cross-env ANALYZE=1 umi build",
+    "build": "umi build",
     "dev": "cross-env APP_TYPE=site umi dev",
     "dev:no-mock": "cross-env MOCK=none umi dev",
-    "build": "umi build",
-    "analyze": "cross-env ANALYZE=1 umi build",
-    "lint:js": "eslint --ext .js src tests",
-    "lint:ts": "tslint -p . -c tslint.yml",
-    "lint:style": "stylelint 'src/**/*.less' --syntax less",
-    "lint:prettier": "check-prettier lint",
-    "lint": "npm run lint:js && npm run lint:ts && npm run lint:style && npm run lint:prettier",
-    "lint:fix": "eslint --fix --ext .js src tests && tslint --fix -p . -c tslint.yml && stylelint --fix 'src/**/*.less' --syntax less",
+    "docker-hub:build": "docker build  -f Dockerfile.hub -t  ant-design-pro ./",
+    "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build",
+    "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up",
+    "docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build",
+    "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up",
+    "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push antdesign/ant-design-pro",
+    "docker:tag": "docker tag ant-design-pro antdesign/ant-design-pro",
+    "functions:build": "npm run generateMock && netlify-lambda build ./lambda",
+    "functions:run": "npm run generateMock && cross-env NODE_ENV=dev netlify-lambda serve ./lambda",
+    "generateMock": "node ./scripts/generateMock",
+    "lint": "eslint --ext .js src mock tests && npm run lint:style && npm run lint:prettier",
     "lint-staged": "lint-staged",
     "lint-staged:js": "eslint --ext .js",
     "lint-staged:ts": "tslint",
+    "lint:fix": "eslint --fix --ext .js src mock tests && stylelint --fix 'src/**/*.less' --syntax less",
+    "lint:js": "eslint --ext .js src tests",
+    "lint:prettier": "check-prettier lint",
+    "lint:style": "stylelint 'src/**/*.less' --syntax less",
+    "lint:ts": "tslint -p . -c tslint.yml",
+    "presite": "cd functions && npm install",
+    "prettier": "node ./scripts/prettier.js",
+    "start": "cross-env APP_TYPE=site umi dev",
+    "start:no-mock": "cross-env MOCK=none umi dev",
     "test": "umi test",
-    "test:component": "umi test ./src/components",
     "test:all": "node ./tests/run-tests.js",
-    "prettier": "node ./scripts/prettier.js",
-    "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up",
-    "docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build",
-    "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up",
-    "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build",
-    "docker-hub:build": "docker build  -f Dockerfile.hub -t  ant-design-pro ./",
-    "docker:tag": "docker tag ant-design-pro antdesign/ant-design-pro",
-    "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push antdesign/ant-design-pro"
+    "test:component": "umi test ./src/components",
+    "tslint": "npm run tslint:fix",
+    "tslint:fix": "tslint --fix 'src/**/*.ts*'"
+  },
+  "husky": {
+    "hooks": {
+      "pre-commit": "npm run lint-staged"
+    }
   },
+  "lint-staged": {
+    "**/*.less": "stylelint --syntax less",
+    "**/*.{js,jsx}": "npm run lint-staged:js",
+    "**/*.{js,ts,tsx,json,jsx,less}": [
+      "node ./scripts/lint-prettier.js",
+      "git add"
+    ],
+    "**/*.{ts,tsx}": "npm run lint-staged:ts"
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions",
+    "not ie <= 10"
+  ],
   "dependencies": {
+    "@types/classnames": "^2.2.7",
+    "@types/react-document-title": "^2.0.3",
     "ant-design-pro": "^2.3.0",
     "antd": "^3.15.0",
     "classnames": "^2.2.6",
     "dva": "^2.4.0",
+    "express": "^4.16.4",
     "lodash": "^4.17.10",
     "lodash-decorators": "^6.0.0",
+    "lodash.isequal": "^4.5.0",
     "memoize-one": "^5.0.0",
     "moment": "^2.22.2",
     "omit.js": "^1.0.0",
     "path-to-regexp": "^2.4.0",
+    "qs": "^6.7.0",
     "rc-animate": "^2.4.4",
     "react": "^16.8.5",
     "react-container-query": "^0.11.0",
@@ -53,13 +82,9 @@
     "umi-request": "^1.0.0"
   },
   "devDependencies": {
-    "@types/classnames": "^2.2.7",
-    "@types/enzyme": "^3.9.0",
-    "@types/jest": "^24.0.11",
-    "@types/lodash": "^4.14.122",
-    "@types/memoize-one": "^4.1.0",
+    "@types/history": "^4.7.2",
     "@types/react": "^16.8.1",
-    "@types/react-document-title": "^2.0.3",
+    "@types/react-dom": "^16.0.11",
     "antd-pro-merge-less": "^1.0.0",
     "antd-theme-webpack-plugin": "^1.2.0",
     "babel-eslint": "^10.0.1",
@@ -70,16 +95,16 @@
     "enzyme": "^3.9.0",
     "eslint": "^5.13.0",
     "eslint-config-airbnb": "^17.1.0",
-    "eslint-config-prettier": "^4.0.0",
+    "eslint-config-prettier": "^4.1.0",
     "eslint-plugin-babel": "^5.3.0",
     "eslint-plugin-compat": "^2.6.3",
     "eslint-plugin-import": "^2.16.0",
-    "eslint-plugin-jsx-a11y": "^6.2.0",
+    "eslint-plugin-jsx-a11y": "^6.2.1",
     "eslint-plugin-markdown": "^1.0.0",
     "eslint-plugin-react": "^7.12.4",
     "gh-pages": "^2.0.1",
     "husky": "^1.3.1",
-    "jest-puppeteer": "^4.0.0",
+    "jest-puppeteer": "^4.1.0",
     "less": "^3.9.0",
     "lint-staged": "^8.1.1",
     "merge-umi-mock-data": "^1.0.4",
@@ -98,40 +123,21 @@
     "tslint-eslint-rules": "^5.4.0",
     "tslint-react": "^3.6.0",
     "umi-plugin-ga": "^1.1.3",
-    "umi-plugin-pro-block": "^1.2.0",
-    "umi-plugin-react": "^1.3.4",
+    "umi-plugin-pro-block": "^1.3.0",
+    "umi-plugin-react": "^1.7.2",
     "umi-types": "^0.2.0"
   },
   "optionalDependencies": {
     "puppeteer": "^1.12.1"
   },
-  "lint-staged": {
-    "**/*.{js,ts,tsx,json,jsx,less}": [
-      "node ./scripts/lint-prettier.js",
-      "git add"
-    ],
-    "**/*.{js,jsx}": "npm run lint-staged:js",
-    "**/*.{ts,tsx}": "npm run lint-staged:ts",
-    "**/*.less": "stylelint --syntax less"
-  },
   "engines": {
     "node": ">=8.0.0"
   },
-  "browserslist": [
-    "> 1%",
-    "last 2 versions",
-    "not ie <= 10"
-  ],
   "checkFiles": [
     "src/**/*.js*",
     "src/**/*.ts*",
     "src/**/*.less",
     "config/**/*.js*",
     "scripts/**/*.js"
-  ],
-  "husky": {
-    "hooks": {
-      "pre-commit": "npm run lint-staged"
-    }
-  }
+  ]
 }

+ 1 - 1
scripts/generateMock.js

@@ -1,3 +1,3 @@
 const generateMock = require('merge-umi-mock-data');
 const path = require('path');
-generateMock(path.join(__dirname, '../mock'), path.join(__dirname, '../functions/mock/index.js'));
+generateMock(path.join(__dirname, '../mock'), path.join(__dirname, '../lambda/mock/index.js'));

+ 1 - 0
scripts/prettier.js

@@ -36,6 +36,7 @@ files.forEach(file => {
       console.log(chalk.green(`${file} is prettier`));
     }
   } catch (e) {
+    console.log(e);
     didError = true;
   }
 });

+ 1 - 1
src/components/GlobalHeader/RightContent.tsx

@@ -2,9 +2,9 @@ import { ConnectProps } from '@/models/connect';
 import { NoticeItem } from '@/models/global';
 import { CurrentUser } from '@/models/user';
 import React, { Component } from 'react';
-import { FormattedMessage, formatMessage } from 'umi-plugin-locale';
 import { Spin, Tag, Menu, Icon, Avatar, Tooltip, message } from 'antd';
 import { ClickParam } from 'antd/es/menu';
+import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
 import moment from 'moment';
 import groupBy from 'lodash/groupBy';
 import { NoticeIcon } from 'ant-design-pro';

+ 12 - 0
src/components/HeaderDropdown/index.d.ts

@@ -0,0 +1,12 @@
+import React from 'react';
+import { DropDownProps } from 'antd/lib/dropdown';
+
+declare type OverlayFunc = () => React.ReactNode;
+
+export interface HeaderDropdownProps extends DropDownProps {
+  overlayClassName?: string;
+  overlay: React.ReactNode | OverlayFunc;
+  placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topCenter' | 'topRight' | 'bottomCenter';
+}
+
+export default class HeaderDropdown extends React.Component<HeaderDropdownProps, any> {}

+ 15 - 0
src/components/HeaderSearch/index.d.ts

@@ -0,0 +1,15 @@
+import React from 'react';
+export interface HeaderSearchProps {
+  placeholder?: string;
+  dataSource?: string[];
+  defaultOpen?: boolean;
+  open?: boolean;
+  onSearch?: (value: string) => void;
+  onChange?: (value: string) => void;
+  onVisibleChange?: (visible: boolean) => void;
+  onPressEnter?: (value: string) => void;
+  style?: React.CSSProperties;
+  className?: string;
+}
+
+export default class HeaderSearch extends React.Component<HeaderSearchProps, any> {}

+ 1 - 1
src/components/SelectLang/index.tsx

@@ -1,5 +1,5 @@
 import React from 'react';
-import { formatMessage, setLocale, getLocale } from 'umi-plugin-locale';
+import { formatMessage, setLocale, getLocale } from 'umi-plugin-react/locale';
 import { Menu, Icon } from 'antd';
 import { ClickParam } from 'antd/es/menu';
 import classNames from 'classnames';

+ 9 - 0
src/components/SettingDrawer/BlockCheckbox.d.ts

@@ -0,0 +1,9 @@
+import React from 'react';
+
+export interface BlockChecboxProps {
+  value: string;
+  onChange: (key: string) => void;
+  list: any[];
+}
+
+export default class BlockChecbox extends React.Component<BlockChecboxProps, any> {}

+ 24 - 0
src/components/SettingDrawer/index.d.ts

@@ -0,0 +1,24 @@
+import React from 'react';
+import { SiderTheme } from 'antd/es/Layout/Sider';
+
+export interface SettingModelState {
+  navTheme: string | SiderTheme;
+  primaryColor: string;
+  layout: string;
+  contentWidth: string;
+  fixedHeader: boolean;
+  autoHideHeader: boolean;
+  fixSiderbar: boolean;
+  menu: { disableLocal: boolean };
+  title: string;
+  pwa: boolean;
+  iconfontUrl: string;
+  colorWeak: boolean;
+}
+
+export interface SettingDrawerProps {
+  setting?: SettingModelState;
+  dispatch?: (args: any) => void;
+}
+
+export default class SettingDrawer extends React.Component<SettingDrawerProps, any> {}

+ 7 - 0
src/components/SettingDrawer/index.less

@@ -4,6 +4,13 @@
   position: relative;
   min-height: 100%;
   background: #fff;
+  :global {
+    .ant-list-item {
+      span {
+        flex: 1;
+      }
+    }
+  }
 }
 
 .blockChecbox {

+ 26 - 14
src/components/SettingDrawer/index.tsx

@@ -1,7 +1,7 @@
 import { ConnectProps, ConnectState, SettingModelState } from '@/models/connect';
 import React, { Component } from 'react';
 import { Select, message, Drawer, List, Switch, Divider, Icon, Button, Alert, Tooltip } from 'antd';
-import { formatMessage } from 'umi-plugin-locale';
+import { formatMessage } from 'umi-plugin-react/locale';
 import { CopyToClipboard } from 'react-copy-to-clipboard';
 import { connect } from 'dva';
 import omit from 'omit.js';
@@ -152,10 +152,18 @@ class SettingDrawer extends Component<SettingDrawerProps, SettingDrawerState> {
         placement="right"
         handler={
           <div className={styles.handle} onClick={this.togglerContent}>
-            <Icon type={collapse ? 'close' : 'setting'} style={{ color: '#fff', fontSize: 20 }} />
+            <Icon
+              type={collapse ? 'close' : 'setting'}
+              style={{
+                color: '#fff',
+                fontSize: 20,
+              }}
+            />
           </div>
         }
-        style={{ zIndex: 999 }}
+        style={{
+          zIndex: 999,
+        }}
       >
         <div className={styles.content}>
           <Body title={formatMessage({ id: 'app.setting.pagestyle' })}>
@@ -213,18 +221,22 @@ class SettingDrawer extends Component<SettingDrawerProps, SettingDrawerState> {
           <Divider />
 
           <Body title={formatMessage({ id: 'app.setting.othersettings' })}>
-            <List.Item
-              actions={[
-                <Switch
-                  key="Switch"
-                  size="small"
-                  checked={!!colorWeak}
-                  onChange={checked => this.changeSetting('colorWeak', checked)}
-                />,
+            <List
+              split={false}
+              renderItem={this.renderLayoutSettingItem}
+              dataSource={[
+                {
+                  title: formatMessage({ id: 'app.setting.weakmode' }),
+                  action: (
+                    <Switch
+                      size="small"
+                      checked={!!colorWeak}
+                      onChange={checked => this.changeSetting('colorWeak', checked)}
+                    />
+                  ),
+                },
               ]}
-            >
-              {formatMessage({ id: 'app.setting.weakmode' })}
-            </List.Item>
+            />
           </Body>
           <Divider />
           <CopyToClipboard

+ 5 - 1
src/components/TopNavHeader/index.tsx

@@ -18,7 +18,11 @@ interface TopNavHeaderState {
 export default class TopNavHeader extends Component<TopNavHeaderProps, TopNavHeaderState> {
   static getDerivedStateFromProps(props: TopNavHeaderProps) {
     return {
-      maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 280 - 165 - 40,
+      maxWidth:
+        (props.contentWidth === 'Fixed' && window.innerWidth > 1200 ? 1200 : window.innerWidth) -
+        280 -
+        120 -
+        40,
     };
   }
 

+ 1 - 1
src/global.tsx

@@ -1,6 +1,6 @@
 import React from 'react';
 import { notification, Button, message } from 'antd';
-import { formatMessage } from 'umi-plugin-locale';
+import { formatMessage } from 'umi-plugin-react/locale';
 import defaultSettings from '../config/defaultSettings';
 
 (window as any).React = React;

+ 5 - 9
src/layouts/Header.tsx

@@ -1,12 +1,12 @@
 import GlobalHeader, { GlobalHeaderProps } from '@/components/GlobalHeader';
 import TopNavHeader, { TopNavHeaderProps } from '@/components/TopNavHeader';
 import { ConnectProps, ConnectState, SettingModelState } from '@/models/connect';
+import React, { Component } from 'react';
+import { formatMessage } from 'umi-plugin-react/locale';
 import { Layout, message } from 'antd';
 import { ClickParam } from 'antd/es/menu';
 import { connect } from 'dva';
 import Animate from 'rc-animate';
-import React, { Component } from 'react';
-import { formatMessage } from 'umi-plugin-locale';
 import router from 'umi/router';
 import styles from './Header.less';
 
@@ -25,10 +25,6 @@ interface HeaderViewState {
 }
 
 class HeaderView extends Component<HeaderViewProps, HeaderViewState> {
-  static defaultProps: Partial<HeaderViewProps> = {
-    handleMenuCollapse: () => void 0,
-  };
-
   static getDerivedStateFromProps(props: HeaderViewProps, state: HeaderViewState) {
     if (!props.autoHideHeader && !state.visible) {
       return {
@@ -37,12 +33,12 @@ class HeaderView extends Component<HeaderViewProps, HeaderViewState> {
     }
     return null;
   }
+  state = {
+    visible: true,
+  };
 
   ticking: boolean = false;
   oldScrollTop: number = 0;
-  state: HeaderViewState = {
-    visible: true,
-  };
 
   componentDidMount() {
     document.addEventListener('scroll', this.handScroll, { passive: true });

+ 1 - 1
src/models/menu.ts

@@ -4,7 +4,7 @@ import { Effect } from 'dva';
 import isEqual from 'lodash/isEqual';
 import memoizeOne from 'memoize-one';
 import { Reducer } from 'redux';
-import { formatMessage } from 'umi-plugin-locale';
+import { formatMessage } from 'umi-plugin-react/locale';
 import { IRoute } from 'umi-types';
 import defaultSettings from '../../config/defaultSettings';
 

+ 126 - 0
src/services/api.js

@@ -0,0 +1,126 @@
+import { stringify } from 'qs';
+import request from '@/utils/request';
+
+export async function queryProjectNotice() {
+  return request('/api/project/notice');
+}
+
+export async function queryActivities() {
+  return request('/api/activities');
+}
+
+export async function queryRule(params) {
+  return request(`/api/rule?${stringify(params)}`);
+}
+
+export async function removeRule(params) {
+  return request('/api/rule', {
+    method: 'POST',
+    data: {
+      ...params,
+      method: 'delete',
+    },
+  });
+}
+
+export async function addRule(params) {
+  return request('/api/rule', {
+    method: 'POST',
+    data: {
+      ...params,
+      method: 'post',
+    },
+  });
+}
+
+export async function updateRule(params = {}) {
+  return request(`/api/rule?${stringify(params.query)}`, {
+    method: 'POST',
+    data: {
+      ...params.body,
+      method: 'update',
+    },
+  });
+}
+
+export async function fakeSubmitForm(params) {
+  return request('/api/forms', {
+    method: 'POST',
+    data: params,
+  });
+}
+
+export async function fakeChartData() {
+  return request('/api/fake_chart_data');
+}
+
+export async function queryTags() {
+  return request('/api/tags');
+}
+
+export async function queryBasicProfile(id) {
+  return request(`/api/profile/basic?id=${id}`);
+}
+
+export async function queryAdvancedProfile() {
+  return request('/api/profile/advanced');
+}
+
+export async function queryFakeList(params) {
+  return request(`/api/fake_list?${stringify(params)}`);
+}
+
+export async function removeFakeList(params) {
+  const { count = 5, ...restParams } = params;
+  return request(`/api/fake_list?count=${count}`, {
+    method: 'POST',
+    data: {
+      ...restParams,
+      method: 'delete',
+    },
+  });
+}
+
+export async function addFakeList(params) {
+  const { count = 5, ...restParams } = params;
+  return request(`/api/fake_list?count=${count}`, {
+    method: 'POST',
+    data: {
+      ...restParams,
+      method: 'post',
+    },
+  });
+}
+
+export async function updateFakeList(params) {
+  const { count = 5, ...restParams } = params;
+  return request(`/api/fake_list?count=${count}`, {
+    method: 'POST',
+    data: {
+      ...restParams,
+      method: 'update',
+    },
+  });
+}
+
+export async function fakeAccountLogin(params) {
+  return request('/api/login/account', {
+    method: 'POST',
+    data: params,
+  });
+}
+
+export async function fakeRegister(params) {
+  return request('/api/register', {
+    method: 'POST',
+    data: params,
+  });
+}
+
+export async function queryNotices(params = {}) {
+  return request(`/api/notices?${stringify(params)}`);
+}
+
+export async function getFakeCaptcha(mobile) {
+  return request(`/api/captcha?mobile=${mobile}`);
+}

+ 1 - 1
src/utils/authority.ts

@@ -13,7 +13,7 @@ export function getAuthority(str?: string): any {
   if (typeof authority === 'string') {
     return [authority];
   }
-  return authority || ['admin'];
+  return authority;
 }
 
 export function setAuthority(authority: string | string[]): void {

+ 1 - 1
src/utils/getPageTitle.ts

@@ -1,7 +1,7 @@
 import isEqual from 'lodash/isEqual';
 import memoizeOne from 'memoize-one';
 import pathToRegexp from 'path-to-regexp';
-import { formatMessage } from 'umi-plugin-locale';
+import { formatMessage } from 'umi-plugin-react/locale';
 import defaultSettings from '../../config/defaultSettings';
 import { MenuDataItem } from '@/components/SiderMenu/BaseMenu';