From 8dc93c47c157e2f214f09b6918ab78cf1633abdc Mon Sep 17 00:00:00 2001 From: boyang Date: Fri, 18 Sep 2020 23:27:47 +0800 Subject: [PATCH] FEATURE DONE: filter --- .eslintignore | 6 +- .prettierignore | 3 +- ...345\215\225\345\205\203202\345\256\244.md" | 4 +- config/config.ts | 16 +- config/defaultSettings.ts | 2 +- package.json | 2 - src/assets/archives.json | 33 +- src/components/vendor/ExpandCollapse.js | 269 ++++++++++++++ src/global.less | 12 +- src/layouts/BasicLayout.less | 4 +- src/layouts/BasicLayout.tsx | 14 +- src/layouts/LoadingLayout.tsx | 2 +- src/layouts/UserLayout.tsx | 8 +- src/locales/en-US.ts | 16 - src/locales/en-US/globalHeader.ts | 13 - src/locales/en-US/menu.ts | 50 --- src/locales/en-US/settingDrawer.ts | 31 -- src/locales/en-US/settings.ts | 60 ---- src/locales/zh-CN.ts | 16 - src/locales/zh-CN/globalHeader.ts | 13 - src/locales/zh-CN/menu.ts | 50 --- src/locales/zh-CN/settingDrawer.ts | 31 -- src/locales/zh-CN/settings.ts | 55 --- src/pages/Lanting/_mock.ts | 115 ------ .../components/ArchiveListContent/index.less | 2 +- .../components/ArchiveListContent/index.tsx | 2 +- .../components/ArchiveListContent/typing.d.ts | 12 + .../components/ArticleListContent/index.less | 38 -- .../components/ArticleListContent/index.tsx | 29 -- src/pages/Lanting/data.ts | 37 +- src/pages/Lanting/index.tsx | 43 +-- src/pages/Lanting/model.ts | 33 +- src/pages/document.ejs | 337 +++++++++--------- 33 files changed, 577 insertions(+), 781 deletions(-) create mode 100644 src/components/vendor/ExpandCollapse.js delete mode 100644 src/locales/en-US.ts delete mode 100644 src/locales/en-US/globalHeader.ts delete mode 100644 src/locales/en-US/menu.ts delete mode 100644 src/locales/en-US/settingDrawer.ts delete mode 100644 src/locales/en-US/settings.ts delete mode 100644 src/locales/zh-CN.ts delete mode 100644 src/locales/zh-CN/globalHeader.ts delete mode 100644 src/locales/zh-CN/menu.ts delete mode 100644 src/locales/zh-CN/settingDrawer.ts delete mode 100644 src/locales/zh-CN/settings.ts delete mode 100644 src/pages/Lanting/_mock.ts create mode 100644 src/pages/Lanting/components/ArchiveListContent/typing.d.ts delete mode 100644 src/pages/Lanting/components/ArticleListContent/index.less delete mode 100644 src/pages/Lanting/components/ArticleListContent/index.tsx diff --git a/.eslintignore b/.eslintignore index 16116a2..4d1f91e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,2 @@ -/lambda/ -/scripts -/config -.history \ No newline at end of file +.history +/src/components/vendor \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index d17efb4..0c69f98 100644 --- a/.prettierignore +++ b/.prettierignore @@ -20,4 +20,5 @@ yarn-error.log .history CNAME /build -/public \ No newline at end of file +/public +/src/components/vendor \ No newline at end of file diff --git "a/archives/comments/10000-\351\251\254\344\272\221\347\232\204\346\271\226\347\225\224\350\212\261\345\233\25516\345\271\2421\345\215\225\345\205\203202\345\256\244.md" "b/archives/comments/10000-\351\251\254\344\272\221\347\232\204\346\271\226\347\225\224\350\212\261\345\233\25516\345\271\2421\345\215\225\345\205\203202\345\256\244.md" index 666d33d..1efda78 100644 --- "a/archives/comments/10000-\351\251\254\344\272\221\347\232\204\346\271\226\347\225\224\350\212\261\345\233\25516\345\271\2421\345\215\225\345\205\203202\345\256\244.md" +++ "b/archives/comments/10000-\351\251\254\344\272\221\347\232\204\346\271\226\347\225\224\350\212\261\345\233\25516\345\271\2421\345\215\225\345\205\203202\345\256\244.md" @@ -27,4 +27,6 @@ 其中有一位花名承志的设计师,创立了“蘑菇街”,他的真名叫陈琪。陈琪的故事是另一个故事的翻版。“大炮”方永新告诉我,在做 B2B 业务的时候,他手下的一个主管后来也去创业了。“他做了一个叫滴滴的项目,做得还不错。”“他叫程维吗?”我问。“是的。” -无招是花名,他的真名叫陈航. “至少当时在阿里巴巴内部,他已经快成为‘臭名昭著’的人:一个从日本回来的职业经理人,做一淘没什么起色,做来往看起来也快要完蛋。阿里似乎给了他不少机会,遗憾的是,他没有抓住其中任何一个。” `然后钉钉` +无招是花名,他的真名叫陈航. “至少当时在阿里巴巴内部,他已经快成为‘臭名昭著’的人:一个从日本回来的职业经理人,做一淘没什么起色,做来往看起来也快要完蛋。阿里似乎给了他不少机会,遗憾的是,他没有抓住其中任何一个。” + +`然后钉钉` diff --git a/config/config.ts b/config/config.ts index 744ff09..a32d077 100644 --- a/config/config.ts +++ b/config/config.ts @@ -10,13 +10,13 @@ export default defineConfig({ dva: { hmr: true, }, - locale: { - // default zh-CN - default: 'zh-CN', - antd: true, - // default true, when it is true, will use `navigator.language` overwrite default - baseNavigator: true, - }, + // locale: { + // // default zh-CN + // default: 'zh-CN', + // antd: true, + // // default true, when it is true, will use `navigator.language` overwrite default + // baseNavigator: true, + // }, dynamicImport: { loading: '@/components/PageLoading/index', }, @@ -49,7 +49,7 @@ export default defineConfig({ redirect: '/lanting', }, { - name: 'lanting', + name: '兰亭已矣', path: '/lanting', icon: 'BookOutlined', component: './Lanting', diff --git a/config/defaultSettings.ts b/config/defaultSettings.ts index 54b02e8..582c20e 100644 --- a/config/defaultSettings.ts +++ b/config/defaultSettings.ts @@ -10,7 +10,7 @@ const proSettings: ProSettings = { fixSiderbar: false, colorWeak: false, menu: { - locale: true, + locale: false, }, title: '兰亭', iconfontUrl: '', diff --git a/package.json b/package.json index cd5d29b..297d1d9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "deploy": "echo TODO", "dev": "npm run start:dev", "fetch:blocks": "pro fetch-blocks && npm run prettier", - "i18n-remove": "pro i18n-remove --locale=zh-CN --write", "postinstall": "umi g tmp", "lint": "umi g tmp && npm run lint:js && npm run lint:prettier", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", @@ -46,7 +45,6 @@ "antd": "^4.6.3", "classnames": "^2.2.6", "lodash": "^4.17.11", - "moment": "^2.25.3", "omit.js": "^2.0.2", "qs": "^6.9.0", "react": "^16.8.6", diff --git a/src/assets/archives.json b/src/assets/archives.json index 3dbbf20..cbe5c8f 100644 --- a/src/assets/archives.json +++ b/src/assets/archives.json @@ -1 +1,32 @@ -{"archives":[{"id":"10000","title":"马云的湖畔花园 16 幢 1 单元 202 室","author":["迟宇宙"],"publisher":"商业人物","date":"2017-09","chapter":"世家","tag":["阿里","公司史"],"remarks":"\n`汗臭, 脚臭, 烟臭. 我是不行` 马云希望阿里巴巴变成技术驱动型公司。他好几次语重心长地对朱鸿说:“我们要有顶尖的技术。”2006 年夏天,吴妈萌生了一个想法。既然阿里巴巴的口号是“让天下没有难做的生意”,那么就应该有一个广告平台,“让天下没有难做的广告”。当时他在北京整合雅虎中国的 P2P(点对点)广告系统,萌生这个想法水到渠成。\n\n2007 年,盛大 CFO 张勇加盟了淘宝,花名逍遥子,很快他便参与了一件大事,“将阿里妈妈装回淘宝的子宫”。\n\n朱鸿读研的时候在, 后来读博去了. 朱鸿再次回到阿里巴巴的时候,阿里妈妈已经与淘宝合到了一起。他成为了淘宝的一员,在阿里的工号是 24083。他记得还在华星的时候,有一次他问:“我怎么没工号?”人力那边说:“给你个 100 号,要不要?”他当时还在读书,就没有要阿里的工号。他去查过 100 号,好像没有人在使用。从他回到阿里的那天起,他开始被叫作“一粟”,沧海一粟的“一粟”。终点又回到了起点,他开始走进另外一个陌生。\n\n湖畔花园, 淘宝, 阿里妈妈, 天猫, 菜鸟, 钉钉. 有个阿里软件的项目曾经在马云的“小黑屋”里关过,但它并没有获得想象中的成功。\n\n其中有一位花名承志的设计师,创立了“蘑菇街”,他的真名叫陈琪。陈琪的故事是另一个故事的翻版。“大炮”方永新告诉我,在做 B2B 业务的时候,他手下的一个主管后来也去创业了。“他做了一个叫滴滴的项目,做得还不错。”“他叫程维吗?”我问。“是的。”\n\n无招是花名,他的真名叫陈航. “至少当时在阿里巴巴内部,他已经快成为‘臭名昭著’的人:一个从日本回来的职业经理人,做一淘没什么起色,做来往看起来也快要完蛋。阿里似乎给了他不少机会,遗憾的是,他没有抓住其中任何一个。” `然后钉钉`\n","hasOrig":true},{"id":"10001","title":"复活“来往”,阿里的社交心结","author":["叶二"],"publisher":"蓝媒汇","date":"2017-09","chapter":"世家","tag":["阿里","社交","来往","钉钉"],"remarks":"\nReal如我 校园社交 点点虫 (原来往) 阅后即焚\n","hasOrig":false}],"fieldFreqMap":{"author":{"迟宇宙":1,"叶二":1},"publisher":{"商业人物":1,"蓝媒汇":1},"date":{"2017-09":2},"tag":{"阿里":2,"公司史":1,"社交":1,"来往":1,"钉钉":1}}} \ No newline at end of file +{ + "archives": [ + { + "id": "10000", + "title": "马云的湖畔花园 16 幢 1 单元 202 室", + "author": ["迟宇宙"], + "publisher": "商业人物", + "date": "2017-09", + "chapter": "世家", + "tag": ["阿里", "公司史"], + "remarks": "\n`汗臭, 脚臭, 烟臭. 我是不行` 马云希望阿里巴巴变成技术驱动型公司。他好几次语重心长地对朱鸿说:“我们要有顶尖的技术。”2006 年夏天,吴妈萌生了一个想法。既然阿里巴巴的口号是“让天下没有难做的生意”,那么就应该有一个广告平台,“让天下没有难做的广告”。当时他在北京整合雅虎中国的 P2P(点对点)广告系统,萌生这个想法水到渠成。\n\n2007 年,盛大 CFO 张勇加盟了淘宝,花名逍遥子,很快他便参与了一件大事,“将阿里妈妈装回淘宝的子宫”。\n\n朱鸿读研的时候在, 后来读博去了. 朱鸿再次回到阿里巴巴的时候,阿里妈妈已经与淘宝合到了一起。他成为了淘宝的一员,在阿里的工号是 24083。他记得还在华星的时候,有一次他问:“我怎么没工号?”人力那边说:“给你个 100 号,要不要?”他当时还在读书,就没有要阿里的工号。他去查过 100 号,好像没有人在使用。从他回到阿里的那天起,他开始被叫作“一粟”,沧海一粟的“一粟”。终点又回到了起点,他开始走进另外一个陌生。\n\n湖畔花园, 淘宝, 阿里妈妈, 天猫, 菜鸟, 钉钉. 有个阿里软件的项目曾经在马云的“小黑屋”里关过,但它并没有获得想象中的成功。\n\n其中有一位花名承志的设计师,创立了“蘑菇街”,他的真名叫陈琪。陈琪的故事是另一个故事的翻版。“大炮”方永新告诉我,在做 B2B 业务的时候,他手下的一个主管后来也去创业了。“他做了一个叫滴滴的项目,做得还不错。”“他叫程维吗?”我问。“是的。”\n\n无招是花名,他的真名叫陈航. “至少当时在阿里巴巴内部,他已经快成为‘臭名昭著’的人:一个从日本回来的职业经理人,做一淘没什么起色,做来往看起来也快要完蛋。阿里似乎给了他不少机会,遗憾的是,他没有抓住其中任何一个。” `然后钉钉`\n", + "hasOrig": true + }, + { + "id": "10001", + "title": "复活“来往”,阿里的社交心结", + "author": ["叶二"], + "publisher": "蓝媒汇", + "date": "2017-09", + "chapter": "世家", + "tag": ["阿里", "社交", "来往", "钉钉"], + "remarks": "\nReal如我 校园社交 点点虫 (原来往) 阅后即焚\n", + "hasOrig": false + } + ], + "fieldFreqMap": { + "author": { "迟宇宙": 1, "叶二": 1 }, + "publisher": { "商业人物": 1, "蓝媒汇": 1 }, + "date": { "2017-09": 2 }, + "tag": { "阿里": 2, "公司史": 1, "社交": 1, "来往": 1, "钉钉": 1 } + } +} diff --git a/src/components/vendor/ExpandCollapse.js b/src/components/vendor/ExpandCollapse.js new file mode 100644 index 0000000..015bef0 --- /dev/null +++ b/src/components/vendor/ExpandCollapse.js @@ -0,0 +1,269 @@ + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +const _createClass = function () { function defineProperties(target, props) { for (let i = 0; i < props.length; i++) { const descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +const _react = require("react"); + +const _react2 = _interopRequireDefault(_react); + +const _propTypes = require("prop-types"); + +const _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError(`Super expression must either be null or a function, not ${ typeof superClass}`); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +const propTypes = { + // the height of data preview + previewHeight: _propTypes2.default.string.isRequired, + // any children you pass in + children: _propTypes2.default.node.isRequired, + // a custom class name + className: _propTypes2.default.string, + // a flag to set default state of data + expanded: _propTypes2.default.bool, + // the text to show for expand + expandText: _propTypes2.default.node, + // the text to show for collapse + collapseText: _propTypes2.default.node, + // option to set if expanded data can be collapsed + collapse: _propTypes2.default.bool, + // a flag to set ellipsis + ellipsis: _propTypes2.default.bool, + // custom text to show before expand text + ellipsisText: _propTypes2.default.string, + // called whenever the user clicks expand button + onExpandClick: _propTypes2.default.func, + // called whenever the user clicks collapse button + onCollapseClick: _propTypes2.default.func, + // called whenever the user clicks expand and collapse button + onClick: _propTypes2.default.func +}; + +const defaultProps = { + className: "", + expanded: false, + expandText: "Expand", + collapseText: "Collapse", + collapse: true, + ellipsis: true, + ellipsisText: "...", + onExpandClick: null, + onCollapseClick: null, + onClick: null +}; + +const ExpandCollapse = function (_React$Component) { + _inherits(ExpandCollapse, _React$Component); + + function ExpandCollapse(props) { + _classCallCheck(this, ExpandCollapse); + + const _this = _possibleConstructorReturn(this, (ExpandCollapse.__proto__ || Object.getPrototypeOf(ExpandCollapse)).call(this, props)); + + _this.state = { + expanded: _this.props.expanded, + shouldExpand: true + }; + + _this.handleClick = _this.handleClick.bind(_this); + _this.shouldDataExpand = _this.shouldDataExpand.bind(_this); + _this.getContentHeight = _this.getContentHeight.bind(_this); + _this.getButton = _this.getButton.bind(_this); + _this.getButtonText = _this.getButtonText.bind(_this); + _this.getClassName = _this.getClassName.bind(_this); + _this.setScrollPosition = _this.setScrollPosition.bind(_this); + _this.setRef = _this.setRef.bind(_this); + return _this; + } + + _createClass(ExpandCollapse, [{ + key: "componentDidMount", + value: function componentDidMount() { + this.shouldDataExpand(); + } + }, { + key: "handleClick", + value: function handleClick(event) { + this.setState({ + expanded: !this.state.expanded + }, function () { + const {expanded} = this.state; + const _props = this.props; + const {onExpandClick} = _props; + const {onCollapseClick} = _props; + const {onClick} = _props; + + + if (onExpandClick) { + if (expanded) { + onExpandClick(event); + } + } + + if (onCollapseClick) { + if (!expanded) { + onCollapseClick(event); + } + } + + if (onClick) { + onClick(event); + } + + this.setScrollPosition(); + }); + } + }, { + key: "setScrollPosition", + value: function setScrollPosition() { + const {expanded} = this.state; + + + if (!expanded) { + const contentRect = this.toggleContent.getBoundingClientRect(); + if (contentRect.top < 0) { + const offsetTop = Math.abs(contentRect.top + (window.pageYOffset || document.documentElement.scrollTop)); + + window.scrollTo(0, offsetTop); + } + } + } + }, { + key: "shouldDataExpand", + value: function shouldDataExpand() { + const {expanded} = this.state; + + + const contentRect = this.toggleContent.getBoundingClientRect(); + const contentBodyRect = this.toggleContent.querySelector(".react-expand-collapse__body").getBoundingClientRect(); + + if (contentRect.height > contentBodyRect.height && !expanded) { + this.setState({ + shouldExpand: false + }); + } + } + }, { + key: "getContentHeight", + value: function getContentHeight() { + const _state = this.state; + const {expanded} = _state; + const {shouldExpand} = _state; + const {previewHeight} = this.props; + + + if (expanded || !shouldExpand) { + return "auto"; + } + + return previewHeight; + } + }, { + key: "getButton", + value: function getButton() { + const _state2 = this.state; + const {expanded} = _state2; + const {shouldExpand} = _state2; + const {collapse} = this.props; + + + if (shouldExpand) { + if (!collapse && expanded) { + return ""; + } + + const buttonText = this.getButtonText(); + + return _react2.default.createElement( + "span", + { + className: "react-expand-collapse__button", + onClick: this.handleClick, + "aria-label": buttonText, + "aria-expanded": expanded, + role: "button" + }, + buttonText + ); + } + + return ""; + } + }, { + key: "getButtonText", + value: function getButtonText() { + const {expanded} = this.state; + const _props2 = this.props; + const {expandText} = _props2; + const {collapseText} = _props2; + const {ellipsis} = _props2; + const {ellipsisText} = _props2; + + + let text = expanded ? collapseText : expandText; + + if (ellipsis) { + text = !expanded ? `${ ellipsisText } ${ text}` : text; + } + + return text; + } + }, { + key: "getClassName", + value: function getClassName() { + const {expanded} = this.state; + const {className} = this.props; + + + const expandedClass = expanded ? "react-expand-collapse--expanded" : ""; + + const classes = ["react-expand-collapse__content", expandedClass].concat(className.split(" ")).join(" "); + + return classes; + } + }, { + key: "setRef", + value: function setRef(ref) { + this.toggleContent = ref; + } + }, { + key: "render", + value: function render() { + const className = this.getClassName(); + const contentHeight = this.getContentHeight(); + const button = this.getButton(); + + return _react2.default.createElement( + "div", + { + className, + ref: this.setRef, + style: { height: contentHeight } + }, + _react2.default.createElement( + "div", + { className: "react-expand-collapse__body" }, + this.props.children + ), + button + ); + } + }]); + + return ExpandCollapse; +}(_react2.default.Component); + +ExpandCollapse.propTypes = propTypes; +ExpandCollapse.defaultProps = defaultProps; + +exports.default = ExpandCollapse; \ No newline at end of file diff --git a/src/global.less b/src/global.less index 80966dd..832fb05 100644 --- a/src/global.less +++ b/src/global.less @@ -56,16 +56,16 @@ ol { // 自定义部分 -------------------------------------------------------------------- .ant-pro-page-container-content, .ant-pro-menu-item-title { - color: #755C1B; + color: #755c1b; font-weight: bold; font-size: 14px; } code { - margin: .1em .1em; - padding: .2em .3em .1em; - background: hsla(0,0%,58.8%,.1); - border: 1px solid hsla(0,0%,39.2%,.1); + margin: 0.1em 0.1em; + padding: 0.2em 0.3em 0.1em; + background: hsla(0, 0%, 58.8%, 0.1); + border: 1px solid hsla(0, 0%, 39.2%, 0.1); border-radius: 4px; - color: #7A4419; + color: #7a4419; } diff --git a/src/layouts/BasicLayout.less b/src/layouts/BasicLayout.less index 34233d7..83b2a30 100644 --- a/src/layouts/BasicLayout.less +++ b/src/layouts/BasicLayout.less @@ -1,5 +1,5 @@ .pro { - :global { + :global { .ant-pro-top-nav-header-logo { margin-left: 12px; h1 { @@ -7,5 +7,5 @@ font-size: 32px; } } - } + } } diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 0fb44e6..059388c 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -10,7 +10,7 @@ import ProLayout, { DefaultFooter, } from '@ant-design/pro-layout'; import React, { useRef } from 'react'; -import { Link, useIntl, connect, Dispatch, history } from 'umi'; +import { Link, connect, Dispatch, history } from 'umi'; import { GithubOutlined } from '@ant-design/icons'; import RightContent from '@/components/GlobalHeader/RightContent'; import { ConnectState } from '@/models/connect'; @@ -32,7 +32,6 @@ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & { [path: string]: MenuDataItem; }; }; - const defaultFooterDom = ( = (props) => { - const { - dispatch, - children, - settings, - } = props; - + const { dispatch, children, settings } = props; const menuDataRef = useRef([]); const handleMenuCollapse = (payload: boolean): void => { @@ -77,20 +71,18 @@ const BasicLayout: React.FC = (props) => { } }; - const { formatMessage } = useIntl(); - return ( history.push('/')} menuItemRender={(menuItemProps, defaultDom) => { if (menuItemProps.isUrl || !menuItemProps.path) { return defaultDom; } + return {defaultDom}; }} footerRender={() => defaultFooterDom} diff --git a/src/layouts/LoadingLayout.tsx b/src/layouts/LoadingLayout.tsx index d095c6f..3d76dbf 100644 --- a/src/layouts/LoadingLayout.tsx +++ b/src/layouts/LoadingLayout.tsx @@ -31,7 +31,7 @@ class LoadingLayout extends React.Component; } diff --git a/src/layouts/UserLayout.tsx b/src/layouts/UserLayout.tsx index e9990a5..1e702b1 100644 --- a/src/layouts/UserLayout.tsx +++ b/src/layouts/UserLayout.tsx @@ -1,6 +1,6 @@ import { DefaultFooter, MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout'; import { Helmet, HelmetProvider } from 'react-helmet-async'; -import { Link, SelectLang, useIntl, ConnectProps, connect } from 'umi'; +import { Link, ConnectProps, connect } from 'umi'; import React from 'react'; import { ConnectState } from '@/models/connect'; import logo from '../assets/icon.png'; @@ -25,11 +25,10 @@ const UserLayout: React.FC = (props) => { pathname: '', }, } = props; - const { formatMessage } = useIntl(); + const { breadcrumb } = getMenuData(routes); const title = getPageTitle({ pathname: location.pathname, - formatMessage, breadcrumb, ...props, }); @@ -41,9 +40,6 @@ const UserLayout: React.FC = (props) => {
-
- -
diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts deleted file mode 100644 index 337c88c..0000000 --- a/src/locales/en-US.ts +++ /dev/null @@ -1,16 +0,0 @@ -import globalHeader from './en-US/globalHeader'; -import menu from './en-US/menu'; -import settingDrawer from './en-US/settingDrawer'; -import settings from './en-US/settings'; - -export default { - 'navBar.lang': 'Languages', - 'layout.user.link.help': 'Help', - 'layout.user.link.privacy': 'Privacy', - 'layout.user.link.terms': 'Terms', - 'app.preview.down.block': 'Download this page to your local project', - ...globalHeader, - ...menu, - ...settingDrawer, - ...settings, -}; diff --git a/src/locales/en-US/globalHeader.ts b/src/locales/en-US/globalHeader.ts deleted file mode 100644 index f252a54..0000000 --- a/src/locales/en-US/globalHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - 'component.globalHeader.search': 'Search', - 'component.globalHeader.search.example1': 'Search example 1', - 'component.globalHeader.search.example2': 'Search example 2', - 'component.globalHeader.search.example3': 'Search example 3', - 'component.globalHeader.help': 'Help', - 'component.globalHeader.notification': 'Notification', - 'component.globalHeader.notification.empty': 'You have viewed all notifications.', - 'component.globalHeader.message': 'Message', - 'component.globalHeader.message.empty': 'You have viewed all messsages.', - 'component.globalHeader.event': 'Event', - 'component.globalHeader.event.empty': 'You have viewed all events.', -}; diff --git a/src/locales/en-US/menu.ts b/src/locales/en-US/menu.ts deleted file mode 100644 index 7d089d4..0000000 --- a/src/locales/en-US/menu.ts +++ /dev/null @@ -1,50 +0,0 @@ -export default { - 'menu.lanting': '兰亭已矣', - 'menu.more-blocks': 'More Blocks', - 'menu.home': 'Home', - 'menu.login': 'Login', - 'menu.register': 'Register', - 'menu.register.result': 'Register Result', - 'menu.dashboard': 'Dashboard', - 'menu.dashboard.analysis': 'Analysis', - 'menu.dashboard.monitor': 'Monitor', - 'menu.dashboard.workplace': 'Workplace', - 'menu.exception.403': '403', - 'menu.exception.404': '404', - 'menu.exception.500': '500', - 'menu.form': 'Form', - 'menu.form.basic-form': 'Basic Form', - 'menu.form.step-form': 'Step Form', - 'menu.form.step-form.info': 'Step Form(write transfer information)', - 'menu.form.step-form.confirm': 'Step Form(confirm transfer information)', - 'menu.form.step-form.result': 'Step Form(finished)', - 'menu.form.advanced-form': 'Advanced Form', - 'menu.list': 'List', - 'menu.list.table-list': 'Search Table', - 'menu.list.basic-list': 'Basic List', - 'menu.list.card-list': 'Card List', - 'menu.list.search-list': 'Search List', - 'menu.list.search-list.articles': 'Search List(articles)', - 'menu.list.search-list.projects': 'Search List(projects)', - 'menu.list.search-list.applications': 'Search List(applications)', - 'menu.profile': 'Profile', - 'menu.profile.basic': 'Basic Profile', - 'menu.profile.advanced': 'Advanced Profile', - 'menu.result': 'Result', - 'menu.result.success': 'Success', - 'menu.result.fail': 'Fail', - 'menu.exception': 'Exception', - 'menu.exception.not-permission': '403', - 'menu.exception.not-find': '404', - 'menu.exception.server-error': '500', - 'menu.exception.trigger': 'Trigger', - 'menu.account': 'Account', - 'menu.account.center': 'Account Center', - '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/en-US/settingDrawer.ts b/src/locales/en-US/settingDrawer.ts deleted file mode 100644 index a644905..0000000 --- a/src/locales/en-US/settingDrawer.ts +++ /dev/null @@ -1,31 +0,0 @@ -export default { - 'app.setting.pagestyle': 'Page style setting', - 'app.setting.pagestyle.dark': 'Dark style', - 'app.setting.pagestyle.light': 'Light style', - 'app.setting.content-width': 'Content Width', - 'app.setting.content-width.fixed': 'Fixed', - 'app.setting.content-width.fluid': 'Fluid', - 'app.setting.themecolor': 'Theme Color', - 'app.setting.themecolor.dust': 'Dust Red', - 'app.setting.themecolor.volcano': 'Volcano', - 'app.setting.themecolor.sunset': 'Sunset Orange', - 'app.setting.themecolor.cyan': 'Cyan', - 'app.setting.themecolor.green': 'Polar Green', - 'app.setting.themecolor.daybreak': 'Daybreak Blue (default)', - 'app.setting.themecolor.geekblue': 'Geek Glue', - 'app.setting.themecolor.purple': 'Golden Purple', - 'app.setting.navigationmode': 'Navigation Mode', - 'app.setting.sidemenu': 'Side Menu Layout', - 'app.setting.topmenu': 'Top Menu Layout', - 'app.setting.fixedheader': 'Fixed Header', - 'app.setting.fixedsidebar': 'Fixed Sidebar', - 'app.setting.fixedsidebar.hint': 'Works on Side Menu Layout', - 'app.setting.hideheader': 'Hidden Header when scrolling', - 'app.setting.hideheader.hint': 'Works when Hidden Header is enabled', - 'app.setting.othersettings': 'Other Settings', - 'app.setting.weakmode': 'Weak Mode', - 'app.setting.copy': 'Copy Setting', - 'app.setting.copyinfo': 'copy success,please replace defaultSettings in src/models/setting.js', - 'app.setting.production.hint': - 'Setting panel shows in development environment only, please manually modify', -}; diff --git a/src/locales/en-US/settings.ts b/src/locales/en-US/settings.ts deleted file mode 100644 index 822dd00..0000000 --- a/src/locales/en-US/settings.ts +++ /dev/null @@ -1,60 +0,0 @@ -export default { - 'app.settings.menuMap.basic': 'Basic Settings', - 'app.settings.menuMap.security': 'Security Settings', - 'app.settings.menuMap.binding': 'Account Binding', - 'app.settings.menuMap.notification': 'New Message Notification', - 'app.settings.basic.avatar': 'Avatar', - 'app.settings.basic.change-avatar': 'Change avatar', - 'app.settings.basic.email': 'Email', - 'app.settings.basic.email-message': 'Please input your email!', - 'app.settings.basic.nickname': 'Nickname', - 'app.settings.basic.nickname-message': 'Please input your Nickname!', - 'app.settings.basic.profile': 'Personal profile', - 'app.settings.basic.profile-message': 'Please input your personal profile!', - 'app.settings.basic.profile-placeholder': 'Brief introduction to yourself', - 'app.settings.basic.country': 'Country/Region', - 'app.settings.basic.country-message': 'Please input your country!', - 'app.settings.basic.geographic': 'Province or city', - 'app.settings.basic.geographic-message': 'Please input your geographic info!', - 'app.settings.basic.address': 'Street Address', - 'app.settings.basic.address-message': 'Please input your address!', - 'app.settings.basic.phone': 'Phone Number', - 'app.settings.basic.phone-message': 'Please input your phone!', - 'app.settings.basic.update': 'Update Information', - 'app.settings.security.strong': 'Strong', - 'app.settings.security.medium': 'Medium', - 'app.settings.security.weak': 'Weak', - 'app.settings.security.password': 'Account Password', - 'app.settings.security.password-description': 'Current password strength', - 'app.settings.security.phone': 'Security Phone', - 'app.settings.security.phone-description': 'Bound phone', - 'app.settings.security.question': 'Security Question', - 'app.settings.security.question-description': - 'The security question is not set, and the security policy can effectively protect the account security', - 'app.settings.security.email': 'Backup Email', - 'app.settings.security.email-description': 'Bound Email', - 'app.settings.security.mfa': 'MFA Device', - 'app.settings.security.mfa-description': - 'Unbound MFA device, after binding, can be confirmed twice', - 'app.settings.security.modify': 'Modify', - 'app.settings.security.set': 'Set', - 'app.settings.security.bind': 'Bind', - 'app.settings.binding.taobao': 'Binding Taobao', - 'app.settings.binding.taobao-description': 'Currently unbound Taobao account', - 'app.settings.binding.alipay': 'Binding Alipay', - 'app.settings.binding.alipay-description': 'Currently unbound Alipay account', - 'app.settings.binding.dingding': 'Binding DingTalk', - 'app.settings.binding.dingding-description': 'Currently unbound DingTalk account', - 'app.settings.binding.bind': 'Bind', - 'app.settings.notification.password': 'Account Password', - 'app.settings.notification.password-description': - 'Messages from other users will be notified in the form of a station letter', - 'app.settings.notification.messages': 'System Messages', - 'app.settings.notification.messages-description': - 'System messages will be notified in the form of a station letter', - 'app.settings.notification.todo': 'To-do Notification', - 'app.settings.notification.todo-description': - 'The to-do list will be notified in the form of a letter from the station', - 'app.settings.open': 'Open', - 'app.settings.close': 'Close', -}; diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts deleted file mode 100644 index fc10b6f..0000000 --- a/src/locales/zh-CN.ts +++ /dev/null @@ -1,16 +0,0 @@ -import globalHeader from './zh-CN/globalHeader'; -import menu from './zh-CN/menu'; -import settingDrawer from './zh-CN/settingDrawer'; -import settings from './zh-CN/settings'; - -export default { - 'navBar.lang': '语言', - 'layout.user.link.help': '帮助', - 'layout.user.link.privacy': '隐私', - 'layout.user.link.terms': '条款', - 'app.preview.down.block': '下载此页面到本地项目', - ...globalHeader, - ...menu, - ...settingDrawer, - ...settings, -}; diff --git a/src/locales/zh-CN/globalHeader.ts b/src/locales/zh-CN/globalHeader.ts deleted file mode 100644 index 493b6f5..0000000 --- a/src/locales/zh-CN/globalHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -export default { - 'component.globalHeader.search': '站内搜索', - 'component.globalHeader.search.example1': '搜索提示一', - 'component.globalHeader.search.example2': '搜索提示二', - 'component.globalHeader.search.example3': '搜索提示三', - 'component.globalHeader.help': '使用文档', - 'component.globalHeader.notification': '通知', - 'component.globalHeader.notification.empty': '你已查看所有通知', - 'component.globalHeader.message': '消息', - 'component.globalHeader.message.empty': '您已读完所有消息', - 'component.globalHeader.event': '待办', - 'component.globalHeader.event.empty': '你已完成所有待办', -}; diff --git a/src/locales/zh-CN/menu.ts b/src/locales/zh-CN/menu.ts deleted file mode 100644 index 794fc34..0000000 --- a/src/locales/zh-CN/menu.ts +++ /dev/null @@ -1,50 +0,0 @@ -export default { - 'menu.lanting': '兰亭已矣', - 'menu.more-blocks': '更多区块', - 'menu.home': '首页', - 'menu.login': '登录', - 'menu.register': '注册', - 'menu.register.result': '注册结果', - 'menu.dashboard': 'Dashboard', - 'menu.dashboard.analysis': '分析页', - 'menu.dashboard.monitor': '监控页', - 'menu.dashboard.workplace': '工作台', - 'menu.exception.403': '403', - 'menu.exception.404': '404', - 'menu.exception.500': '500', - 'menu.form': '表单页', - 'menu.form.basic-form': '基础表单', - 'menu.form.step-form': '分步表单', - 'menu.form.step-form.info': '分步表单(填写转账信息)', - 'menu.form.step-form.confirm': '分步表单(确认转账信息)', - 'menu.form.step-form.result': '分步表单(完成)', - 'menu.form.advanced-form': '高级表单', - 'menu.list': '列表页', - 'menu.list.table-list': '查询表格', - 'menu.list.basic-list': '标准列表', - 'menu.list.card-list': '卡片列表', - 'menu.list.search-list': '搜索列表', - 'menu.list.search-list.articles': '搜索列表(文章)', - 'menu.list.search-list.projects': '搜索列表(项目)', - 'menu.list.search-list.applications': '搜索列表(应用)', - 'menu.profile': '详情页', - 'menu.profile.basic': '基础详情页', - 'menu.profile.advanced': '高级详情页', - 'menu.result': '结果页', - 'menu.result.success': '成功页', - 'menu.result.fail': '失败页', - 'menu.exception': '异常页', - 'menu.exception.not-permission': '403', - 'menu.exception.not-find': '404', - 'menu.exception.server-error': '500', - 'menu.exception.trigger': '触发错误', - 'menu.account': '个人页', - 'menu.account.center': '个人中心', - '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-CN/settingDrawer.ts b/src/locales/zh-CN/settingDrawer.ts deleted file mode 100644 index 15685a4..0000000 --- a/src/locales/zh-CN/settingDrawer.ts +++ /dev/null @@ -1,31 +0,0 @@ -export default { - 'app.setting.pagestyle': '整体风格设置', - 'app.setting.pagestyle.dark': '暗色菜单风格', - 'app.setting.pagestyle.light': '亮色菜单风格', - 'app.setting.content-width': '内容区域宽度', - 'app.setting.content-width.fixed': '定宽', - 'app.setting.content-width.fluid': '流式', - 'app.setting.themecolor': '主题色', - 'app.setting.themecolor.dust': '薄暮', - 'app.setting.themecolor.volcano': '火山', - 'app.setting.themecolor.sunset': '日暮', - 'app.setting.themecolor.cyan': '明青', - 'app.setting.themecolor.green': '极光绿', - 'app.setting.themecolor.daybreak': '拂晓蓝(默认)', - 'app.setting.themecolor.geekblue': '极客蓝', - 'app.setting.themecolor.purple': '酱紫', - 'app.setting.navigationmode': '导航模式', - 'app.setting.sidemenu': '侧边菜单布局', - 'app.setting.topmenu': '顶部菜单布局', - 'app.setting.fixedheader': '固定 Header', - 'app.setting.fixedsidebar': '固定侧边菜单', - 'app.setting.fixedsidebar.hint': '侧边菜单布局时可配置', - 'app.setting.hideheader': '下滑时隐藏 Header', - 'app.setting.hideheader.hint': '固定 Header 时可配置', - 'app.setting.othersettings': '其他设置', - 'app.setting.weakmode': '色弱模式', - 'app.setting.copy': '拷贝设置', - 'app.setting.copyinfo': '拷贝成功,请到 src/defaultSettings.js 中替换默认配置', - 'app.setting.production.hint': - '配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件', -}; diff --git a/src/locales/zh-CN/settings.ts b/src/locales/zh-CN/settings.ts deleted file mode 100644 index df8af43..0000000 --- a/src/locales/zh-CN/settings.ts +++ /dev/null @@ -1,55 +0,0 @@ -export default { - 'app.settings.menuMap.basic': '基本设置', - 'app.settings.menuMap.security': '安全设置', - 'app.settings.menuMap.binding': '账号绑定', - 'app.settings.menuMap.notification': '新消息通知', - 'app.settings.basic.avatar': '头像', - 'app.settings.basic.change-avatar': '更换头像', - 'app.settings.basic.email': '邮箱', - 'app.settings.basic.email-message': '请输入您的邮箱!', - 'app.settings.basic.nickname': '昵称', - 'app.settings.basic.nickname-message': '请输入您的昵称!', - 'app.settings.basic.profile': '个人简介', - 'app.settings.basic.profile-message': '请输入个人简介!', - 'app.settings.basic.profile-placeholder': '个人简介', - 'app.settings.basic.country': '国家/地区', - 'app.settings.basic.country-message': '请输入您的国家或地区!', - 'app.settings.basic.geographic': '所在省市', - 'app.settings.basic.geographic-message': '请输入您的所在省市!', - 'app.settings.basic.address': '街道地址', - 'app.settings.basic.address-message': '请输入您的街道地址!', - 'app.settings.basic.phone': '联系电话', - 'app.settings.basic.phone-message': '请输入您的联系电话!', - 'app.settings.basic.update': '更新基本信息', - 'app.settings.security.strong': '强', - 'app.settings.security.medium': '中', - 'app.settings.security.weak': '弱', - 'app.settings.security.password': '账户密码', - 'app.settings.security.password-description': '当前密码强度', - 'app.settings.security.phone': '密保手机', - 'app.settings.security.phone-description': '已绑定手机', - 'app.settings.security.question': '密保问题', - 'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全', - 'app.settings.security.email': '备用邮箱', - 'app.settings.security.email-description': '已绑定邮箱', - 'app.settings.security.mfa': 'MFA 设备', - 'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认', - 'app.settings.security.modify': '修改', - 'app.settings.security.set': '设置', - 'app.settings.security.bind': '绑定', - 'app.settings.binding.taobao': '绑定淘宝', - 'app.settings.binding.taobao-description': '当前未绑定淘宝账号', - 'app.settings.binding.alipay': '绑定支付宝', - 'app.settings.binding.alipay-description': '当前未绑定支付宝账号', - 'app.settings.binding.dingding': '绑定钉钉', - 'app.settings.binding.dingding-description': '当前未绑定钉钉账号', - 'app.settings.binding.bind': '绑定', - 'app.settings.notification.password': '账户密码', - 'app.settings.notification.password-description': '其他用户的消息将以站内信的形式通知', - 'app.settings.notification.messages': '系统消息', - 'app.settings.notification.messages-description': '系统消息将以站内信的形式通知', - 'app.settings.notification.todo': '待办任务', - 'app.settings.notification.todo-description': '待办任务将以站内信的形式通知', - 'app.settings.open': '开', - 'app.settings.close': '关', -}; diff --git a/src/pages/Lanting/_mock.ts b/src/pages/Lanting/_mock.ts deleted file mode 100644 index cc32c7a..0000000 --- a/src/pages/Lanting/_mock.ts +++ /dev/null @@ -1,115 +0,0 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { Request, Response } from 'express'; -import { ListItemDataType } from './data'; - -const titles = [ - 'Alipay', - 'Angular', - 'Ant Design', - 'Ant Design Pro', - 'Bootstrap', - 'React', - 'Vue', - 'Webpack', -]; -const avatars = [ - 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay - 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular - 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design - 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro - 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap - 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React - 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue - 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack -]; - -const covers = [ - 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', - 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', - 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', - 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png', -]; -const desc = [ - '那是一种内在的东西, 他们到达不了,也无法触及的', - '希望是一个好东西,也许是最好的,好东西是不会消亡的', - '生命就像一盒巧克力,结果往往出人意料', - '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', - '那时候我只会想自己想要什么,从不想自己拥有什么', -]; -const user = [ - '付小小', - '曲丽丽', - '林东东', - '周星星', - '吴加好', - '朱偏右', - '鱼酱', - '乐哥', - '谭小仪', - '仲尼', -]; - -function fakeList(count: number): ListItemDataType[] { - const list = []; - for (let i = 0; i < count; i += 1) { - list.push({ - id: `fake-list-${Math.random().toString(36).slice(2, 6)}${i}`, - owner: user[i % 10], - title: titles[i % 8], - avatar: avatars[i % 8], - cover: parseInt(`${i / 4}`, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)], - status: ['active', 'exception', 'normal'][i % 3] as - | 'normal' - | 'exception' - | 'active' - | 'success', - percent: Math.ceil(Math.random() * 50) + 50, - logo: avatars[i % 8], - href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - subDescription: desc[i % 5], - description: - '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', - activeUser: Math.ceil(Math.random() * 100000) + 100000, - newUser: Math.ceil(Math.random() * 1000) + 1000, - star: Math.ceil(Math.random() * 100) + 100, - like: Math.ceil(Math.random() * 100) + 100, - message: Math.ceil(Math.random() * 10) + 10, - content: - '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。', - members: [ - { - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', - name: '曲丽丽', - id: 'member1', - }, - { - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', - name: '王昭君', - id: 'member2', - }, - { - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', - name: '董娜娜', - id: 'member3', - }, - ], - }); - } - - return list; -} - -function getFakeList(req: Request, res: Response) { - const params = req.query; - - const count = params.count * 1 || 20; - - const result = fakeList(count); - return res.json(result); -} - -export default { - 'GET /api/fake_list': getFakeList, -}; diff --git a/src/pages/Lanting/components/ArchiveListContent/index.less b/src/pages/Lanting/components/ArchiveListContent/index.less index 65c0644..6a19d3f 100644 --- a/src/pages/Lanting/components/ArchiveListContent/index.less +++ b/src/pages/Lanting/components/ArchiveListContent/index.less @@ -40,7 +40,7 @@ } } -:global { +:global { .react-expand-collapse__content { position: relative; overflow-y: hidden; diff --git a/src/pages/Lanting/components/ArchiveListContent/index.tsx b/src/pages/Lanting/components/ArchiveListContent/index.tsx index 6191529..018f579 100644 --- a/src/pages/Lanting/components/ArchiveListContent/index.tsx +++ b/src/pages/Lanting/components/ArchiveListContent/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { CalendarOutlined, DownOutlined, UpOutlined } from '@ant-design/icons'; import ReactMarkdown from 'react-markdown'; -import ExpandCollapse from 'react-expand-collapse'; +import ExpandCollapse from '@/components/vendor/ExpandCollapse'; import styles from './index.less'; import { Archive } from '../../data'; diff --git a/src/pages/Lanting/components/ArchiveListContent/typing.d.ts b/src/pages/Lanting/components/ArchiveListContent/typing.d.ts new file mode 100644 index 0000000..b0afb0a --- /dev/null +++ b/src/pages/Lanting/components/ArchiveListContent/typing.d.ts @@ -0,0 +1,12 @@ +declare module 'react-expand-collapse' { + import * as React from 'react'; + + export interface ExpandCollapseProps { + previewHeight: string; + expandText: any; + collapseText: any; + ellipsis: boolean; + } + + export default class ExpandCollapse extends React.PureComponent {} +} diff --git a/src/pages/Lanting/components/ArticleListContent/index.less b/src/pages/Lanting/components/ArticleListContent/index.less deleted file mode 100644 index eca0811..0000000 --- a/src/pages/Lanting/components/ArticleListContent/index.less +++ /dev/null @@ -1,38 +0,0 @@ -@import '~antd/es/style/themes/default.less'; - -.listContent { - .description { - max-width: 720px; - line-height: 22px; - } - .extra { - margin-top: 16px; - color: @text-color-secondary; - line-height: 22px; - & > :global(.ant-avatar) { - position: relative; - top: 1px; - width: 20px; - height: 20px; - margin-right: 8px; - vertical-align: top; - } - & > em { - margin-left: 16px; - color: @disabled-color; - font-style: normal; - } - } -} - -@media screen and (max-width: @screen-xs) { - .listContent { - .extra { - & > em { - display: block; - margin-top: 8px; - margin-left: 0; - } - } - } -} diff --git a/src/pages/Lanting/components/ArticleListContent/index.tsx b/src/pages/Lanting/components/ArticleListContent/index.tsx deleted file mode 100644 index 6a763b2..0000000 --- a/src/pages/Lanting/components/ArticleListContent/index.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Avatar } from 'antd'; -import React from 'react'; -import moment from 'moment'; -import styles from './index.less'; - -interface ArticleListContentProps { - data: { - content: React.ReactNode; - updatedAt: number; - avatar: string; - owner: string; - href: string; - }; -} - -const ArticleListContent: React.FC = ({ - data: { content, updatedAt, avatar, owner, href }, -}) => ( -
-
{content}
-
- - {owner} 发布在 {href} - {moment(updatedAt).format('YYYY-MM-DD HH:mm')} -
-
-); - -export default ArticleListContent; diff --git a/src/pages/Lanting/data.ts b/src/pages/Lanting/data.ts index a3f85a8..d9e3aa8 100644 --- a/src/pages/Lanting/data.ts +++ b/src/pages/Lanting/data.ts @@ -1,33 +1,3 @@ -export interface Member { - avatar: string; - name: string; - id: string; -} - -export interface ListItemDataType { - id: string; - owner: string; - title: string; - avatar: string; - cover: string; - status: 'normal' | 'exception' | 'active' | 'success'; - percent: number; - logo: string; - href: string; - body?: any; - updatedAt: number; - createdAt: number; - subDescription: string; - description: string; - activeUser: number; - newUser: number; - star: number; - like: number; - message: number; - content: string; - members: Member[]; -} - export type Chapter = '本纪' | '世家' | '列传' | '群像' | '随园食单' | string; export class FieldFreqMap { @@ -73,3 +43,10 @@ export class Archives { fieldFreqMap: FieldFreqMap = new FieldFreqMap(); } + +export interface FilterValues { + author: string[]; + date: string[]; + publisher: string[]; + tag: string[]; +} diff --git a/src/pages/Lanting/index.tsx b/src/pages/Lanting/index.tsx index 6925c26..536411e 100644 --- a/src/pages/Lanting/index.tsx +++ b/src/pages/Lanting/index.tsx @@ -1,13 +1,13 @@ import React, { FC } from 'react'; import { Card, Form, List, Select, Tag, Collapse } from 'antd'; -import { FormInstance } from 'antd/lib/form/Form' +import { FormInstance } from 'antd/lib/form/Form'; import { EditOutlined, BankOutlined, DownOutlined } from '@ant-design/icons'; import { connect, Dispatch } from 'umi'; import { PageContainer } from '@ant-design/pro-layout'; import { fieldToTranslation } from '@/utils/utils'; import ArchiveListContent from './components/ArchiveListContent'; import { StateType } from './model'; -import { Archives, Archive } from './data'; +import { Archives, Archive, FilterValues } from './data'; import StandardFormRow from './components/StandardFormRow'; import styles from './style.less'; @@ -57,13 +57,15 @@ const generateSelect = (field: string, archives: Archives, isLast: boolean) => { const generateSelects = (archives: Archives) => { return ['author', 'publisher', 'date', 'tag'].map((f, idx) => - generateSelect(f, archives, idx === 3) + generateSelect(f, archives, idx === 3), ); -} +}; -const getFilterElem = (archives: Archives, form: FormInstance, - onValuesChange: (changedValues: any, values: any) => void) => { - +const getFilterElem = ( + archives: Archives, + form: FormInstance, + onValuesChange: (changedValues: any, values: FilterValues) => void, +) => { return ( @@ -87,16 +89,14 @@ const getFilterElem = (archives: Archives, form: FormInstance, const Lanting: FC = ({ dispatch, - lanting: { archives }, + lanting: { compiledArchives, currentArchives }, }) => { const [form] = Form.useForm(); - const onFilterChange = (changedValues: any, values: any) => { + const onFilterChange = (_: any, values: FilterValues) => { dispatch({ type: 'lanting/queryList', payload: { - test1: 2, - changedValues, values, }, }); @@ -105,14 +105,14 @@ const Lanting: FC = ({ return ( size="large" rowKey="id" itemLayout="vertical" - dataSource={archives.archives} + dataSource={currentArchives} renderItem={(item) => ( = ({ extra={
} > - {item.title} - : -

- {item.title} -

+ title={ + item.hasOrig ? ( + + {item.title} + + ) : ( + {item.title} + ) } description={ {item.tag.map((t) => ( - {t} + {t} ))} } diff --git a/src/pages/Lanting/model.ts b/src/pages/Lanting/model.ts index 237ea51..68739a5 100644 --- a/src/pages/Lanting/model.ts +++ b/src/pages/Lanting/model.ts @@ -1,9 +1,10 @@ import { Reducer } from 'umi'; import compiledArchives from '@/assets/archives.json'; -import { Archives } from './data'; +import { Archive, Archives, FilterValues } from './data'; export interface StateType { - archives: Archives; + compiledArchives: Archives; + currentArchives: Archive[]; } export interface ModelType { @@ -14,17 +15,41 @@ export interface ModelType { }; } +const filterArchives = (filters: FilterValues, archives: Archive[]) => { + const results = archives.filter((archive) => { + if (!filters.date.includes('all') && !filters.date.includes(archive.date)) { + return false; + } + if (!filters.publisher.includes('all') && !filters.publisher.includes(archive.publisher)) { + return false; + } + if ( + !filters.author.includes('all') && + !archive.author.some((a) => filters.author.includes(a)) + ) { + return false; + } + if (!filters.tag.includes('all') && !archive.tag.some((a) => filters.tag.includes(a))) { + return false; + } + return true; + }); + return results; +}; + const Model: ModelType = { namespace: 'lanting', state: { - archives: compiledArchives, + compiledArchives, + currentArchives: compiledArchives.archives.slice(), }, reducers: { queryList(state, action) { - console.log('XXXTEMP', action); + const filteredArchives = filterArchives(action.payload.values, compiledArchives.archives); return { ...state, + currentArchives: filteredArchives, } as StateType; }, }, diff --git a/src/pages/document.ejs b/src/pages/document.ejs index 2e4a62a..b90eb6d 100644 --- a/src/pages/document.ejs +++ b/src/pages/document.ejs @@ -1,15 +1,20 @@ - - - - - - - - 兰亭 - - - - - -
- -
-
-
- + " + > +
+
+ +
+
+
+ logo + 兰亭已矣
-
-
- logo - 兰亭已矣
-
- - - \ No newline at end of file + +