yangjie #45

Merged
yangqiang merged 19 commits from yangjie into master 2024-12-18 13:52:10 +08:00
2 changed files with 20 additions and 12 deletions
Showing only changes of commit bfd629f264 - Show all commits

View File

@ -5,13 +5,16 @@ import { Button, Input, message, Modal } from 'antd';
import { useState, useImperativeHandle, forwardRef } from "react";
const UserName = forwardRef((props: any, ref: any) => {
useImperativeHandle(ref, () => ({
changeModal: (str: string) => {
setUserName(str)
changeModal: (data: any) => {
setInfo(data)
setUserNameModal(true)
}
}))
const [userNameModal, setUserNameModal] = useState(false);
const [userName, setUserName] = useState('');
const [info, setInfo] = useState({
userName: '',
uid: ''
});
return (
<>
<Modal
@ -28,9 +31,12 @@ const UserName = forwardRef((props: any, ref: any) => {
<Input
placeholder="请输入用户名称"
style={{ width: '100%' }}
value={userName}
value={info.userName}
onChange={(e) => {
setUserName(e.target.value)
setInfo({
...info,
userName: e.target.value
})
}}
/>
</div>
@ -40,12 +46,11 @@ const UserName = forwardRef((props: any, ref: any) => {
<Button type="primary"
onClick={async () => {
const stateInfo = await JSON.parse(storage.getItem('stateInfo') as string);
const userInfo = await JSON.parse(storage.getItem('user') as string);
if (userName) {
if (info.userName) {
PutAlterUname({
nickName: userName,
nickName: info.userName,
roomNum: stateInfo.channelId,
uid: userInfo.uid,
uid: info.uid,
}).then((res) => {
if (res.code === 200) {
message.success('修改成功')

View File

@ -1284,7 +1284,7 @@ const Meeting: React.FC = () => {
break;
case 'ModifyNickName':
setRoomUserList((res: any) => {
let userItem = res.find((row: any) => row.uid === item.uid)
let userItem = res.find((row: any) => row.uid == item.uid)
if (userItem) {
userItem.userName = item.nickName
}
@ -2505,9 +2505,12 @@ const Meeting: React.FC = () => {
<Button
type="primary"
className='m-ant-btn'
style={{ width: '100%' }}
style={{ width: '100%', marginTop: '10px' }}
onClick={() => {
userNameRef.current.changeModal(item.userName)
userNameRef.current.changeModal({
userName: item.userName,
uid: item.uid
})
}}
></Button>
</div>