From 00a69d5759a05e198aa337daaef68ef774ab0e7f Mon Sep 17 00:00:00 2001 From: zhengw <247276359@qq.com> Date: Mon, 24 Apr 2023 15:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=BE=A4=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ChatLogs/ChatUtils.tsx | 35 +++++++++++++------ .../ChatLogs/components/index.module.scss | 2 +- src/pages/ChatLogs/index.module.scss | 2 +- src/pages/ChatLogs/index.tsx | 12 +++---- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/pages/ChatLogs/ChatUtils.tsx b/src/pages/ChatLogs/ChatUtils.tsx index cc4cd1e..b7d7785 100644 --- a/src/pages/ChatLogs/ChatUtils.tsx +++ b/src/pages/ChatLogs/ChatUtils.tsx @@ -190,22 +190,37 @@ type IGroupIcon = { */ export const GroupIcon: React.FC = (props) => { const [list, setList] = useState([[], [], []]); + const [size, setSize] = useState(12); useEffect(() => { let temp: any = [[], [], []]; const { groupList } = props; - for (let index = 0; index < 9; index++) { - const element = groupList[index]; - if (index < 3) { - temp[0].push(element); - } else if (index < 6) { - temp[1].push(element); - } else { - temp[2].push(element); + // groupList.reverse(); + if (groupList.length <= 4) { + setSize(18); + for (let index = 0; index < 9; index++) { + const element = groupList[index]; + if (index < 2) { + temp[0].push(element); + } else { + temp[1].push(element); + } + } + } else { + setSize(12); + for (let index = 0; index < 9; index++) { + const element = groupList[index]; + if (index < 3) { + temp[0].push(element); + } else if (index < 6) { + temp[1].push(element); + } else if (index < 9) { + temp[2].push(element); + } } } temp.reverse(); - setList(temp); + setList(JSON.parse(JSON.stringify(temp))); }, [props.groupList]); return ( @@ -217,7 +232,7 @@ export const GroupIcon: React.FC = (props) => { return el ? (
{el.avatar ? ( { if (Array.isArray(res.data) && res.data.length) { setSelectStaff(res.data[0]); selectStaffRef.current = res.data[0]; - // res.data.forEach((element: IStaffsItem) => { - // if (element.user_id == 'yangxb') { - // setSelectStaff(element); - // selectStaffRef.current = element; - // } - // }); + res.data.forEach((element: IStaffsItem) => { + if (element.user_id == 'yangxb') { + setSelectStaff(element); + selectStaffRef.current = element; + } + }); setStaffsList(res.data); setInnerStaffsList(res.data); getCustFollowsList();