diff --git a/.eslintignore b/.eslintignore
index 43ab7824efa0352bbcbffde924c60fb1d2634518..c1fcbb8a79c1eb2990b138469a6d86f8e02eefda 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,3 @@
-/functions/mock/**
+/lambda/mock/**
/scripts
-/config
\ No newline at end of file
+/config
diff --git a/.eslintrc.js b/.eslintrc.js
index 10309cef189855ac5cc6c46feabf83e56731e2f6..aeeca68fee6a891c9a1719140228cc0ef8d44598 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -34,6 +34,6 @@ module.exports = {
'linebreak-style': 0,
},
settings: {
- polyfills: ['fetch', 'promises', 'url'],
+ polyfills: ['fetch', 'promises', 'url', 'object-assign'],
},
};
diff --git a/.firebaserc b/.firebaserc
deleted file mode 100644
index e3a9a50c8a53831595f67ab41862f94d8f050bd0..0000000000000000000000000000000000000000
--- a/.firebaserc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "projects": {
- "default": "antd-pro"
- }
-}
diff --git a/.gitignore b/.gitignore
index 2859215803d95b14b51d6618bf9cc99587b99aa1..253591b5200c5227e85ef7fa1ea33a5279a4deaa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,8 +25,8 @@ package-lock.json
# visual studio code
.history
*.log
-
-functions/mock
+functions/*
+lambda/mock/index.js
.temp/**
# umi
diff --git a/README.md b/README.md
index ce0725dfd5b671fde4dcc894108b4f8a997fe027..c6da6474c5ce12b04bd107d4eb5b3c74dd804b6d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-English | [简体中文](./README.zh-CN.md) | [Русский](./README.ru-RU.md)
+English | [简体中文](./README.zh-CN.md) | [Русский](./README.ru-RU.md) | [Türkçe](./README.tr-TR.md)
+
+React ile kurumsal uygulamalar için taslak olarak geliştirilmiş kullanıma hazır bir UI çözümü.
+
+[![CircleCI Status](https://circleci.com/gh/ant-design/ant-design-pro.svg?style=svg)](https://circleci.com/gh/ant-design/ant-design-pro/)
+[![Build status](https://ci.appveyor.com/api/projects/status/67fxu2by3ibvqtat/branch/master?svg=true)](https://ci.appveyor.com/project/afc163/ant-design-pro/branch/master)
+[![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro)
+[![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev)
+[![Gitter](https://img.shields.io/gitter/room/ant-design/pro-english.svg)](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)(🇺🇸)
+[![Gitter](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)(🇨🇳)
+[![Netlify Status](https://api.netlify.com/api/v1/badges/b68e9850-a529-4364-9d3b-d70aade560f9/deploy-status)](https://app.netlify.com/sites/ant-design-pro/deploys)
+![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png)
+
+
+
+- Önizleme: http://preview.pro.ant.design
+- Anasayfa: http://pro.ant.design
+- Dokümantasyon: http://pro.ant.design/docs/getting-started
+- ChangeLog: http://pro.ant.design/docs/changelog
+- SSS: http://pro.ant.design/docs/faq
+- Çinde barındırılan site: http://ant-design-pro.gitee.io
+
+## 2.0 Versiyonu Şimdi Yayında! 🎉🎉🎉
+[Announcing Ant Design Pro 2.0.0](https://medium.com/ant-design/beautiful-and-powerful-ant-design-pro-2-0-release-51358da5af95)
+
+## Çeviri Desteği :loudspeaker:
+
+Çeviriler için yardımınıza ihtiyacımız var: https://github.com/ant-design/ant-design-pro/issues/120
+
+## Özellikler
+
+- :gem: **Zarif Tasarım**: Buradan [Ant Design özellikleri](http://ant.design/)
+- :triangular_ruler: **Ortak Şablonlar**: Kurumsal uygulamalar için şablonlar
+- :rocket: **Sanatsal gelişim durumu**: Newest development stack of React/umi/dva/antd
+- :iphone: **Responsive**: Değişken ekran boyutları için tasarlanmıştır
+- :art: **Tema Kullanımı**: Basit ayarlar ile özelleştirilebilir tema
+- :globe_with_meridians: **Uluslararası**: Built-in i18n solution
+- :gear: **Best Practices**: İyi kod için sağlam iş akışı
+- :1234: **Mock Geliştirme**: Model(Mock) geliştirmeler için kolay çözüm
+- :white_check_mark: **UI Testi**: Unit ve e2e testleri ile güvenli sürdürülebilirlik
+
+## Şablonlar
+
+```
+- Dashboard
+ - Analitik
+ - Monitör
+ - Çalışma alanı
+- Form
+ - Basit Form
+ - Step Form
+ - Gelişmiş Form
+- List
+ - Standard Tablo
+ - Standard Liste
+ - Kart Liste
+ - Arama Listesi (Project/Applications/Article)
+- Profil
+ - Basit Profil
+ - Gelişmiş Profil
+- Hesap
+ - Hesap Yönetimi
+ - Hesap Ayarları
+- Sonuç
+ - Başarılı
+ - Hatalı
+- Hatalar
+ - 403
+ - 404
+ - 500
+- Kullanıcı
+ - Giriş
+ - Kayıt
+ - Kayıt Sonucu
+```
+
+## Kullanım
+
+### bash ile kullanım
+
+```bash
+$ git clone https://github.com/ant-design/ant-design-pro.git --depth=1
+$ cd ant-design-pro
+$ npm install
+$ npm start # visit http://localhost:8000
+```
+
+### Docker ile kullanım
+
+```bash
+# preview
+$ 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
+
+
+# production dev
+$ npm run docker-prod:dev
+
+# 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.
+
+## Tarayıcı desteği
+
+Modern internet tarayıcıları ve IE11.
+
+| [ {}
diff --git a/src/components/Authorized/AuthorizedRoute.d.ts b/src/components/Authorized/AuthorizedRoute.d.ts
index fc78000440d3ca375cadee4e581f51532c8c35bb..f94427daddeba278493bd49d1f90ecb47f74dde2 100644
--- a/src/components/Authorized/AuthorizedRoute.d.ts
+++ b/src/components/Authorized/AuthorizedRoute.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
import { RouteProps } from 'react-router';
type authorityFN = (currentAuthority?: string) => boolean;
diff --git a/src/components/Authorized/AuthorizedRoute.js b/src/components/Authorized/AuthorizedRoute.js
index 39c6a665f1bf522622ac73e2333f0739c587b1a2..a622ed381ac1b7e5c53851ec1c9cb66aad93ae88 100644
--- a/src/components/Authorized/AuthorizedRoute.js
+++ b/src/components/Authorized/AuthorizedRoute.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { Route, Redirect } from 'react-router-dom';
+import { Route, Redirect } from 'umi';
import Authorized from './Authorized';
// TODO: umi只会返回render和rest
diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js
index ba83f5b9a14ea01db4824df72db79eb91c19506b..4b49d1f877843694db238b280c3986b612db4e43 100644
--- a/src/components/Authorized/CheckPermissions.js
+++ b/src/components/Authorized/CheckPermissions.js
@@ -2,21 +2,13 @@ import React from 'react';
import PromiseRender from './PromiseRender';
import { CURRENT } from './renderAuthorize';
-function isPromise(obj) {
- return (
- !!obj &&
- (typeof obj === 'object' || typeof obj === 'function') &&
- typeof obj.then === 'function'
- );
-}
-
/**
* 通用权限检查方法
* Common check permissions method
- * @param { 权限判定 Permission judgment type string |array | Promise | Function } authority
- * @param { 你的权限 Your permission description type:string} currentAuthority
- * @param { 通过的组件 Passing components } target
- * @param { 未通过的组件 no pass components } Exception
+ * @param { 权限判定 | Permission judgment } authority
+ * @param { 你的权限 | Your permission description } currentAuthority
+ * @param { 通过的组件 | Passing components } target
+ * @param { 未通过的组件 | no pass components } Exception
*/
const checkPermissions = (authority, currentAuthority, target, Exception) => {
// 没有判定权限.默认查看所有
@@ -26,47 +18,36 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
}
// 数组处理
if (Array.isArray(authority)) {
- if (authority.indexOf(currentAuthority) >= 0) {
- return target;
- }
if (Array.isArray(currentAuthority)) {
- for (let i = 0; i < currentAuthority.length; i += 1) {
- const element = currentAuthority[i];
- if (authority.indexOf(element) >= 0) {
- return target;
- }
+ if (currentAuthority.some(item => authority.includes(item))) {
+ return target;
}
+ } else if (authority.includes(currentAuthority)) {
+ return target;
}
return Exception;
}
-
// string 处理
if (typeof authority === 'string') {
- if (authority === currentAuthority) {
- return target;
- }
if (Array.isArray(currentAuthority)) {
- for (let i = 0; i < currentAuthority.length; i += 1) {
- const element = currentAuthority[i];
- if (authority === element) {
- return target;
- }
+ if (currentAuthority.some(item => authority === item)) {
+ return target;
}
+ } else if (authority === currentAuthority) {
+ return target;
}
return Exception;
}
-
// Promise 处理
- if (isPromise(authority)) {
+ if (authority instanceof Promise) {
return ;
}
-
// Function 处理
if (typeof authority === 'function') {
try {
const bool = authority(currentAuthority);
// 函数执行后返回值是 Promise
- if (isPromise(bool)) {
+ if (bool instanceof Promise) {
return ;
}
if (bool) {
diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js
index 8e2a4059d8689ca1e0be623aedd14cc9a2d75134..58de65934a64dab00013d1b61eb9fa731f758e34 100644
--- a/src/components/Authorized/PromiseRender.js
+++ b/src/components/Authorized/PromiseRender.js
@@ -1,7 +1,9 @@
-import React from 'react';
import { Spin } from 'antd';
+import isEqual from 'lodash/isEqual';
+import React from 'react';
+import { isComponentClass } from './Secured';
-export default class PromiseRender extends React.PureComponent {
+export default class PromiseRender extends React.Component {
state = {
component: null,
};
@@ -10,10 +12,14 @@ export default class PromiseRender extends React.PureComponent {
this.setRenderComponent(this.props);
}
- componentDidUpdate(nextProps) {
- // new Props enter
- this.setRenderComponent(nextProps);
- }
+ shouldComponentUpdate = (nextProps, nextState) => {
+ const { component } = this.state;
+ if (!isEqual(nextProps, this.props)) {
+ this.setRenderComponent(nextProps);
+ }
+ if (nextState.component !== component) return true;
+ return false;
+ };
// set render Component : ok or error
setRenderComponent(props) {
@@ -37,8 +43,12 @@ export default class PromiseRender extends React.PureComponent {
// Authorized render is already instantiated, children is no instantiated
// Secured is not instantiated
checkIsInstantiation = target => {
- if (!React.isValidElement(target)) {
- return target;
+ if (isComponentClass(target)) {
+ const Target = target;
+ return props => ;
+ }
+ if (React.isValidElement(target)) {
+ return props => React.cloneElement(target, props);
}
return () => target;
};
diff --git a/src/components/Authorized/Secured.js b/src/components/Authorized/Secured.js
index c935183dac25c82786336cef97cc905220153271..25b961f01649cc232531f800e89bb46959820032 100644
--- a/src/components/Authorized/Secured.js
+++ b/src/components/Authorized/Secured.js
@@ -1,31 +1,43 @@
import React from 'react';
import Exception from '../Exception';
import CheckPermissions from './CheckPermissions';
+
/**
* 默认不能访问任何页面
* default is "NULL"
*/
const Exception403 = () => ;
+export const isComponentClass = component => {
+ if (!component) return false;
+ const proto = Object.getPrototypeOf(component);
+ if (proto === React.Component || proto === Function.prototype) return true;
+ return isComponentClass(proto);
+};
+
// Determine whether the incoming component has been instantiated
// AuthorizedRoute is already instantiated
// Authorized render is already instantiated, children is no instantiated
// Secured is not instantiated
const checkIsInstantiation = target => {
- if (!React.isValidElement(target)) {
- return target;
+ if (isComponentClass(target)) {
+ const Target = target;
+ return props => ;
+ }
+ if (React.isValidElement(target)) {
+ return props => React.cloneElement(target, props);
}
return () => target;
};
/**
- * 用于判断是否拥有权限访问此view权限
- * authority 支持传入 string, function:()=>boolean|Promise
- * e.g. 'user' 只有user用户能访问
- * e.g. 'user,admin' user和 admin 都能访问
+ * 用于判断是否拥有权限访问此 view 权限
+ * authority 支持传入 string, () => boolean | Promise
+ * e.g. 'user' 只有 user 用户能访问
+ * e.g. 'user,admin' user 和 admin 都能访问
* e.g. ()=>boolean 返回true能访问,返回false不能访问
* e.g. Promise then 能访问 catch不能访问
- * e.g. authority support incoming string, function: () => boolean | Promise
+ * e.g. authority support incoming string, () => boolean | Promise
* e.g. 'user' only user user can access
* e.g. 'user, admin' user and admin can access
* e.g. () => boolean true to be able to visit, return false can not be accessed
diff --git a/src/components/Authorized/demo/secured.md b/src/components/Authorized/demo/secured.md
index 1e9537af19d3613b9ea6684f8933afa283ba1415..1999852fd609c5aba9475a40caf9d15d3c111ee5 100644
--- a/src/components/Authorized/demo/secured.md
+++ b/src/components/Authorized/demo/secured.md
@@ -16,7 +16,9 @@ const { Secured } = RenderAuthorized('user');
@Secured('admin')
class TestSecuredString extends React.Component {
render() {
- ;
+ return (
+
+ )
}
}
ReactDOM.render(
diff --git a/src/components/Authorized/index.d.ts b/src/components/Authorized/index.d.ts
index b3e2f56c6c3784daa62e908286566c954db1675f..72c98587979899e0f172cf48637c6ab4bb3951e8 100644
--- a/src/components/Authorized/index.d.ts
+++ b/src/components/Authorized/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
import AuthorizedRoute, { authority } from './AuthorizedRoute';
export type IReactComponent =
| React.StatelessComponent
diff --git a/src/components/AvatarList/AvatarItem.d.ts b/src/components/AvatarList/AvatarItem.d.ts
index 5681de77c2b3634ee8a54487fe15d07044fa8ca4..0e809ab458db93321d68388f227e46cd6a34e411 100644
--- a/src/components/AvatarList/AvatarItem.d.ts
+++ b/src/components/AvatarList/AvatarItem.d.ts
@@ -1,10 +1,15 @@
-import * as React from 'react';
-export interface IAvatarItemProps {
+import React from 'react';
+
+export declare type SizeType = number | 'small' | 'default' | 'large';
+
+export interface AvatarItemProps {
tips: React.ReactNode;
src: string;
+ size?: SizeType;
style?: React.CSSProperties;
+ onClick?: () => void;
}
-export default class AvatarItem extends React.Component {
- constructor(props: IAvatarItemProps);
+export default class AvatarItem extends React.Component {
+ constructor(props: AvatarItemProps);
}
diff --git a/src/components/AvatarList/index.d.ts b/src/components/AvatarList/index.d.ts
index f49ca010d9fe19febd4eaed391278012109dd444..e454a8be4e4d0f6bd9d77fa66fd9c8c7447964aa 100644
--- a/src/components/AvatarList/index.d.ts
+++ b/src/components/AvatarList/index.d.ts
@@ -1,14 +1,14 @@
-import * as React from 'react';
-import AvatarItem from './AvatarItem';
+import React from 'react';
+import AvatarItem, { AvatarItemProps, SizeType } from './AvatarItem';
-export interface IAvatarListProps {
- size?: 'large' | 'small' | 'mini' | 'default';
+export interface AvatarListProps {
+ Item?: React.ReactElement;
+ size?: SizeType;
maxLength?: number;
excessItemsStyle?: React.CSSProperties;
style?: React.CSSProperties;
- children: React.ReactElement | Array>;
+ children: React.ReactElement | Array>;
}
-
-export default class AvatarList extends React.Component {
+export default class AvatarList extends React.Component {
public static Item: typeof AvatarItem;
}
diff --git a/src/components/Charts/AsyncLoadBizCharts.js b/src/components/Charts/AsyncLoadBizCharts.js
deleted file mode 100644
index 8d9a2cd059b692da7a7848f71c269610a9d534c1..0000000000000000000000000000000000000000
--- a/src/components/Charts/AsyncLoadBizCharts.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import React from 'react';
-import PageLoading from '../PageLoading';
-import { importCDN } from '@/utils/utils';
-
-let isLoaderBizChart = false;
-const loadBizCharts = async () => {
- if (isLoaderBizChart) {
- return Promise.resolve(true);
- }
- await Promise.all([
- importCDN('//gw.alipayobjects.com/os/lib/bizcharts/3.4.3/umd/BizCharts.min.js'),
- importCDN('//gw.alipayobjects.com/os/lib/antv/data-set/0.10.1/dist/data-set.min.js'),
- ]);
- // eslint-disable-next-line no-console
- console.log('bizCharts load success');
- isLoaderBizChart = true;
- return Promise.resolve(true);
-};
-
-class AsyncLoadBizCharts extends React.Component {
- state = {
- loading: !isLoaderBizChart,
- };
-
- async componentDidMount() {
- await loadBizCharts();
- requestAnimationFrame(() => {
- this.setState({
- loading: false,
- });
- });
- }
-
- render() {
- const { children } = this.props;
- const { loading } = this.state;
- if (!loading) {
- return children;
- }
- return ;
- }
-}
-
-export { loadBizCharts, AsyncLoadBizCharts };
diff --git a/src/components/Charts/Bar/index.d.ts b/src/components/Charts/Bar/index.d.ts
index 4899082509dacb84701bb2e02fbe69ba1d06e149..67bb1dd0cd4a4f39880bf67f62534d2e1883d732 100644
--- a/src/components/Charts/Bar/index.d.ts
+++ b/src/components/Charts/Bar/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IBarProps {
title: React.ReactNode;
color?: string;
diff --git a/src/components/Charts/ChartCard/index.d.ts b/src/components/Charts/ChartCard/index.d.ts
index 0437c0c857d7f1c63c506c5eb238583a251714d0..5153f5e062589a1b650cd63a79577aaa3dfdd8ea 100644
--- a/src/components/Charts/ChartCard/index.d.ts
+++ b/src/components/Charts/ChartCard/index.d.ts
@@ -1,5 +1,5 @@
import { CardProps } from 'antd/lib/card';
-import * as React from 'react';
+import React from 'react';
export interface IChartCardProps extends CardProps {
title: React.ReactNode;
diff --git a/src/components/Charts/Field/index.d.ts b/src/components/Charts/Field/index.d.ts
index 975fb667d8db178c1154162f4803e20f1c72a8e4..80b1bf1d7198e5710a8b06435eadd72d327ab895 100644
--- a/src/components/Charts/Field/index.d.ts
+++ b/src/components/Charts/Field/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IFieldProps {
label: React.ReactNode;
value: React.ReactNode;
diff --git a/src/components/Charts/Gauge/index.d.ts b/src/components/Charts/Gauge/index.d.ts
index 66e3c003a957581d88a06e63b32a7a3e76c5cd3a..fe5500918c7173834922d68f2a1f5306f43fe7da 100644
--- a/src/components/Charts/Gauge/index.d.ts
+++ b/src/components/Charts/Gauge/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IGaugeProps {
title: React.ReactNode;
color?: string;
diff --git a/src/components/Charts/Gauge/index.js b/src/components/Charts/Gauge/index.js
index 2249211aeaad53652d578c8dc050a60795129b68..e97f126e6e42b00b131ebdbdbe63fc8de0da70fa 100644
--- a/src/components/Charts/Gauge/index.js
+++ b/src/components/Charts/Gauge/index.js
@@ -146,7 +146,7 @@ class Gauge extends React.Component {
${title}
- ${data[0].value * 10}%
+ ${(data[0].value * 10).toFixed(2)}%
`}
/>
diff --git a/src/components/Charts/MiniArea/index.d.ts b/src/components/Charts/MiniArea/index.d.ts
index b223b68ca097e01f1c76e4e2cb4e95e9db4dc39b..8b4e71cab78e8ecdaf1f49559957660e9fc77547 100644
--- a/src/components/Charts/MiniArea/index.d.ts
+++ b/src/components/Charts/MiniArea/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
// g2已经更新到3.0
// 不带的写了
diff --git a/src/components/Charts/MiniBar/index.d.ts b/src/components/Charts/MiniBar/index.d.ts
index 0c4bd6cce558f4b948691c553c65d76c8c34fc6b..b2685339eab30833120979e1356c3913654c8305 100644
--- a/src/components/Charts/MiniBar/index.d.ts
+++ b/src/components/Charts/MiniBar/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IMiniBarProps {
color?: string;
height: number;
diff --git a/src/components/Charts/MiniProgress/index.d.ts b/src/components/Charts/MiniProgress/index.d.ts
index aaeb7261d7ea06dfad935faf7c00238035ea921d..6111d88d585000899875e83ec11e4fe9072fe84e 100644
--- a/src/components/Charts/MiniProgress/index.d.ts
+++ b/src/components/Charts/MiniProgress/index.d.ts
@@ -1,6 +1,7 @@
-import * as React from 'react';
+import React from 'react';
export interface IMiniProgressProps {
target: number;
+ targetLabel: string;
color?: string;
strokeWidth?: number;
percent?: number;
diff --git a/src/components/Charts/MiniProgress/index.js b/src/components/Charts/MiniProgress/index.js
index 795c79b15951e2bdde85c0a6fa1427ba46c8df1c..dd5712e8a850c8acbd41d959d73f17a96ecb65eb 100644
--- a/src/components/Charts/MiniProgress/index.js
+++ b/src/components/Charts/MiniProgress/index.js
@@ -1,27 +1,34 @@
import React from 'react';
import { Tooltip } from 'antd';
-
import styles from './index.less';
-const MiniProgress = ({ target, color = 'rgb(19, 194, 194)', strokeWidth, percent }) => (
-
-
-
-
-
+const MiniProgress = ({
+ targetLabel,
+ target,
+ color = 'rgb(19, 194, 194)',
+ strokeWidth,
+ percent,
+}) => {
+ return (
+
-);
+ );
+};
export default MiniProgress;
diff --git a/src/components/Charts/MiniProgress/index.less b/src/components/Charts/MiniProgress/index.less
index 40ba70be6bd3d4fb2a52efc34582c6ad81346e37..e1e0b4fc5169615814efe60821f39dc3e1bc58b9 100644
--- a/src/components/Charts/MiniProgress/index.less
+++ b/src/components/Charts/MiniProgress/index.less
@@ -19,6 +19,8 @@
position: absolute;
top: 0;
bottom: 0;
+ z-index: 9;
+ width: 20px;
span {
position: absolute;
top: 0;
diff --git a/src/components/Charts/Pie/index.d.ts b/src/components/Charts/Pie/index.d.ts
index 66c93eeb5d856928697335530c090c68492e81a5..63aecfa3d699f2148ca776b50f11f22387466ec3 100644
--- a/src/components/Charts/Pie/index.d.ts
+++ b/src/components/Charts/Pie/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IPieProps {
animate?: boolean;
color?: string;
diff --git a/src/components/Charts/Radar/index.d.ts b/src/components/Charts/Radar/index.d.ts
index 963ac8c37c112c360cd399b039d790e53b83a2a3..6a7dd42afe22ba23cbf0050f7334e3d2e383850a 100644
--- a/src/components/Charts/Radar/index.d.ts
+++ b/src/components/Charts/Radar/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IRadarProps {
title?: React.ReactNode;
height: number;
diff --git a/src/components/Charts/TagCloud/index.d.ts b/src/components/Charts/TagCloud/index.d.ts
index 462650c4dbb7532670d200141f7cbebc52525808..ac25269dfe1c414148bbcdcada429b978c3011a4 100644
--- a/src/components/Charts/TagCloud/index.d.ts
+++ b/src/components/Charts/TagCloud/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface ITagCloudProps {
data: Array<{
name: string;
diff --git a/src/components/Charts/TagCloud/index.js b/src/components/Charts/TagCloud/index.js
index d94699bd551c0c33319bd3d61eac2c4edb613bbe..4898d821a3f9282fdce7d1bb05e85c8e6f7a71d2 100644
--- a/src/components/Charts/TagCloud/index.js
+++ b/src/components/Charts/TagCloud/index.js
@@ -51,20 +51,16 @@ class TagCloud extends Component {
initTagCloud = () => {
function getTextAttrs(cfg) {
- return Object.assign(
- {},
- {
- fillOpacity: cfg.opacity,
- fontSize: cfg.origin._origin.size,
- rotate: cfg.origin._origin.rotate,
- text: cfg.origin._origin.text,
- textAlign: 'center',
- fontFamily: cfg.origin._origin.font,
- fill: cfg.color,
- textBaseline: 'Alphabetic',
- },
- cfg.style
- );
+ return Object.assign({}, cfg.style, {
+ fillOpacity: cfg.opacity,
+ fontSize: cfg.origin._origin.size,
+ rotate: cfg.origin._origin.rotate,
+ text: cfg.origin._origin.text,
+ textAlign: 'center',
+ fontFamily: cfg.origin._origin.font,
+ fill: cfg.color,
+ textBaseline: 'Alphabetic',
+ });
}
// 给point注册一个词云的shape
diff --git a/src/components/Charts/TimelineChart/index.d.ts b/src/components/Charts/TimelineChart/index.d.ts
index 40b94325a9833e9479846b323387e6515160fb7e..0f547e7736c807790f4b4581262b83c27266a1e0 100644
--- a/src/components/Charts/TimelineChart/index.d.ts
+++ b/src/components/Charts/TimelineChart/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface ITimelineChartProps {
data: Array<{
x: number;
diff --git a/src/components/Charts/WaterWave/index.d.ts b/src/components/Charts/WaterWave/index.d.ts
index 8f5588d29f29baa7a5409eded24fb2cbe82e1c53..e30a7e48f7478618e716757b095929c889797db7 100644
--- a/src/components/Charts/WaterWave/index.d.ts
+++ b/src/components/Charts/WaterWave/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface IWaterWaveProps {
title: React.ReactNode;
color?: string;
diff --git a/src/components/Charts/index.js b/src/components/Charts/index.js
index 56a1c565f4a162f4ef0cee14b39116596ed9a9f0..294eeb65f430ea18af184fc27ba9f2d11c188d47 100644
--- a/src/components/Charts/index.js
+++ b/src/components/Charts/index.js
@@ -1,28 +1,16 @@
-import React, { Suspense } from 'react';
import numeral from 'numeral';
import ChartCard from './ChartCard';
import Field from './Field';
-
-const getComponent = Component => {
- return props => {
- return (
-
-
-
- );
- };
-};
-
-const Bar = getComponent(React.lazy(() => import('./Bar')));
-const Pie = getComponent(React.lazy(() => import('./Pie')));
-const Radar = getComponent(React.lazy(() => import('./Radar')));
-const Gauge = getComponent(React.lazy(() => import('./Gauge')));
-const MiniArea = getComponent(React.lazy(() => import('./MiniArea')));
-const MiniBar = getComponent(React.lazy(() => import('./MiniBar')));
-const MiniProgress = getComponent(React.lazy(() => import('./MiniProgress')));
-const WaterWave = getComponent(React.lazy(() => import('./WaterWave')));
-const TagCloud = getComponent(React.lazy(() => import('./TagCloud')));
-const TimelineChart = getComponent(React.lazy(() => import('./TimelineChart')));
+import Bar from './Bar';
+import Pie from './Pie';
+import Radar from './Radar';
+import Gauge from './Gauge';
+import MiniArea from './MiniArea';
+import MiniBar from './MiniBar';
+import MiniProgress from './MiniProgress';
+import WaterWave from './WaterWave';
+import TagCloud from './TagCloud';
+import TimelineChart from './TimelineChart';
const yuan = val => `¥ ${numeral(val).format('0,0')}`;
diff --git a/src/components/CountDown/index.d.ts b/src/components/CountDown/index.d.ts
index d39a2e951830d5cddca08c8becbdb500847448b3..af658e3f6c4b0af3dfd7e374bc3d247c9577a5c4 100644
--- a/src/components/CountDown/index.d.ts
+++ b/src/components/CountDown/index.d.ts
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
export interface ICountDownProps {
format?: (time: number) => void;
target: Date | number;
diff --git a/src/components/DescriptionList/Description.d.ts b/src/components/DescriptionList/Description.d.ts
index 2a17be374accc8e2a1ffa9812327398a6c3f7173..41c0497075fe1178108e9903b4eb0d56c9e93fcc 100644
--- a/src/components/DescriptionList/Description.d.ts
+++ b/src/components/DescriptionList/Description.d.ts
@@ -1,9 +1,11 @@
-import * as React from 'react';
+import React from 'react';
+import { ColProps } from 'antd/es/col';
-export default class Description extends React.Component<
- {
- term: React.ReactNode;
- style?: React.CSSProperties;
- },
- any
-> {}
+export interface DescriptionProps extends ColProps {
+ column?: number;
+ key?: string | number;
+ style?: React.CSSProperties;
+ term?: React.ReactNode;
+}
+
+export default class Description extends React.Component
{}
diff --git a/src/components/DescriptionList/index.d.ts b/src/components/DescriptionList/index.d.ts
index 96ccfa7da3a21d790e3348a65603488303780669..c0bb071c5a33fe6d593b1722ffe707667c65cc60 100644
--- a/src/components/DescriptionList/index.d.ts
+++ b/src/components/DescriptionList/index.d.ts
@@ -1,15 +1,17 @@
-import * as React from 'react';
-import Description from './Description';
+import React from 'react';
+import Description, { DescriptionProps } from './Description';
-export interface IDescriptionListProps {
- layout?: 'horizontal' | 'vertical';
+export interface DescriptionListProps {
+ className?: string;
col?: number;
- title: React.ReactNode;
+ description?: DescriptionProps[];
gutter?: number;
+ layout?: 'horizontal' | 'vertical';
size?: 'large' | 'small';
style?: React.CSSProperties;
+ title?: React.ReactNode;
}
-export default class DescriptionList extends React.Component {
+export default class DescriptionList extends React.Component {
public static Description: typeof Description;
}
diff --git a/src/components/DescriptionList/index.less b/src/components/DescriptionList/index.less
index 4048a128ee949cfd5c8ab94ea5b5c331cd1bb22b..c3cf8e69e7cd0269f359b20fa73e868a7e87182b 100644
--- a/src/components/DescriptionList/index.less
+++ b/src/components/DescriptionList/index.less
@@ -8,6 +8,14 @@
overflow: hidden;
}
}
+ // fix margin top error of following descriptionList
+ & + & {
+ :global {
+ .ant-row {
+ margin-top: 16px;
+ }
+ }
+ }
.title {
margin-bottom: 16px;
@@ -47,6 +55,14 @@
margin-bottom: -8px;
}
}
+ // fix margin top error of following descriptionList
+ & + .descriptionList {
+ :global {
+ .ant-row {
+ margin-top: 8px;
+ }
+ }
+ }
.title {
margin-bottom: 12px;
color: @text-color;
diff --git a/src/components/EditableItem/index.d.ts b/src/components/EditableItem/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..fc69b2748fe5f406a56d6ece4d635e4e52d03e97
--- /dev/null
+++ b/src/components/EditableItem/index.d.ts
@@ -0,0 +1,7 @@
+import React from 'react';
+
+export interface EditableItemProps {
+ onChange?: (value?: string | string[] | number) => void;
+}
+
+export default class EditableItem extends React.Component {}
diff --git a/src/components/EditableLinkGroup/index.d.ts b/src/components/EditableLinkGroup/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..07a42abecd33f6ec3ad3f3785a902cd79e36deb3
--- /dev/null
+++ b/src/components/EditableLinkGroup/index.d.ts
@@ -0,0 +1,9 @@
+import React from 'react';
+
+export interface EditableLinkGroupProps {
+ links: any[];
+ onAdd: () => void;
+ linkElement: string;
+}
+
+export default class EditableLinkGroup extends React.Component {}
diff --git a/src/components/EditorContextMenu/FlowContextMenu.js b/src/components/EditorContextMenu/FlowContextMenu.js
new file mode 100644
index 0000000000000000000000000000000000000000..cbb7041f2003d17f4ef53d7ea8925ff8df2bf537
--- /dev/null
+++ b/src/components/EditorContextMenu/FlowContextMenu.js
@@ -0,0 +1,36 @@
+import React from 'react';
+import { NodeMenu, EdgeMenu, GroupMenu, MultiMenu, CanvasMenu, ContextMenu } from 'gg-editor';
+import MenuItem from './MenuItem';
+import styles from './index.less';
+
+const FlowContextMenu = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FlowContextMenu;
diff --git a/src/components/EditorContextMenu/KoniContextMenu.js b/src/components/EditorContextMenu/KoniContextMenu.js
new file mode 100644
index 0000000000000000000000000000000000000000..8b049a5ee7d0d0dae9216d6f01f1f5e40b4a9904
--- /dev/null
+++ b/src/components/EditorContextMenu/KoniContextMenu.js
@@ -0,0 +1,3 @@
+import FlowContextMenu from './FlowContextMenu';
+
+export default FlowContextMenu;
diff --git a/src/components/EditorContextMenu/MenuItem.js b/src/components/EditorContextMenu/MenuItem.js
new file mode 100644
index 0000000000000000000000000000000000000000..4cbde89e1a9a79f5ee0eb44ac5a443cd58feddb1
--- /dev/null
+++ b/src/components/EditorContextMenu/MenuItem.js
@@ -0,0 +1,20 @@
+import React from 'react';
+import { Command } from 'gg-editor';
+import upperFirst from 'lodash/upperFirst';
+import IconFont from '../../common/IconFont';
+import styles from './index.less';
+
+const MenuItem = props => {
+ const { command, icon, text } = props;
+
+ return (
+
+
+
+ {text || upperFirst(command)}
+
+
+ );
+};
+
+export default MenuItem;
diff --git a/src/components/EditorContextMenu/MindContextMenu.js b/src/components/EditorContextMenu/MindContextMenu.js
new file mode 100644
index 0000000000000000000000000000000000000000..2a9d43cd28672b2c0afa4d9370f40f3366e00718
--- /dev/null
+++ b/src/components/EditorContextMenu/MindContextMenu.js
@@ -0,0 +1,24 @@
+import React from 'react';
+import { NodeMenu, CanvasMenu, ContextMenu } from 'gg-editor';
+import MenuItem from './MenuItem';
+import styles from './index.less';
+
+const MindContextMenu = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default MindContextMenu;
diff --git a/src/components/EditorContextMenu/index.js b/src/components/EditorContextMenu/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..16fcde018fc9e647daea97683cf46a5a9d264cfe
--- /dev/null
+++ b/src/components/EditorContextMenu/index.js
@@ -0,0 +1,5 @@
+import FlowContextMenu from './FlowContextMenu';
+import MindContextMenu from './MindContextMenu';
+import KoniContextMenu from './KoniContextMenu';
+
+export { FlowContextMenu, MindContextMenu, KoniContextMenu };
diff --git a/src/components/EditorContextMenu/index.less b/src/components/EditorContextMenu/index.less
new file mode 100644
index 0000000000000000000000000000000000000000..8a2cdae3bfbe5ffaaef812f8ab22677f5340dc91
--- /dev/null
+++ b/src/components/EditorContextMenu/index.less
@@ -0,0 +1,39 @@
+.contextMenu {
+ display: none;
+ overflow: hidden;
+ background: #fff;
+ border-radius: 4px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
+
+ .item {
+ display: flex;
+ align-items: center;
+ padding: 5px 12px;
+ cursor: pointer;
+ transition: all 0.3s;
+ user-select: none;
+
+ &:hover {
+ background: #e6f7ff;
+ }
+
+ i {
+ margin-right: 8px;
+ }
+ }
+
+ :global {
+ .disable {
+ :local {
+ .item {
+ color: rgba(0, 0, 0, 0.25);
+ cursor: auto;
+
+ &:hover {
+ background: #fff;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/components/EditorDetailPanel/DetailForm.js b/src/components/EditorDetailPanel/DetailForm.js
new file mode 100644
index 0000000000000000000000000000000000000000..3d68011530023482b45bf4afb29971b7c33a83d8
--- /dev/null
+++ b/src/components/EditorDetailPanel/DetailForm.js
@@ -0,0 +1,129 @@
+import React, { Fragment } from 'react';
+import { Card, Form, Input, Select } from 'antd';
+import { withPropsAPI } from 'gg-editor';
+import upperFirst from 'lodash/upperFirst';
+
+const { Item } = Form;
+const { Option } = Select;
+
+const inlineFormItemLayout = {
+ labelCol: {
+ sm: { span: 8 },
+ },
+ wrapperCol: {
+ sm: { span: 16 },
+ },
+};
+
+class DetailForm extends React.Component {
+ get item() {
+ const { propsAPI } = this.props;
+
+ return propsAPI.getSelected()[0];
+ }
+
+ handleSubmit = e => {
+ if (e && e.preventDefault) {
+ e.preventDefault();
+ }
+
+ const { form, propsAPI } = this.props;
+ const { getSelected, executeCommand, update } = propsAPI;
+
+ setTimeout(() => {
+ form.validateFieldsAndScroll((err, values) => {
+ if (err) {
+ return;
+ }
+
+ const item = getSelected()[0];
+
+ if (!item) {
+ return;
+ }
+
+ executeCommand(() => {
+ update(item, {
+ ...values,
+ });
+ });
+ });
+ }, 0);
+ };
+
+ renderEdgeShapeSelect = () => {
+ return (
+
+ Smooth
+ Polyline
+ Polyline Round
+
+ );
+ };
+
+ renderNodeDetail = () => {
+ const { form } = this.props;
+ const { label } = this.item.getModel();
+
+ return (
+ -
+ {form.getFieldDecorator('label', {
+ initialValue: label,
+ })(
)}
+
+ );
+ };
+
+ renderEdgeDetail = () => {
+ const { form } = this.props;
+ const { label = '', shape = 'flow-smooth' } = this.item.getModel();
+
+ return (
+
+ -
+ {form.getFieldDecorator('label', {
+ initialValue: label,
+ })(
)}
+
+ -
+ {form.getFieldDecorator('shape', {
+ initialValue: shape,
+ })(this.renderEdgeShapeSelect())}
+
+
+ );
+ };
+
+ renderGroupDetail = () => {
+ const { form } = this.props;
+ const { label = '新建分组' } = this.item.getModel();
+
+ return (
+ -
+ {form.getFieldDecorator('label', {
+ initialValue: label,
+ })(
)}
+
+ );
+ };
+
+ render() {
+ const { type } = this.props;
+
+ if (!this.item) {
+ return null;
+ }
+
+ return (
+
+
+
+ );
+ }
+}
+
+export default Form.create()(withPropsAPI(DetailForm));
diff --git a/src/components/EditorDetailPanel/FlowDetailPanel.js b/src/components/EditorDetailPanel/FlowDetailPanel.js
new file mode 100644
index 0000000000000000000000000000000000000000..8d6816186b96e555406d5c5534903e3dc3d98b6b
--- /dev/null
+++ b/src/components/EditorDetailPanel/FlowDetailPanel.js
@@ -0,0 +1,29 @@
+import React from 'react';
+import { Card } from 'antd';
+import { NodePanel, EdgePanel, GroupPanel, MultiPanel, CanvasPanel, DetailPanel } from 'gg-editor';
+import DetailForm from './DetailForm';
+import styles from './index.less';
+
+const FlowDetailPanel = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FlowDetailPanel;
diff --git a/src/components/EditorDetailPanel/KoniDetailPanel.js b/src/components/EditorDetailPanel/KoniDetailPanel.js
new file mode 100644
index 0000000000000000000000000000000000000000..18aea9a44f5d96009d696e6bf145b3715c0d824c
--- /dev/null
+++ b/src/components/EditorDetailPanel/KoniDetailPanel.js
@@ -0,0 +1,3 @@
+import FlowDetailPanel from './FlowDetailPanel';
+
+export default FlowDetailPanel;
diff --git a/src/components/EditorDetailPanel/MindDetailPanel.js b/src/components/EditorDetailPanel/MindDetailPanel.js
new file mode 100644
index 0000000000000000000000000000000000000000..6b4d5c9eadd0a6f5d656d3c2f772dde7af45f85d
--- /dev/null
+++ b/src/components/EditorDetailPanel/MindDetailPanel.js
@@ -0,0 +1,20 @@
+import React from 'react';
+import { Card } from 'antd';
+import { NodePanel, CanvasPanel, DetailPanel } from 'gg-editor';
+import DetailForm from './DetailForm';
+import styles from './index.less';
+
+const MindDetailPanel = () => {
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+export default MindDetailPanel;
diff --git a/src/components/EditorDetailPanel/index.js b/src/components/EditorDetailPanel/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..8df063eff1c22b6ce5a3ecffbd004b7de681b73b
--- /dev/null
+++ b/src/components/EditorDetailPanel/index.js
@@ -0,0 +1,5 @@
+import FlowDetailPanel from './FlowDetailPanel';
+import MindDetailPanel from './MindDetailPanel';
+import KoniDetailPanel from './KoniDetailPanel';
+
+export { FlowDetailPanel, MindDetailPanel, KoniDetailPanel };
diff --git a/src/components/EditorDetailPanel/index.less b/src/components/EditorDetailPanel/index.less
new file mode 100644
index 0000000000000000000000000000000000000000..081945be43c093076bab1744984f5377a34f0fe2
--- /dev/null
+++ b/src/components/EditorDetailPanel/index.less
@@ -0,0 +1,10 @@
+.detailPanel {
+ flex: 1;
+ background: #fafafa;
+
+ :global {
+ .ant-card {
+ background: #fafafa;
+ }
+ }
+}
diff --git a/src/components/EditorItemPanel/FlowItemPanel.js b/src/components/EditorItemPanel/FlowItemPanel.js
new file mode 100644
index 0000000000000000000000000000000000000000..b3b46930c86e407e100984bf6d253f480e3c244e
--- /dev/null
+++ b/src/components/EditorItemPanel/FlowItemPanel.js
@@ -0,0 +1,55 @@
+import React from 'react';
+import { Card } from 'antd';
+import { ItemPanel, Item } from 'gg-editor';
+import styles from './index.less';
+
+const FlowItemPanel = () => {
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FlowItemPanel;
diff --git a/src/components/EditorItemPanel/KoniItemPanel.js b/src/components/EditorItemPanel/KoniItemPanel.js
new file mode 100644
index 0000000000000000000000000000000000000000..655ea99a6682da3ae814f29a2bdffa27d827512e
--- /dev/null
+++ b/src/components/EditorItemPanel/KoniItemPanel.js
@@ -0,0 +1,51 @@
+import React from 'react';
+import { Card } from 'antd';
+import { ItemPanel, Item } from 'gg-editor';
+import styles from './index.less';
+
+const KoniItemPanel = () => {
+ return (
+
+
+
+
+
+
+
+ );
+};
+
+export default KoniItemPanel;
diff --git a/src/components/EditorItemPanel/index.js b/src/components/EditorItemPanel/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..2ba03fbb700d78600d6ea668a57ffaad4e0586a6
--- /dev/null
+++ b/src/components/EditorItemPanel/index.js
@@ -0,0 +1,4 @@
+import FlowItemPanel from './FlowItemPanel';
+import KoniItemPanel from './KoniItemPanel';
+
+export { FlowItemPanel, KoniItemPanel };
diff --git a/src/components/EditorItemPanel/index.less b/src/components/EditorItemPanel/index.less
new file mode 100644
index 0000000000000000000000000000000000000000..a7acc366d1715dc50003f7e7c1335e2844112a41
--- /dev/null
+++ b/src/components/EditorItemPanel/index.less
@@ -0,0 +1,20 @@
+.itemPanel {
+ flex: 1;
+ background: #fafafa;
+
+ :global {
+ .ant-card {
+ background: #fafafa;
+ }
+
+ .ant-card-body {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+
+ > div {
+ margin-bottom: 16px;
+ }
+ }
+ }
+}
diff --git a/src/components/EditorKoniCustomNode/index.js b/src/components/EditorKoniCustomNode/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..4c13bb4f42cb3c20e55b26e63de9cdb5c9448e5d
--- /dev/null
+++ b/src/components/EditorKoniCustomNode/index.js
@@ -0,0 +1,33 @@
+import React from 'react';
+import { RegisterNode } from 'gg-editor';
+
+class KoniCustomNode extends React.Component {
+ render() {
+ const config = {
+ draw(item) {
+ const keyShape = this.drawKeyShape(item);
+
+ // draw label
+ this.drawLabel(item);
+
+ // draw image
+ const group = item.getGraphicGroup();
+ const model = item.getModel();
+
+ group.addShape('image', {
+ attrs: {
+ x: -7,
+ y: -7,
+ img: model.icon,
+ },
+ });
+
+ return keyShape;
+ },
+ };
+
+ return ;
+ }
+}
+
+export default KoniCustomNode;
diff --git a/src/components/EditorMinimap/index.js b/src/components/EditorMinimap/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..8c86b242845629d533e8d55ce436c0cd63ae59d5
--- /dev/null
+++ b/src/components/EditorMinimap/index.js
@@ -0,0 +1,13 @@
+import React from 'react';
+import { Card } from 'antd';
+import { Minimap } from 'gg-editor';
+
+const EditorMinimap = () => {
+ return (
+
+
+
+ );
+};
+
+export default EditorMinimap;
diff --git a/src/components/EditorToolbar/FlowToolbar.js b/src/components/EditorToolbar/FlowToolbar.js
new file mode 100644
index 0000000000000000000000000000000000000000..374c1858bcd07f1a68368fd437ac11e0c7eb5113
--- /dev/null
+++ b/src/components/EditorToolbar/FlowToolbar.js
@@ -0,0 +1,32 @@
+import React from 'react';
+import { Divider } from 'antd';
+import { Toolbar } from 'gg-editor';
+import ToolbarButton from './ToolbarButton';
+import styles from './index.less';
+
+const FlowToolbar = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FlowToolbar;
diff --git a/src/components/EditorToolbar/KoniToolbar.js b/src/components/EditorToolbar/KoniToolbar.js
new file mode 100644
index 0000000000000000000000000000000000000000..f222007aff66a7d41abfd1f6bd459d7d7138c116
--- /dev/null
+++ b/src/components/EditorToolbar/KoniToolbar.js
@@ -0,0 +1,3 @@
+import FlowToolbar from './FlowToolbar';
+
+export default FlowToolbar;
diff --git a/src/components/EditorToolbar/MindToolbar.js b/src/components/EditorToolbar/MindToolbar.js
new file mode 100644
index 0000000000000000000000000000000000000000..1c83286ac0b06abfe634b141bb7bf4beee266cba
--- /dev/null
+++ b/src/components/EditorToolbar/MindToolbar.js
@@ -0,0 +1,27 @@
+import React from 'react';
+import { Divider } from 'antd';
+import { Toolbar } from 'gg-editor';
+import ToolbarButton from './ToolbarButton';
+import styles from './index.less';
+
+const FlowToolbar = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FlowToolbar;
diff --git a/src/components/EditorToolbar/ToolbarButton.js b/src/components/EditorToolbar/ToolbarButton.js
new file mode 100644
index 0000000000000000000000000000000000000000..eb5b4ffa2f0fab721aeb8de278d243dca99d9f85
--- /dev/null
+++ b/src/components/EditorToolbar/ToolbarButton.js
@@ -0,0 +1,24 @@
+import React from 'react';
+import { Tooltip } from 'antd';
+import { Command } from 'gg-editor';
+import upperFirst from 'lodash/upperFirst';
+import IconFont from '../../common/IconFont';
+import styles from './index.less';
+
+const ToolbarButton = props => {
+ const { command, icon, text } = props;
+
+ return (
+
+
+
+
+
+ );
+};
+
+export default ToolbarButton;
diff --git a/src/components/EditorToolbar/index.js b/src/components/EditorToolbar/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..ac08e3dc54a84c9d2f292878f706d34c01091474
--- /dev/null
+++ b/src/components/EditorToolbar/index.js
@@ -0,0 +1,5 @@
+import FlowToolbar from './FlowToolbar';
+import MindToolbar from './MindToolbar';
+import KoniToolbar from './KoniToolbar';
+
+export { FlowToolbar, MindToolbar, KoniToolbar };
diff --git a/src/components/EditorToolbar/index.less b/src/components/EditorToolbar/index.less
new file mode 100644
index 0000000000000000000000000000000000000000..a5cca37c2931b149d39c94410e0d105922173e29
--- /dev/null
+++ b/src/components/EditorToolbar/index.less
@@ -0,0 +1,39 @@
+.toolbar {
+ display: flex;
+ align-items: center;
+
+ :global {
+ .command i {
+ display: inline-block;
+ width: 27px;
+ height: 27px;
+ margin: 0 6px;
+ padding-top: 6px;
+ text-align: center;
+ border: 1px solid #fff;
+ cursor: pointer;
+
+ &:hover {
+ border: 1px solid #e6e9ed;
+ }
+ }
+
+ .disable i {
+ color: rgba(0, 0, 0, 0.25);
+ cursor: auto;
+
+ &:hover {
+ border: 1px solid #fff;
+ }
+ }
+ }
+}
+
+.tooltip {
+ :global {
+ .ant-tooltip-inner {
+ font-size: 12px;
+ border-radius: 0;
+ }
+ }
+}
diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts
index 37d508d77335048de87287fc52fb9f457e89dc33..075fa789a40ec7904dd39e9c293206bf86ac0db8 100644
--- a/src/components/Ellipsis/index.d.ts
+++ b/src/components/Ellipsis/index.d.ts
@@ -1,13 +1,13 @@
-import * as React from 'react';
+import React from 'react';
import { TooltipProps } from 'antd/lib/tooltip';
-export interface IEllipsisTooltipProps extends TooltipProps {
+export interface EllipsisTooltipProps extends TooltipProps {
title?: undefined;
overlayStyle?: undefined;
}
-export interface IEllipsisProps {
- tooltip?: boolean | IEllipsisTooltipProps;
+export interface EllipsisProps {
+ tooltip?: boolean | EllipsisTooltipProps;
length?: number;
lines?: number;
style?: React.CSSProperties;
@@ -18,4 +18,4 @@ export interface IEllipsisProps {
export function getStrFullLength(str: string): number;
export function cutStrByFullLength(str: string, maxLength: number): string;
-export default class Ellipsis extends React.Component {}
+export default class Ellipsis extends React.Component {}
diff --git a/src/components/Exception/index.d.ts b/src/components/Exception/index.d.ts
index a74abb1fa6334cb2b8ef987aab5a1b5dc1f0d531..b8cb65dd92d4a896e745821ddb8dc6aea2cc08da 100644
--- a/src/components/Exception/index.d.ts
+++ b/src/components/Exception/index.d.ts
@@ -1,15 +1,23 @@
-import * as React from 'react';
-export interface IExceptionProps {
+import React from 'react';
+import * as H from 'history';
+
+export interface ExceptionProps<
+ L = {
+ to: H.LocationDescriptor;
+ href?: H.LocationDescriptor;
+ replace?: boolean;
+ innerRef?: (node: HTMLAnchorElement | null) => void;
+ }
+> {
type?: '403' | '404' | '500';
title?: React.ReactNode;
desc?: React.ReactNode;
img?: string;
actions?: React.ReactNode;
- linkElement?: string | React.ComponentType;
+ linkElement?: string | React.ComponentType;
style?: React.CSSProperties;
className?: string;
backText?: React.ReactNode;
redirect?: string;
}
-
-export default class Exception extends React.Component {}
+export default class Exception extends React.Component {}
diff --git a/src/components/FooterToolbar/index.d.ts b/src/components/FooterToolbar/index.d.ts
index 9c6ac5b4cad95ade8f24a1b02e6de72f4770bfeb..9ec202c1c5b3d986fc5f11ea94560ea2cdb90501 100644
--- a/src/components/FooterToolbar/index.d.ts
+++ b/src/components/FooterToolbar/index.d.ts
@@ -1,7 +1,8 @@
-import * as React from 'react';
-export interface IFooterToolbarProps {
+import React from 'react';
+export interface FooterToolbarProps {
extra: React.ReactNode;
style?: React.CSSProperties;
+ className?: string;
}
-export default class FooterToolbar extends React.Component {}
+export default class FooterToolbar extends React.Component {}
diff --git a/src/components/GlobalFooter/index.d.ts b/src/components/GlobalFooter/index.d.ts
index 3fa5c423eba263aa4c9d39eb49f395781c5e8f43..efde77dbd4bfd58ed27da72a56e6328b3eefdee5 100644
--- a/src/components/GlobalFooter/index.d.ts
+++ b/src/components/GlobalFooter/index.d.ts
@@ -1,5 +1,5 @@
-import * as React from 'react';
-export interface IGlobalFooterProps {
+import React from 'react';
+export interface GlobalFooterProps {
links?: Array<{
key?: string;
title: React.ReactNode;
@@ -8,6 +8,7 @@ export interface IGlobalFooterProps {
}>;
copyright?: React.ReactNode;
style?: React.CSSProperties;
+ className?: string;
}
-export default class GlobalFooter extends React.Component {}
+export default class GlobalFooter extends React.Component {}
diff --git a/src/components/GlobalHeader/RightContent.d.ts b/src/components/GlobalHeader/RightContent.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..275d9996a06d881735b6bcc70af5887ca2769f67
--- /dev/null
+++ b/src/components/GlobalHeader/RightContent.d.ts
@@ -0,0 +1,26 @@
+import React from 'react';
+import { DropDownProps } from 'antd/lib/dropdown';
+import { ClickParam } from 'antd/es/menu';
+import { SiderTheme } from 'antd/es/Layout/Sider';
+
+export interface GlobalHeaderRightProps {
+ notices?: any[];
+ dispatch?: (args: any) => void;
+ currentUser?: {
+ avatar?: string;
+ name?: string;
+ title?: string;
+ group?: string;
+ signature?: string;
+ geographic?: any;
+ tags?: any[];
+ unreadCount: number;
+ };
+ fetchingNotices?: boolean;
+ onNoticeVisibleChange?: (visible: boolean) => void;
+ onMenuClick?: (param: ClickParam) => void;
+ onNoticeClear?: (tabName: string) => void;
+ theme?: SiderTheme;
+}
+
+export default class GlobalHeaderRight extends React.Component {}
diff --git a/src/components/GlobalHeader/RightContent.js b/src/components/GlobalHeader/RightContent.js
index dad360ff08299518c7d3fdc7026c2b3b289b883f..d40e1166c670af5955030dff1278d2747aa2e655 100644
--- a/src/components/GlobalHeader/RightContent.js
+++ b/src/components/GlobalHeader/RightContent.js
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
-import { FormattedMessage, formatMessage } from 'umi/locale';
-import { Spin, Tag, Menu, Icon, Avatar, Tooltip } from 'antd';
+import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
+import { Spin, Tag, Menu, Icon, Avatar, Tooltip, message } from 'antd';
import moment from 'moment';
import groupBy from 'lodash/groupBy';
import NoticeIcon from '../NoticeIcon';
@@ -63,30 +63,13 @@ export default class GlobalHeaderRight extends PureComponent {
});
};
- fetchMoreNotices = tabProps => {
- const { list, name } = tabProps;
- const { dispatch, notices = [] } = this.props;
- const lastItemId = notices[notices.length - 1].id;
- dispatch({
- type: 'global/fetchMoreNotices',
- payload: {
- lastItemId,
- type: name,
- offset: list.length,
- },
- });
- };
-
render() {
const {
currentUser,
- fetchingMoreNotices,
fetchingNotices,
- loadedAllNotices,
onNoticeVisibleChange,
onMenuClick,
onNoticeClear,
- skeletonCount,
theme,
} = this.props;
const menu = (
@@ -110,11 +93,6 @@ export default class GlobalHeaderRight extends PureComponent {
);
- const loadMoreProps = {
- skeletonCount,
- loadedAll: loadedAllNotices,
- loading: fetchingMoreNotices,
- };
const noticeData = this.getNoticeData();
const unreadMsg = this.getUnreadData(noticeData);
let className = styles.right;
@@ -155,44 +133,43 @@ export default class GlobalHeaderRight extends PureComponent {
console.log(item, tabProps); // eslint-disable-line
this.changeReadState(item, tabProps);
}}
+ loading={fetchingNotices}
locale={{
emptyText: formatMessage({ id: 'component.noticeIcon.empty' }),
clear: formatMessage({ id: 'component.noticeIcon.clear' }),
- loadedAll: formatMessage({ id: 'component.noticeIcon.loaded' }),
- loadMore: formatMessage({ id: 'component.noticeIcon.loading-more' }),
+ viewMore: formatMessage({ id: 'component.noticeIcon.view-more' }),
+ notification: formatMessage({ id: 'component.globalHeader.notification' }),
+ message: formatMessage({ id: 'component.globalHeader.message' }),
+ event: formatMessage({ id: 'component.globalHeader.event' }),
}}
onClear={onNoticeClear}
- onLoadMore={this.fetchMoreNotices}
onPopupVisibleChange={onNoticeVisibleChange}
- loading={fetchingNotices}
+ onViewMore={() => message.info('Click on view more')}
clearClose
>
{currentUser.name ? (
diff --git a/src/components/GlobalHeader/index.d.ts b/src/components/GlobalHeader/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..7d2fcf6e3c7ada8f269842152a955eaf510213bb
--- /dev/null
+++ b/src/components/GlobalHeader/index.d.ts
@@ -0,0 +1,13 @@
+import React from 'react';
+
+export interface GlobalHeaderProps {
+ collapsed?: boolean;
+ onCollapse?: (collapsed: boolean) => void;
+ isMobile?: boolean;
+ logo?: string;
+ onNoticeClear?: (type: string) => void;
+ onMenuClick?: ({ key: string }) => void;
+ onNoticeVisibleChange?: (b: boolean) => void;
+}
+
+export default class GlobalHeader extends React.Component {}
diff --git a/src/components/HeaderDropdown/index.d.ts b/src/components/HeaderDropdown/index.d.ts
index e9dac7e532570e2f85a6a220d5d4ff9b97194927..a1fd50aa0f0deb8db3effed9e65e5e9c6a066286 100644
--- a/src/components/HeaderDropdown/index.d.ts
+++ b/src/components/HeaderDropdown/index.d.ts
@@ -1,2 +1,12 @@
-import * as React from 'react';
-export default class HeaderDropdown extends React.Component {}
+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 {}
diff --git a/src/components/HeaderSearch/index.d.ts b/src/components/HeaderSearch/index.d.ts
index d78fde471ccd522d821f77b790647f5620efdb7e..fcf7c11d2205b5a75ca6c797c8e936be00ddb2b7 100644
--- a/src/components/HeaderSearch/index.d.ts
+++ b/src/components/HeaderSearch/index.d.ts
@@ -1,5 +1,5 @@
-import * as React from 'react';
-export interface IHeaderSearchProps {
+import React from 'react';
+export interface HeaderSearchProps {
placeholder?: string;
dataSource?: string[];
defaultOpen?: boolean;
@@ -12,4 +12,4 @@ export interface IHeaderSearchProps {
className?: string;
}
-export default class HeaderSearch extends React.Component {}
+export default class HeaderSearch extends React.Component {}
diff --git a/src/components/Login/LoginItem.d.ts b/src/components/Login/LoginItem.d.ts
index bcfb73b86b75ee39f3f7b609e426ea4f1f6f2ce1..563e94e0489802e9f70b9e407776817f2d20bb25 100644
--- a/src/components/Login/LoginItem.d.ts
+++ b/src/components/Login/LoginItem.d.ts
@@ -1,11 +1,28 @@
-import * as React from 'react';
-export interface ILoginItemProps {
+import React from 'react';
+import { WrappedFormUtils } from 'antd/es/form/Form';
+import ItemMap from './map';
+import { Omit } from 'antd/es/_util/type';
+
+export type WrappedLoginItemProps = Omit;
+export type LoginItemType = { [K in keyof typeof ItemMap]: React.FC };
+
+export interface LoginItemProps {
name?: string;
rules?: any[];
style?: React.CSSProperties;
- onGetCaptcha?: () => void;
+ onGetCaptcha?: (event?: MouseEvent) => void;
placeholder?: string;
buttonText?: React.ReactNode;
+ onPressEnter?: (e: any) => void;
+ countDown?: number;
+ getCaptchaButtonText?: string;
+ getCaptchaSecondText?: string;
+ updateActive: (activeItem: any) => void;
+ form: WrappedFormUtils;
+ type: string;
+ defaultValue?: string;
+ customprops?: any;
+ onChange?: (e: any) => void;
}
-export default class LoginItem extends React.Component {}
+export default class LoginItem extends React.Component {}
diff --git a/src/components/Login/LoginTab.d.ts b/src/components/Login/LoginTab.d.ts
index db651f7b40c6194d1cd0cb8430736fc4d369e34d..c3f13ecb45cbe659d62d60f8bd3864681a336720 100644
--- a/src/components/Login/LoginTab.d.ts
+++ b/src/components/Login/LoginTab.d.ts
@@ -1,7 +1,11 @@
-import * as React from 'react';
+import React from 'react';
-export interface ILoginTabProps {
+export interface LoginTabProps {
key?: string;
tab?: React.ReactNode;
+ tabUtil: {
+ addTab: (id: any) => void;
+ removeTab: (id: any) => void;
+ };
}
-export default class LoginTab extends React.Component {}
+export default class LoginTab extends React.Component {}
diff --git a/src/components/Login/demo/basic.md b/src/components/Login/demo/basic.md
index 5fbd0ca25448f92e964538c545edaf07d595ff27..05475384c0878cec7c5c13bf7d0678e58d1599be 100644
--- a/src/components/Login/demo/basic.md
+++ b/src/components/Login/demo/basic.md
@@ -18,65 +18,94 @@ class LoginDemo extends React.Component {
notice: '',
type: 'tab2',
autoLogin: true,
- }
+ };
onSubmit = (err, values) => {
- console.log('value collected ->', { ...values, autoLogin: this.state.autoLogin });
+ console.log('value collected ->', {
+ ...values,
+ autoLogin: this.state.autoLogin,
+ });
if (this.state.type === 'tab1') {
- this.setState({
- notice: '',
- }, () => {
- if (!err && (values.username !== 'admin' || values.password !== '888888')) {
- setTimeout(() => {
- this.setState({
- notice: 'The combination of username and password is incorrect!',
- });
- }, 500);
- }
- });
+ this.setState(
+ {
+ notice: '',
+ },
+ () => {
+ if (
+ !err &&
+ (values.username !== 'admin' || values.password !== '888888')
+ ) {
+ setTimeout(() => {
+ this.setState({
+ notice:
+ 'The combination of username and password is incorrect!',
+ });
+ }, 500);
+ }
+ },
+ );
}
- }
+ };
onTabChange = (key) => {
this.setState({
type: key,
});
- }
+ };
changeAutoLogin = (e) => {
this.setState({
autoLogin: e.target.checked,
});
- }
+ };
render() {
return (
-
-
- {
- this.state.notice &&
-
- }
-
-
-
-
-
- console.log('Get captcha!')} name="captcha" />
-
-
- Login
-
- Other login methods
-
-
-
-
Register
-
-
+
+
+
+ {this.state.notice && (
+
+ )}
+
+
+
+
+
+ console.log('Get captcha!')}
+ name="captcha"
+ />
+
+
+ Login
+
+
+
);
}
}
@@ -85,6 +114,10 @@ ReactDOM.render( , mountNode);
````
diff --git a/src/components/PageHeader/demo/simple.md b/src/components/PageHeader/demo/simple.md
deleted file mode 100644
index d0ad1f7d2f4e07208900b9e57891952cb7d39942..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/demo/simple.md
+++ /dev/null
@@ -1,32 +0,0 @@
----
-order: 3
-title: Simple
----
-
-简单的页头。
-
-````jsx
-import PageHeader from 'ant-design-pro/lib/PageHeader';
-
-const breadcrumbList = [{
- title: '一级菜单',
- href: '/',
-}, {
- title: '二级菜单',
- href: '/',
-}, {
- title: '三级菜单',
-}];
-
-ReactDOM.render(
-
-, mountNode);
-````
-
-
diff --git a/src/components/PageHeader/demo/standard.md b/src/components/PageHeader/demo/standard.md
deleted file mode 100644
index 5c59c933c282b913b4bb56d69ee915feb56fc29f..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/demo/standard.md
+++ /dev/null
@@ -1,102 +0,0 @@
----
-order: 1
-title: Standard
----
-
-标准页头。
-
-````jsx
-import PageHeader from 'ant-design-pro/lib/PageHeader';
-import DescriptionList from 'ant-design-pro/lib/DescriptionList';
-import { Button, Menu, Dropdown, Icon, Row, Col } from 'antd';
-
-const { Description } = DescriptionList;
-const ButtonGroup = Button.Group;
-
-const description = (
-
- 曲丽丽
- XX 服务
- 2017-07-07
- 12421
-
-);
-
-const menu = (
-
- 选项一
- 选项二
- 选项三
-
-);
-
-const action = (
-
-
- 操作
- 操作
-
-
-
-
- 主操作
-
-);
-
-const extra = (
-
-
- 状态
- 待审批
-
-
- 订单金额
- ¥ 568.08
-
-
-);
-
-const breadcrumbList = [{
- title: '一级菜单',
- href: '/',
-}, {
- title: '二级菜单',
- href: '/',
-}, {
- title: '三级菜单',
-}];
-
-const tabList = [{
- key: 'detail',
- tab: '详情',
-}, {
- key: 'rule',
- tab: '规则',
-}];
-
-function onTabChange(key) {
- console.log(key);
-}
-
-ReactDOM.render(
-
-
}
- action={action}
- content={description}
- extraContent={extra}
- breadcrumbList={breadcrumbList}
- tabList={tabList}
- tabActiveKey="detail"
- onTabChange={onTabChange}
- />
-
-, mountNode);
-````
-
-
diff --git a/src/components/PageHeader/demo/structure.md b/src/components/PageHeader/demo/structure.md
deleted file mode 100644
index 429eed6319f6f483da6ac724242a07f0626e3f0c..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/demo/structure.md
+++ /dev/null
@@ -1,68 +0,0 @@
----
-order: 0
-title: Structure
----
-
-基本结构,具备响应式布局功能,主要断点为 768px 和 576px,拖动窗口改变大小试试看。
-
-````jsx
-import PageHeader from 'ant-design-pro/lib/PageHeader';
-
-const breadcrumbList = [{
- title: '面包屑',
-}];
-
-const tabList = [{
- key: '1',
- tab: '页签一',
-}, {
- key: '2',
- tab: '页签二',
-}, {
- key: '3',
- tab: '页签三',
-}];
-
-ReactDOM.render(
- }
- logo={logo
}
- action={action
}
- content={content
}
- extraContent={extraContent
}
- breadcrumbList={breadcrumbList}
- tabList={tabList}
- tabActiveKey="1"
- />
-
-, mountNode);
-````
-
-
diff --git a/src/components/PageHeader/index.d.ts b/src/components/PageHeader/index.d.ts
deleted file mode 100644
index eacbb2de903681f1eee250d83c71e4642ca41d0d..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/index.d.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import * as React from 'react';
-export interface IPageHeaderProps {
- title?: React.ReactNode | string;
- logo?: React.ReactNode | string;
- action?: React.ReactNode | string;
- content?: React.ReactNode;
- extraContent?: React.ReactNode;
- routes?: any[];
- params?: any;
- breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>;
- tabList?: Array<{ key: string; tab: React.ReactNode }>;
- tabActiveKey?: string;
- tabDefaultActiveKey?: string;
- onTabChange?: (key: string) => void;
- tabBarExtraContent?: React.ReactNode;
- linkElement?: React.ReactNode;
- style?: React.CSSProperties;
- home?: React.ReactNode;
- wide?: boolean;
- hiddenBreadcrumb?: boolean;
-}
-
-export default class PageHeader extends React.Component {}
diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js
deleted file mode 100644
index 17c1a7e28299bee95bd9181e2ed435a3fb0232e9..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/index.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import React, { PureComponent } from 'react';
-import { Tabs, Skeleton } from 'antd';
-import classNames from 'classnames';
-import styles from './index.less';
-import BreadcrumbView from './breadcrumb';
-
-const { TabPane } = Tabs;
-export default class PageHeader extends PureComponent {
- onChange = key => {
- const { onTabChange } = this.props;
- if (onTabChange) {
- onTabChange(key);
- }
- };
-
- render() {
- const {
- title = '',
- logo,
- action,
- content,
- extraContent,
- tabList,
- className,
- tabActiveKey,
- tabDefaultActiveKey,
- tabBarExtraContent,
- loading = false,
- wide = false,
- hiddenBreadcrumb = false,
- } = this.props;
-
- const clsString = classNames(styles.pageHeader, className);
- const activeKeyProps = {};
- if (tabDefaultActiveKey !== undefined) {
- activeKeyProps.defaultActiveKey = tabDefaultActiveKey;
- }
- if (tabActiveKey !== undefined) {
- activeKeyProps.activeKey = tabActiveKey;
- }
- return (
-
-
-
- {hiddenBreadcrumb ? null : }
-
- {logo &&
{logo}
}
-
-
-
{title}
- {action &&
{action}
}
-
-
- {content &&
{content}
}
- {extraContent &&
{extraContent}
}
-
-
-
- {tabList && tabList.length ? (
-
- {tabList.map(item => (
-
- ))}
-
- ) : null}
-
-
-
- );
- }
-}
diff --git a/src/components/PageHeader/index.less b/src/components/PageHeader/index.less
deleted file mode 100644
index 81125bbd5b064e5eda41cc70616abfd0fd138f53..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/index.less
+++ /dev/null
@@ -1,161 +0,0 @@
-@import '~antd/lib/style/themes/default.less';
-
-.pageHeader {
- padding: 16px 32px 0 32px;
- background: @component-background;
- border-bottom: @border-width-base @border-style-base @border-color-split;
- .wide {
- max-width: 1200px;
- margin: auto;
- }
- .detail {
- display: flex;
- }
-
- .row {
- display: flex;
- width: 100%;
- }
-
- .breadcrumb {
- margin-bottom: 16px;
- }
-
- .tabs {
- margin: 0 0 0 -8px;
-
- :global {
- // 1px 可以让选中效果显示完成
- .ant-tabs-bar {
- margin-bottom: 1px;
- border-bottom: none;
- }
- }
- }
-
- .logo {
- flex: 0 1 auto;
- margin-right: 16px;
- padding-top: 1px;
- > img {
- display: block;
- width: 28px;
- height: 28px;
- border-radius: @border-radius-base;
- }
- }
-
- .title {
- color: @heading-color;
- font-weight: 500;
- font-size: 20px;
- }
-
- .action {
- min-width: 266px;
- margin-left: 56px;
-
- :global {
- .ant-btn-group:not(:last-child),
- .ant-btn:not(:last-child) {
- margin-right: 8px;
- }
-
- .ant-btn-group > .ant-btn {
- margin-right: 0;
- }
- }
- }
-
- .title,
- .content {
- flex: auto;
- }
-
- .action,
- .extraContent,
- .main {
- flex: 0 1 auto;
- }
-
- .main {
- width: 100%;
- }
-
- .title,
- .action {
- margin-bottom: 16px;
- }
-
- .logo,
- .content,
- .extraContent {
- margin-bottom: 16px;
- }
-
- .action,
- .extraContent {
- text-align: right;
- }
-
- .extraContent {
- min-width: 242px;
- margin-left: 88px;
- }
-}
-
-@media screen and (max-width: @screen-xl) {
- .pageHeader {
- .extraContent {
- margin-left: 44px;
- }
- }
-}
-
-@media screen and (max-width: @screen-lg) {
- .pageHeader {
- .extraContent {
- margin-left: 20px;
- }
- }
-}
-
-@media screen and (max-width: @screen-md) {
- .pageHeader {
- .row {
- display: block;
- }
-
- .action,
- .extraContent {
- margin-left: 0;
- text-align: left;
- }
- }
-}
-
-@media screen and (max-width: @screen-sm) {
- .pageHeader {
- .detail {
- display: block;
- }
- }
-}
-
-@media screen and (max-width: @screen-xs) {
- .pageHeader {
- .action {
- :global {
- .ant-btn-group,
- .ant-btn {
- display: block;
- margin-bottom: 8px;
- }
- .ant-btn-group > .ant-btn {
- display: inline-block;
- margin-bottom: 0;
- }
- }
- }
- }
-}
diff --git a/src/components/PageHeader/index.md b/src/components/PageHeader/index.md
deleted file mode 100644
index 48543f5f4dcad7012984fddc045f35292ca7bc88..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/index.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: PageHeader
-subtitle: 页头
-cols: 1
-order: 11
----
-
-页头用来声明页面的主题,包含了用户所关注的最重要的信息,使用户可以快速理解当前页面是什么以及它的功能。
-
-## API
-
-| 参数 | 说明 | 类型 | 默认值 |
-|----------|------------------------------------------|-------------|-------|
-| title | title 区域 | ReactNode | - |
-| logo | logo区域 | ReactNode | - |
-| action | 操作区,位于 title 行的行尾 | ReactNode | - |
-| home | 默认的主页说明文字 | ReactNode | - |
-| content | 内容区 | ReactNode | - |
-| extraContent | 额外内容区,位于content的右侧 | ReactNode | - |
-| breadcrumbList | 面包屑数据,配置了此属性时 `routes` `params` `location` `breadcrumbNameMap` 无效 | array<{title: ReactNode, href?: string}> | - |
-| hiddenBreadcrumb |隐藏面包屑 | boolean | false |
-| routes | 面包屑相关属性,router 的路由栈信息 | object[] | - |
-| params | 面包屑相关属性,路由的参数 | object | - |
-| location | 面包屑相关属性,当前的路由信息 | object | - |
-| breadcrumbNameMap | 面包屑相关属性,路由的地址-名称映射表 | object | - |
-| tabList | tab 标题列表 | array<{key: string, tab: ReactNode}> | - |
-| tabActiveKey | 当前高亮的 tab 项 | string | - |
-| tabDefaultActiveKey | 默认高亮的 tab 项 | string | 第一项 |
-| wide | 是否定宽 | boolean | false |
-| onTabChange | 切换面板的回调 | (key) => void | - |
-| itemRender | 自定义节点方法 | (menuItem) => ReactNode | - |
-| linkElement | 定义链接的元素,默认为 `a`,可传入 react-router 的 Link | string\|ReactElement | - |
-
-> 面包屑的配置方式有三种,一是直接配置 `breadcrumbList`,二是结合 `react-router@2` `react-router@3`,配置 `routes` 及 `params` 实现,类似 [面包屑 Demo](https://ant.design/components/breadcrumb-cn/#components-breadcrumb-demo-router),三是结合 `react-router@4`,配置 `location` `breadcrumbNameMap`,优先级依次递减,脚手架中使用最后一种。 对于后两种用法,你也可以将 `routes` `params` 及 `location` `breadcrumbNameMap` 放到 context 中,组件会自动获取。
diff --git a/src/components/PageHeader/index.test.js b/src/components/PageHeader/index.test.js
deleted file mode 100644
index d22706e9c231db2c8c7e3e2981b5d26f04c86750..0000000000000000000000000000000000000000
--- a/src/components/PageHeader/index.test.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import { getBreadcrumb } from './breadcrumb';
-import { urlToList } from '../_utils/pathTools';
-
-const routerData = {
- '/dashboard/analysis': {
- name: '分析页',
- },
- '/userinfo': {
- name: '用户列表',
- },
- '/userinfo/:id': {
- name: '用户信息',
- },
- '/userinfo/:id/addr': {
- name: '收货订单',
- },
-};
-describe('test getBreadcrumb', () => {
- it('Simple url', () => {
- expect(getBreadcrumb(routerData, '/dashboard/analysis').name).toEqual('分析页');
- });
- it('Parameters url', () => {
- expect(getBreadcrumb(routerData, '/userinfo/2144').name).toEqual('用户信息');
- });
- it('The middle parameter url', () => {
- expect(getBreadcrumb(routerData, '/userinfo/2144/addr').name).toEqual('收货订单');
- });
- it('Loop through the parameters', () => {
- const urlNameList = urlToList('/userinfo/2144/addr').map(
- url => getBreadcrumb(routerData, url).name
- );
- expect(urlNameList).toEqual(['用户列表', '用户信息', '收货订单']);
- });
-
- it('a path', () => {
- const urlNameList = urlToList('/userinfo').map(url => getBreadcrumb(routerData, url).name);
- expect(urlNameList).toEqual(['用户列表']);
- });
- it('Secondary path', () => {
- const urlNameList = urlToList('/userinfo/2144').map(url => getBreadcrumb(routerData, url).name);
- expect(urlNameList).toEqual(['用户列表', '用户信息']);
- });
-});
diff --git a/src/components/PageHeaderWrapper/GridContent.d.ts b/src/components/PageHeaderWrapper/GridContent.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..a3d3a308f2aa5cd3688e8de8092d54cc3094572e
--- /dev/null
+++ b/src/components/PageHeaderWrapper/GridContent.d.ts
@@ -0,0 +1,8 @@
+import React from 'react';
+
+export interface GridContentProps {
+ contentWidth: string;
+ children: React.ReactNode;
+}
+
+export default class GridContent extends React.Component {}
diff --git a/src/components/PageHeaderWrapper/breadcrumb.js b/src/components/PageHeaderWrapper/breadcrumb.js
new file mode 100644
index 0000000000000000000000000000000000000000..02fe66fd26530f68bd99e6a3c863f384a82e611d
--- /dev/null
+++ b/src/components/PageHeaderWrapper/breadcrumb.js
@@ -0,0 +1,116 @@
+import React from 'react';
+import pathToRegexp from 'path-to-regexp';
+import Link from 'umi/link';
+import { FormattedMessage } from 'umi-plugin-react/locale';
+import { urlToList } from '../_utils/pathTools';
+
+// 渲染Breadcrumb 子节点
+// Render the Breadcrumb child node
+const itemRender = (route, params, routes, paths) => {
+ const last = routes.indexOf(route) === routes.length - 1;
+ return last || !route.component ? (
+ {route.breadcrumbName}
+ ) : (
+ {route.breadcrumbName}
+ );
+};
+
+const renderItemLocal = item => {
+ if (item.locale) {
+ return ;
+ }
+ return item.name;
+};
+
+export const getBreadcrumb = (breadcrumbNameMap, url) => {
+ let breadcrumb = breadcrumbNameMap[url];
+ if (!breadcrumb) {
+ Object.keys(breadcrumbNameMap).forEach(item => {
+ if (pathToRegexp(item).test(url)) {
+ breadcrumb = breadcrumbNameMap[item];
+ }
+ });
+ }
+ return breadcrumb || {};
+};
+
+export const getBreadcrumbProps = props => {
+ const { routes, params, location, breadcrumbNameMap } = props;
+ return {
+ routes,
+ params,
+ routerLocation: location,
+ breadcrumbNameMap,
+ };
+};
+
+// Generated according to props
+const conversionFromProps = props => {
+ const { breadcrumbList } = props;
+ return breadcrumbList.map(item => {
+ const { title, href } = item;
+ return {
+ path: href,
+ breadcrumbName: title,
+ };
+ });
+};
+
+const conversionFromLocation = (routerLocation, breadcrumbNameMap, props) => {
+ const { home } = props;
+ // Convert the url to an array
+ const pathSnippets = urlToList(routerLocation.pathname);
+ // Loop data mosaic routing
+ const extraBreadcrumbItems = pathSnippets.map(url => {
+ const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url);
+ if (currentBreadcrumb.inherited) {
+ return null;
+ }
+ const name = renderItemLocal(currentBreadcrumb);
+ const { hideInBreadcrumb } = currentBreadcrumb;
+ return name && !hideInBreadcrumb
+ ? {
+ path: url,
+ breadcrumbName: name,
+ }
+ : null;
+ });
+ // Add home breadcrumbs to your head if defined
+ if (home) {
+ extraBreadcrumbItems.unshift({
+ path: '/',
+ breadcrumbName: home,
+ });
+ }
+ return extraBreadcrumbItems;
+};
+
+/**
+ * 将参数转化为面包屑
+ * Convert parameters into breadcrumbs
+ */
+export const conversionBreadcrumbList = props => {
+ const { breadcrumbList } = props;
+ const { routes, params, routerLocation, breadcrumbNameMap } = getBreadcrumbProps(props);
+ if (breadcrumbList && breadcrumbList.length) {
+ return conversionFromProps();
+ }
+ // 如果传入 routes 和 params 属性
+ // If pass routes and params attributes
+ if (routes && params) {
+ return {
+ routes: routes.filter(route => route.breadcrumbName),
+ params,
+ itemRender,
+ };
+ }
+ // 根据 location 生成 面包屑
+ // Generate breadcrumbs based on location
+ if (routerLocation && routerLocation.pathname) {
+ return {
+ routes: conversionFromLocation(routerLocation, breadcrumbNameMap, props),
+ itemRender,
+ };
+ }
+ return {};
+};
diff --git a/src/components/PageHeaderWrapper/index.d.ts b/src/components/PageHeaderWrapper/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..21c8759b1563cecad6ee36e1d39a54247984489a
--- /dev/null
+++ b/src/components/PageHeaderWrapper/index.d.ts
@@ -0,0 +1,12 @@
+import React from 'react';
+export interface ResultProps {
+ actions?: React.ReactNode;
+ className?: string;
+ description?: React.ReactNode;
+ extra?: React.ReactNode;
+ style?: React.CSSProperties;
+ title?: React.ReactNode;
+ type: 'success' | 'error';
+}
+
+export default class Result extends React.Component {}
diff --git a/src/components/PageHeaderWrapper/index.js b/src/components/PageHeaderWrapper/index.js
index cd745f66e8db1182493560238cc60762235dad09..7a766834c4ac39cd3628409d45fe3cd09bff1fe7 100644
--- a/src/components/PageHeaderWrapper/index.js
+++ b/src/components/PageHeaderWrapper/index.js
@@ -1,40 +1,103 @@
import React from 'react';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
-import PageHeader from '@/components/PageHeader';
+import { PageHeader, Tabs, Typography } from 'antd';
import { connect } from 'dva';
+import classNames from 'classnames';
import GridContent from './GridContent';
import styles from './index.less';
import MenuContext from '@/layouts/MenuContext';
+import { conversionBreadcrumbList } from './breadcrumb';
-const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => (
-
- {top}
-
- {value => (
- }
- {...value}
- key="pageheader"
- {...restProps}
- linkElement={Link}
- itemRender={item => {
- if (item.locale) {
- return ;
- }
- return item.title;
+const { Title } = Typography;
+
+/**
+ * render Footer tabList
+ * In order to be compatible with the old version of the PageHeader
+ * basically all the functions are implemented.
+ */
+const renderFooter = ({ tabList, activeKeyProps, onTabChange, tabBarExtraContent }) => {
+ return tabList && tabList.length ? (
+ {
+ if (onTabChange) {
+ onTabChange(key);
+ }
+ }}
+ tabBarExtraContent={tabBarExtraContent}
+ >
+ {tabList.map(item => (
+
+ ))}
+
+ ) : null;
+};
+
+const PageHeaderWrapper = ({
+ children,
+ contentWidth,
+ wrapperClassName,
+ top,
+ title,
+ content,
+ logo,
+ extraContent,
+ ...restProps
+}) => {
+ return (
+
+ {top}
+ {title && content && (
+
+ {value => {
+ return (
+
+ {title}
+
+ }
+ key="pageheader"
+ {...restProps}
+ breadcrumb={conversionBreadcrumbList({
+ ...value,
+ ...restProps,
+ home: ,
+ })}
+ className={styles.pageHeader}
+ linkElement={Link}
+ footer={renderFooter(restProps)}
+ >
+
+ {logo &&
{logo}
}
+
+
+ {content &&
{content}
}
+ {extraContent &&
{extraContent}
}
+
+
+
+
+ );
}}
- />
+
)}
-
- {children ? (
-
- {children}
-
- ) : null}
-
-);
+ {children ? (
+
+ {children}
+
+ ) : null}
+
+ );
+};
export default connect(({ setting }) => ({
contentWidth: setting.contentWidth,
diff --git a/src/components/PageHeaderWrapper/index.less b/src/components/PageHeaderWrapper/index.less
index 39a449657a98b039c29e6654fd117267cbb5283a..119585bbaef2af9a3a3f4dd90ce882a50a5a98e8 100644
--- a/src/components/PageHeaderWrapper/index.less
+++ b/src/components/PageHeaderWrapper/index.less
@@ -1,11 +1,110 @@
@import '~antd/lib/style/themes/default.less';
-.content {
+.children-content {
margin: 24px 24px 0;
}
-@media screen and (max-width: @screen-sm) {
+.main {
+ :global {
+ .ant-page-header {
+ padding: 16px 32px 0;
+ background: #fff;
+ border-bottom: 1px solid #e8e8e8;
+ }
+ }
+
+ .wide {
+ max-width: 1200px;
+ margin: auto;
+ }
+ .detail {
+ display: flex;
+ }
+
+ .row {
+ display: flex;
+ width: 100%;
+ }
+
+ .logo {
+ flex: 0 1 auto;
+ margin-right: 16px;
+ padding-top: 1px;
+ > img {
+ display: block;
+ width: 28px;
+ height: 28px;
+ border-radius: @border-radius-base;
+ }
+ }
+
+ .title-content {
+ margin-bottom: 16px;
+ }
+
+ @media screen and (max-width: @screen-sm) {
+ .content {
+ margin: 24px 0 0;
+ }
+ }
+
+ .title,
.content {
- margin: 24px 0 0;
+ flex: auto;
+ }
+
+ .extraContent,
+ .main {
+ flex: 0 1 auto;
+ }
+
+ .main {
+ width: 100%;
+ }
+
+ .title {
+ margin-bottom: 16px;
+ }
+
+ .logo,
+ .content,
+ .extraContent {
+ margin-bottom: 16px;
+ }
+
+ .extraContent {
+ min-width: 242px;
+ margin-left: 88px;
+ text-align: right;
+ }
+}
+
+@media screen and (max-width: @screen-xl) {
+ .extraContent {
+ margin-left: 44px;
+ }
+}
+
+@media screen and (max-width: @screen-lg) {
+ .extraContent {
+ margin-left: 20px;
+ }
+}
+
+@media screen and (max-width: @screen-md) {
+ .row {
+ display: block;
+ }
+
+ .action,
+ .extraContent {
+ margin-left: 0;
+ text-align: left;
+ }
+}
+
+@media screen and (max-width: @screen-sm) {
+ .detail {
+ display: block;
}
}
diff --git a/src/components/Result/index.d.ts b/src/components/Result/index.d.ts
index 0c34c254014f49c0d7322acc1dab47cbd2fd52b4..21c8759b1563cecad6ee36e1d39a54247984489a 100644
--- a/src/components/Result/index.d.ts
+++ b/src/components/Result/index.d.ts
@@ -1,11 +1,12 @@
-import * as React from 'react';
-export interface IResultProps {
- type: 'success' | 'error';
- title: React.ReactNode;
+import React from 'react';
+export interface ResultProps {
+ actions?: React.ReactNode;
+ className?: string;
description?: React.ReactNode;
extra?: React.ReactNode;
- actions?: React.ReactNode;
style?: React.CSSProperties;
+ title?: React.ReactNode;
+ type: 'success' | 'error';
}
-export default class Result extends React.Component {}
+export default class Result extends React.Component {}
diff --git a/src/components/SelectLang/index.d.ts b/src/components/SelectLang/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d2c53fa32b8c1fe1934d70835d09992ea8475d87
--- /dev/null
+++ b/src/components/SelectLang/index.d.ts
@@ -0,0 +1,7 @@
+import React from 'react';
+
+export interface SelectLangProps {
+ className?: string;
+}
+
+export default class SelectLang extends React.Component {}
diff --git a/src/components/SelectLang/index.js b/src/components/SelectLang/index.js
index f6abe2f279ef9c8c34463406f0c2a94503e6650d..3ce3fb8d3634b21f8471135e0a5da1db9c63d9d0 100644
--- a/src/components/SelectLang/index.js
+++ b/src/components/SelectLang/index.js
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
-import { formatMessage, setLocale, getLocale } from 'umi/locale';
+import { formatMessage, setLocale, getLocale } from 'umi-plugin-react/locale';
import { Menu, Icon } from 'antd';
import classNames from 'classnames';
import HeaderDropdown from '../HeaderDropdown';
diff --git a/src/components/SettingDrawer/BlockCheckbox.d.ts b/src/components/SettingDrawer/BlockCheckbox.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1012294ec0d129e79c936ed8c9cdce681eaad980
--- /dev/null
+++ b/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 {}
diff --git a/src/components/SettingDrawer/ThemeColor.d.ts b/src/components/SettingDrawer/ThemeColor.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..17bc3e8dec81b3695fa21a459d826b9e5f220937
--- /dev/null
+++ b/src/components/SettingDrawer/ThemeColor.d.ts
@@ -0,0 +1,10 @@
+import React from 'react';
+
+export interface TagProps {
+ color: string;
+ check: boolean;
+ className?: string;
+ onClick?: () => void;
+}
+
+export default class ThemeColor extends React.Component {}
diff --git a/src/components/SettingDrawer/ThemeColor.js b/src/components/SettingDrawer/ThemeColor.js
index e5d66d4be5cb29a2684eff46734e06fba17d6923..9765b737e44a3a8168f5561306cdca56fc9c5e88 100644
--- a/src/components/SettingDrawer/ThemeColor.js
+++ b/src/components/SettingDrawer/ThemeColor.js
@@ -1,6 +1,6 @@
import React from 'react';
import { Tooltip, Icon } from 'antd';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import styles from './ThemeColor.less';
const Tag = ({ color, check, ...rest }) => (
diff --git a/src/components/SettingDrawer/index.d.ts b/src/components/SettingDrawer/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..22273089eb54c481a581cd0e53635b05fbae8234
--- /dev/null
+++ b/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 {}
diff --git a/src/components/SettingDrawer/index.js b/src/components/SettingDrawer/index.js
index 4b279f593ec8cf032d00bb6783b01b001a4b016d..dcf341a0212ff943c7bafd7654f37b1cfbfa7470 100644
--- a/src/components/SettingDrawer/index.js
+++ b/src/components/SettingDrawer/index.js
@@ -1,6 +1,6 @@
-import React, { PureComponent } from 'react';
+import React, { Component } from 'react';
import { Select, message, Drawer, List, Switch, Divider, Icon, Button, Alert, Tooltip } from 'antd';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { connect } from 'dva';
import omit from 'omit.js';
@@ -23,7 +23,7 @@ const Body = ({ children, title, style }) => (
);
@connect(({ setting }) => ({ setting }))
-class SettingDrawer extends PureComponent {
+class SettingDrawer extends Component {
state = {
collapse: false,
};
@@ -137,7 +137,7 @@ class SettingDrawer extends PureComponent {
onClose={this.togglerContent}
placement="right"
handler={
-
+
}
- onHandleClick={this.togglerContent}
style={{
zIndex: 999,
}}
@@ -208,17 +207,22 @@ class SettingDrawer extends PureComponent {
-
this.changeSetting('colorWeak', checked)}
- />,
+ this.changeSetting('colorWeak', checked)}
+ />
+ ),
+ },
]}
- >
- {formatMessage({ id: 'app.setting.weakmode' })}
-
+ />
void;
+ isMobile?: boolean;
+ openKeys?: any;
+ theme?: SiderTheme;
+ mode?: MenuMode;
+ className?: string;
+ collapsed?: boolean;
+ handleOpenChange?: (openKeys: any[]) => void;
+ menuData?: any[];
+ style?: React.CSSProperties;
+ onOpenChange?: (openKeys: string[]) => void;
+}
+
+export default class BaseMenu extends React.Component {}
diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js
index 6c8c7022219e552b1b5696c16e50eac0070ad052..9ab66ec3c03111edb1920d7d61e14dfef92838a2 100644
--- a/src/components/SiderMenu/BaseMenu.js
+++ b/src/components/SiderMenu/BaseMenu.js
@@ -33,13 +33,13 @@ export default class BaseMenu extends PureComponent {
* 获得菜单子节点
* @memberof SiderMenu
*/
- getNavMenuItems = (menusData, parent) => {
+ getNavMenuItems = menusData => {
if (!menusData) {
return [];
}
return menusData
.filter(item => item.name && !item.hideInMenu)
- .map(item => this.getSubMenuOrItem(item, parent))
+ .map(item => this.getSubMenuOrItem(item))
.filter(item => item);
};
diff --git a/src/components/SiderMenu/SiderMenu.d.ts b/src/components/SiderMenu/SiderMenu.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..c18162a8df526f009d9575742eb24748d5e66afb
--- /dev/null
+++ b/src/components/SiderMenu/SiderMenu.d.ts
@@ -0,0 +1,11 @@
+import React from 'react';
+import * as H from 'history';
+import { BaseMenuProps } from './BaseMenu';
+import { SiderTheme } from 'antd/es/Layout/Sider';
+
+export interface SiderMenuProps extends BaseMenuProps {
+ logo?: string;
+ fixSiderbar?: boolean;
+}
+
+export default class SiderMenu extends React.Component {}
diff --git a/src/components/SiderMenu/index.d.ts b/src/components/SiderMenu/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..383df9e11d934270685cadc6d6b38d3f2449f9bc
--- /dev/null
+++ b/src/components/SiderMenu/index.d.ts
@@ -0,0 +1,13 @@
+import React from 'react';
+import { SiderTheme } from 'antd/es/Layout/Sider';
+
+export interface SiderMenuProps {
+ isMobile: boolean;
+ menuData: any[];
+ collapsed: boolean;
+ logo?: string;
+ theme?: SiderTheme;
+ onCollapse: (payload: boolean) => void;
+}
+
+export default class SiderMenuWrapper extends React.Component {}
diff --git a/src/components/StandardFormRow/index.d.ts b/src/components/StandardFormRow/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..de06c9b8292f54373292089364281688eb8a95bc
--- /dev/null
+++ b/src/components/StandardFormRow/index.d.ts
@@ -0,0 +1,11 @@
+import React from 'react';
+
+export interface StandardFormRowProps {
+ title: string;
+ last?: boolean;
+ block?: boolean;
+ grid?: boolean;
+ style?: React.CSSProperties;
+}
+
+export default class StandardFormRow extends React.Component {}
diff --git a/src/components/StandardTable/index.d.ts b/src/components/StandardTable/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d9addeffae1b59d9a7ea2bbc1924e6c9543e94f5
--- /dev/null
+++ b/src/components/StandardTable/index.d.ts
@@ -0,0 +1,19 @@
+import React from 'react';
+import { PaginationConfig, SorterResult, TableCurrentDataSource } from 'antd/lib/table';
+
+export interface StandardTableProps {
+ columns: any;
+ onSelectRow: (row: any) => void;
+ data: any;
+ rowKey?: string;
+ selectedRows: any[];
+ onChange?: (
+ pagination: PaginationConfig,
+ filters: Record,
+ sorter: SorterResult,
+ extra?: TableCurrentDataSource
+ ) => void;
+ loading?: boolean;
+}
+
+export default class StandardTable extends React.Component {}
diff --git a/src/components/TagSelect/TagSelectOption.d.ts b/src/components/TagSelect/TagSelectOption.d.ts
index 366b297a7d3ff01c2a07a5c219b1b04558b8f8ab..3343d744ce1f5ae5e4ad252146e6c891447292ee 100644
--- a/src/components/TagSelect/TagSelectOption.d.ts
+++ b/src/components/TagSelect/TagSelectOption.d.ts
@@ -1,8 +1,12 @@
-import * as React from 'react';
+import React from 'react';
-export interface ITagSelectOptionProps {
- value: string | number;
+export interface TagSelectOptionProps {
+ value?: string | number;
style?: React.CSSProperties;
+ checked?: boolean;
+ onChange?: (value: string | number, state: boolean) => void;
}
-export default class TagSelectOption extends React.Component {}
+export default class TagSelectOption extends React.Component {
+ public static isTagSelectOption?: boolean;
+}
diff --git a/src/components/TagSelect/index.d.ts b/src/components/TagSelect/index.d.ts
index 9de30263f1795b5cb323085b9eb3109d720c14cb..c225a86fe676fafbca8c4ff2f2ab9ebb06651994 100644
--- a/src/components/TagSelect/index.d.ts
+++ b/src/components/TagSelect/index.d.ts
@@ -1,16 +1,23 @@
-import * as React from 'react';
-import TagSelectOption from './TagSelectOption';
+import React from 'react';
+import TagSelectOption, { TagSelectOptionProps } from './TagSelectOption';
-export interface ITagSelectProps {
+export interface TagSelectProps {
onChange?: (value: string[]) => void;
expandable?: boolean;
value?: string[] | number[];
style?: React.CSSProperties;
hideCheckAll?: boolean;
- actionsText?: { expandText?: string; collapseText?: string; selectAllText?: string };
+ actionsText?: {
+ expandText?: React.ReactNode;
+ collapseText?: React.ReactNode;
+ selectAllText?: React.ReactNode;
+ };
+ className: string;
+ Option: TagSelectOptionProps;
+ children: React.ReactElement | Array>;
}
-export default class TagSelect extends React.Component {
+export default class TagSelect extends React.Component {
public static Option: typeof TagSelectOption;
private children:
| React.ReactElement
diff --git a/src/components/TopNavHeader/index.d.ts b/src/components/TopNavHeader/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2d6631be39d999010264de2771e960f887eb4966
--- /dev/null
+++ b/src/components/TopNavHeader/index.d.ts
@@ -0,0 +1,25 @@
+import React from 'react';
+import { SiderTheme, CollapseType } from 'antd/es/Layout/Sider';
+import { MenuMode } from 'antd/es/menu';
+
+export interface TopNavHeaderProps {
+ theme: SiderTheme;
+ contentWidth?: string;
+ menuData?: any[];
+ logo?: string;
+ mode?: MenuMode;
+ flatMenuKeys?: any[];
+ onCollapse?: (collapsed: boolean, type?: CollapseType) => void;
+ isMobile?: boolean;
+ openKeys?: any;
+ className?: string;
+ collapsed?: boolean;
+ handleOpenChange?: (openKeys: any[]) => void;
+ style?: React.CSSProperties;
+ onOpenChange?: (openKeys: string[]) => void;
+ onNoticeClear?: (type: string) => void;
+ onMenuClick?: ({ key: string }) => void;
+ onNoticeVisibleChange?: (b: boolean) => void;
+}
+
+export default class TopNavHeader extends React.Component {}
diff --git a/src/components/TopNavHeader/index.js b/src/components/TopNavHeader/index.js
index 2d0e06561e0ef053594f157cd428b68874cc951d..0b6440e6d40f147fc083daf4fb9ce9a21eb60df0 100644
--- a/src/components/TopNavHeader/index.js
+++ b/src/components/TopNavHeader/index.js
@@ -13,7 +13,11 @@ export default class TopNavHeader extends PureComponent {
static getDerivedStateFromProps(props) {
return {
- maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 280 - 165 - 40,
+ maxWidth:
+ (props.contentWidth === 'Fixed' && window.innerWidth > 1200 ? 1200 : window.innerWidth) -
+ 280 -
+ 120 -
+ 40,
};
}
diff --git a/src/components/Trend/index.d.ts b/src/components/Trend/index.d.ts
index 7dc02010301cb3194c41d91b6bf01ac1dbdce1b8..a7775ae9b53ea3e5390f31a7df113ce4b6c3a5e6 100644
--- a/src/components/Trend/index.d.ts
+++ b/src/components/Trend/index.d.ts
@@ -1,10 +1,11 @@
-import * as React from 'react';
+import React from 'react';
export interface ITrendProps {
colorful?: boolean;
flag: 'up' | 'down';
style?: React.CSSProperties;
reverseColor?: boolean;
+ className?: string;
}
export default class Trend extends React.Component {}
diff --git a/src/defaultSettings.js b/src/defaultSettings.js
index 4ba7eb390c49069b68053d9823f194a76f99391d..4e7e8018c5ed602b27f28cacff272e8f788383ca 100644
--- a/src/defaultSettings.js
+++ b/src/defaultSettings.js
@@ -11,8 +11,9 @@ module.exports = {
},
title: 'Ant Design Pro',
pwa: true,
- // your iconfont Symbol Scrip Url
+ // Your custom iconfont Symbol script Url
// eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js
- // 注意:如果需要图标多色,Iconfont图标项目里要进行批量去色处理
+ // 注意:如果需要图标多色,Iconfont 图标项目里要进行批量去色处理
+ // Usage: https://github.com/ant-design/ant-design-pro/pull/3517
iconfontUrl: '',
};
diff --git a/src/e2e/baseLayout.e2e.js b/src/e2e/baseLayout.e2e.js
index 74938719d5a2c071fba3f1e407ca18af1c36720e..70bb984df31a07311ef8a8f49df3554b56917400 100644
--- a/src/e2e/baseLayout.e2e.js
+++ b/src/e2e/baseLayout.e2e.js
@@ -5,13 +5,17 @@ const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
function formatter(data) {
return data
.reduce((pre, item) => {
- pre.push(item.path);
+ if (item.routes) {
+ pre.push(item.routes[0].path);
+ } else {
+ pre.push(item.path);
+ }
return pre;
}, [])
.filter(item => item);
}
-describe('Homepage', async () => {
+describe('Homepage', () => {
const testPage = path => async () => {
await page.goto(`${BASE_URL}${path}`);
await page.waitForSelector('footer', {
diff --git a/src/e2e/topMenu.e2e.js b/src/e2e/topMenu.e2e.js
index 51ff9f35c632e3c6471b153b45f76b40e9a11cc9..d90983b9fef9d63ab2a64ce3c36ee7aed66622f5 100644
--- a/src/e2e/topMenu.e2e.js
+++ b/src/e2e/topMenu.e2e.js
@@ -4,6 +4,7 @@ describe('Homepage', () => {
beforeAll(async () => {
jest.setTimeout(1000000);
});
+
it('topmenu should have footer', async () => {
const params = '/form/basic-form?navTheme=light&layout=topmenu';
await page.goto(`${BASE_URL}${params}`);
diff --git a/src/global.js b/src/global.js
index bebe4829c63d4f4a47f4aa7bf649f23e2deef90d..a0ecf97a027f3c687d6856e67d80817a002c94e7 100644
--- a/src/global.js
+++ b/src/global.js
@@ -1,6 +1,6 @@
import React from 'react';
import { notification, Button, message } from 'antd';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import defaultSettings from './defaultSettings';
window.React = React;
diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js
index 338968764205ff7caed5c6042f0e5c459f237e5d..3b4ae35c112b1f6d5ab5c2be017e85a7dd6c5973 100644
--- a/src/layouts/BasicLayout.js
+++ b/src/layouts/BasicLayout.js
@@ -4,15 +4,11 @@ import DocumentTitle from 'react-document-title';
import { connect } from 'dva';
import { ContainerQuery } from 'react-container-query';
import classNames from 'classnames';
-import pathToRegexp from 'path-to-regexp';
import Media from 'react-media';
-import Authorized from '@/utils/Authorized';
import logo from '../assets/logo.svg';
import Footer from './Footer';
import Header from './Header';
import Context from './MenuContext';
-import Exception403 from '../pages/Exception/403';
-import PageLoading from '@/components/PageLoading';
import SiderMenu from '@/components/SiderMenu';
import getPageTitle from '@/utils/getPageTitle';
import styles from './BasicLayout.less';
@@ -49,10 +45,7 @@ const query = {
class BasicLayout extends React.Component {
componentDidMount() {
- const {
- dispatch,
- route: { routes, authority },
- } = this.props;
+ const { dispatch } = this.props;
dispatch({
type: 'user/fetchCurrent',
});
@@ -61,7 +54,6 @@ class BasicLayout extends React.Component {
});
dispatch({
type: 'menu/getMenuData',
- payload: { routes, authority },
});
}
@@ -73,29 +65,6 @@ class BasicLayout extends React.Component {
};
}
- getRouteAuthority = (pathname, routeData) => {
- const routes = routeData.slice(); // clone
-
- const getAuthority = (routeDatas, path) => {
- let authorities;
- routeDatas.forEach(route => {
- // check partial route
- if (pathToRegexp(`${route.path}(.*)`).test(path)) {
- if (route.authority) {
- authorities = route.authority;
- }
- // is exact route?
- if (!pathToRegexp(route.path).test(path) && route.routes) {
- authorities = getAuthority(route.routes, path);
- }
- }
- });
- return authorities;
- };
-
- return getAuthority(routes, pathname);
- };
-
getLayoutStyle = () => {
const { fixSiderbar, isMobile, collapsed, layout } = this.props;
if (fixSiderbar && layout !== 'topmenu' && !isMobile) {
@@ -132,12 +101,10 @@ class BasicLayout extends React.Component {
isMobile,
menuData,
breadcrumbNameMap,
- route: { routes },
fixedHeader,
} = this.props;
const isTop = PropsLayout === 'topmenu';
- const routerConfig = this.getRouteAuthority(pathname, routes);
const contentStyle = !fixedHeader ? { paddingTop: 0 } : {};
const layout = (
@@ -165,9 +132,7 @@ class BasicLayout extends React.Component {
{...this.props}
/>
- }>
- {children}
-
+ {children}
@@ -184,7 +149,7 @@ class BasicLayout extends React.Component {
)}
- }>{this.renderSettingDrawer()}
+ {this.renderSettingDrawer()}
);
}
diff --git a/src/layouts/Header.js b/src/layouts/Header.js
index 0059ee7ea951319140e6589da1134e5fbe3b12c2..e58d37c56c37afff57b04f75e6ec1b8f6b199c56 100644
--- a/src/layouts/Header.js
+++ b/src/layouts/Header.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import { Layout, message } from 'antd';
import Animate from 'rc-animate';
import { connect } from 'dva';
@@ -120,7 +120,10 @@ class HeaderView extends Component {
const isTop = layout === 'topmenu';
const width = this.getHeadWidth();
const HeaderDom = visible ? (
-
+
{isTop && !isMobile ? (
({
collapsed: global.collapsed,
fetchingMoreNotices: loading.effects['global/fetchMoreNotices'],
fetchingNotices: loading.effects['global/fetchNotices'],
- loadedAllNotices: global.loadedAllNotices,
notices: global.notices,
setting,
}))(HeaderView);
diff --git a/src/layouts/UserLayout.js b/src/layouts/UserLayout.js
index 18fb176e26e9af4b08b34e52d23e69c03b19688a..93f826b30cfb187edd27a8d9a88a345da3f30c88 100644
--- a/src/layouts/UserLayout.js
+++ b/src/layouts/UserLayout.js
@@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import { connect } from 'dva';
import Link from 'umi/link';
import { Icon } from 'antd';
diff --git a/src/locales/en-US.js b/src/locales/en-US.js
index 25f2888c58c13f5ee8532e0b522cfd7169b77a2a..a10691ce541b067721da3e4f0356d3b3a27f3e7b 100644
--- a/src/locales/en-US.js
+++ b/src/locales/en-US.js
@@ -10,6 +10,7 @@ import settingDrawer from './en-US/settingDrawer';
import settings from './en-US/settings';
import pwa from './en-US/pwa';
import component from './en-US/component';
+import editor from './en-US/editor';
export default {
'navBar.lang': 'Languages',
@@ -32,4 +33,5 @@ export default {
...settings,
...pwa,
...component,
+ ...editor,
};
diff --git a/src/locales/en-US/component.js b/src/locales/en-US/component.js
index 3ba7eeda69c7cd6edc5fd8d205bd626531737a45..910f30e1115034deb50232050092a296c3263a13 100644
--- a/src/locales/en-US/component.js
+++ b/src/locales/en-US/component.js
@@ -2,4 +2,5 @@ export default {
'component.tagSelect.expand': 'Expand',
'component.tagSelect.collapse': 'Collapse',
'component.tagSelect.all': 'All',
+ 'component.miniProgress.tooltipDefault': 'Target value',
};
diff --git a/src/locales/en-US/editor.js b/src/locales/en-US/editor.js
new file mode 100644
index 0000000000000000000000000000000000000000..81bd0f170a0aca1a2a438898d177062de65f4256
--- /dev/null
+++ b/src/locales/en-US/editor.js
@@ -0,0 +1,11 @@
+export default {
+ 'app.editor.flow.title': 'Flowchart Editor',
+ 'app.editor.flow.description':
+ 'The flow chart is an excellent way to represent the idea of the algorithm.',
+ 'app.editor.koni.title': 'Koni Editor',
+ 'app.editor.koni.description':
+ 'The topology diagram refers to the network structure diagram composed of network node devices and communication media.',
+ 'app.editor.mind.title': 'Mind Map Editor',
+ 'app.editor.mind.description':
+ 'The brain map is an effective graphical thinking tool for expressing divergent thinking. It is simple but effective and is a practical thinking tool.',
+};
diff --git a/src/locales/en-US/globalHeader.js b/src/locales/en-US/globalHeader.js
index 29f21d7d264c280642637ee533d762dc92e64423..60b6d4ec2d4608a8daf42407b3b5e8afd414b205 100644
--- a/src/locales/en-US/globalHeader.js
+++ b/src/locales/en-US/globalHeader.js
@@ -13,6 +13,5 @@ export default {
'component.noticeIcon.clear': 'Clear',
'component.noticeIcon.cleared': 'Cleared',
'component.noticeIcon.empty': 'No notifications',
- 'component.noticeIcon.loaded': 'Loaded',
- 'component.noticeIcon.loading-more': 'Loading more',
+ 'component.noticeIcon.view-more': 'View more',
};
diff --git a/src/locales/en-US/menu.js b/src/locales/en-US/menu.js
index 056c255eca4bffa91f1e11706ec92d2b4b96cdc7..25805ead5e598de6c1539b1dafa70b1079f877af 100644
--- a/src/locales/en-US/menu.js
+++ b/src/locales/en-US/menu.js
@@ -38,4 +38,8 @@ export default {
'menu.account.settings': 'Account Settings',
'menu.account.trigger': 'Trigger Error',
'menu.account.logout': 'Logout',
+ 'menu.editor': 'Graphic Editor',
+ 'menu.editor.flow': 'Flow Editor',
+ 'menu.editor.mind': 'Mind Editor',
+ 'menu.editor.koni': 'Koni Editor',
};
diff --git a/src/locales/pt-BR.js b/src/locales/pt-BR.js
index af8bcee53c1a28e9436853fe9a6a4c8b61d4755e..19e82643d4d9aab5eadd19b35c371bb46c5c8e03 100644
--- a/src/locales/pt-BR.js
+++ b/src/locales/pt-BR.js
@@ -10,6 +10,7 @@ import settingDrawer from './pt-BR/settingDrawer';
import settings from './pt-BR/settings';
import pwa from './pt-BR/pwa';
import component from './pt-BR/component';
+import editor from './pt-BR/editor';
export default {
'navBar.lang': 'Idiomas',
@@ -32,4 +33,5 @@ export default {
...settings,
...pwa,
...component,
+ ...editor,
};
diff --git a/src/locales/pt-BR/component.js b/src/locales/pt-BR/component.js
index 7cf9999c3ab4296935f65eb6d270ec4c9126c485..d3a2c1b3137bfbd70c859c0923e12ed11f842f4b 100644
--- a/src/locales/pt-BR/component.js
+++ b/src/locales/pt-BR/component.js
@@ -2,4 +2,5 @@ export default {
'component.tagSelect.expand': 'Expandir',
'component.tagSelect.collapse': 'Diminuir',
'component.tagSelect.all': 'Todas',
+ 'component.miniProgress.tooltipDefault': 'Valor alvo',
};
diff --git a/src/locales/pt-BR/editor.js b/src/locales/pt-BR/editor.js
new file mode 100644
index 0000000000000000000000000000000000000000..10237f9b7443fa000fbfc6254e0621053cea7318
--- /dev/null
+++ b/src/locales/pt-BR/editor.js
@@ -0,0 +1,11 @@
+export default {
+ 'app.editor.flow.title': 'Editor de diagrama de flujo',
+ 'app.editor.flow.description':
+ 'El diagrama de flujo es una excelente manera de representar la idea del algoritmo.',
+ 'app.editor.koni.title': 'Editor de topologia',
+ 'app.editor.koni.description':
+ 'El diagrama de topología se refiere al diagrama de estructura de red compuesto por dispositivos de nodo de red y medios de comunicación.',
+ 'app.editor.mind.title': 'Editor de mapas cerebrales',
+ 'app.editor.mind.description':
+ 'El mapa cerebral es una herramienta de pensamiento gráfico eficaz para expresar el pensamiento divergente. Es simple pero efectivo y es una herramienta de pensamiento práctico.',
+};
diff --git a/src/locales/pt-BR/globalHeader.js b/src/locales/pt-BR/globalHeader.js
index eac034d50bd65844b3d5246011344f7c3fdab008..c92739919227815c35d19e1ccf39949fdb8ba255 100644
--- a/src/locales/pt-BR/globalHeader.js
+++ b/src/locales/pt-BR/globalHeader.js
@@ -14,5 +14,5 @@ export default {
'component.noticeIcon.cleared': 'Limpo',
'component.noticeIcon.empty': 'Sem notificações',
'component.noticeIcon.loaded': 'Carregado',
- 'component.noticeIcon.loading-more': 'Carregar mais',
+ 'component.noticeIcon.view-more': 'Veja mais',
};
diff --git a/src/locales/pt-BR/menu.js b/src/locales/pt-BR/menu.js
index 77ee7fd7e37cbd51ee043f2ebb472e1b097faa5c..994f73cd10dd597a89ea29c5e7703f170c1a9da0 100644
--- a/src/locales/pt-BR/menu.js
+++ b/src/locales/pt-BR/menu.js
@@ -38,4 +38,8 @@ export default {
'menu.account.settings': 'Configurar Conta',
'menu.account.trigger': 'Disparar Erro',
'menu.account.logout': 'Sair',
+ 'menu.editor': 'Graphic Editor',
+ 'menu.editor.flow': 'Flow Editor',
+ 'menu.editor.mind': 'Mind Editor',
+ 'menu.editor.koni': 'Koni Editor',
};
diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js
index cf601f378ee3d2584adaf91fb87e81249dcfbf3b..6cc85e4b9aab540d6e330f8c4270a9d71c1ea102 100644
--- a/src/locales/zh-CN.js
+++ b/src/locales/zh-CN.js
@@ -10,6 +10,7 @@ import settingDrawer from './zh-CN/settingDrawer';
import settings from './zh-CN/settings';
import pwa from './zh-CN/pwa';
import component from './zh-CN/component';
+import editor from './zh-CN/editor';
export default {
'navBar.lang': '语言',
@@ -32,4 +33,5 @@ export default {
...settings,
...pwa,
...component,
+ ...editor,
};
diff --git a/src/locales/zh-CN/component.js b/src/locales/zh-CN/component.js
index 1f1feadbf6f1494e8da6a1e781a87399f1c46a8a..8d988ca0be8f0cc25b69879f90f799ec3b5774ec 100644
--- a/src/locales/zh-CN/component.js
+++ b/src/locales/zh-CN/component.js
@@ -2,4 +2,5 @@ export default {
'component.tagSelect.expand': '展开',
'component.tagSelect.collapse': '收起',
'component.tagSelect.all': '全部',
+ 'component.miniProgress.tooltipDefault': '目标值',
};
diff --git a/src/locales/zh-CN/editor.js b/src/locales/zh-CN/editor.js
new file mode 100644
index 0000000000000000000000000000000000000000..1688644e8130e38cf2193a1ab40e511f4b55a1a0
--- /dev/null
+++ b/src/locales/zh-CN/editor.js
@@ -0,0 +1,9 @@
+export default {
+ 'app.editor.flow.title': '流程图编辑器',
+ 'app.editor.flow.description': '千言万语不如一张图,流程图是表示算法思路的好方法',
+ 'app.editor.koni.title': '拓扑编辑器',
+ 'app.editor.koni.description': '拓扑结构图是指由网络节点设备和通信介质构成的网络结构图',
+ 'app.editor.mind.title': '脑图编辑器',
+ 'app.editor.mind.description':
+ '脑图是表达发散性思维的有效图形思维工具 ,它简单却又很有效,是一种实用性的思维工具。',
+};
diff --git a/src/locales/zh-CN/exception.js b/src/locales/zh-CN/exception.js
index 6f645daed63e332c6ad54aa146bdcf4e720c38c8..1b89ab76b33a52727731f14fe8ebc2efd8820f91 100644
--- a/src/locales/zh-CN/exception.js
+++ b/src/locales/zh-CN/exception.js
@@ -1,6 +1,6 @@
export default {
'app.exception.back': '返回首页',
- 'app.exception.description.403': '抱歉,你无权访问该页面',
+ 'app.exception.description.403': '抱歉,你无权访问此页面',
'app.exception.description.404': '抱歉,你访问的页面不存在',
'app.exception.description.500': '抱歉,服务器出错了',
};
diff --git a/src/locales/zh-CN/globalHeader.js b/src/locales/zh-CN/globalHeader.js
index 204538294cedfe4d37dfa7436dadf9dc8f6b73ef..9fd66a5875f088d1071b48e87b1102c128663be8 100644
--- a/src/locales/zh-CN/globalHeader.js
+++ b/src/locales/zh-CN/globalHeader.js
@@ -13,6 +13,5 @@ export default {
'component.noticeIcon.clear': '清空',
'component.noticeIcon.cleared': '清空了',
'component.noticeIcon.empty': '暂无数据',
- 'component.noticeIcon.loaded': '加载完毕',
- 'component.noticeIcon.loading-more': '加载更多',
+ 'component.noticeIcon.view-more': '查看更多',
};
diff --git a/src/locales/zh-CN/menu.js b/src/locales/zh-CN/menu.js
index 5657c6e056a8f8dc5bff5fc964246b43a1070e70..c057bb2a9c0e9d1bbf7b0c484207ab0d6e79bea4 100644
--- a/src/locales/zh-CN/menu.js
+++ b/src/locales/zh-CN/menu.js
@@ -38,4 +38,8 @@ export default {
'menu.account.settings': '个人设置',
'menu.account.trigger': '触发报错',
'menu.account.logout': '退出登录',
+ 'menu.editor': '图形编辑器',
+ 'menu.editor.flow': '流程编辑器',
+ 'menu.editor.mind': '脑图编辑器',
+ 'menu.editor.koni': '拓扑编辑器',
};
diff --git a/src/locales/zh-TW.js b/src/locales/zh-TW.js
index c621733984db2b669fdff1b4fdc89ac777617ed3..33351509fb4d01009053f7718ccea8b39a2bd183 100644
--- a/src/locales/zh-TW.js
+++ b/src/locales/zh-TW.js
@@ -10,6 +10,7 @@ import settingDrawer from './zh-TW/settingDrawer';
import settings from './zh-TW/settings';
import pwa from './zh-TW/pwa';
import component from './zh-TW/component';
+import editor from './zh-TW/editor';
export default {
'navBar.lang': '語言',
@@ -32,4 +33,5 @@ export default {
...settings,
...pwa,
...component,
+ ...editor,
};
diff --git a/src/locales/zh-TW/component.js b/src/locales/zh-TW/component.js
index ba48e299a91a29a64e2f9834cf5b0b1d3c080fb4..dde9eb5998ca5d4bb177840d2c595f02f0fea7e3 100644
--- a/src/locales/zh-TW/component.js
+++ b/src/locales/zh-TW/component.js
@@ -2,4 +2,5 @@ export default {
'component.tagSelect.expand': '展開',
'component.tagSelect.collapse': '收起',
'component.tagSelect.all': '全部',
+ 'component.miniProgress.tooltipDefault': '目标值',
};
diff --git a/src/locales/zh-TW/editor.js b/src/locales/zh-TW/editor.js
new file mode 100644
index 0000000000000000000000000000000000000000..d1d137748446283a76e6fefc15e35554c6d4ae1e
--- /dev/null
+++ b/src/locales/zh-TW/editor.js
@@ -0,0 +1,9 @@
+export default {
+ 'app.editor.flow.title': '流程圖編輯器',
+ 'app.editor.flow.description': '千言萬語不如一張圖,流程圖是表示算法思路的好方法',
+ 'app.editor.koni.title': '拓撲編輯器',
+ 'app.editor.koni.description': '拓撲結構圖是指由網絡節點設備和通信介質構成的網絡結構圖',
+ 'app.editor.mind.title': '腦圖編輯器',
+ 'app.editor.mind.description':
+ '腦圖是表達發散性思維的有效圖形思維工具 ,它簡單卻又很有效,是一種實用性的思維工具',
+};
diff --git a/src/locales/zh-TW/exception.js b/src/locales/zh-TW/exception.js
index 24a266137bb503e4aa6917daebc2240eaa9150aa..119140d705fcabd6ee04073474c63a18ee1b006a 100644
--- a/src/locales/zh-TW/exception.js
+++ b/src/locales/zh-TW/exception.js
@@ -1,6 +1,6 @@
export default {
'app.exception.back': '返回首頁',
- 'app.exception.description.403': '抱歉,妳無權訪問該頁面',
+ 'app.exception.description.403': '抱歉,妳無權訪問此頁面',
'app.exception.description.404': '抱歉,妳訪問的頁面不存在',
'app.exception.description.500': '抱歉,服務器出錯了',
};
diff --git a/src/locales/zh-TW/globalHeader.js b/src/locales/zh-TW/globalHeader.js
index c7b4e6f6cdc0a42569640f04bfb1a1636ff88159..ed5845185c9e040b43d7d79e914d5358175a7adb 100644
--- a/src/locales/zh-TW/globalHeader.js
+++ b/src/locales/zh-TW/globalHeader.js
@@ -13,6 +13,5 @@ export default {
'component.noticeIcon.clear': '清空',
'component.noticeIcon.cleared': '清空了',
'component.noticeIcon.empty': '暫無資料',
- 'component.noticeIcon.loaded': '加載完畢',
- 'component.noticeIcon.loading-more': '加載更多',
+ 'component.noticeIcon.view-more': '查看更多',
};
diff --git a/src/locales/zh-TW/menu.js b/src/locales/zh-TW/menu.js
index 7bd71a7a7ca8ae5698968a7f1f0d8a8d4dc7c19c..2b1a49ea4b15647700bfb26f3c1680fefe890f9c 100644
--- a/src/locales/zh-TW/menu.js
+++ b/src/locales/zh-TW/menu.js
@@ -38,4 +38,8 @@ export default {
'menu.exception.not-find': '404',
'menu.exception.server-error': '500',
'menu.exception.trigger': '触发错误',
+ 'menu.editor': '圖形編輯器',
+ 'menu.editor.flow': '流程編輯器',
+ 'menu.editor.mind': '腦圖編輯器',
+ 'menu.editor.koni': '拓撲編輯器',
};
diff --git a/src/models/global.js b/src/models/global.js
index 42895b5929507c5c31609bc8ef226f25095d648a..34cff599b1072d2df8615f09e634a5e2548de0bf 100644
--- a/src/models/global.js
+++ b/src/models/global.js
@@ -6,42 +6,14 @@ export default {
state: {
collapsed: false,
notices: [],
- loadedAllNotices: false,
},
effects: {
*fetchNotices(_, { call, put, select }) {
const data = yield call(queryNotices);
- const loadedAllNotices = data && data.length && data[data.length - 1] === null;
- yield put({
- type: 'setLoadedStatus',
- payload: loadedAllNotices,
- });
yield put({
type: 'saveNotices',
- payload: data.filter(item => item),
- });
- const unreadCount = yield select(
- state => state.global.notices.filter(item => !item.read).length
- );
- yield put({
- type: 'user/changeNotifyCount',
- payload: {
- totalCount: data.length,
- unreadCount,
- },
- });
- },
- *fetchMoreNotices({ payload }, { call, put, select }) {
- const data = yield call(queryNotices, payload);
- const loadedAllNotices = data && data.length && data[data.length - 1] === null;
- yield put({
- type: 'setLoadedStatus',
- payload: loadedAllNotices,
- });
- yield put({
- type: 'pushNotices',
- payload: data.filter(item => item),
+ payload: data,
});
const unreadCount = yield select(
state => state.global.notices.filter(item => !item.read).length
@@ -114,18 +86,6 @@ export default {
notices: state.notices.filter(item => item.type !== payload),
};
},
- pushNotices(state, { payload }) {
- return {
- ...state,
- notices: [...state.notices, ...payload],
- };
- },
- setLoadedStatus(state, { payload }) {
- return {
- ...state,
- loadedAllNotices: payload,
- };
- },
},
subscriptions: {
diff --git a/src/models/login.js b/src/models/login.js
index 82fc4249a57c96a9f6387cd34c3b152387f2b320..b5d226aa6bb893f569ba9a3b868116f34bf0e3ed 100644
--- a/src/models/login.js
+++ b/src/models/login.js
@@ -33,8 +33,7 @@ export default {
redirect = redirect.substr(redirect.indexOf('#') + 1);
}
} else {
- window.location.href = redirect;
- return;
+ redirect = null;
}
}
yield put(routerRedux.replace(redirect || '/'));
@@ -54,14 +53,17 @@ export default {
},
});
reloadAuthorized();
- yield put(
- routerRedux.push({
- pathname: '/user/login',
- search: stringify({
- redirect: window.location.href,
- }),
- })
- );
+ // redirect
+ if (window.location.pathname !== '/user/login') {
+ yield put(
+ routerRedux.replace({
+ pathname: '/user/login',
+ search: stringify({
+ redirect: window.location.href,
+ }),
+ })
+ );
+ }
},
},
diff --git a/src/models/menu.js b/src/models/menu.js
index d87072a594e46fb9e21be53d5de47c49da31f73d..b2e565158d16531dbb97a83651b738246aeb679e 100644
--- a/src/models/menu.js
+++ b/src/models/menu.js
@@ -1,6 +1,6 @@
import memoizeOne from 'memoize-one';
import isEqual from 'lodash/isEqual';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import Authorized from '@/utils/Authorized';
import { menu } from '../defaultSettings';
import { queryMenu } from '@/services/user';
@@ -9,6 +9,9 @@ const { check } = Authorized;
// Conversion router to menu.
function formatter(data, parentAuthority, parentName) {
+ if (!data) {
+ return undefined;
+ }
return data
.map(item => {
if (!item.name || !item.path) {
@@ -16,7 +19,7 @@ function formatter(data, parentAuthority, parentName) {
}
let locale = 'menu';
- if (parentName) {
+ if (parentName && parentName !== '/') {
locale = `${parentName}.${item.name}`;
} else {
locale = `menu.${item.name}`;
@@ -76,6 +79,9 @@ const filterMenuData = menuData => {
* @param {Object} menuData 菜单配置
*/
const getBreadcrumbNameMap = menuData => {
+ if (!menuData) {
+ return {};
+ }
const routerMap = {};
const flattenMenuData = data => {
diff --git a/src/pages/404.js b/src/pages/404.js
index 34921c02b789dff7b692f12d6b1ceb9a562ce372..ada3484e5edfe618f8b88bc900d9e42b9a4b7ac3 100644
--- a/src/pages/404.js
+++ b/src/pages/404.js
@@ -1,6 +1,6 @@
import React from 'react';
import Link from 'umi/link';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import Exception from '@/components/Exception';
export default () => (
diff --git a/src/pages/Account/Settings/BaseView.js b/src/pages/Account/Settings/BaseView.js
index f2f2b3a925be290f24c016a6a08230b0fbffde5c..040bd7b5c4b9b3ea3b005b076e8e5f317abe50dc 100644
--- a/src/pages/Account/Settings/BaseView.js
+++ b/src/pages/Account/Settings/BaseView.js
@@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { Form, Input, Upload, Select, Button } from 'antd';
import { connect } from 'dva';
import styles from './BaseView.less';
diff --git a/src/pages/Account/Settings/BindingView.js b/src/pages/Account/Settings/BindingView.js
index 29a29890ca0d5ab339f872f1fe614ff9b0122ea4..f2908874d27f578399a8e805a22ae7f23b8f8a40 100644
--- a/src/pages/Account/Settings/BindingView.js
+++ b/src/pages/Account/Settings/BindingView.js
@@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { Icon, List } from 'antd';
class BindingView extends Component {
diff --git a/src/pages/Account/Settings/NotificationView.js b/src/pages/Account/Settings/NotificationView.js
index 96677bbd269501cb9e901ea0f30b58ed2e51d774..00175ccfd3422dba4a3b1dcdd0f25bfc3c2208ff 100644
--- a/src/pages/Account/Settings/NotificationView.js
+++ b/src/pages/Account/Settings/NotificationView.js
@@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import { Switch, List } from 'antd';
class NotificationView extends Component {
diff --git a/src/pages/Account/Settings/SecurityView.js b/src/pages/Account/Settings/SecurityView.js
index 0706bd0b9b2988bb41bcc2a3fe9ab20f65f6bf16..96dbf32c0effb88eda517576c7c34dfb911e97de 100644
--- a/src/pages/Account/Settings/SecurityView.js
+++ b/src/pages/Account/Settings/SecurityView.js
@@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { List } from 'antd';
// import { getTimeDistance } from '@/utils/utils';
diff --git a/src/pages/Account/Settings/_layout.js b/src/pages/Account/Settings/_layout.js
index 5defae7335734b7ac47cb130602eda59d361fce7..e2ab47011b85cce60f3023c0a1be78e0bbb68f0a 100644
--- a/src/pages/Account/Settings/_layout.js
+++ b/src/pages/Account/Settings/_layout.js
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { connect } from 'dva';
import router from 'umi/router';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import { Menu } from 'antd';
import GridContent from '@/components/PageHeaderWrapper/GridContent';
import styles from './Info.less';
diff --git a/src/pages/Authorized.js b/src/pages/Authorized.js
index c29d9610e7b2873c8ca5e0085a865cfc6ab9ffb0..5889812b685d096519e90ff29e837321aa88e032 100644
--- a/src/pages/Authorized.js
+++ b/src/pages/Authorized.js
@@ -1,13 +1,38 @@
import React from 'react';
-import RenderAuthorized from '@/components/Authorized';
-import { getAuthority } from '@/utils/authority';
import Redirect from 'umi/redirect';
+import pathToRegexp from 'path-to-regexp';
+import { connect } from 'dva';
+import Authorized from '@/utils/Authorized';
+import { getAuthority } from '@/utils/authority';
+import Exception403 from '@/pages/Exception/403';
-const Authority = getAuthority();
-const Authorized = RenderAuthorized(Authority);
+function AuthComponent({ children, location, routerData }) {
+ const auth = getAuthority();
+ const isLogin = auth && auth[0] !== 'guest';
+ const getRouteAuthority = (path, routeData) => {
+ let authorities;
+ routeData.forEach(route => {
+ // match prefix
+ if (pathToRegexp(`${route.path}(.*)`).test(path)) {
+ authorities = route.authority || authorities;
-export default ({ children }) => (
- }>
- {children}
-
-);
+ // get children authority recursively
+ if (route.routes) {
+ authorities = getRouteAuthority(path, route.routes) || authorities;
+ }
+ }
+ });
+ return authorities;
+ };
+ return (
+ : }
+ >
+ {children}
+
+ );
+}
+export default connect(({ menu: menuModel }) => ({
+ routerData: menuModel.routerData,
+}))(AuthComponent);
diff --git a/src/pages/Dashboard/Analysis.js b/src/pages/Dashboard/Analysis.js
index cceab9bdcdf5ba8356f6f59462aea6529a78e2fa..0d222cc3c7bb16ed0ad1190f46a8e10629c6d372 100644
--- a/src/pages/Dashboard/Analysis.js
+++ b/src/pages/Dashboard/Analysis.js
@@ -5,7 +5,6 @@ import GridContent from '@/components/PageHeaderWrapper/GridContent';
import { getTimeDistance } from '@/utils/utils';
import styles from './Analysis.less';
import PageLoading from '@/components/PageLoading';
-import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
const IntroduceRow = React.lazy(() => import('./IntroduceRow'));
const SalesCard = React.lazy(() => import('./SalesCard'));
@@ -39,7 +38,6 @@ class Analysis extends Component {
type: 'chart/clear',
});
cancelAnimationFrame(this.reqRef);
- clearTimeout(this.timeoutId);
}
handleChangeSalesType = e => {
@@ -183,8 +181,4 @@ class Analysis extends Component {
}
}
-export default props => (
-
-
-
-);
+export default Analysis;
diff --git a/src/pages/Dashboard/IntroduceRow.js b/src/pages/Dashboard/IntroduceRow.js
index 7262826facd502554097616192dc6af1a1df4514..f7e67df075fb258af3050950543dcb1313a29f49 100644
--- a/src/pages/Dashboard/IntroduceRow.js
+++ b/src/pages/Dashboard/IntroduceRow.js
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { Row, Col, Icon, Tooltip } from 'antd';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
import styles from './Analysis.less';
import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts';
import Trend from '@/components/Trend';
@@ -135,7 +135,15 @@ const IntroduceRow = memo(({ loading, visitData }) => (
}
contentHeight={46}
>
-
+
diff --git a/src/pages/Dashboard/Monitor.js b/src/pages/Dashboard/Monitor.js
index d9bb87c614a90ac1bd01da9028b5919235ae94be..de8035342bad5cdc69cef8d57d1532835b6ae5bc 100644
--- a/src/pages/Dashboard/Monitor.js
+++ b/src/pages/Dashboard/Monitor.js
@@ -1,7 +1,6 @@
import React, { Component } from 'react';
-import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
import { connect } from 'dva';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { Row, Col, Card, Tooltip } from 'antd';
import { Pie, WaterWave, Gauge, TagCloud } from '@/components/Charts';
import NumberInfo from '@/components/NumberInfo';
@@ -242,8 +241,4 @@ class Monitor extends Component {
}
}
-export default props => (
-
-
-
-);
+export default Monitor;
diff --git a/src/pages/Dashboard/OfflineData.js b/src/pages/Dashboard/OfflineData.js
index f7d06ef07b8f10f93a86320b3b17d081816a462f..71791313d29451dcfaf017738f37cdadbe330730 100644
--- a/src/pages/Dashboard/OfflineData.js
+++ b/src/pages/Dashboard/OfflineData.js
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { Card, Tabs, Row, Col } from 'antd';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import styles from './Analysis.less';
import { TimelineChart, Pie } from '@/components/Charts';
import NumberInfo from '@/components/NumberInfo';
diff --git a/src/pages/Dashboard/ProportionSales.js b/src/pages/Dashboard/ProportionSales.js
index ff16a7d231751d8311b76078df1f182dbfcce34d..39771300bdeb82f9f8549160ab06ca7952aeac9d 100644
--- a/src/pages/Dashboard/ProportionSales.js
+++ b/src/pages/Dashboard/ProportionSales.js
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { Card, Radio } from 'antd';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import styles from './Analysis.less';
import { Pie } from '@/components/Charts';
import Yuan from '@/utils/Yuan';
diff --git a/src/pages/Dashboard/SalesCard.js b/src/pages/Dashboard/SalesCard.js
index 3ab577757067c329a79028cbec08deb3dfc61787..ee6adf214ec3709646c478e7be28c39cab7b0f1b 100644
--- a/src/pages/Dashboard/SalesCard.js
+++ b/src/pages/Dashboard/SalesCard.js
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { Row, Col, Card, Tabs, DatePicker } from 'antd';
-import { FormattedMessage, formatMessage } from 'umi/locale';
+import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
import numeral from 'numeral';
import styles from './Analysis.less';
import { Bar } from '@/components/Charts';
diff --git a/src/pages/Dashboard/TopSearch.js b/src/pages/Dashboard/TopSearch.js
index 4e75ea7d51ebba6a5d52e336c24d318f8e5d5a41..bd893950d05e2817a2861e2baf17ea5a6af6c0c8 100644
--- a/src/pages/Dashboard/TopSearch.js
+++ b/src/pages/Dashboard/TopSearch.js
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { Row, Col, Table, Tooltip, Card, Icon } from 'antd';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import Trend from '@/components/Trend';
import numeral from 'numeral';
import styles from './Analysis.less';
diff --git a/src/pages/Dashboard/Workplace.js b/src/pages/Dashboard/Workplace.js
index 3e7ff986abe821cb2ef6956db700365b07e424fb..d71b122a74b41147590b53bb566efaeed36d3f2a 100644
--- a/src/pages/Dashboard/Workplace.js
+++ b/src/pages/Dashboard/Workplace.js
@@ -3,7 +3,6 @@ import moment from 'moment';
import { connect } from 'dva';
import Link from 'umi/link';
import { Row, Col, Card, List, Avatar } from 'antd';
-import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
import { Radar } from '@/components/Charts';
import EditableLinkGroup from '@/components/EditableLinkGroup';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
@@ -253,8 +252,4 @@ class Workplace extends PureComponent {
}
}
-export default props => (
-
-
-
-);
+export default Workplace;
diff --git a/src/pages/Editor/Flow/index.js b/src/pages/Editor/Flow/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..a5f3257904579be07e75afa34327fe01d30d1c45
--- /dev/null
+++ b/src/pages/Editor/Flow/index.js
@@ -0,0 +1,45 @@
+import React from 'react';
+import { Row, Col } from 'antd';
+import GGEditor, { Flow } from 'gg-editor';
+import EditorMinimap from '@/components/EditorMinimap';
+import { FlowContextMenu } from '@/components/EditorContextMenu';
+import { FlowToolbar } from '@/components/EditorToolbar';
+import { FlowItemPanel } from '@/components/EditorItemPanel';
+import { FlowDetailPanel } from '@/components/EditorDetailPanel';
+import styles from './index.less';
+import { FormattedMessage } from 'umi-plugin-react/locale';
+import PageHeaderWrapper from '@/components/PageHeaderWrapper';
+
+GGEditor.setTrackable(false);
+
+const FlowPage = () => {
+ return (
+ }
+ content={ }
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FlowPage;
diff --git a/src/pages/Editor/Flow/index.less b/src/pages/Editor/Flow/index.less
new file mode 100644
index 0000000000000000000000000000000000000000..aeffa8293bba01745b47148456f4df752bddbdf0
--- /dev/null
+++ b/src/pages/Editor/Flow/index.less
@@ -0,0 +1,41 @@
+.editor {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ width: 100%;
+ height: calc(100vh - 250px);
+ background: #fff;
+}
+
+.editorHd {
+ padding: 8px;
+ border: 1px solid #e6e9ed;
+}
+
+.editorBd {
+ flex: 1;
+}
+
+.editorSidebar,
+.editorContent {
+ display: flex;
+ flex-direction: column;
+}
+
+.editorSidebar {
+ background: #fafafa;
+
+ &:first-child {
+ border-right: 1px solid #e6e9ed;
+ }
+
+ &:last-child {
+ border-left: 1px solid #e6e9ed;
+ }
+}
+
+.flow,
+.mind,
+.koni {
+ flex: 1;
+}
diff --git a/src/pages/Editor/Koni/index.js b/src/pages/Editor/Koni/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..c53737bd10d72598dd304906b0dea7d3945765a1
--- /dev/null
+++ b/src/pages/Editor/Koni/index.js
@@ -0,0 +1,47 @@
+import React from 'react';
+import { Row, Col } from 'antd';
+import GGEditor, { Koni } from 'gg-editor';
+import EditorMinimap from '@/components/EditorMinimap';
+import { KoniContextMenu } from '@/components/EditorContextMenu';
+import { KoniToolbar } from '@/components/EditorToolbar';
+import { KoniItemPanel } from '@/components/EditorItemPanel';
+import { KoniDetailPanel } from '@/components/EditorDetailPanel';
+import KoniCustomNode from '@/components/EditorKoniCustomNode';
+import styles from '../Flow/index.less';
+import { FormattedMessage } from 'umi-plugin-react/locale';
+import PageHeaderWrapper from '@/components/PageHeaderWrapper';
+
+GGEditor.setTrackable(false);
+
+const KoniPage = () => {
+ return (
+ }
+ content={ }
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default KoniPage;
diff --git a/src/pages/Editor/Mind/index.js b/src/pages/Editor/Mind/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..998e00584f6d14c7382040641c905d6e081cf808
--- /dev/null
+++ b/src/pages/Editor/Mind/index.js
@@ -0,0 +1,42 @@
+import React from 'react';
+import { Row, Col } from 'antd';
+import GGEditor, { Mind } from 'gg-editor';
+import EditorMinimap from '@/components/EditorMinimap';
+import { MindContextMenu } from '@/components/EditorContextMenu';
+import { MindToolbar } from '@/components/EditorToolbar';
+import { MindDetailPanel } from '@/components/EditorDetailPanel';
+import data from '@/common/worldCup2018.json';
+import styles from '../Flow/index.less';
+import { FormattedMessage } from 'umi-plugin-react/locale';
+import PageHeaderWrapper from '@/components/PageHeaderWrapper';
+
+GGEditor.setTrackable(false);
+
+const MindPage = () => {
+ return (
+ }
+ content={ }
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default MindPage;
diff --git a/src/pages/Exception/403.js b/src/pages/Exception/403.js
index 35e4ca3a12f36701d7120cd2d840c44ebca1b5dc..e91f9c91d498c4e12ae739d5afc746beaaf3f3bf 100644
--- a/src/pages/Exception/403.js
+++ b/src/pages/Exception/403.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
import Exception from '@/components/Exception';
diff --git a/src/pages/Exception/404.js b/src/pages/Exception/404.js
index 84c986c5e577a141ccc675ce49dd3b9b4399a519..f21b1f89dee571da356523e6cf2981d17874de22 100644
--- a/src/pages/Exception/404.js
+++ b/src/pages/Exception/404.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
import Exception from '@/components/Exception';
diff --git a/src/pages/Exception/500.js b/src/pages/Exception/500.js
index 9d96f21203ef5466593a674b4b6da89bd6dde39f..904844cd1e74cfd07d6ad0f1063a9fa315b6b2a4 100644
--- a/src/pages/Exception/500.js
+++ b/src/pages/Exception/500.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
import Exception from '@/components/Exception';
diff --git a/src/pages/Forms/BasicForm.js b/src/pages/Forms/BasicForm.js
index 55833150a1ed63d053e894968d35ac548c3129ae..dd86ebacc62b8ff3bd6f84af021623350ec427cb 100644
--- a/src/pages/Forms/BasicForm.js
+++ b/src/pages/Forms/BasicForm.js
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { connect } from 'dva';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import {
Form,
Input,
diff --git a/src/pages/List/Search/Applications.js b/src/pages/List/Search/Applications.js
index e36012ddde3578696ee10fe4a45148f5a0421839..e8161898f0ec93077a1be42e6c5c50882ab7bed0 100644
--- a/src/pages/List/Search/Applications.js
+++ b/src/pages/List/Search/Applications.js
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import numeral from 'numeral';
import { connect } from 'dva';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import { Row, Col, Form, Card, Select, Icon, Avatar, List, Tooltip, Dropdown, Menu } from 'antd';
import TagSelect from '@/components/TagSelect';
import StandardFormRow from '@/components/StandardFormRow';
diff --git a/src/pages/List/Search/Articles.js b/src/pages/List/Search/Articles.js
index 5ab311ba0835434d1cfb98d7c0e0fdc3f17430e0..6182d4972374806b5fb958256d360cfe82840194 100644
--- a/src/pages/List/Search/Articles.js
+++ b/src/pages/List/Search/Articles.js
@@ -1,7 +1,7 @@
import React, { Component, Fragment } from 'react';
import { connect } from 'dva';
import { Form, Card, Select, List, Tag, Icon, Row, Col, Button } from 'antd';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import TagSelect from '@/components/TagSelect';
import StandardFormRow from '@/components/StandardFormRow';
diff --git a/src/pages/List/Search/Projects.js b/src/pages/List/Search/Projects.js
index 3f4a6e9d7a5fa7076912fd7987039cbc72b3079c..2ae82a88a17ebaf2144649eaaeccee6f6c33bdcb 100644
--- a/src/pages/List/Search/Projects.js
+++ b/src/pages/List/Search/Projects.js
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import moment from 'moment';
import { connect } from 'dva';
import { Row, Col, Form, Card, Select, List } from 'antd';
-import { FormattedMessage } from 'umi/locale';
+import { FormattedMessage } from 'umi-plugin-react/locale';
import TagSelect from '@/components/TagSelect';
import AvatarList from '@/components/AvatarList';
diff --git a/src/pages/Result/Error.js b/src/pages/Result/Error.js
index fba2da6d13c08785b0443c8760308b0aeebd2863..b8e528d54d690bf2c5ba81991efbc687812e20ed 100644
--- a/src/pages/Result/Error.js
+++ b/src/pages/Result/Error.js
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { Button, Icon, Card } from 'antd';
import Result from '@/components/Result';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
diff --git a/src/pages/Result/Success.js b/src/pages/Result/Success.js
index 74d19dc38c23dc39c73f107c6407cb577bbcb3e7..0b100806cef9b52cdd41c4a37a7e2006da1ea7b8 100644
--- a/src/pages/Result/Success.js
+++ b/src/pages/Result/Success.js
@@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { Button, Row, Col, Icon, Steps, Card } from 'antd';
import Result from '@/components/Result';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
diff --git a/src/pages/Result/Success.test.js b/src/pages/Result/Success.test.js
deleted file mode 100644
index 9bc9b8dffdc39e5db8dbfd5b2c9e5203a4845e26..0000000000000000000000000000000000000000
--- a/src/pages/Result/Success.test.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-import { shallow } from 'enzyme';
-import Success from './Success';
-
-it('renders with Result', () => {
- const wrapper = shallow( );
- expect(wrapper.find('Result').length).toBe(1);
- expect(wrapper.find('Result').prop('type')).toBe('success');
-});
diff --git a/src/pages/User/Login.js b/src/pages/User/Login.js
index 6ddece46d54cd48b46251539b34a3c3efb700959..e3498bd3e4fc9ceafae9f5e3af63a1b066ef681a 100644
--- a/src/pages/User/Login.js
+++ b/src/pages/User/Login.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { connect } from 'dva';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
import { Checkbox, Alert, Icon } from 'antd';
import Login from '@/components/Login';
diff --git a/src/pages/User/Register.js b/src/pages/User/Register.js
index ea4565c28bac77692a0f520ef372b7f4b8e5dc0a..d685965f5f3da55b4a63fbce3ebc4c46a9bf0880 100644
--- a/src/pages/User/Register.js
+++ b/src/pages/User/Register.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { connect } from 'dva';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import Link from 'umi/link';
import router from 'umi/router';
import { Form, Input, Button, Select, Row, Col, Popover, Progress } from 'antd';
diff --git a/src/pages/User/RegisterResult.js b/src/pages/User/RegisterResult.js
index 6e338b277b917cd3d23c3b883f7c710ec306018c..d1bfe59ac12d0bd025e87aac30274fbd2951b608 100644
--- a/src/pages/User/RegisterResult.js
+++ b/src/pages/User/RegisterResult.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { formatMessage, FormattedMessage } from 'umi/locale';
+import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
import { Button } from 'antd';
import Link from 'umi/link';
import Result from '@/components/Result';
diff --git a/src/pages/_routes.json b/src/pages/_routes.json
index 81b4b64126973c4197eaccf12dfb2783924e3480..f137bb5e951a659a2690e1248c3eaaaef4c97383 100644
--- a/src/pages/_routes.json
+++ b/src/pages/_routes.json
@@ -53,5 +53,10 @@
"path": "/account/settings",
"exact": true,
"redirect": "/account/settings/baseview"
+ },
+ {
+ "path": "/editor",
+ "exact": true,
+ "redirect": "/deitor/flow"
}
]
diff --git a/src/services/api.js b/src/services/api.js
index 6e789bcc9a14ca47fa08c711aec60742e4bd2353..5358a8e186a0adae677c5db8b7d8e815a2cd53ed 100644
--- a/src/services/api.js
+++ b/src/services/api.js
@@ -16,7 +16,7 @@ export async function queryRule(params) {
export async function removeRule(params) {
return request('/api/rule', {
method: 'POST',
- body: {
+ data: {
...params,
method: 'delete',
},
@@ -26,7 +26,7 @@ export async function removeRule(params) {
export async function addRule(params) {
return request('/api/rule', {
method: 'POST',
- body: {
+ data: {
...params,
method: 'post',
},
@@ -36,7 +36,7 @@ export async function addRule(params) {
export async function updateRule(params = {}) {
return request(`/api/rule?${stringify(params.query)}`, {
method: 'POST',
- body: {
+ data: {
...params.body,
method: 'update',
},
@@ -46,7 +46,7 @@ export async function updateRule(params = {}) {
export async function fakeSubmitForm(params) {
return request('/api/forms', {
method: 'POST',
- body: params,
+ data: params,
});
}
@@ -74,7 +74,7 @@ export async function removeFakeList(params) {
const { count = 5, ...restParams } = params;
return request(`/api/fake_list?count=${count}`, {
method: 'POST',
- body: {
+ data: {
...restParams,
method: 'delete',
},
@@ -85,7 +85,7 @@ export async function addFakeList(params) {
const { count = 5, ...restParams } = params;
return request(`/api/fake_list?count=${count}`, {
method: 'POST',
- body: {
+ data: {
...restParams,
method: 'post',
},
@@ -96,7 +96,7 @@ export async function updateFakeList(params) {
const { count = 5, ...restParams } = params;
return request(`/api/fake_list?count=${count}`, {
method: 'POST',
- body: {
+ data: {
...restParams,
method: 'update',
},
@@ -106,14 +106,14 @@ export async function updateFakeList(params) {
export async function fakeAccountLogin(params) {
return request('/api/login/account', {
method: 'POST',
- body: params,
+ data: params,
});
}
export async function fakeRegister(params) {
return request('/api/register', {
method: 'POST',
- body: params,
+ data: params,
});
}
diff --git a/src/utils/authority.js b/src/utils/authority.js
index 3d2e7b34961a0b6fdf2a705d040f9726d9981065..288c1e68adc9381a821ba1032cb068791e0184ee 100644
--- a/src/utils/authority.js
+++ b/src/utils/authority.js
@@ -1,4 +1,6 @@
// use localStorage to store the authority info, which might be sent from server in actual project.
+const { NODE_ENV } = process.env;
+
export function getAuthority(str) {
// return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
const authorityString =
@@ -13,7 +15,10 @@ export function getAuthority(str) {
if (typeof authority === 'string') {
return [authority];
}
- return authority || ['admin'];
+ if (!authority && NODE_ENV !== 'production') {
+ return ['admin'];
+ }
+ return authority;
}
export function setAuthority(authority) {
diff --git a/src/utils/getPageTitle.js b/src/utils/getPageTitle.js
index 0dd1e6207858670ee08f256ff10e292717e6a078..30e2dce1d0c580db30cc6bd78a07d99c088e99d6 100644
--- a/src/utils/getPageTitle.js
+++ b/src/utils/getPageTitle.js
@@ -1,4 +1,4 @@
-import { formatMessage } from 'umi/locale';
+import { formatMessage } from 'umi-plugin-react/locale';
import pathToRegexp from 'path-to-regexp';
import isEqual from 'lodash/isEqual';
import memoizeOne from 'memoize-one';
diff --git a/src/utils/request.js b/src/utils/request.js
index 398b787f1e5d8cd3381c8fbd9201dd33544ac9d5..0801b1d4b1cb0dc8c1bc86ce7f70e9a3457b364e 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,8 +1,10 @@
-import fetch from 'dva/fetch';
+/**
+ * request 网络请求工具
+ * 更详细的api文档: https://bigfish.alipay.com/doc/api#request
+ */
+import { extend } from 'umi-request';
import { notification } from 'antd';
import router from 'umi/router';
-import hash from 'hash.js';
-import { isAntdPro } from './utils';
const codeMessage = {
200: '服务器成功返回请求的数据。',
@@ -22,134 +24,49 @@ const codeMessage = {
504: '网关超时。',
};
-const checkStatus = response => {
- if (response.status >= 200 && response.status < 300) {
- return response;
- }
+/**
+ * 异常处理程序
+ */
+const errorHandler = error => {
+ const { response = {} } = error;
const errortext = codeMessage[response.status] || response.statusText;
+ const { status, url } = response;
+
+ if (status === 401) {
+ notification.error({
+ message: '未登录或登录已过期,请重新登录。',
+ });
+ // @HACK
+ /* eslint-disable no-underscore-dangle */
+ window.g_app._store.dispatch({
+ type: 'login/logout',
+ });
+ return;
+ }
notification.error({
- message: `请求错误 ${response.status}: ${response.url}`,
+ message: `请求错误 ${status}: ${url}`,
description: errortext,
});
- const error = new Error(errortext);
- error.name = response.status;
- error.response = response;
- throw error;
-};
-
-const cachedSave = (response, hashcode) => {
- /**
- * Clone a response data and store it in sessionStorage
- * Does not support data other than json, Cache only json
- */
- const contentType = response.headers.get('Content-Type');
- if (contentType && contentType.match(/application\/json/i)) {
- // All data is saved as text
- response
- .clone()
- .text()
- .then(content => {
- sessionStorage.setItem(hashcode, content);
- sessionStorage.setItem(`${hashcode}:timestamp`, Date.now());
- });
+ // environment should not be used
+ if (status === 403) {
+ router.push('/exception/403');
+ return;
+ }
+ if (status <= 504 && status >= 500) {
+ router.push('/exception/500');
+ return;
+ }
+ if (status >= 404 && status < 422) {
+ router.push('/exception/404');
}
- return response;
};
/**
- * Requests a URL, returning a promise.
- *
- * @param {string} url The URL we want to request
- * @param {object} [option] The options we want to pass to "fetch"
- * @return {object} An object containing either "data" or "err"
+ * 配置request请求时的默认参数
*/
-export default function request(url, option) {
- const options = {
- expirys: isAntdPro(),
- ...option,
- };
- /**
- * Produce fingerprints based on url and parameters
- * Maybe url has the same parameters
- */
- const fingerprint = url + (options.body ? JSON.stringify(options.body) : '');
- const hashcode = hash
- .sha256()
- .update(fingerprint)
- .digest('hex');
+const request = extend({
+ errorHandler, // 默认错误处理
+ credentials: 'include', // 默认请求是否带上cookie
+});
- const defaultOptions = {
- credentials: 'include',
- };
- const newOptions = { ...defaultOptions, ...options };
- if (
- newOptions.method === 'POST' ||
- newOptions.method === 'PUT' ||
- newOptions.method === 'DELETE'
- ) {
- if (!(newOptions.body instanceof FormData)) {
- newOptions.headers = {
- Accept: 'application/json',
- 'Content-Type': 'application/json; charset=utf-8',
- ...newOptions.headers,
- };
- newOptions.body = JSON.stringify(newOptions.body);
- } else {
- // newOptions.body is FormData
- newOptions.headers = {
- Accept: 'application/json',
- ...newOptions.headers,
- };
- }
- }
-
- const expirys = options.expirys && 60;
- // options.expirys !== false, return the cache,
- if (options.expirys !== false) {
- const cached = sessionStorage.getItem(hashcode);
- const whenCached = sessionStorage.getItem(`${hashcode}:timestamp`);
- if (cached !== null && whenCached !== null) {
- const age = (Date.now() - whenCached) / 1000;
- if (age < expirys) {
- const response = new Response(new Blob([cached]));
- return response.json();
- }
- sessionStorage.removeItem(hashcode);
- sessionStorage.removeItem(`${hashcode}:timestamp`);
- }
- }
- return fetch(url, newOptions)
- .then(checkStatus)
- .then(response => cachedSave(response, hashcode))
- .then(response => {
- // DELETE and 204 do not return data by default
- // using .json will report an error.
- if (newOptions.method === 'DELETE' || response.status === 204) {
- return response.text();
- }
- return response.json();
- })
- .catch(e => {
- const status = e.name;
- if (status === 401) {
- // @HACK
- /* eslint-disable no-underscore-dangle */
- window.g_app._store.dispatch({
- type: 'login/logout',
- });
- return;
- }
- // environment should not be used
- if (status === 403) {
- router.push('/exception/403');
- return;
- }
- if (status <= 504 && status >= 500) {
- router.push('/exception/500');
- return;
- }
- if (status >= 404 && status < 422) {
- router.push('/exception/404');
- }
- });
-}
+export default request;
diff --git a/tsconfig.json b/tsconfig.json
index 5be3083113eb212c29bc33d59b6e73932bbcb0f9..5c26101123fa262ec736067de2c211da06ffbfd9 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,7 +9,7 @@
"jsx": "react",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
- "rootDirs": ["/src", "/test", "/mock","./typings"],
+ "rootDirs": ["/src", "/test", "/mock", "./typings"],
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,