Browse Source

Merge branch 'master' into eslint-typescript

pull/4336/head
陈帅 7 years ago
parent
commit
888df38b7c
  1. 1
      .eslintrc.js
  2. 8
      .gitpod.yml
  3. 12
      .prettierignore
  4. 8
      .prettierrc
  5. 7
      .stylelintrc.json
  6. 20
      CODE_OF_CONDUCT.md
  7. 37
      README.fr-FR.md
  8. 36
      README.ja-JP.md
  9. 36
      README.md
  10. 12
      README.ru-RU.md
  11. 36
      README.tr-TR.md
  12. 36
      README.zh-CN.md
  13. 2
      config/plugin.config.ts
  14. 4
      docker/docker-compose.dev.yml
  15. 5207
      lambda/mock/index.js
  16. 16
      package.json
  17. 28
      src/components/CopyBlock/index.tsx
  18. 29
      src/components/GlobalFooter/index.less
  19. 40
      src/components/GlobalFooter/index.tsx
  20. 2
      src/components/GlobalHeader/AvatarDropdown.tsx
  21. 2
      src/components/GlobalHeader/index.less
  22. 2
      src/components/HeaderDropdown/index.less
  23. 2
      src/components/HeaderSearch/index.less
  24. 2
      src/components/NoticeIcon/NoticeList.less
  25. 2
      src/components/NoticeIcon/index.less
  26. 2
      src/components/SelectLang/index.less
  27. 1
      src/components/SelectLang/index.tsx
  28. 2
      src/global.less
  29. 2
      src/layouts/BasicLayout.tsx
  30. 2
      src/layouts/UserLayout.less
  31. 49
      src/layouts/UserLayout.tsx
  32. 8
      src/models/setting.ts
  33. 4
      src/pages/Welcome.tsx
  34. 10
      src/pages/document.ejs
  35. 1
      src/typings.d.ts

1
.eslintrc.js

@ -1,4 +1,5 @@
const eslintConfig = require('umi-lint/config/.eslintrc.js'); const eslintConfig = require('umi-lint/config/.eslintrc.js');
module.exports = { module.exports = {
...eslintConfig, ...eslintConfig,
globals: { globals: {

8
.gitpod.yml

@ -1,6 +1,6 @@
ports: ports:
- port: 8000 - port: 8000
onOpen: open-preview onOpen: open-preview
tasks: tasks:
- init: npm install - init: npm install
command: npm start command: npm start

12
.prettierignore

@ -2,3 +2,15 @@
package.json package.json
.umi .umi
.umi-production .umi-production
/dist
.dockerignore
.DS_Store
.eslintignore
*.png
*.toml
docker
.editorconfig
Dockerfile*
.gitignore
.prettierignore
LICENSE

8
.prettierrc

@ -9,6 +9,12 @@
"options": { "options": {
"parser": "json" "parser": "json"
} }
},
{
"files": "document.ejs",
"options": {
"parser": "html"
}
} }
] ]
} }

7
.stylelintrc.json

@ -5,12 +5,9 @@
"stylelint-config-rational-order", "stylelint-config-rational-order",
"stylelint-config-prettier" "stylelint-config-prettier"
], ],
"plugins": [ "plugins": ["stylelint-order", "stylelint-declaration-block-no-ignored-properties"],
"stylelint-order",
"stylelint-declaration-block-no-ignored-properties"
],
"rules": { "rules": {
"no-descending-specificity": null, "no-descending-specificity": null,
"plugin/declaration-block-no-ignored-properties": true "plugin/declaration-block-no-ignored-properties": true
} }
} }

20
CODE_OF_CONDUCT.md

@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
Examples of behavior that contributes to creating a positive environment include: Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language - Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences - Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism - Gracefully accepting constructive criticism
* Focusing on what is best for the community - Focusing on what is best for the community
* Showing empathy towards other community members - Showing empathy towards other community members
Examples of unacceptable behavior by participants include: Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances - The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks - Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment - Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission - Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting - Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities ## Our Responsibilities

37
README.fr-FR.md

@ -77,32 +77,18 @@ Nous avons besoin de votre aide: https://github.com/ant-design/ant-design-pro/is
### Utiliser bash ### Utiliser bash
```bash ```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 -b v2 $ yarn create umi # or npm create umi
$ cd ant-design-pro
$ npm install
$ npm start # visiter http://localhost:8000
```
### Utilisation par docker
```bash
# aperçu
$ docker pull antdesign/ant-design-pro
$ docker run -p 80:80 antdesign/ant-design-pro
# ouvrir http://localhost
# développement
$ npm run docker:dev
# construction # Choose ant-design-pro:
$ npm run docker:build Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
$ npm install
# développement en production $ npm start # visit http://localhost:8000
$ npm run docker-prod:dev
# construction en production
$ npm run docker-prod:build
``` ```
### Utilisation de Gitpod ### Utilisation de Gitpod
@ -129,9 +115,8 @@ Toute forme de contribution est la bienvenue, voici quelques exemples de façons
- Soumettre des [issues](http://github.com/ant-design/ant-design-pro/issues) pour reporter les bugs ou poser des questions. - Soumettre des [issues](http://github.com/ant-design/ant-design-pro/issues) pour reporter les bugs ou poser des questions.
- Proposer des [pull requests](http://github.com/ant-design/ant-design-pro/pulls) pour améliorer notre code. - Proposer des [pull requests](http://github.com/ant-design/ant-design-pro/pulls) pour améliorer notre code.
<div align="center"> <div align="center">
<a href="https://www.netlify.com"> <a href="https://www.netlify.com">
<img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"/> <img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"/>
</a> </a>
</div> </div>

36
README.ja-JP.md

@ -77,32 +77,18 @@
### bash を使う方法 ### bash を使う方法
```bash ```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 $ yarn create umi # or npm create umi
$ cd ant-design-pro
$ npm install
$ npm start # http://localhost:8000 を開く
```
### Docker を使う方法
```bash
# プレビュー
$ docker pull antdesign/ant-design-pro
$ docker run -p 80:80 antdesign/ant-design-pro
# http://localhost を開く
# dev # Choose ant-design-pro:
$ npm run docker:dev Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
# build $ npm install
$ npm run docker:build $ npm start # http://localhost:8000 を開く
# production dev
$ npm run docker-prod:dev
# production build
$ npm run docker-prod:build
``` ```
### Gitpod を使う方法 ### Gitpod を使う方法
@ -135,4 +121,4 @@ Gitpod(GitHub 用の無料オンライン開発環境)でプロジェクト
<a href="https://www.netlify.com"> <a href="https://www.netlify.com">
<img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"/> <img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"/>
</a> </a>
</div> </div>

36
README.md

@ -79,32 +79,18 @@ We need your help: https://github.com/ant-design/ant-design-pro/issues/120
### Use bash ### Use bash
```bash ```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 -b v2 $ yarn create umi # or npm create umi
$ cd ant-design-pro
$ npm install
$ npm start # visit http://localhost:8000
```
### Use by docker
```bash
# preview
$ docker pull antdesign/ant-design-pro
$ docker run -p 80:80 antdesign/ant-design-pro
# open http://localhost
# dev # Choose ant-design-pro:
$ npm run docker:dev Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
# build $ npm install
$ npm run docker:build $ npm start # visit http://localhost:8000
# production dev
$ npm run docker-prod:dev
# production build
$ npm run docker-prod:build
``` ```
### Use Gitpod ### Use Gitpod
@ -135,4 +121,4 @@ Any type of contribution is welcome, here are some examples of how you may contr
<a href="https://www.netlify.com"> <a href="https://www.netlify.com">
<img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"/> <img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg"/>
</a> </a>
</div> </div>

12
README.ru-RU.md

@ -71,8 +71,16 @@ UI-решение "из коробки" для корпоративных при
## Использование ## Использование
```bash ```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 -b v2 $ yarn create umi # or npm create umi
$ cd ant-design-pro
# Choose ant-design-pro:
Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
$ npm install $ npm install
$ npm start # visit http://localhost:8000 $ npm start # visit http://localhost:8000
``` ```

36
README.tr-TR.md

@ -74,35 +74,19 @@ React ile kurumsal uygulamalar için taslak olarak geliştirilmiş kullanıma ha
## Kullanım ## Kullanım
### bash ile kullanım
```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 -b v2
$ cd ant-design-pro
$ npm install
$ npm start # visit http://localhost:8000
```
### Docker ile kullanım
```bash ```bash
# preview $ yarn create umi # or npm create umi
$ docker pull chenshuai2144/ant-design-pro
$ docker run -p 80:80 chenshuai2144/ant-design-pro
# open http://localhost
# dev
$ npm run docker:dev
# build
$ npm run docker:build
# Choose ant-design-pro:
Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
# production dev $ npm install
$ npm run docker-prod:dev $ npm start # visit http://localhost:8000
# production build
$ npm run docker-prod:build
``` ```
Daha fazla talimat için [dokümantasyon](http://pro.ant.design/docs/getting-started) sayfasına göz atın. Daha fazla talimat için [dokümantasyon](http://pro.ant.design/docs/getting-started) sayfasına göz atın.

36
README.zh-CN.md

@ -72,35 +72,19 @@
## 使用 ## 使用
### 使用命令行
```bash
$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1 -b v2
$ cd ant-design-pro
$ npm install
$ npm start # 访问 http://localhost:8000
```
### 使用 docker
```bash ```bash
# preview $ yarn create umi # or npm create umi
$ docker pull antdesign/ant-design-pro
$ docker run -p 80:80 antdesign/ant-design-pro
# open http://localhost
# dev
$ npm run docker:dev
# build
$ npm run docker:build
# Choose ant-design-pro:
Select the boilerplate type (Use arrow keys)
❯ ant-design-pro - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
app - Create project with a simple boilerplate, support typescript.
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.
# production dev $ npm install
$ npm run docker-prod:dev $ npm start # visit http://localhost:8000
// production build
$ npm run docker-prod:build
``` ```
更多信息请参考 [使用文档](http://pro.ant.design/docs/getting-started)。 更多信息请参考 [使用文档](http://pro.ant.design/docs/getting-started)。

2
config/plugin.config.ts

@ -63,7 +63,7 @@ export default (config: any) => {
// { // {
// antDir: path.join(__dirname, '../node_modules/antd'), // antDir: path.join(__dirname, '../node_modules/antd'),
// stylesDir, // stylesDir,
// varFile: path.join(__dirname, '../node_modules/antd/lib/style/themes/default.less'), // varFile: path.join(__dirname, '../node_modules/antd/es/style/themes/default.less'),
// mainLessFile: outFile, // themeVariables: ['@primary-color'], // mainLessFile: outFile, // themeVariables: ['@primary-color'],
// indexFileName: 'index.html', // indexFileName: 'index.html',
// generateOne: true, // generateOne: true,

4
docker/docker-compose.dev.yml

@ -1,4 +1,4 @@
version: "3.5" version: '3.5'
services: services:
ant-design-pro_dev: ant-design-pro_dev:
@ -7,7 +7,7 @@ services:
build: build:
context: ../ context: ../
dockerfile: Dockerfile.dev dockerfile: Dockerfile.dev
container_name: "ant-design-pro_dev" container_name: 'ant-design-pro_dev'
volumes: volumes:
- ../src:/usr/src/app/src - ../src:/usr/src/app/src
- ../config:/usr/src/app/config - ../config:/usr/src/app/config

5207
lambda/mock/index.js

File diff suppressed because it is too large

16
package.json

@ -20,11 +20,11 @@
"lint": "npm run lint:js && npm run lint:style && npm run lint:prettier", "lint": "npm run lint:js && npm run lint:style && npm run lint:prettier",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style && npm run tslint:fix", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
"lint:prettier": "check-prettier lint", "lint:prettier": "check-prettier lint",
"lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
"prettier": " check-prettier write", "prettier": "prettier -c --write '**/*'",
"site": "npm run fetch:blocks && npm run functions:build && umi build", "site": "npm run fetch:blocks && npm run functions:build && umi build",
"start": "umi dev", "start": "umi dev",
"start:no-mock": "cross-env MOCK=none umi dev", "start:no-mock": "cross-env MOCK=none umi dev",
@ -39,10 +39,11 @@
}, },
"lint-staged": { "lint-staged": {
"**/*.less": "stylelint --syntax less", "**/*.less": "stylelint --syntax less",
"**/*.{js,ts,tsx,md,json,jsx,less}": [ "**/*.{js,jsx,tsx,ts,less,md,json}": [
"npm run prettier", "prettier --write",
"git add" "git add"
], ],
"**/*.{js,jsx}": "npm run lint-staged:js",
"**/*.{js,ts,tsx}": "npm run lint-staged:js" "**/*.{js,ts,tsx}": "npm run lint-staged:js"
}, },
"browserslist": [ "browserslist": [
@ -73,11 +74,10 @@
"react-media": "^1.9.2", "react-media": "^1.9.2",
"react-media-hook2": "^1.0.5", "react-media-hook2": "^1.0.5",
"redux": "^4.0.1", "redux": "^4.0.1",
"umi": "^2.7.0-beta.2", "umi": "^2.7.2",
"umi-plugin-ga": "^1.1.3", "umi-plugin-ga": "^1.1.3",
"umi-plugin-locale": "^2.8.0-beta.1",
"umi-plugin-pro-block": "^1.3.2", "umi-plugin-pro-block": "^1.3.2",
"umi-plugin-react": "^1.8.0-beta.1", "umi-plugin-react": "^1.8.2",
"umi-request": "^1.0.7" "umi-request": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
@ -180,4 +180,4 @@
"create-umi" "create-umi"
] ]
} }
} }

28
src/components/CopyBlock/index.tsx

@ -3,6 +3,7 @@ import { Icon, Popover, Typography } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale'; import { FormattedMessage } from 'umi-plugin-react/locale';
import React from 'react'; import React from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { isAntDesignPro } from '@/utils/utils';
import styles from './index.less'; import styles from './index.less';
const firstUpperCase = (pathString: string): string => { const firstUpperCase = (pathString: string): string => {
@ -13,13 +14,38 @@ const firstUpperCase = (pathString: string): string => {
.filter((s): boolean => !!s) .filter((s): boolean => !!s)
.join(''); .join('');
}; };
// when click block copy, send block url to ga
const onBlockCopy = (label: string) => {
if (!isAntDesignPro()) {
return;
}
const ga =
window &&
(window as {
ga: Function;
}).ga;
if (ga) {
ga('send', 'event', {
eventCategory: 'block',
eventAction: 'copy',
eventLabel: label,
});
}
};
const BlockCodeView: React.SFC<{ const BlockCodeView: React.SFC<{
url: string; url: string;
}> = ({ url }) => { }> = ({ url }) => {
const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`; const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`;
return ( return (
<div className={styles['copy-block-view']}> <div className={styles['copy-block-view']}>
<Typography.Paragraph copyable={{ text: blockUrl }}> <Typography.Paragraph
copyable={{
text: blockUrl,
onCopy: () => onBlockCopy(url),
}}
>
<code className={styles['copy-block-code']}>{blockUrl}</code> <code className={styles['copy-block-code']}>{blockUrl}</code>
</Typography.Paragraph> </Typography.Paragraph>
</div> </div>

29
src/components/GlobalFooter/index.less

@ -1,29 +0,0 @@
@import '~antd/lib/style/themes/default.less';
.globalFooter {
margin: 48px 0 24px 0;
padding: 0 16px;
text-align: center;
.links {
margin-bottom: 8px;
a {
color: @text-color-secondary;
transition: all 0.3s;
&:not(:last-child) {
margin-right: 40px;
}
&:hover {
color: @text-color;
}
}
}
.copyright {
color: @text-color-secondary;
font-size: @font-size-base;
}
}

40
src/components/GlobalFooter/index.tsx

@ -1,40 +0,0 @@
import React from 'react';
import classNames from 'classnames';
import styles from './index.less';
export interface GlobalFooterProps {
links?: {
key?: string;
title: React.ReactNode;
href: string;
blankTarget?: boolean;
}[];
copyright?: React.ReactNode;
style?: React.CSSProperties;
className?: string;
}
const GlobalFooter: React.SFC<GlobalFooterProps> = ({ className, links, copyright }) => {
const clsString = classNames(styles.globalFooter, className);
return (
<footer className={clsString}>
{links && (
<div className={styles.links}>
{links.map(link => (
<a
key={link.key}
title={link.key}
target={link.blankTarget ? '_blank' : '_self'}
href={link.href}
>
{link.title}
</a>
))}
</div>
)}
{copyright && <div className={styles.copyright}>{copyright}</div>}
</footer>
);
};
export default GlobalFooter;

2
src/components/GlobalHeader/AvatarDropdown.tsx

@ -1,7 +1,7 @@
import { Avatar, Icon, Menu, Spin } from 'antd'; import { Avatar, Icon, Menu, Spin } from 'antd';
import { ConnectProps, ConnectState } from '@/models/connect'; import { ConnectProps, ConnectState } from '@/models/connect';
import { ClickParam } from 'antd/lib/menu'; import { ClickParam } from 'antd/es/menu';
import { CurrentUser } from '@/models/user'; import { CurrentUser } from '@/models/user';
import { FormattedMessage } from 'umi-plugin-react/locale'; import { FormattedMessage } from 'umi-plugin-react/locale';
import React from 'react'; import React from 'react';

2
src/components/GlobalHeader/index.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
@pro-header-hover-bg: rgba(0, 0, 0, 0.025); @pro-header-hover-bg: rgba(0, 0, 0, 0.025);

2
src/components/HeaderDropdown/index.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.container > * { .container > * {
background-color: #fff; background-color: #fff;

2
src/components/HeaderSearch/index.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.headerSearch { .headerSearch {
:global(.anticon-search) { :global(.anticon-search) {

2
src/components/NoticeIcon/NoticeList.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.list { .list {
max-height: 400px; max-height: 400px;

2
src/components/NoticeIcon/index.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.popover { .popover {
position: relative; position: relative;

2
src/components/SelectLang/index.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.menu { .menu {
:global(.anticon) { :global(.anticon) {

1
src/components/SelectLang/index.tsx

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

2
src/global.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
html, html,
body, body,

2
src/layouts/BasicLayout.tsx

@ -18,8 +18,8 @@ import Link from 'umi/link';
import RightContent from '@/components/GlobalHeader/RightContent'; import RightContent from '@/components/GlobalHeader/RightContent';
import { connect } from 'dva'; import { connect } from 'dva';
import { formatMessage } from 'umi-plugin-react/locale'; import { formatMessage } from 'umi-plugin-react/locale';
import logo from '../assets/logo.svg';
import { isAntDesignPro } from '@/utils/utils'; import { isAntDesignPro } from '@/utils/utils';
import logo from '../assets/logo.svg';
export interface BasicLayoutProps extends ProLayoutComponentsProps, ConnectProps { export interface BasicLayoutProps extends ProLayoutComponentsProps, ConnectProps {
breadcrumbNameMap: { breadcrumbNameMap: {

2
src/layouts/UserLayout.less

@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less'; @import '~antd/es/style/themes/default.less';
.container { .container {
display: flex; display: flex;

49
src/layouts/UserLayout.tsx

@ -1,43 +1,17 @@
import { MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout'; import { ConnectProps, ConnectState } from '@/models/connect';
import React, { Fragment } from 'react'; import { DefaultFooter, MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout';
import { ConnectProps } from '@/models/connect';
import DocumentTitle from 'react-document-title'; import DocumentTitle from 'react-document-title';
import GlobalFooter from '@/components/GlobalFooter';
import { Icon } from 'antd';
import Link from 'umi/link'; import Link from 'umi/link';
import React from 'react';
import SelectLang from '@/components/SelectLang'; import SelectLang from '@/components/SelectLang';
import { formatMessage } from 'umi-plugin-locale'; import { connect } from 'dva';
import { formatMessage } from 'umi-plugin-react/locale';
import logo from '../assets/logo.svg'; import logo from '../assets/logo.svg';
import styles from './UserLayout.less'; import styles from './UserLayout.less';
const links = [
{
key: 'help',
title: formatMessage({ id: 'layout.user.link.help' }),
href: '',
},
{
key: 'privacy',
title: formatMessage({ id: 'layout.user.link.privacy' }),
href: '',
},
{
key: 'terms',
title: formatMessage({ id: 'layout.user.link.terms' }),
href: '',
},
];
const copyright = (
<Fragment>
Copyright <Icon type="copyright" /> 2019
</Fragment>
);
export interface UserLayoutProps extends ConnectProps { export interface UserLayoutProps extends ConnectProps {
breadcrumbNameMap: { [path: string]: MenuDataItem }; breadcrumbNameMap: { [path: string]: MenuDataItem };
navTheme: 'dark' | 'light';
} }
const UserLayout: React.SFC<UserLayoutProps> = props => { const UserLayout: React.SFC<UserLayoutProps> = props => {
@ -45,19 +19,23 @@ const UserLayout: React.SFC<UserLayoutProps> = props => {
route = { route = {
routes: [], routes: [],
}, },
} = props;
const { routes = [] } = route;
const {
children, children,
location = { location = {
pathname: '', pathname: '',
}, },
} = props; } = props;
const { routes = [] } = route;
const { breadcrumb } = getMenuData(routes, props); const { breadcrumb } = getMenuData(routes, props);
return ( return (
<DocumentTitle <DocumentTitle
title={getPageTitle({ title={getPageTitle({
pathname: location.pathname, pathname: location.pathname,
breadcrumb, breadcrumb,
formatMessage, formatMessage,
...props,
})} })}
> >
<div className={styles.container}> <div className={styles.container}>
@ -76,9 +54,12 @@ const UserLayout: React.SFC<UserLayoutProps> = props => {
</div> </div>
{children} {children}
</div> </div>
<GlobalFooter links={links} copyright={copyright} /> <DefaultFooter />
</div> </div>
</DocumentTitle> </DocumentTitle>
); );
}; };
export default UserLayout;
export default connect(({ settings }: ConnectState) => ({
...settings,
}))(UserLayout);

8
src/models/setting.ts

@ -1,7 +1,7 @@
import { Reducer } from 'redux';
// eslint-disable-next-line eslint-comments/disable-enable-pair // eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable promise/catch-or-return */ /* eslint-disable promise/catch-or-return */
import { message } from 'antd'; import { message } from 'antd';
import { Reducer } from 'redux';
import defaultSettings, { DefaultSettings } from '../../config/defaultSettings'; import defaultSettings, { DefaultSettings } from '../../config/defaultSettings';
import themeColorClient from '../components/SettingDrawer/themeColorClient'; import themeColorClient from '../components/SettingDrawer/themeColorClient';
@ -107,7 +107,7 @@ const SettingModel: SettingModelType = {
}); });
const { primaryColor, colorWeak } = setting; const { primaryColor, colorWeak } = setting;
if (state.primaryColor !== primaryColor) { if (primaryColor && state.primaryColor !== primaryColor) {
updateTheme(primaryColor); updateTheme(primaryColor);
} }
updateColorWeak(!!colorWeak); updateColorWeak(!!colorWeak);
@ -136,13 +136,13 @@ const SettingModel: SettingModelType = {
} }
}); });
const { primaryColor, colorWeak, contentWidth } = payload; const { primaryColor, colorWeak, contentWidth } = payload;
if (state.primaryColor !== primaryColor) { if (primaryColor && state.primaryColor !== primaryColor) {
updateTheme(primaryColor); updateTheme(primaryColor);
} }
if (state.contentWidth !== contentWidth && window.dispatchEvent) { if (state.contentWidth !== contentWidth && window.dispatchEvent) {
window.dispatchEvent(new Event('resize')); window.dispatchEvent(new Event('resize'));
} }
updateColorWeak(colorWeak); updateColorWeak(!!colorWeak);
window.history.replaceState(null, 'setting', urlParams.href); window.history.replaceState(null, 'setting', urlParams.href);
return { return {
...state, ...state,

4
src/pages/Welcome.tsx

@ -3,8 +3,8 @@ import React from 'react';
export default (): React.ReactNode => ( export default (): React.ReactNode => (
<p style={{ textAlign: 'center' }}> <p style={{ textAlign: 'center' }}>
Want to add more pages? Please refer to{' '} Want to add more pages? Please refer to{' '}
<a href="https://umijs.org/guide/block.html" target="_blank" rel="noopener noreferrer"> <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
umi block use block
</a> </a>
</p> </p>

10
src/pages/document.ejs

@ -30,18 +30,16 @@
font-variant: tabular-nums; font-variant: tabular-nums;
line-height: 1.5; line-height: 1.5;
list-style: none; list-style: none;
-webkit-font-feature-settings: "tnum"; -webkit-font-feature-settings: 'tnum';
font-feature-settings: "tnum"; font-feature-settings: 'tnum';
position: absolute; position: absolute;
display: none; display: none;
color: #1890ff; color: #1890ff;
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
opacity: 0; opacity: 0;
-webkit-transition: -webkit-transform 0.3s -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: -webkit-transform 0.3s
cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86), transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
-webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);

1
src/typings.d.ts

@ -21,6 +21,7 @@ declare module '@antv/data-set';
declare module 'nzh/cn'; declare module 'nzh/cn';
declare module 'webpack-theme-color-replacer'; declare module 'webpack-theme-color-replacer';
declare let ga: Function;
// preview.pro.ant.design only do not use in your production ; // preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
declare let ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: 'site' | undefined; declare let ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: 'site' | undefined;

Loading…
Cancel
Save