+
-
+
{
+ const v = value.replace(/<\/?.+?\/?>/g, '')
+ if (!v) {
+ throw Error('请输入内容')
+ }
+ },
+ },
+ ]}
>
diff --git a/web-react/src/pages/system/notice/index.jsx b/web-react/src/pages/system/notice/index.jsx
index 5a94045..0b37040 100644
--- a/web-react/src/pages/system/notice/index.jsx
+++ b/web-react/src/pages/system/notice/index.jsx
@@ -28,7 +28,7 @@ const apiAction = {
* 用于弹窗标题
* [必要]
*/
-const name = '啥玩意'
+const name = '通知公告'
/**
* 统一配置权限标识
@@ -253,6 +253,7 @@ export default class index extends Component {
this.table.current.onReloadData()}
@@ -264,6 +265,7 @@ export default class index extends Component {
this.table.current.onReloadData()}
diff --git a/web-react/src/views/main/_layout/header/index.jsx b/web-react/src/views/main/_layout/header/index.jsx
index e289d28..0cdf6c8 100644
--- a/web-react/src/views/main/_layout/header/index.jsx
+++ b/web-react/src/views/main/_layout/header/index.jsx
@@ -1,23 +1,19 @@
import React, { Component, useState } from 'react'
-import { Layout, Badge, Popover, Menu, Modal } from 'antd'
+import { Layout, Badge, Popover, Menu, Modal, Tooltip, Popconfirm } from 'antd'
import { AntIcon, Container } from 'components'
-import Logo from '../logo'
-import User from './user'
-import Search from './search'
import store from 'store'
import { api } from 'common/api'
+import Logo from '../logo'
+import Search from './search'
+import Notice from './notice'
+import User from './user'
+
const { getState, subscribe, dispatch } = store
export default class index extends Component {
state = {
...getState('layout'),
- notice: {
- count: 0,
- data: [],
- },
- modalVisible: false,
- currentNotice: {},
}
constructor(props) {
@@ -28,10 +24,6 @@ export default class index extends Component {
})
}
- componentDidMount() {
- this.loadNotice()
- }
-
componentWillUnmount() {
this.unsubscribe()
}
@@ -43,27 +35,8 @@ export default class index extends Component {
})
}
- async loadNotice() {
- const { data } = await api.sysNoticeGetCount()
- const items = await api.sysNoticeInfo()
- this.setState({
- notice: {
- count: data,
- data: items.data,
- },
- })
- }
- async showDetail(params, visible) {
- this.setState({ currentNotice: params })
-
- if (visible) {
- this.setState({ modalVisible: visible })
- } else {
- this.setState({ modalVisible: visible })
- }
- }
render() {
- const { allowSiderCollapsed, notice, currentNotice } = this.state
+ const { allowSiderCollapsed, theme } = this.state
return (
@@ -80,57 +53,38 @@ export default class index extends Component {
-
window.realodContentWindow()}
- >
-
-
-
-
- {notice.data.map(item => (
- this.showDetail(item, true)}
- key={item.id}
- >
- {item.title}
-
- ))}
-
- }
- >
-
-
-
-
-
-
- this.showDetail(false)}
- onCancel={() => this.showDetail(false)}
- style={{ zIndex: 1000 }}
+
+ window.realodContentWindow()}
>
-
-
- 发布人:{currentNotice.createdUserName}
- {' '}
- 发布时间:{currentNotice.createdTime}
-
-
-
+
+
+
+
+
+ {
+ dispatch({
+ type: 'SET_THEME',
+ theme: { default: 'dark', dark: 'default' }[theme],
+ })
+ window.location.reload()
+ }}
+ >
+
+
+
+
+
diff --git a/web-react/src/views/main/_layout/header/notice.jsx b/web-react/src/views/main/_layout/header/notice.jsx
new file mode 100644
index 0000000..dd89eab
--- /dev/null
+++ b/web-react/src/views/main/_layout/header/notice.jsx
@@ -0,0 +1,145 @@
+import React, { Component } from 'react'
+import { Badge, Divider, List, Menu, Modal, Popover, Row, Spin } from 'antd'
+import { AntIcon, Image } from 'components'
+import { api } from 'common/api'
+import InfiniteScroll from 'react-infinite-scroller'
+import moment from 'moment'
+
+export default class notice extends Component {
+ state = {
+ count: 0,
+ list: [],
+
+ loading: false,
+ hasMore: true,
+
+ detailVisible: false,
+ detailLoading: false,
+ detailData: {},
+ }
+
+ async componentDidMount() {
+ const { data: count } = await api.sysNoticeUnread()
+ this.setState({ count })
+ }
+
+ finish() {
+ this.setState({ loading: false, hasMore: false })
+ }
+
+ async onInfiniteOnLoad(pageIndex) {
+ this.setState({ loading: true })
+ const { list } = this.state
+ if (list.length >= 30) {
+ return this.finish()
+ }
+
+ const {
+ data: { items },
+ } = await api.sysNoticeReceived({
+ pageIndex,
+ pageSize: 5,
+ sortField: 'createdTime',
+ sortOrder: 'descend',
+ })
+
+ if (!items.length) {
+ return this.finish()
+ }
+
+ this.setState({
+ list: [...list, ...items],
+ loading: false,
+ })
+ }
+
+ async onOpenDetail(id) {
+ this.setState({ detailLoading: true, detailVisible: true })
+ const { data } = await api.sysNoticeDetail({ id })
+ this.setState({
+ detailLoading: false,
+ detailData: data,
+ })
+ }
+
+ renderList() {
+ const { list, loading, hasMore } = this.state
+ return (
+
this.onInfiniteOnLoad(pageIndex)}
+ hasMore={!loading && hasMore}
+ useWindow={false}
+ threshold={100}
+ >
+ (
+
+ }
+ title={
+ this.onOpenDetail(item.id)}
+ >
+ {item.title}
+
+ }
+ description={moment(item.createdTime || item.publicTime).fromNow()}
+ />
+ {item.content}
+
+ )}
+ >
+ {loading && hasMore && (
+
+ } />
+
+ )}
+
+
+ )
+ }
+
+ render() {
+ const { count, detailLoading, detailVisible, detailData } = this.state
+
+ return (
+
+
+
+
+
+
+
+ this.setState({ detailVisible: false, detailData: {} })}
+ >
+ }>
+ {detailData.title}
+
+
+
+
+ 发布人:{detailData.publicUserName}
+ 发布时间:{detailData.publicTime}
+
+
+
+
+ )
+ }
+}
diff --git a/web-react/yarn.lock b/web-react/yarn.lock
index 963891e..a636c28 100644
--- a/web-react/yarn.lock
+++ b/web-react/yarn.lock
@@ -9285,7 +9285,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"
-prop-types@^15.5.10, prop-types@^15.6.2, prop-types@^15.7.2:
+prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.npm.taobao.org/prop-types/download/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha1-UsQedbjIfnK52TYOAga5ncv/psU=
@@ -9877,6 +9877,13 @@ react-error-overlay@^6.0.9:
resolved "https://registry.nlark.com/react-error-overlay/download/react-error-overlay-6.0.9.tgz?cache=0&sync_timestamp=1618847933355&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact-error-overlay%2Fdownload%2Freact-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha1-PHQwEMk1lgjDdezWvHbzXZOZWwo=
+react-infinite-scroller@^1.2.4:
+ version "1.2.4"
+ resolved "https://registry.npm.taobao.org/react-infinite-scroller/download/react-infinite-scroller-1.2.4.tgz#f67eaec4940a4ce6417bebdd6e3433bfc38826e9"
+ integrity sha1-9n6uxJQKTOZBe+vdbjQzv8OIJuk=
+ dependencies:
+ prop-types "^15.5.8"
+
react-is@^16.12.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1:
version "16.13.1"
resolved "https://registry.nlark.com/react-is/download/react-is-16.13.1.tgz?cache=0&sync_timestamp=1623273254569&other_urls=https%3A%2F%2Fregistry.nlark.com%2Freact-is%2Fdownload%2Freact-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"