|
@@ -1,53 +1,102 @@
|
|
|
-import { useWebSocket } from 'ahooks'
|
|
|
|
|
-import { Button } from 'antd'
|
|
|
|
|
-import { useRef, useEffect, useMemo } from 'react'
|
|
|
|
|
-// import QueueAnim from 'rc-queue-anim'
|
|
|
|
|
|
|
+import TimeLineList from '@/components/TimeLineList'
|
|
|
|
|
|
|
|
-enum ReadyState {
|
|
|
|
|
- '0' = '连接中',
|
|
|
|
|
- '1' = '正常',
|
|
|
|
|
- '2' = '断开中',
|
|
|
|
|
- '3' = '断开'
|
|
|
|
|
|
|
+type LogItem = {
|
|
|
|
|
+ id: string
|
|
|
|
|
+ createTime: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const Test = () => {
|
|
const Test = () => {
|
|
|
- const { readyState, latestMessage, disconnect, connect } = useWebSocket(
|
|
|
|
|
- 'ws://192.168.1.26:9000/m/v1/mail/fanout/progress'
|
|
|
|
|
- )
|
|
|
|
|
- const messageHistory = useRef([])
|
|
|
|
|
- const messageBox = useRef<HTMLElement>(null)
|
|
|
|
|
- messageHistory.current = useMemo(() => {
|
|
|
|
|
- if (latestMessage?.data) {
|
|
|
|
|
- const data = JSON.parse(latestMessage.data)
|
|
|
|
|
- return messageHistory.current.concat(data)
|
|
|
|
|
|
|
+ const dataSource = [
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2022-05-24 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iMdgcO0O0Op245O',
|
|
|
|
|
+ createTime: '2022-05-23 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlc60Op245O',
|
|
|
|
|
+ createTime: '2022-05-23 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iM10O0Op245O',
|
|
|
|
|
+ createTime: '2022-05-23 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iMdgaaadO0OpO0O0O',
|
|
|
|
|
+ createTime: '2022-05-22 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1bwerMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1b1cO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTl2werMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlc5rMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
}
|
|
}
|
|
|
- return messageHistory.current
|
|
|
|
|
- }, [latestMessage])
|
|
|
|
|
-
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- if (messageBox.current.scrollHeight - messageBox.current.clientHeight > messageBox.current.scrollTop) {
|
|
|
|
|
- messageBox.current?.scroll({ top: messageBox.current?.scrollHeight })
|
|
|
|
|
|
|
+ ]
|
|
|
|
|
+ const dataSource1 = [
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2022-05-24 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iMdgcO0O0Op245O',
|
|
|
|
|
+ createTime: '2022-05-23 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1iMdgaaadO0OpO0O0O',
|
|
|
|
|
+ createTime: '2022-05-22 12:09:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1bwerMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlcd1b1cO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTl2werMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'McTlc5rMdgcO0O0OpO0O0O',
|
|
|
|
|
+ createTime: '2021-08-25 12:21:41'
|
|
|
}
|
|
}
|
|
|
- }, [messageHistory.current])
|
|
|
|
|
-
|
|
|
|
|
|
|
+ ]
|
|
|
return (
|
|
return (
|
|
|
- <div className="w-full h-full bg-hex-cccccc p-4 flex flex-row">
|
|
|
|
|
- <div>
|
|
|
|
|
- <Button onClick={() => connect()}>连接</Button>
|
|
|
|
|
- <Button onClick={() => disconnect()}>断开</Button>
|
|
|
|
|
- <div>当前连接状态:{ReadyState[readyState]}</div>
|
|
|
|
|
|
|
+ <div className="h-full w-full flex flex-row overflow-scroll">
|
|
|
|
|
+ <div className="w-300px h-400px">
|
|
|
|
|
+ <TimeLineList<LogItem>
|
|
|
|
|
+ mode="line"
|
|
|
|
|
+ dataSource={dataSource}
|
|
|
|
|
+ renderItem={() => <div className="w-200px h-150px bg-yellow-400" />}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="w-300px h-400px">
|
|
|
|
|
+ <TimeLineList<LogItem>
|
|
|
|
|
+ mode="line"
|
|
|
|
|
+ dataSource={dataSource}
|
|
|
|
|
+ // renderItem={() => <div className="w-200px h-150px bg-yellow-400" />}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="w-300px h-400px">
|
|
|
|
|
+ <TimeLineList<LogItem>
|
|
|
|
|
+ mode="card"
|
|
|
|
|
+ dataSource={dataSource1}
|
|
|
|
|
+ renderItem={() => <div className="w-full h-150px bg-green-400" />}
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
- {/* <QueueAnim
|
|
|
|
|
- className="ml-4 border w-400px h-400px border-gray-400 overflow-y-auto overflow-x-hidden"
|
|
|
|
|
- ref={messageBox}
|
|
|
|
|
- >
|
|
|
|
|
- {messageHistory.current?.map(item => (
|
|
|
|
|
- <div key={item.mail}>
|
|
|
|
|
- <span>{item.mail}</span>
|
|
|
|
|
- <span>{item.status}</span>
|
|
|
|
|
- </div>
|
|
|
|
|
- ))}
|
|
|
|
|
- </QueueAnim> */}
|
|
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|