import styles from '@/components/StupWizard/index.module.scss' import ImageUrl from '@/utils/package/imageUrl'; import { Button, Checkbox, Empty, Input, message, Modal, Popover, Radio, Select, Slider, Space } from 'antd'; import { forwardRef, useEffect, useImperativeHandle, useState, memo } from "react"; import { agora } from '@/utils/package/agora' import { CloseOutlined, LoadingOutlined, QuestionCircleOutlined } from '@ant-design/icons'; import { storage } from '@/utils'; import path from 'path'; import { role } from '@/config/role'; import { storageSeeting } from '@/utils/package/public'; let meetingUserInfo = '' as any; const fs = require('fs').promises; const { exec } = require('child_process'); let c = +new Date(); const StupWizard = forwardRef((_props: any, ref: any) => { useImperativeHandle(ref, () => ({ changeModal: (index: number = 0, data: any) => { meetingUserInfo = data; setIsStupWizard(true) if (location.hash.indexOf('/meeting') === -1) { agora.init() } setList((res: any) => { res.forEach((item: any) => { item.active = false }); res[index].active = true; return res }) const setting = JSON.parse(storage.getItem('setting') as string) for (const key in storageSeeting) { if (setting[key] === undefined) { setting[key] = storageSeeting[key] } } storage.setItem('setting', JSON.stringify(setting)) }, getStupWizardModal: () => { return isStupWizard } })) const [list, setList] = useState([ { title: '通用', icon: ImageUrl.icon45, iconActive: ImageUrl.icon45Active, active: true, }, { title: '视频', icon: ImageUrl.icon39, iconActive: ImageUrl.icon39Active, active: false, }, { title: '音频', icon: ImageUrl.icon40, iconActive: ImageUrl.icon40Active, active: false, }, { title: '录制', icon: ImageUrl.icon41, iconActive: ImageUrl.icon41Active, active: false, }, { title: '文件下载', icon: ImageUrl.icon42, iconActive: ImageUrl.icon42Active, active: false, } ]) const [isStupWizard, setIsStupWizard] = useState(false); return ( <>
{list.map((row: any, index: number) => { return (
{ const userInfo = JSON.parse(storage.getItem('user') as string) await agora.destroyRendererByConfigPreview(Number(userInfo.screenShareId), c) const newList = [...list]; newList.forEach(item => item.active = false); newList[index].active = true; setList(newList) agora.stopPlaybackDeviceTest() agora.stopRecordingDeviceTest() }}> {row.title}
) })}
{ const userInfo = JSON.parse(storage.getItem('user') as string) if (location.hash.indexOf('/meeting') === -1) { agora.release() } await agora.destroyRendererByConfigPreview(Number(userInfo.screenShareId), c) setIsStupWizard(false) }} /> {list[0].active ? : null} {list[1].active ? : null} {list[2].active ? : null} {list[3].active ? : null} {list[4].active ? : null}
) }) const CurrencyComponents = () => { const [optionsValue, setOperationValue] = useState<'hide' | 'quit'>('hide'); const [voiceStimulation, setVoiceStimulation] = useState(true); const setting = JSON.parse(storage.getItem('setting') as string) useEffect(() => { setOperationValue(setting.closeSetting) setVoiceStimulation(setting.voiceStimulation) }, []); return ( <>
通用
关闭按钮设置 { setting.closeSetting = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setOperationValue(e.target.value) }} style={{ flexShrink: 0, margin: '10px 0' }} value={optionsValue}> 退出主程序 不退出程序,最小化到托盘
语音激励 开启语音激励后,会优先显示正在说话的与会成员。 } title="" > { setting.voiceStimulation = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setVoiceStimulation(e.target.value) }} style={{ flexShrink: 0, margin: '10px 0' }} value={voiceStimulation}> 开启 关闭
) } const VideoComponents = () => { const [videoDeviceManager, setVideoDeviceManager] = useState({ list: [], item: null, }); const [videoKey, setVideoKey] = useState('beautyEffect'); const [virtualBackgroundImg] = useState([ ImageUrl.virtualBackground1, ImageUrl.virtualBackground2, ImageUrl.virtualBackground3, ImageUrl.virtualBackground4, ImageUrl.virtualBackground5, ImageUrl.virtualBackground6, ]); const [beautyEffect, setBeautyEffect] = useState({ isBeautyEffect: false, //是否打开美颜 lighteningContrastLevel: 1, //对比度 lighteningLevel: 0, //美白程度 smoothnessLevel: 0, //磨皮程度 rednessLevel: 0, //红润度 sharpnessLevel: 0, //锐化程度 }); const [colorEnhancement, setColorEnhancement] = useState({ isColorEnhancement: false, //是否打开色彩增强 strengthLevel: 0.5, //色彩增强程度 skinProtectLevel: 1, //肤色保护程度 }); const [darkLightEnhancement, setDarkLightEnhancement] = useState({ isDarkLightEnhancement: false, //是否打开暗光增强 level: 0, //暗光增强等级 mode: 0, //暗光增强模式 }); const [virtualBackground, setVirtualBackground] = useState({ isVirtualBackground: false, //是否打开虚拟背景 color: '0xFFFFFF', // 纯色 sourceIndex: '', // 背景图下标 }); const setting = JSON.parse(storage.getItem('setting') as string) useEffect(() => { setBeautyEffect(setting.beautyEffect) setColorEnhancement(setting.colorEnhancement) setDarkLightEnhancement(setting.darkLightEnhancement) setVirtualBackground(setting.virtualBackground) getVideoDeviceList() }, []); useEffect(() => { agora.setBeautyEffectOptions(beautyEffect.isBeautyEffect, beautyEffect) }, [beautyEffect]); useEffect(() => { agora.setColorEnhanceOptions(colorEnhancement.isColorEnhancement, colorEnhancement) }, [colorEnhancement]); useEffect(() => { agora.setLowlightEnhanceOptions(darkLightEnhancement.isDarkLightEnhancement, darkLightEnhancement) }, [darkLightEnhancement]); useEffect(() => { if (typeof virtualBackground.sourceIndex === 'number') { if (storage.getItem('env') === 'development') { window.electron.getAppPath().then((res: string) => { const imagePath = path.join(res, 'src', 'assets', 'virtualBackground', `${virtualBackground.sourceIndex + 1}.png`); agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { source: imagePath, background_source_type: 2, color: Number(virtualBackground.color), }) }) } else { const imagePath = path.join((process as any).resourcesPath, 'images', `${virtualBackground.sourceIndex + 1}.png`); agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { source: imagePath, background_source_type: 2, color: Number(virtualBackground.color), }) } } else { agora.enableVirtualBackground(virtualBackground.isVirtualBackground, { background_source_type: 1, color: Number(virtualBackground.color), }) } }, [virtualBackground]); const getVideoDeviceList = async (): Promise => { const userInfo = JSON.parse(storage.getItem('user') as string) agora.getVideoDeviceManager().then(async (res) => { const { list } = res setVideoDeviceManager({ list: list.map((row: any) => { return { value: row.deviceId, label: row.deviceName } }), item: setting.videoDeviceId, }) if (setting.videoDeviceId && list.length) { await agora.setVideoDeviceManager(setting.videoDeviceId) await agora.startPreview('videoPreview', Number(userInfo.screenShareId), c) } }) } return ( <>
视频
{ videoDeviceManager.item ?
:
}
摄像头: 解释说明:如未检测到摄像头请插拔后重试 } title="" > { let hexInt = parseInt('0x' + e.target.value.split('#')[1], 16) setting.virtualBackground.color = hexInt storage.setItem('setting', JSON.stringify(setting)) setVirtualBackground({ ...virtualBackground, color: hexInt }) }} />
{ virtualBackgroundImg.map((item, index) => { return (
{ setting.virtualBackground.sourceIndex = index; storage.setItem('setting', JSON.stringify(setting)) setVirtualBackground({ ...virtualBackground, sourceIndex: index }) }}>
) }) }
: null}
{videoKey === 'colorEnhancement' ?
{ setting.beautyEffect.isBeautyEffect = e.target.checked; storage.setItem('setting', JSON.stringify(setting)) setBeautyEffect({ ...beautyEffect, isBeautyEffect: e.target.checked }) }}> 美颜效果
对比度
{ setting.beautyEffect.lighteningContrastLevel = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setBeautyEffect({ ...beautyEffect, lighteningContrastLevel: e.target.value }) }} style={{ flexShrink: 0, margin: '10px 0' }} value={beautyEffect.lighteningContrastLevel}> 低对比度 正常对比度 高对比度
美白程度
{ setting.beautyEffect.lighteningLevel = e storage.setItem('setting', JSON.stringify(setting)) setBeautyEffect({ ...beautyEffect, lighteningLevel: e }) }} disabled={!beautyEffect.isBeautyEffect} />
磨皮程度
{ setting.beautyEffect.smoothnessLevel = e storage.setItem('setting', JSON.stringify(setting)) setBeautyEffect({ ...beautyEffect, smoothnessLevel: e }) }} disabled={!beautyEffect.isBeautyEffect} />
红润度
{ setting.beautyEffect.rednessLevel = e storage.setItem('setting', JSON.stringify(setting)) setBeautyEffect({ ...beautyEffect, rednessLevel: e }) }} disabled={!beautyEffect.isBeautyEffect} />
锐化程度
{ setting.beautyEffect.sharpnessLevel = e storage.setItem('setting', JSON.stringify(setting)) setBeautyEffect({ ...beautyEffect, sharpnessLevel: e }) }} disabled={!beautyEffect.isBeautyEffect} />
: null} {videoKey === 'darkLightEnhancement' ?
{ setting.colorEnhancement.isColorEnhancement = e.target.checked; storage.setItem('setting', JSON.stringify(setting)) setColorEnhancement({ ...colorEnhancement, isColorEnhancement: e.target.checked }) }}> 色彩增强
色彩增强程度
{ setting.colorEnhancement.strengthLevel = e storage.setItem('setting', JSON.stringify(setting)) setColorEnhancement({ ...colorEnhancement, strengthLevel: e }) }} disabled={!colorEnhancement.isColorEnhancement} />
肤色保护程度
{ setting.colorEnhancement.skinProtectLevel = e storage.setItem('setting', JSON.stringify(setting)) setColorEnhancement({ ...colorEnhancement, skinProtectLevel: e }) }} disabled={!colorEnhancement.isColorEnhancement} />
: null} {videoKey === 'virtualBackground' ?
{ setting.darkLightEnhancement.isDarkLightEnhancement = e.target.checked; storage.setItem('setting', JSON.stringify(setting)) setDarkLightEnhancement({ ...darkLightEnhancement, isDarkLightEnhancement: e.target.checked }) }}> 暗光增强
暗光增强等级
{ setting.darkLightEnhancement.level = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setDarkLightEnhancement({ ...darkLightEnhancement, level: e.target.value }) }} style={{ flexShrink: 0, margin: '10px 0' }} value={darkLightEnhancement.level}> (默认)优先画质的暗光增强,会处理视频图像的亮度、细节、噪声,消耗的性能适中,处理速度适中,综合画质最优。 优先性能的暗光增强,会处理视频图像的亮度、细节,消耗的性能较少,处理速度较快。
暗光增强模式
{ setting.darkLightEnhancement.mode = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setDarkLightEnhancement({ ...darkLightEnhancement, mode: e.target.value }) }} style={{ flexShrink: 0, margin: '10px 0' }} value={darkLightEnhancement.mode}> (默认)自动模式。SDK 会根据环境光亮度自动开启或关闭暗光增强功能,以适时补光和防止过曝。 手动模式。用户需手动开启或关闭暗光增强功能。
: null}
) } const AudioComponents = () => { const [audioDeviceManager, setAudioDeviceManager] = useState({ playBackList: [], ecordingList: [], playBackItem: null, ecordingItem: null, playBackVolume: 0, playBackActive: false, ecordingActive: false, ecordingVolume: 0, autoEcordingVolume: true, isAINoiseReduction: true, aINoiseReduction: 1 }); const setting = JSON.parse(storage.getItem('setting') as string) useEffect(() => { getAudioMediaList() agora.registerEventHandler({ onAudioVolumeIndication: (speakers: any) => { speakers.forEach((item: any) => { if (item.uid === 0 || item.uid === 1) { const percentage = (item.volume / 255) * 100 const dom = document.getElementById('deviceTest') as any; if (dom) { dom.style.width = `${percentage}%` } } }); } }) }, []); const getAudioMediaList = async (): Promise => { const { playBackList, ecordingList, ecordingVolume } = await agora.getAudioMediaList(); if (!setting.ecordingVolume) { setting.ecordingVolume = ecordingVolume; } if (!setting.playBackVolume) { setting.playBackVolume = 127; } setAudioDeviceManager({ ...audioDeviceManager, playBackList: playBackList.map((row: any) => { return { value: row.deviceId, label: row.deviceName } }), ecordingList: ecordingList.map((row: any) => { return { value: row.deviceId, label: row.deviceName } }), playBackItem: setting.playBackDeviceId, ecordingItem: setting.ecordingDeviceId, ecordingVolume: setting.ecordingVolume, playBackVolume: setting.playBackVolume, autoEcordingVolume: setting.autoEcordingVolume, isAINoiseReduction: setting.isAINoiseReduction, aINoiseReduction: setting.aINoiseReduction, }) } return ( <>
音频
麦克风: { setting.playBackDeviceId = e; storage.setItem('setting', JSON.stringify(setting)) setAudioDeviceManager({ ...audioDeviceManager, playBackItem: e }) agora.setPlaybackDevice(e) }} />; {audioDeviceManager.playBackActive ?
{ agora.stopPlaybackDeviceTest() setAudioDeviceManager({ ...audioDeviceManager, playBackActive: false, ecordingActive: false, }) }}>结束
:
{ agora.stopRecordingDeviceTest() agora.startPlaybackDeviceTest() setAudioDeviceManager({ ...audioDeviceManager, playBackActive: true, ecordingActive: false, }) }}>测试
}
{audioDeviceManager.playBackActive ?
: null}
输出音量: { setting.playBackVolume = e; storage.setItem('setting', JSON.stringify(setting)) agora.setPlaybackDeviceVolume(e) setAudioDeviceManager({ ...audioDeviceManager, playBackVolume: e, }) }} disabled={!audioDeviceManager.playBackItem} />
) } const RecordingComponents = () => { const [filePath, setFilePath] = useState('') const [isRecordingTips, setIsRecordingTips] = useState(false) const setting = JSON.parse(storage.getItem('setting') as string) useEffect(() => { if (!setting.recordingFilesPath) { // 获取安装父目录 const currentDirectory = __dirname; const parentDirectory = path.resolve(currentDirectory, '../../Downloads') + '\\'; setting.recordingFilesPath = parentDirectory; setFilePath(setting.recordingFilesPath) } else { setFilePath(setting.recordingFilesPath); } if (setting.isRecordingTips === undefined) { setting.isRecordingTips = true; } storage.setItem('setting', JSON.stringify(setting)) setIsRecordingTips(setting.isRecordingTips) window.addEventListener('customStorageChange', handleCustomStorageChange); return () => { window.removeEventListener('customStorageChange', handleCustomStorageChange); }; }, []) const handleCustomStorageChange = (e: any): void => { if (e.key === 'setting') { const setting = JSON.parse(storage.getItem('setting') as string) setFilePath(setting.recordingFilesPath) } }; return ( <>
录制
本地录制
本地录制文件路径 { setting.recordingFilesPath = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setFilePath(e.target.value) }} />
录制设置
{ setting.isRecordingTips = e.target.checked; storage.setItem('setting', JSON.stringify(setting)) setIsRecordingTips(e.target.checked) }} checked={isRecordingTips}>开启入会录制提示
) } const FileComponents = () => { const [filePath, setFilePath] = useState('') const [isShareSavePath, setIsShareSavePath] = useState(true) const setting = JSON.parse(storage.getItem('setting') as string) useEffect(() => { if (!setting.shareFilesPath) { // 获取安装父目录 const currentDirectory = __dirname; const parentDirectory = path.resolve(currentDirectory, '../../Downloads') + '\\'; setting.shareFilesPath = parentDirectory setFilePath(setting.shareFilesPath) storage.setItem('setting', JSON.stringify(setting)) } else { setFilePath(setting.shareFilesPath); } setIsShareSavePath(setting.isShareSavePath) window.addEventListener('customStorageChange', handleCustomStorageChange); return () => { window.removeEventListener('customStorageChange', handleCustomStorageChange); }; }, []) const handleCustomStorageChange = (e: any): void => { if (e.key === 'setting') { const setting = JSON.parse(storage.getItem('setting') as string) setFilePath(setting.shareFilesPath) } }; return ( <>
文件下载
文件下载
保存位置 { setting.shareFilesPath = e.target.value; storage.setItem('setting', JSON.stringify(setting)) setFilePath(e.target.value) }} />
{ setting.isShareSavePath = e.target.checked; storage.setItem('setting', JSON.stringify(setting)) setIsShareSavePath(e.target.checked) }} checked={isShareSavePath}>下载前询问每个文件保存位置
) } export default memo(StupWizard)