diff --git a/src/components/JoinSetting/index.tsx b/src/components/JoinSetting/index.tsx index cae390c..9f8455f 100644 --- a/src/components/JoinSetting/index.tsx +++ b/src/components/JoinSetting/index.tsx @@ -16,14 +16,12 @@ const JoinSetting = forwardRef((_props: any, ref: any) => { setUser(userInfo) setJoinRoomSettingModal(true) setJoinRoomSettingForm((res: any) => { - res.list.forEach((item: any) => { + res.forEach((item: any) => { item.active = false }); - return { - ...res, - roomNum: roomNum - } + return res }) + setRoomNumber(roomNum) if (location.hash.indexOf('/meeting') === -1) { agora.init() } @@ -32,43 +30,35 @@ const JoinSetting = forwardRef((_props: any, ref: any) => { })) const navigate = useNavigate(); const [user, setUser] = useState({}); + const [roomNumber, setRoomNumber] = useState('') const [joinRoomSettingModal, setJoinRoomSettingModal] = useState(false) - const [joinRoomSettingForm, setJoinRoomSettingForm] = useState({ - list: [ - { - title: '静音', - icon: ImageUrl.icon22, - iconActive: ImageUrl.icon22Active, - active: false, - }, - { - title: '关闭视频', - icon: ImageUrl.icon23, - iconActive: ImageUrl.icon23Active, - active: false, - }, - ], - roomNum: '', - }) + const [joinRoomSettingForm, setJoinRoomSettingForm] = useState( + [{ + title: '静音', + icon: ImageUrl.icon22, + iconActive: ImageUrl.icon22Active, + active: false, + }, + { + title: '关闭视频', + icon: ImageUrl.icon23, + iconActive: ImageUrl.icon23Active, + active: false, + },] + ) const getDeviceList = (): void => { time = setInterval(async () => { - const list = [...joinRoomSettingForm.list] + const list = [...joinRoomSettingForm] await agora.getAudioMediaList().then(res => { if (!res.ecordingList.length) { list[0].active = false - setJoinRoomSettingForm({ - ...joinRoomSettingForm, - list - }) + setJoinRoomSettingForm(list) } }) await agora.getVideoDeviceManager().then(res => { if (!res.list.length) { list[1].active = false - setJoinRoomSettingForm({ - ...joinRoomSettingForm, - list - }) + setJoinRoomSettingForm(list) } }) }, 1000) @@ -112,29 +102,26 @@ const JoinSetting = forwardRef((_props: any, ref: any) => { 请输入会议号 { const regex = /^[0-9]*$/; if (regex.test(e.target.value)) { - setJoinRoomSettingForm({ - ...joinRoomSettingForm, - roomNum: e.target.value - }) + setRoomNumber(e.target.value); } }} />
- {joinRoomSettingForm.list[1].active ?
+ {joinRoomSettingForm[1].active ?
: null}
{ - joinRoomSettingForm.list.map((item, index) => { + joinRoomSettingForm.map((item, index) => { return
{ let msg = ''; if (index === 0) { @@ -154,12 +141,9 @@ const JoinSetting = forwardRef((_props: any, ref: any) => { message.error('未检测到麦克风!') return } - const list = [...joinRoomSettingForm.list] + const list = [...joinRoomSettingForm] list[index].active = !list[index].active - setJoinRoomSettingForm({ - ...joinRoomSettingForm, - list - }) + setJoinRoomSettingForm(list) if (index === 1) { if (list[index].active) { agora.startPreview('videoPreview', Number(user.account)) @@ -175,28 +159,28 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {