Commit 6e57d067 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'optimize/timeline' into 'main'

Optimize/timeline

See merge request !116
parents dbc42578 6432746b
Pipeline #20466 passed with stages
in 7 minutes and 21 seconds
...@@ -2,14 +2,12 @@ import React, { useEffect } from "react"; ...@@ -2,14 +2,12 @@ import React, { useEffect } from "react";
import { useAppSelector } from "../../hook"; import { useAppSelector } from "../../hook";
import { selectMeHint, selectOpHint } from "../../reducers/duel/hintSlice"; import { selectMeHint, selectOpHint } from "../../reducers/duel/hintSlice";
import { selectCurrentPhase } from "../../reducers/duel/phaseSlice"; import { selectCurrentPhase } from "../../reducers/duel/phaseSlice";
import { selectChat } from "../../reducers/chatSlice";
import { notification } from "antd"; import { notification } from "antd";
const HintNotification = () => { const HintNotification = () => {
const meHint = useAppSelector(selectMeHint); const meHint = useAppSelector(selectMeHint);
const opHint = useAppSelector(selectOpHint); const opHint = useAppSelector(selectOpHint);
const currentPhase = useAppSelector(selectCurrentPhase); const currentPhase = useAppSelector(selectCurrentPhase);
const chat = useAppSelector(selectChat);
const [api, contextHolder] = notification.useNotification(); const [api, contextHolder] = notification.useNotification();
useEffect(() => { useEffect(() => {
...@@ -39,16 +37,6 @@ const HintNotification = () => { ...@@ -39,16 +37,6 @@ const HintNotification = () => {
} }
}, [currentPhase]); }, [currentPhase]);
useEffect(() => {
if (chat !== "") {
api.info({
message: "Chat",
description: chat,
placement: "topLeft",
});
}
}, [chat]);
return <>{contextHolder}</>; return <>{contextHolder}</>;
}; };
......
import React from "react"; import React, { useEffect, useState } from "react";
import { Timeline } from "antd"; import { Timeline, TimelineItemProps } from "antd";
import { UserOutlined, SettingOutlined } from "@ant-design/icons"; import { SettingOutlined } from "@ant-design/icons";
import { useAppSelector } from "../../hook";
import { selectChat } from "../../reducers/chatSlice";
const DuelTimeLine = () => ( const DuelTimeLine = () => {
<Timeline const [items, setItems] = useState<TimelineItemProps[]>([]);
items={[ const chat = useAppSelector(selectChat);
{
dot: <UserOutlined />, useEffect(() => {
children: "对手消息", setItems((prev) =>
color: "red", prev.concat([
}, {
{ dot: <SettingOutlined />,
dot: <UserOutlined />, children: chat,
children: "自己消息", color: "red",
color: "green", },
}, ])
{ );
dot: <SettingOutlined />, }, [chat]);
children: "系统消息",
}, return <Timeline items={items} />;
]} };
/>
);
export default DuelTimeLine; export default DuelTimeLine;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment