diff --git a/src/components/TagSelect/index.d.ts b/src/components/TagSelect/index.d.ts index 736ca52f17bb12a137d0c04b1be260b4c7c6c1e8..9de30263f1795b5cb323085b9eb3109d720c14cb 100644 --- a/src/components/TagSelect/index.d.ts +++ b/src/components/TagSelect/index.d.ts @@ -7,6 +7,7 @@ export interface ITagSelectProps { value?: string[] | number[]; style?: React.CSSProperties; hideCheckAll?: boolean; + actionsText?: { expandText?: string; collapseText?: string; selectAllText?: string }; } export default class TagSelect extends React.Component { diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index f65764f54ac9f2104e8051a0a8fe73b65b6371cd..34d6ba2daa1bd3cd01c2bdf511b44e7f9590a4c5 100644 --- a/src/components/TagSelect/index.js +++ b/src/components/TagSelect/index.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Tag, Icon } from 'antd'; @@ -15,8 +16,18 @@ const TagSelectOption = ({ children, checked, onChange, value }) => ( TagSelectOption.isTagSelectOption = true; class TagSelect extends Component { + static propTypes = { + actionsText: PropTypes.object, + hideCheckAll: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), + }; + static defaultProps = { hideCheckAll: false, + actionsText: { + expandText: 'Expand', + collapseText: 'Collapse', + selectAllText: 'All', + }, }; constructor(props) { @@ -88,19 +99,21 @@ class TagSelect extends Component { render() { const { value, expand } = this.state; - const { children, hideCheckAll, className, style, expandable } = this.props; - + const { children, hideCheckAll, className, style, expandable, actionsText } = this.props; const checkedAll = this.getAllTags().length === value.length; + const { expandText = 'Expand', collapseText = 'Collapse', selectAllText = 'All' } = + actionsText === null ? {} : actionsText; const cls = classNames(styles.tagSelect, className, { [styles.hasExpandTag]: expandable, [styles.expanded]: expand, }); + return (
{hideCheckAll ? null : ( - 全部 + {selectAllText} )} {value && @@ -117,7 +130,7 @@ class TagSelect extends Component { })} {expandable && ( - {expand ? '收起' : '展开'} + {expand ? collapseText : expandText} )}
diff --git a/src/locales/en-US.js b/src/locales/en-US.js index fcaffcebaab472855ab6118ce547355bf38b3334..25f2888c58c13f5ee8532e0b522cfd7169b77a2a 100644 --- a/src/locales/en-US.js +++ b/src/locales/en-US.js @@ -9,6 +9,7 @@ import result from './en-US/result'; import settingDrawer from './en-US/settingDrawer'; import settings from './en-US/settings'; import pwa from './en-US/pwa'; +import component from './en-US/component'; export default { 'navBar.lang': 'Languages', @@ -30,4 +31,5 @@ export default { ...settingDrawer, ...settings, ...pwa, + ...component, }; diff --git a/src/locales/en-US/component.js b/src/locales/en-US/component.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba7eeda69c7cd6edc5fd8d205bd626531737a45 --- /dev/null +++ b/src/locales/en-US/component.js @@ -0,0 +1,5 @@ +export default { + 'component.tagSelect.expand': 'Expand', + 'component.tagSelect.collapse': 'Collapse', + 'component.tagSelect.all': 'All', +}; diff --git a/src/locales/pt-BR.js b/src/locales/pt-BR.js index d0fe21b782e66b31cb23ee18a39731d7fd766ac0..af8bcee53c1a28e9436853fe9a6a4c8b61d4755e 100644 --- a/src/locales/pt-BR.js +++ b/src/locales/pt-BR.js @@ -9,6 +9,7 @@ import result from './pt-BR/result'; import settingDrawer from './pt-BR/settingDrawer'; import settings from './pt-BR/settings'; import pwa from './pt-BR/pwa'; +import component from './pt-BR/component'; export default { 'navBar.lang': 'Idiomas', @@ -30,4 +31,5 @@ export default { ...settingDrawer, ...settings, ...pwa, + ...component, }; diff --git a/src/locales/pt-BR/component.js b/src/locales/pt-BR/component.js new file mode 100644 index 0000000000000000000000000000000000000000..1af478deca99563834a21caaac9f41230504ff09 --- /dev/null +++ b/src/locales/pt-BR/component.js @@ -0,0 +1,5 @@ +export default { + 'component.tagSelect.expand': 'Expandir', + 'component.tagSelect.collapse': 'Colapso', + 'component.tagSelect.all': 'Todas', +}; diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js index 4330d60ae6d30bf9a3446b4ad777b9a8077b5a84..cf601f378ee3d2584adaf91fb87e81249dcfbf3b 100644 --- a/src/locales/zh-CN.js +++ b/src/locales/zh-CN.js @@ -9,6 +9,7 @@ import result from './zh-CN/result'; import settingDrawer from './zh-CN/settingDrawer'; import settings from './zh-CN/settings'; import pwa from './zh-CN/pwa'; +import component from './zh-CN/component'; export default { 'navBar.lang': '语言', @@ -30,4 +31,5 @@ export default { ...settingDrawer, ...settings, ...pwa, + ...component, }; diff --git a/src/locales/zh-CN/component.js b/src/locales/zh-CN/component.js new file mode 100644 index 0000000000000000000000000000000000000000..1f1feadbf6f1494e8da6a1e781a87399f1c46a8a --- /dev/null +++ b/src/locales/zh-CN/component.js @@ -0,0 +1,5 @@ +export default { + 'component.tagSelect.expand': '展开', + 'component.tagSelect.collapse': '收起', + 'component.tagSelect.all': '全部', +}; diff --git a/src/locales/zh-TW.js b/src/locales/zh-TW.js index 986820ef3af850807cf000d6ed9c1a0e8280a276..c621733984db2b669fdff1b4fdc89ac777617ed3 100644 --- a/src/locales/zh-TW.js +++ b/src/locales/zh-TW.js @@ -9,6 +9,7 @@ import result from './zh-TW/result'; import settingDrawer from './zh-TW/settingDrawer'; import settings from './zh-TW/settings'; import pwa from './zh-TW/pwa'; +import component from './zh-TW/component'; export default { 'navBar.lang': '語言', @@ -30,4 +31,5 @@ export default { ...settingDrawer, ...settings, ...pwa, + ...component, }; diff --git a/src/locales/zh-TW/component.js b/src/locales/zh-TW/component.js new file mode 100644 index 0000000000000000000000000000000000000000..ba48e299a91a29a64e2f9834cf5b0b1d3c080fb4 --- /dev/null +++ b/src/locales/zh-TW/component.js @@ -0,0 +1,5 @@ +export default { + 'component.tagSelect.expand': '展開', + 'component.tagSelect.collapse': '收起', + 'component.tagSelect.all': '全部', +}; diff --git a/src/pages/List/Applications.js b/src/pages/List/Applications.js index 4f32f8e6637683959f93c6d97d14c849d9d71207..e36012ddde3578696ee10fe4a45148f5a0421839 100644 --- a/src/pages/List/Applications.js +++ b/src/pages/List/Applications.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import numeral from 'numeral'; import { connect } from 'dva'; +import { FormattedMessage } from 'umi/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'; @@ -69,6 +70,14 @@ class FilterCardList extends PureComponent { }, }; + const actionsTextMap = { + expandText: , + collapseText: ( + + ), + selectAllText: , + }; + const itemMenu = ( @@ -96,7 +105,7 @@ class FilterCardList extends PureComponent { {getFieldDecorator('category')( - + 类目一 类目二 类目三 diff --git a/src/pages/List/Articles.js b/src/pages/List/Articles.js index 5df46d5fc11f7d7ba0c67b7cdc40a901a24a1d34..c1c04b72316b0e16c04b397b9052c4a5568001f6 100644 --- a/src/pages/List/Articles.js +++ b/src/pages/List/Articles.js @@ -1,6 +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 TagSelect from '@/components/TagSelect'; import StandardFormRow from '@/components/StandardFormRow'; @@ -104,6 +105,14 @@ class SearchList extends Component { }, }; + const actionsTextMap = { + expandText: , + collapseText: ( + + ), + selectAllText: , + }; + const loadMore = list.length > 0 ? (
@@ -126,7 +135,7 @@ class SearchList extends Component { {getFieldDecorator('category')( - + 类目一 类目二 类目三 diff --git a/src/pages/List/Projects.js b/src/pages/List/Projects.js index 430ca4201803d71f85fb84a98b2ca3fa4bdac9c2..3f4a6e9d7a5fa7076912fd7987039cbc72b3079c 100644 --- a/src/pages/List/Projects.js +++ b/src/pages/List/Projects.js @@ -2,6 +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 TagSelect from '@/components/TagSelect'; import AvatarList from '@/components/AvatarList'; @@ -96,6 +97,14 @@ class CoverCardList extends PureComponent { }, }; + const actionsTextMap = { + expandText: , + collapseText: ( + + ), + selectAllText: , + }; + return (
@@ -103,7 +112,7 @@ class CoverCardList extends PureComponent { {getFieldDecorator('category')( - + 类目一 类目二 类目三