|
|
@@ -7,14 +7,15 @@ import consts from '@/consts'
|
|
|
import { useRequest } from 'umi'
|
|
|
import { useModal } from '@/components/Modal'
|
|
|
import MessageDrawer from './components/MessageDrawer'
|
|
|
+import ws, { CmdType } from '@/utils/ws'
|
|
|
// import MarkDown from 'react-markdown'
|
|
|
|
|
|
const Notification = () => {
|
|
|
const { toggleDrawer, setDrawerProps } = useModal()
|
|
|
// const { sendMsg } = useWebSocketFn()
|
|
|
const msgTypeEnum = {
|
|
|
- message: '通知',
|
|
|
- notification: '消息'
|
|
|
+ message: '消息',
|
|
|
+ notification: '通知'
|
|
|
}
|
|
|
const [state, setState] = useState({
|
|
|
loading: false,
|
|
|
@@ -53,10 +54,13 @@ const Notification = () => {
|
|
|
|
|
|
const { run: trySendMessage } = useRequest(sendMessage, {
|
|
|
manual: true,
|
|
|
- onSuccess: () => {
|
|
|
+ onSuccess: result => {
|
|
|
initData({ current: state.current })
|
|
|
// tRef.current?.reload()
|
|
|
- // sendMsg(cmdType.Notice, result)
|
|
|
+ ws.sendMessage({
|
|
|
+ cmd: CmdType.NoticeOrMessage,
|
|
|
+ ...result
|
|
|
+ })
|
|
|
},
|
|
|
onError: e => {
|
|
|
message.error(e.message)
|
|
|
@@ -90,7 +94,8 @@ const Notification = () => {
|
|
|
hasMore={state.hasMore}
|
|
|
loader={<Skeleton avatar paragraph={{ rows: 1 }} active />}
|
|
|
endMessage={<Divider plain>别再滚啦,已是尽头</Divider>}
|
|
|
- scrollableTarget="scrollableDiv">
|
|
|
+ scrollableTarget="scrollableDiv"
|
|
|
+ >
|
|
|
<List
|
|
|
itemLayout="horizontal"
|
|
|
// pagination={{ pageSize: 5 }}
|
|
|
@@ -102,7 +107,8 @@ const Notification = () => {
|
|
|
title={
|
|
|
<span
|
|
|
className="cursor-pointer text-primary"
|
|
|
- onClick={() => showMessageDrawer(item)}>
|
|
|
+ onClick={() => showMessageDrawer(item)}
|
|
|
+ >
|
|
|
{item.title}
|
|
|
</span>
|
|
|
}
|