@trtc/calls-uikit-vue2 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-zh_CN.md +83 -0
- package/README.md +89 -0
- package/debug/GenerateTestUserSig-es.js +26 -0
- package/debug/lib-generate-test-usersig-es.min.js +2 -0
- package/package.json +42 -0
- package/src/Components/TUICallKit.vue +334 -0
- package/src/Components/assets/MicrophoneVolume/desktop/mic-off.svg +5 -0
- package/src/Components/assets/MicrophoneVolume/desktop/mic-on.svg +5 -0
- package/src/Components/assets/base/close.svg +1 -0
- package/src/Components/assets/base/error.svg +1 -0
- package/src/Components/assets/base/info.svg +1 -0
- package/src/Components/assets/base/loading-circle.svg +1 -0
- package/src/Components/assets/base/success.svg +1 -0
- package/src/Components/assets/base/waring.svg +1 -0
- package/src/Components/assets/button/accept.svg +1 -0
- package/src/Components/assets/button/background-blur-close.svg +1 -0
- package/src/Components/assets/button/background-blur-open.svg +1 -0
- package/src/Components/assets/button/camera-close.svg +1 -0
- package/src/Components/assets/button/camera-open.svg +1 -0
- package/src/Components/assets/button/desktop/arrow.png +0 -0
- package/src/Components/assets/button/desktop/fullScreen.svg +4 -0
- package/src/Components/assets/button/desktop/inviteUser.svg +1 -0
- package/src/Components/assets/button/desktop/minimize.svg +6 -0
- package/src/Components/assets/button/hangup.svg +1 -0
- package/src/Components/assets/button/microphone-close.svg +1 -0
- package/src/Components/assets/button/microphone-open.svg +1 -0
- package/src/Components/assets/button/mobile/down.svg +1 -0
- package/src/Components/assets/button/mobile/inviteUser.svg +1 -0
- package/src/Components/assets/button/mobile/minimize.svg +1 -0
- package/src/Components/assets/button/mobile/switch-camera.svg +1 -0
- package/src/Components/assets/button/mobile/up.svg +1 -0
- package/src/Components/assets/button/speaker-close.svg +1 -0
- package/src/Components/assets/button/speaker-open.svg +1 -0
- package/src/Components/assets/button/switch-audio.svg +1 -0
- package/src/Components/assets/common/arrows.svg +1 -0
- package/src/Components/assets/common/call.svg +1 -0
- package/src/Components/assets/common/close.svg +1 -0
- package/src/Components/assets/common/defaultAvatar.svg +1 -0
- package/src/Components/assets/common/loading-audio.svg +1 -0
- package/src/Components/assets/common/loading-video.png +0 -0
- package/src/Components/assets/common/microphone-volumn-close.svg +1 -0
- package/src/Components/assets/desktop/acceptAudio.svg +4 -0
- package/src/Components/assets/desktop/acceptVideo.svg +8 -0
- package/src/Components/assets/desktop/arrow.png +0 -0
- package/src/Components/assets/desktop/camera-false.svg +5 -0
- package/src/Components/assets/desktop/camera.svg +6 -0
- package/src/Components/assets/desktop/floatCallEnd.svg +3 -0
- package/src/Components/assets/desktop/floatFullScreen.svg +3 -0
- package/src/Components/assets/desktop/floatMicrophone.svg +4 -0
- package/src/Components/assets/desktop/floatMicrophoneClosed.svg +3 -0
- package/src/Components/assets/desktop/fullScreen.svg +4 -0
- package/src/Components/assets/desktop/hangup.svg +4 -0
- package/src/Components/assets/desktop/invite_user.svg +5 -0
- package/src/Components/assets/desktop/microphone-false.svg +8 -0
- package/src/Components/assets/desktop/microphone.svg +9 -0
- package/src/Components/assets/desktop/minimize.svg +6 -0
- package/src/Components/assets/desktop/permission/index.ts +11 -0
- package/src/Components/assets/desktop/permission/mac/permit-en.jpg +0 -0
- package/src/Components/assets/desktop/permission/mac/permit-zh.jpg +0 -0
- package/src/Components/assets/desktop/permission/win/permit-en.png +0 -0
- package/src/Components/assets/desktop/permission/win/permit-zh.png +0 -0
- package/src/Components/assets/desktop/switchScreen.svg +5 -0
- package/src/Components/assets/desktop/trans.svg +6 -0
- package/src/Components/assets/floatingWindow/desktop/floatCallEnd.svg +3 -0
- package/src/Components/assets/floatingWindow/desktop/floatFullScreen.svg +3 -0
- package/src/Components/assets/floatingWindow/desktop/floatMicrophone.svg +4 -0
- package/src/Components/assets/floatingWindow/desktop/floatMicrophoneClosed.svg +3 -0
- package/src/Components/assets/floatingWindow/mobile/camera-close.svg +1 -0
- package/src/Components/assets/floatingWindow/mobile/camera-open.svg +1 -0
- package/src/Components/assets/floatingWindow/mobile/earphone.svg +1 -0
- package/src/Components/assets/floatingWindow/mobile/microphone-close.svg +1 -0
- package/src/Components/assets/floatingWindow/mobile/microphone-open.svg +1 -0
- package/src/Components/assets/mobile/accept.png +0 -0
- package/src/Components/assets/mobile/audio-false.png +0 -0
- package/src/Components/assets/mobile/audio-true.png +0 -0
- package/src/Components/assets/mobile/camera-false.png +0 -0
- package/src/Components/assets/mobile/camera-true.png +0 -0
- package/src/Components/assets/mobile/default_avatar.png +0 -0
- package/src/Components/assets/mobile/hangup.png +0 -0
- package/src/Components/assets/mobile/loading.png +0 -0
- package/src/Components/assets/mobile/phone_dialing.mp3 +0 -0
- package/src/Components/assets/mobile/phone_ringing.mp3 +0 -0
- package/src/Components/assets/mobile/speaker-false.png +0 -0
- package/src/Components/assets/mobile/speaker-true.png +0 -0
- package/src/Components/assets/mobile/switch_camera.png +0 -0
- package/src/Components/assets/mobile/swtich-camera.png +0 -0
- package/src/Components/assets/mobile/trans.png +0 -0
- package/src/Components/assets/permission/desktop/index.ts +11 -0
- package/src/Components/assets/permission/desktop/mac/permit-en.jpg +0 -0
- package/src/Components/assets/permission/desktop/mac/permit-zh.jpg +0 -0
- package/src/Components/assets/permission/desktop/win/permit-en.png +0 -0
- package/src/Components/assets/permission/desktop/win/permit-zh.png +0 -0
- package/src/Components/assets/streamInfo/mobile/mic-off-h5.svg +1 -0
- package/src/Components/assets/streamInfo/mobile/mic-on-h5.svg +1 -0
- package/src/Components/assets/streamInfo/mobile/microphone-close-group.svg +1 -0
- package/src/Components/assets/streamInfo/mobile/microphone-close-single.svg +1 -0
- package/src/Components/assets/streamInfo/mobile/volumn.svg +1 -0
- package/src/Components/assets/streamInfo/networkStatus.png +0 -0
- package/src/Components/components/GroupCall/BackGround/BackGround.vue +20 -0
- package/src/Components/components/GroupCall/BtnOperate/BtnOperate.vue +116 -0
- package/src/Components/components/GroupCall/BtnOperate/style/desktop.scss +60 -0
- package/src/Components/components/GroupCall/BtnOperate/style/index.scss +2 -0
- package/src/Components/components/GroupCall/BtnOperate/style/mobile.scss +39 -0
- package/src/Components/components/GroupCall/GroupCall.vue +129 -0
- package/src/Components/components/GroupCall/InviteInfo/InviteInfo.vue +116 -0
- package/src/Components/components/GroupCall/InviteInfo/mobile/InviteCallee.vue +120 -0
- package/src/Components/components/GroupCall/MediaContainer/MediaContainer.vue +267 -0
- package/src/Components/components/GroupCall/MediaContainer/StreamLoading/StreamLoading.vue +22 -0
- package/src/Components/components/GroupCall/PusherPlayer/PusherPlayer.vue +67 -0
- package/src/Components/components/GroupCall/PusherPlayer/deskTop/RemoteStreamList.vue +483 -0
- package/src/Components/components/GroupCall/PusherPlayer/mobile/RemoteStreamList.vue +151 -0
- package/src/Components/components/GroupCall/PusherPlayer/wechat/RemoteStreamList.vue +299 -0
- package/src/Components/components/SingleCall/BtnOperate/BtnOperate.vue +126 -0
- package/src/Components/components/SingleCall/BtnOperate/style/desktop.scss +60 -0
- package/src/Components/components/SingleCall/BtnOperate/style/index.scss +2 -0
- package/src/Components/components/SingleCall/BtnOperate/style/mobile.scss +39 -0
- package/src/Components/components/SingleCall/InviteInfo/InviteInfo.vue +161 -0
- package/src/Components/components/SingleCall/InviteInfo/mobile/SingleAudio.vue +69 -0
- package/src/Components/components/SingleCall/InviteInfo/mobile/SingleVideo.vue +67 -0
- package/src/Components/components/SingleCall/InviteInfo/style/desktop.sass +0 -0
- package/src/Components/components/SingleCall/InviteInfo/style/mobile.sass +0 -0
- package/src/Components/components/SingleCall/MediaContainer/MediaContainer.vue +165 -0
- package/src/Components/components/SingleCall/PusherPlayer/PusherPlayer.vue +215 -0
- package/src/Components/components/SingleCall/PusherPlayer/WeChatStream.vue +53 -0
- package/src/Components/components/SingleCall/PusherPlayer/wechat/Player.vue +110 -0
- package/src/Components/components/SingleCall/PusherPlayer/wechat/Pusher.vue +113 -0
- package/src/Components/components/SingleCall/SingleCall.vue +28 -0
- package/src/Components/components/SingleCall/hooks/useGetLargeViewName.ts +32 -0
- package/src/Components/components/base/Avatar/Avatar.ts +38 -0
- package/src/Components/components/base/Avatar/Avatar.vue +53 -0
- package/src/Components/components/base/Avatar/style/Avatar.scss +40 -0
- package/src/Components/components/base/Button/Button.ts +60 -0
- package/src/Components/components/base/Button/Button.vue +61 -0
- package/src/Components/components/base/Button/style/Button.scss +42 -0
- package/src/Components/components/base/Grid/Grid.ts +26 -0
- package/src/Components/components/base/Grid/Grid.vue +40 -0
- package/src/Components/components/base/Grid/GridItem/GridItem.vue +81 -0
- package/src/Components/components/base/Grid/GridItem/style/GridItem.scss +13 -0
- package/src/Components/components/base/Icon/Icon.ts +9 -0
- package/src/Components/components/base/Icon/Icon.vue +21 -0
- package/src/Components/components/base/Layout/Col/Col.ts +23 -0
- package/src/Components/components/base/Layout/Col/Col.vue +46 -0
- package/src/Components/components/base/Layout/Col/style/Col.scss +9 -0
- package/src/Components/components/base/Layout/Row/Row.ts +23 -0
- package/src/Components/components/base/Layout/Row/Row.vue +38 -0
- package/src/Components/components/base/Layout/Row/style/Row.scss +10 -0
- package/src/Components/components/base/Layout/constant.ts +1 -0
- package/src/Components/components/base/Loading/Circle/Circle.ts +13 -0
- package/src/Components/components/base/Loading/Circle/Circle.vue +36 -0
- package/src/Components/components/base/Loading/Circle/style/Circle.scss +26 -0
- package/src/Components/components/base/Loading/Dot/Dot.ts +13 -0
- package/src/Components/components/base/Loading/Dot/Dot.vue +44 -0
- package/src/Components/components/base/Loading/Dot/style/Dot.scss +61 -0
- package/src/Components/components/base/Loading/Loading.ts +29 -0
- package/src/Components/components/base/Loading/Loading.vue +36 -0
- package/src/Components/components/base/Loading/style/Loading.scss +18 -0
- package/src/Components/components/base/Message/Message.ts +117 -0
- package/src/Components/components/base/Message/Message.vue +60 -0
- package/src/Components/components/base/Message/style/Message.scss +49 -0
- package/src/Components/components/base/MessageGroup/MessageGroup.vue +37 -0
- package/src/Components/components/base/Overlay/Overlay.ts +46 -0
- package/src/Components/components/base/Overlay/Overlay.vue +75 -0
- package/src/Components/components/base/Overlay/style/Overlay.scss +40 -0
- package/src/Components/components/base/Popover/Popover.ts +36 -0
- package/src/Components/components/base/Popover/Popover.vue +44 -0
- package/src/Components/components/base/Popover/PopoverWeb/PopoverWeb.vue +110 -0
- package/src/Components/components/base/Popover/PopoverWx/PopoverWx.vue +15 -0
- package/src/Components/components/base/Popover/style/Popover.scss +30 -0
- package/src/Components/components/base/Popover/utils/calculatePosition.ts +50 -0
- package/src/Components/components/base/Portal/Portal.ts +14 -0
- package/src/Components/components/base/Portal/Portal.vue +26 -0
- package/src/Components/components/base/Portal/miniprogram/Portal.vue +20 -0
- package/src/Components/components/base/Portal/vue2/Portal.vue +53 -0
- package/src/Components/components/base/Portal/vue3/Portal.vue +19 -0
- package/src/Components/components/base/TKImage/TKImage.ts +34 -0
- package/src/Components/components/base/TKImage/TKImage.vue +77 -0
- package/src/Components/components/base/TKImage/style/TKImage.scss +20 -0
- package/src/Components/components/base/TKText/TKText.ts +24 -0
- package/src/Components/components/base/TKText/TKText.vue +43 -0
- package/src/Components/components/base/TKText/style/TKText.scss +19 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindow.ts +19 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindow.vue +46 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindowItem/ToggleWindowItem.ts +5 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindowItem/ToggleWindowItem.vue +62 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindowItem/style/ToggleWindowItem.scss +38 -0
- package/src/Components/components/base/ToggleWindow/constant.ts +1 -0
- package/src/Components/components/base/ToggleWindow/style/ToggleWindow.scss +7 -0
- package/src/Components/components/base/assets/message/close.svg +5 -0
- package/src/Components/components/base/assets/message/error.svg +1 -0
- package/src/Components/components/base/assets/message/info.svg +1 -0
- package/src/Components/components/base/assets/message/success.svg +1 -0
- package/src/Components/components/base/assets/message/warning.svg +1 -0
- package/src/Components/components/base/constants/index.ts +8 -0
- package/src/Components/components/base/hooks/useListenerEvent.ts +36 -0
- package/src/Components/components/base/hooks/useOnClickOutSide.ts +27 -0
- package/src/Components/components/base/styles/common.scss +43 -0
- package/src/Components/components/base/styles/var.scss +132 -0
- package/src/Components/components/base/util/checkEnv.ts +51 -0
- package/src/Components/components/base/util/checkVueVersion.ts +11 -0
- package/src/Components/components/base/util/classNames.ts +34 -0
- package/src/Components/components/base/util/filterObject.ts +11 -0
- package/src/Components/components/base/util/index.ts +10 -0
- package/src/Components/components/common/AudioStream/AudioStream.ts +29 -0
- package/src/Components/components/common/AudioStream/AudioStream.vue +65 -0
- package/src/Components/components/common/Button/Accept.vue +66 -0
- package/src/Components/components/common/Button/Camera.vue +115 -0
- package/src/Components/components/common/Button/FullScreen.vue +32 -0
- package/src/Components/components/common/Button/Hangup.vue +57 -0
- package/src/Components/components/common/Button/InviteUser.vue +52 -0
- package/src/Components/components/common/Button/Microphone.vue +109 -0
- package/src/Components/components/common/Button/Minimize.vue +41 -0
- package/src/Components/components/common/Button/Reject.vue +52 -0
- package/src/Components/components/common/Button/Speaker.vue +98 -0
- package/src/Components/components/common/Button/SwitchAudioCall.vue +86 -0
- package/src/Components/components/common/Button/SwitchCamera.vue +58 -0
- package/src/Components/components/common/Button/Timer.vue +19 -0
- package/src/Components/components/common/Button/ToggleButtonPanel.vue +44 -0
- package/src/Components/components/common/Button/ToggleSize.vue +50 -0
- package/src/Components/components/common/Button/VirtualBackground.vue +76 -0
- package/src/Components/components/common/Button/hooks/useConfig.ts +33 -0
- package/src/Components/components/common/Button/props/Button.ts +15 -0
- package/src/Components/components/common/Button/style/common.scss +5 -0
- package/src/Components/components/common/Button/style/desktop.scss +49 -0
- package/src/Components/components/common/Button/style/index.scss +2 -0
- package/src/Components/components/common/Button/style/mobile.scss +63 -0
- package/src/Components/components/common/ButtonPanel/ButtonPanel.vue +238 -0
- package/src/Components/components/common/ButtonPanel/config/InitConfig.ts +252 -0
- package/src/Components/components/common/ButtonPanel/config/VirtualBackgroundMobileConfig.ts +29 -0
- package/src/Components/components/common/ButtonPanel/hooks/useButtonPanelLayout.ts +63 -0
- package/src/Components/components/common/DeviceSelect/DeviceSelect.ts +11 -0
- package/src/Components/components/common/DeviceSelect/DeviceSelect.vue +158 -0
- package/src/Components/components/common/FloatWindow/FloatWindow.vue +68 -0
- package/src/Components/components/common/FloatWindow/desktop/FloatWindow.vue +106 -0
- package/src/Components/components/common/FloatWindow/mobile/FloatWindow.vue +28 -0
- package/src/Components/components/common/FloatWindow/mobile/FloatWindowGroupCall.vue +141 -0
- package/src/Components/components/common/FloatWindow/mobile/FloatWindowSingleCall.vue +109 -0
- package/src/Components/components/common/JoinGroupCard/JoinGroupCard.vue +51 -0
- package/src/Components/components/common/JoinGroupCard/desktop/JoinGroupCard.scss +80 -0
- package/src/Components/components/common/JoinGroupCard/desktop/JoinGroupCard.vue +57 -0
- package/src/Components/components/common/JoinGroupCard/mobile/JoinGroupCard.scss +60 -0
- package/src/Components/components/common/JoinGroupCard/mobile/JoinGroupCard.vue +65 -0
- package/src/Components/components/common/MicVolume/MicVolume.vue +37 -0
- package/src/Components/components/common/MicVolume/MicVolumeClosed.vue +11 -0
- package/src/Components/components/common/MicrophoneVolume/MicrophoneVolume.ts +10 -0
- package/src/Components/components/common/MicrophoneVolume/MicrophoneVolume.vue +61 -0
- package/src/Components/components/common/OverlayStream/OverlayStream.ts +102 -0
- package/src/Components/components/common/OverlayStream/OverlayStream.vue +108 -0
- package/src/Components/components/common/OverlayStream/style/OverlayStream.scss +12 -0
- package/src/Components/components/common/OverlayStream/style/mobile.scss +32 -0
- package/src/Components/components/common/OverlayStream/style/pc.scss +21 -0
- package/src/Components/components/common/PermitTip/CloseIcon.vue +3 -0
- package/src/Components/components/common/PermitTip/PermitTip.ts +37 -0
- package/src/Components/components/common/PermitTip/PermitTip.vue +62 -0
- package/src/Components/components/common/PermitTip/SystemPermitTip.vue +160 -0
- package/src/Components/components/common/Player/Player.ts +18 -0
- package/src/Components/components/common/Player/Player.vue +59 -0
- package/src/Components/components/common/Player/WeChatPlayer/WeChatPlayer.vue +101 -0
- package/src/Components/components/common/Player/WeChatPlayer/style/index.scss +38 -0
- package/src/Components/components/common/Popover/Popover.vue +85 -0
- package/src/Components/components/common/Pusher/Pusher.ts +18 -0
- package/src/Components/components/common/Pusher/Pusher.vue +78 -0
- package/src/Components/components/common/Pusher/WeChatPusher/WeChatPusher.vue +70 -0
- package/src/Components/components/common/Pusher/WeChatPusher/style/index.scss +37 -0
- package/src/Components/components/common/SelectUser/SelectUser.vue +74 -0
- package/src/Components/components/common/SelectUser/components/Dialog/TDialog.vue +94 -0
- package/src/Components/components/common/SelectUser/components/Dialog/style/color.css +43 -0
- package/src/Components/components/common/SelectUser/components/Dialog/style/dialog.css +3 -0
- package/src/Components/components/common/SelectUser/components/Dialog/style/h5.css +49 -0
- package/src/Components/components/common/SelectUser/components/Dialog/style/web.css +55 -0
- package/src/Components/components/common/SelectUser/components/Icon/TIcon.vue +44 -0
- package/src/Components/components/common/SelectUser/components/Icon/style/icon.css +6 -0
- package/src/Components/components/common/SelectUser/components/Transfer/TTransfer.vue +304 -0
- package/src/Components/components/common/SelectUser/components/Transfer/icon/back.svg +16 -0
- package/src/Components/components/common/SelectUser/components/Transfer/icon/cancel.svg +23 -0
- package/src/Components/components/common/SelectUser/components/Transfer/icon/selected.svg +27 -0
- package/src/Components/components/common/SelectUser/components/Transfer/style/color.css +64 -0
- package/src/Components/components/common/SelectUser/components/Transfer/style/h5.css +86 -0
- package/src/Components/components/common/SelectUser/components/Transfer/style/transfer.css +17 -0
- package/src/Components/components/common/SelectUser/components/Transfer/style/web.css +146 -0
- package/src/Components/components/common/SelectUser/index.ts +12 -0
- package/src/Components/components/common/Swiper/Swiper.vue +145 -0
- package/src/Components/components/common/Swiper/SwiperSlider.vue +55 -0
- package/src/Components/components/common/Swiper/index.ts +10 -0
- package/src/Components/components/common/Swiper/useSlide.ts +56 -0
- package/src/Components/components/common/Swiper/useSwiperSliders.ts +34 -0
- package/src/Components/components/common/SwiperWx/Swiper.vue +123 -0
- package/src/Components/components/common/SwiperWx/SwiperSlider.vue +87 -0
- package/src/Components/components/common/SwiperWx/index.ts +5 -0
- package/src/Components/components/common/SwiperWx/useSlide.ts +60 -0
- package/src/Components/components/common/SwiperWx/useSwiperSliders.ts +23 -0
- package/src/Components/components/common/TKStreamInfo/StreamInfo.ts +34 -0
- package/src/Components/components/common/TKStreamInfo/StreamInfoMobile.vue +82 -0
- package/src/Components/components/common/TKStreamInfo/StreamInfoPC.vue +58 -0
- package/src/Components/components/common/TKStreamInfo/TKStreamInfo.vue +47 -0
- package/src/Components/components/common/Timer/Timer.ts +14 -0
- package/src/Components/components/common/Timer/Timer.vue +24 -0
- package/src/Components/components/common/Tip/Tip.ts +5 -0
- package/src/Components/components/common/Tip/Tip.vue +67 -0
- package/src/Components/components/common/Toast/Toast.ts +87 -0
- package/src/Components/components/common/Toast/Toast.vue +133 -0
- package/src/Components/components/common/Toast/index.ts +6 -0
- package/src/Components/components/common/Toast/type.ts +16 -0
- package/src/Components/components/common/TopBar/TopBar.ts +8 -0
- package/src/Components/components/common/TopBar/TopBar.vue +120 -0
- package/src/Components/components/common/Waiting/Waiting.vue +126 -0
- package/src/Components/components/config/button/ClosedPanelUI.ts +109 -0
- package/src/Components/components/config/button/DefaultUI.ts +550 -0
- package/src/Components/components/config/button/index.ts +2 -0
- package/src/Components/context/ButtonPanelContext.ts +6 -0
- package/src/Components/context/CallInfoContext.ts +15 -0
- package/src/Components/context/CallerUserInfoContext.ts +9 -0
- package/src/Components/context/CustomUIConfigContext.ts +1 -0
- package/src/Components/context/FloatWindowContext.ts +5 -0
- package/src/Components/context/FocusItemContext.ts +1 -0
- package/src/Components/context/IsClickableContext.ts +1 -0
- package/src/Components/context/PopoverContext.ts +1 -0
- package/src/Components/context/TranslateContext.ts +1 -0
- package/src/Components/context/UserInfoContextExcludeVolume.ts +8 -0
- package/src/Components/context/index.ts +10 -0
- package/src/Components/hooks/index.ts +22 -0
- package/src/Components/hooks/useButtonPanelStatus.ts +6 -0
- package/src/Components/hooks/useCallDuration.ts +32 -0
- package/src/Components/hooks/useCallInfoContext.ts +6 -0
- package/src/Components/hooks/useCallerUserInfoContext.ts +6 -0
- package/src/Components/hooks/useCustomUI.ts +7 -0
- package/src/Components/hooks/useCustomUIButtonConfig.ts +96 -0
- package/src/Components/hooks/useDeviceList.ts +51 -0
- package/src/Components/hooks/useFloatWindowContext.ts +6 -0
- package/src/Components/hooks/useFocusContext.ts +6 -0
- package/src/Components/hooks/useGetVolumeMap.ts +59 -0
- package/src/Components/hooks/useGroupCallLayout.ts +142 -0
- package/src/Components/hooks/useIsClickableContext.ts +6 -0
- package/src/Components/hooks/useJoinGroupCall.ts +69 -0
- package/src/Components/hooks/useNetWorkStatus.ts +30 -0
- package/src/Components/hooks/usePlayer.ts +32 -0
- package/src/Components/hooks/usePopover.ts +6 -0
- package/src/Components/hooks/useTip.ts +42 -0
- package/src/Components/hooks/useTranslate.ts +7 -0
- package/src/Components/hooks/useUserInfoContextExcludeVolume.ts +6 -0
- package/src/Components/hooks/useViewBackgroundConfig.ts +12 -0
- package/src/Components/util/deepClone.ts +15 -0
- package/src/Components/util/findValues.ts +21 -0
- package/src/Components/util/index.ts +6 -0
- package/src/Components/util/isEmpty.ts +15 -0
- package/src/Components/util/isEqual.ts +40 -0
- package/src/Components/util/isObject.ts +3 -0
- package/src/Components/util/stringToPath.ts +78 -0
- package/src/Components/util/toggleScreen.ts +10 -0
- package/src/Components/util/uiConfig.ts +74 -0
- package/src/TUICallService/CallService/UIDesign.ts +174 -0
- package/src/TUICallService/CallService/bellContext.ts +88 -0
- package/src/TUICallService/CallService/chatCombine.ts +313 -0
- package/src/TUICallService/CallService/engineEventHandler.ts +404 -0
- package/src/TUICallService/CallService/index.ts +797 -0
- package/src/TUICallService/CallService/miniProgram.ts +65 -0
- package/src/TUICallService/CallService/utils.ts +281 -0
- package/src/TUICallService/TUIGlobal/tuiGlobal.ts +43 -0
- package/src/TUICallService/TUIStore/callStore.ts +93 -0
- package/src/TUICallService/TUIStore/tuiStore.ts +167 -0
- package/src/TUICallService/assets/phone_dialing.mp3 +0 -0
- package/src/TUICallService/assets/phone_ringing.mp3 +0 -0
- package/src/TUICallService/const/call.ts +157 -0
- package/src/TUICallService/const/error.ts +20 -0
- package/src/TUICallService/const/index.ts +103 -0
- package/src/TUICallService/const/log.ts +9 -0
- package/src/TUICallService/index.ts +37 -0
- package/src/TUICallService/interface/ICallService.ts +70 -0
- package/src/TUICallService/interface/ICallStore.ts +55 -0
- package/src/TUICallService/interface/ITUIGlobal.ts +36 -0
- package/src/TUICallService/interface/ITUIStore.ts +87 -0
- package/src/TUICallService/interface/index.ts +4 -0
- package/src/TUICallService/locales/en.ts +135 -0
- package/src/TUICallService/locales/index.ts +61 -0
- package/src/TUICallService/locales/ja_JP.ts +134 -0
- package/src/TUICallService/locales/zh-cn.ts +130 -0
- package/src/TUICallService/serve/callManager.ts +109 -0
- package/src/TUICallService/utils/common-utils.ts +269 -0
- package/src/TUICallService/utils/decorators/promise-retry.ts +51 -0
- package/src/TUICallService/utils/env.ts +51 -0
- package/src/TUICallService/utils/index.ts +32 -0
- package/src/TUICallService/utils/is-empty.ts +31 -0
- package/src/TUICallService/utils/retry.ts +88 -0
- package/src/TUICallService/utils/timer.ts +162 -0
- package/src/TUICallService/utils/validate/avoidRepeatedCall.ts +39 -0
- package/src/TUICallService/utils/validate/index.ts +7 -0
- package/src/TUICallService/utils/validate/validateConfig.ts +203 -0
- package/src/TUICallService/utils/validate/validateParams.ts +88 -0
- package/src/TUICallService/utils/validate/validateStatus.ts +26 -0
- package/src/adapter-vue.ts +4 -0
- package/src/index.ts +65 -0
- package/tuicall-uikit-vue2.es.js +12469 -0
- package/tuicall-uikit-vue2.umd.js +102 -0
- package/types/Components/assets/desktop/permission/index.d.ts +5 -0
- package/types/Components/assets/permission/desktop/index.d.ts +5 -0
- package/types/Components/components/SingleCall/hooks/useGetLargeViewName.d.ts +2 -0
- package/types/Components/components/base/Avatar/Avatar.d.ts +34 -0
- package/types/Components/components/base/Button/Button.d.ts +56 -0
- package/types/Components/components/base/Grid/Grid.d.ts +23 -0
- package/types/Components/components/base/Icon/Icon.d.ts +9 -0
- package/types/Components/components/base/Layout/Col/Col.d.ts +20 -0
- package/types/Components/components/base/Layout/Row/Row.d.ts +20 -0
- package/types/Components/components/base/Layout/constant.d.ts +1 -0
- package/types/Components/components/base/Loading/Circle/Circle.d.ts +13 -0
- package/types/Components/components/base/Loading/Dot/Dot.d.ts +13 -0
- package/types/Components/components/base/Loading/Loading.d.ts +26 -0
- package/types/Components/components/base/Message/Message.d.ts +50 -0
- package/types/Components/components/base/Overlay/Overlay.d.ts +45 -0
- package/types/Components/components/base/Popover/Popover.d.ts +34 -0
- package/types/Components/components/base/Popover/utils/calculatePosition.d.ts +4 -0
- package/types/Components/components/base/Portal/Portal.d.ts +14 -0
- package/types/Components/components/base/TKImage/TKImage.d.ts +33 -0
- package/types/Components/components/base/TKText/TKText.d.ts +24 -0
- package/types/Components/components/base/ToggleWindow/ToggleWindow.d.ts +18 -0
- package/types/Components/components/base/ToggleWindow/ToggleWindowItem/ToggleWindowItem.d.ts +5 -0
- package/types/Components/components/base/ToggleWindow/constant.d.ts +1 -0
- package/types/Components/components/base/constants/index.d.ts +7 -0
- package/types/Components/components/base/hooks/useListenerEvent.d.ts +13 -0
- package/types/Components/components/base/hooks/useOnClickOutSide.d.ts +1 -0
- package/types/Components/components/base/util/checkEnv.d.ts +10 -0
- package/types/Components/components/base/util/checkVueVersion.d.ts +4 -0
- package/types/Components/components/base/util/classNames.d.ts +1 -0
- package/types/Components/components/base/util/filterObject.d.ts +1 -0
- package/types/Components/components/base/util/index.d.ts +5 -0
- package/types/Components/components/common/AudioStream/AudioStream.d.ts +29 -0
- package/types/Components/components/common/Button/hooks/useConfig.d.ts +2 -0
- package/types/Components/components/common/Button/props/Button.d.ts +15 -0
- package/types/Components/components/common/ButtonPanel/config/InitConfig.d.ts +89 -0
- package/types/Components/components/common/ButtonPanel/config/VirtualBackgroundMobileConfig.d.ts +66 -0
- package/types/Components/components/common/ButtonPanel/hooks/useButtonPanelLayout.d.ts +4 -0
- package/types/Components/components/common/DeviceSelect/DeviceSelect.d.ts +11 -0
- package/types/Components/components/common/MicrophoneVolume/MicrophoneVolume.d.ts +10 -0
- package/types/Components/components/common/OverlayStream/OverlayStream.d.ts +92 -0
- package/types/Components/components/common/PermitTip/PermitTip.d.ts +3 -0
- package/types/Components/components/common/Player/Player.d.ts +18 -0
- package/types/Components/components/common/Pusher/Pusher.d.ts +18 -0
- package/types/Components/components/common/SelectUser/index.d.ts +6 -0
- package/types/Components/components/common/Swiper/index.d.ts +7 -0
- package/types/Components/components/common/Swiper/useSlide.d.ts +7 -0
- package/types/Components/components/common/Swiper/useSwiperSliders.d.ts +1 -0
- package/types/Components/components/common/SwiperWx/index.d.ts +4 -0
- package/types/Components/components/common/SwiperWx/useSlide.d.ts +9 -0
- package/types/Components/components/common/SwiperWx/useSwiperSliders.d.ts +1 -0
- package/types/Components/components/common/TKStreamInfo/StreamInfo.d.ts +34 -0
- package/types/Components/components/common/Timer/Timer.d.ts +14 -0
- package/types/Components/components/common/Tip/Tip.d.ts +5 -0
- package/types/Components/components/common/Toast/Toast.d.ts +4 -0
- package/types/Components/components/common/Toast/index.d.ts +2 -0
- package/types/Components/components/common/Toast/type.d.ts +16 -0
- package/types/Components/components/common/TopBar/TopBar.d.ts +8 -0
- package/types/Components/components/config/button/ClosedPanelUI.d.ts +3380 -0
- package/types/Components/components/config/button/DefaultUI.d.ts +14751 -0
- package/types/Components/components/config/button/index.d.ts +2 -0
- package/types/Components/context/ButtonPanelContext.d.ts +4 -0
- package/types/Components/context/CallInfoContext.d.ts +13 -0
- package/types/Components/context/CallerUserInfoContext.d.ts +8 -0
- package/types/Components/context/CustomUIConfigContext.d.ts +1 -0
- package/types/Components/context/FloatWindowContext.d.ts +4 -0
- package/types/Components/context/FocusItemContext.d.ts +1 -0
- package/types/Components/context/IsClickableContext.d.ts +1 -0
- package/types/Components/context/PopoverContext.d.ts +1 -0
- package/types/Components/context/TranslateContext.d.ts +1 -0
- package/types/Components/context/UserInfoContextExcludeVolume.d.ts +6 -0
- package/types/Components/context/index.d.ts +10 -0
- package/types/Components/hooks/index.d.ts +20 -0
- package/types/Components/hooks/useButtonPanelStatus.d.ts +2 -0
- package/types/Components/hooks/useCallDuration.d.ts +3 -0
- package/types/Components/hooks/useCallInfoContext.d.ts +2 -0
- package/types/Components/hooks/useCallerUserInfoContext.d.ts +2 -0
- package/types/Components/hooks/useCustomUI.d.ts +3 -0
- package/types/Components/hooks/useCustomUIButtonConfig.d.ts +1 -0
- package/types/Components/hooks/useDeviceList.d.ts +7 -0
- package/types/Components/hooks/useFloatWindowContext.d.ts +2 -0
- package/types/Components/hooks/useFocusContext.d.ts +1 -0
- package/types/Components/hooks/useGetVolumeMap.d.ts +1 -0
- package/types/Components/hooks/useGroupCallLayout.d.ts +1 -0
- package/types/Components/hooks/useIsClickableContext.d.ts +2 -0
- package/types/Components/hooks/useJoinGroupCall.d.ts +9 -0
- package/types/Components/hooks/useNetWorkStatus.d.ts +3 -0
- package/types/Components/hooks/usePlayer.d.ts +1 -0
- package/types/Components/hooks/usePopover.d.ts +2 -0
- package/types/Components/hooks/useTip.d.ts +5 -0
- package/types/Components/hooks/useTranslate.d.ts +2 -0
- package/types/Components/hooks/useUserInfoContextExcludeVolume.d.ts +2 -0
- package/types/Components/hooks/useViewBackgroundConfig.d.ts +1 -0
- package/types/Components/util/deepClone.d.ts +1 -0
- package/types/Components/util/findValues.d.ts +1 -0
- package/types/Components/util/index.d.ts +6 -0
- package/types/Components/util/isEmpty.d.ts +1 -0
- package/types/Components/util/isEqual.d.ts +1 -0
- package/types/Components/util/isObject.d.ts +1 -0
- package/types/Components/util/stringToPath.d.ts +12 -0
- package/types/Components/util/toggleScreen.d.ts +1 -0
- package/types/Components/util/uiConfig.d.ts +3 -0
- package/types/TUICallService/CallService/UIDesign.d.ts +28 -0
- package/types/TUICallService/CallService/bellContext.d.ts +19 -0
- package/types/TUICallService/CallService/chatCombine.d.ts +50 -0
- package/types/TUICallService/CallService/engineEventHandler.d.ts +35 -0
- package/types/TUICallService/CallService/index.d.ts +98 -0
- package/types/TUICallService/CallService/miniProgram.d.ts +7 -0
- package/types/TUICallService/CallService/utils.d.ts +42 -0
- package/types/TUICallService/TUIGlobal/tuiGlobal.d.ts +21 -0
- package/types/TUICallService/TUIStore/callStore.d.ts +10 -0
- package/types/TUICallService/TUIStore/tuiStore.d.ts +57 -0
- package/types/TUICallService/const/call.d.ts +141 -0
- package/types/TUICallService/const/error.d.ts +2 -0
- package/types/TUICallService/const/index.d.ts +27 -0
- package/types/TUICallService/const/log.d.ts +7 -0
- package/types/TUICallService/index.d.ts +5 -0
- package/types/TUICallService/interface/ICallService.d.ts +69 -0
- package/types/TUICallService/interface/ICallStore.d.ts +47 -0
- package/types/TUICallService/interface/ITUIGlobal.d.ts +36 -0
- package/types/TUICallService/interface/ITUIStore.d.ts +83 -0
- package/types/TUICallService/interface/index.d.ts +4 -0
- package/types/TUICallService/locales/en.d.ts +128 -0
- package/types/TUICallService/locales/index.d.ts +10 -0
- package/types/TUICallService/locales/ja_JP.d.ts +127 -0
- package/types/TUICallService/locales/zh-cn.d.ts +123 -0
- package/types/TUICallService/serve/callManager.d.ts +11 -0
- package/types/TUICallService/utils/common-utils.d.ts +62 -0
- package/types/TUICallService/utils/decorators/promise-retry.d.ts +32 -0
- package/types/TUICallService/utils/env.d.ts +10 -0
- package/types/TUICallService/utils/index.d.ts +2 -0
- package/types/TUICallService/utils/is-empty.d.ts +2 -0
- package/types/TUICallService/utils/retry.d.ts +36 -0
- package/types/TUICallService/utils/timer.d.ts +64 -0
- package/types/TUICallService/utils/validate/avoidRepeatedCall.d.ts +10 -0
- package/types/TUICallService/utils/validate/index.d.ts +2 -0
- package/types/TUICallService/utils/validate/validateConfig.d.ts +188 -0
- package/types/TUICallService/utils/validate/validateParams.d.ts +1 -0
- package/types/TUICallService/utils/validate/validateStatus.d.ts +5 -0
- package/types/adapter-vue.d.ts +2 -0
- package/types/index.d.ts +11 -0
- package/types/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CallMediaType, CallStatus } from '../const/index';
|
|
2
|
+
|
|
3
|
+
export function initialUI() {
|
|
4
|
+
// 收起键盘
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
wx.hideKeyboard && wx.hideKeyboard({
|
|
7
|
+
complete: () => {},
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
// 检测运行时环境, 当是微信开发者工具时, 提示用户需要手机调试
|
|
11
|
+
export function checkRunPlatform() {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const systemInfo = wx.getSystemInfoSync();
|
|
14
|
+
if (systemInfo.platform === 'devtools') {
|
|
15
|
+
// 当前运行在微信开发者工具里
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
wx.showModal({
|
|
18
|
+
icon: 'none',
|
|
19
|
+
title: '运行环境提醒',
|
|
20
|
+
content: '微信开发者工具不支持原生推拉流组件(即 <live-pusher> 和 <live-player> 标签),请使用真机调试或者扫码预览。',
|
|
21
|
+
showCancel: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export function initAndCheckRunEnv() {
|
|
26
|
+
initialUI(); // miniProgram 收起键盘, 隐藏 tabBar
|
|
27
|
+
checkRunPlatform(); // miniProgram 检测运行时环境
|
|
28
|
+
}
|
|
29
|
+
export async function beforeCall(type: CallMediaType, that: any) {
|
|
30
|
+
try {
|
|
31
|
+
initAndCheckRunEnv();
|
|
32
|
+
// 检查设备权限
|
|
33
|
+
const deviceMap = {
|
|
34
|
+
microphone: true,
|
|
35
|
+
camera: type === CallMediaType.VIDEO,
|
|
36
|
+
};
|
|
37
|
+
const hasDevicePermission = await that._tuiCallEngine.deviceCheck(deviceMap); // miniProgram 检查设备权限
|
|
38
|
+
return hasDevicePermission ? CallStatus.CALLING : CallStatus.IDLE;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.debug(error);
|
|
41
|
+
return CallStatus.IDLE;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// 套餐问题提示, 小程序最低需要群组通话版, 1v1 通话版本使用 TRTC 就会报错
|
|
45
|
+
export function handlePackageError(error) {
|
|
46
|
+
if (error?.code === -1002) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
wx.showModal({
|
|
49
|
+
icon: 'none',
|
|
50
|
+
title: 'error',
|
|
51
|
+
content: error?.message || '',
|
|
52
|
+
showCancel: false,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function handleNoPusherCapabilityError(){
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
wx.showModal({
|
|
60
|
+
icon: 'none',
|
|
61
|
+
title: '权限提示',
|
|
62
|
+
content: '当前小程序 appid 不具备 <live-pusher> 和 <live-player> 的使用权限,您将无法正常使用实时通话能力,请使用企业小程序账号申请权限后再进行开发体验',
|
|
63
|
+
showCancel: false,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { NAME, StoreName, CallStatus, StatusChange, CallMediaType, ROOM_ID_TYPE } from '../const/index';
|
|
2
|
+
import { handleNoDevicePermissionError } from '../utils/common-utils';
|
|
3
|
+
import { IUserInfo } from '../interface/ICallService';
|
|
4
|
+
import { ITUIStore } from '../interface/ITUIStore';
|
|
5
|
+
import { CallTips, t } from '../locales/index';
|
|
6
|
+
import TuiStore from '../TUIStore/tuiStore';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const TUIStore: ITUIStore = TuiStore.getInstance();
|
|
9
|
+
|
|
10
|
+
// 设置默认的 UserInfo 信息
|
|
11
|
+
export function setDefaultUserInfo(userId: string, domId?: string): IUserInfo {
|
|
12
|
+
const userInfo: IUserInfo = {
|
|
13
|
+
userId,
|
|
14
|
+
nick: '',
|
|
15
|
+
avatar: '',
|
|
16
|
+
remark: '',
|
|
17
|
+
displayUserInfo: '',
|
|
18
|
+
isAudioAvailable: false,
|
|
19
|
+
isVideoAvailable: false,
|
|
20
|
+
isEnter: false,
|
|
21
|
+
domId: domId || userId,
|
|
22
|
+
};
|
|
23
|
+
return domId ? userInfo : { ...userInfo, isEnter: false }; // localUserInfo 没有 isEnter, remoteUserInfoList 有 isEnter
|
|
24
|
+
}
|
|
25
|
+
// 获取个人用户信息
|
|
26
|
+
export async function getMyProfile(myselfUserId: string, tim: any): Promise<IUserInfo> {
|
|
27
|
+
let localUserInfo: IUserInfo = setDefaultUserInfo(myselfUserId, NAME.LOCAL_VIDEO);
|
|
28
|
+
try {
|
|
29
|
+
if (!tim) return localUserInfo;
|
|
30
|
+
const res = await tim.getMyProfile();
|
|
31
|
+
const currentLocalUserInfo = TUIStore?.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); // localUserInfo may have been updated
|
|
32
|
+
if (res?.code === 0) {
|
|
33
|
+
localUserInfo = {
|
|
34
|
+
...localUserInfo,
|
|
35
|
+
...currentLocalUserInfo,
|
|
36
|
+
userId: res?.data?.userID,
|
|
37
|
+
nick: res?.data?.nick,
|
|
38
|
+
avatar: res?.data?.avatar,
|
|
39
|
+
displayUserInfo: res?.data?.nick || res?.data?.userID,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return localUserInfo;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(`${NAME.PREFIX}getMyProfile failed, error: ${error}.`);
|
|
45
|
+
return localUserInfo;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// 获取远端用户列表信息
|
|
49
|
+
export async function getRemoteUserProfile(userIdList: Array<string>, tim: any): Promise<any> {
|
|
50
|
+
let remoteUserInfoList: IUserInfo[] = userIdList.map((userId: string) => setDefaultUserInfo(userId));
|
|
51
|
+
try {
|
|
52
|
+
if (!tim) return remoteUserInfoList;
|
|
53
|
+
|
|
54
|
+
if (tim?.getFriendProfile) {
|
|
55
|
+
const res = await tim.getFriendProfile({ userIDList: userIdList });
|
|
56
|
+
if (res.code === 0) {
|
|
57
|
+
const { friendList = [], failureUserIDList = [] } = res.data;
|
|
58
|
+
let unFriendList: IUserInfo[] = failureUserIDList.map((obj: any) => obj.userID);
|
|
59
|
+
if (failureUserIDList.length > 0) {
|
|
60
|
+
const res = await tim.getUserProfile({ userIDList: failureUserIDList.map((obj: any) => obj.userID) });
|
|
61
|
+
if (res?.code === 0) {
|
|
62
|
+
unFriendList = res?.data || [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const currentRemoteUserInfoList = TUIStore?.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); // remoteUserInfoList may have been updated
|
|
66
|
+
const tempFriendIdList: string[] = friendList.map((obj: any) => obj.userID);
|
|
67
|
+
const tempUnFriendIdList: string[] = unFriendList.map((obj: any) => obj.userID);
|
|
68
|
+
remoteUserInfoList = userIdList.map((userId: string) => {
|
|
69
|
+
const defaultUserInfo: IUserInfo = setDefaultUserInfo(userId);
|
|
70
|
+
const friendListIndex: number = tempFriendIdList.indexOf(userId);
|
|
71
|
+
const unFriendListIndex: number = tempUnFriendIdList.indexOf(userId);
|
|
72
|
+
let remark = '';
|
|
73
|
+
let nick = '';
|
|
74
|
+
let displayUserInfo = '' ;
|
|
75
|
+
let avatar = '';
|
|
76
|
+
if (friendListIndex !== -1) {
|
|
77
|
+
remark = friendList[friendListIndex]?.remark || '';
|
|
78
|
+
nick = friendList[friendListIndex]?.profile?.nick || '';
|
|
79
|
+
displayUserInfo = remark || nick || defaultUserInfo.userId || '';
|
|
80
|
+
avatar = friendList[friendListIndex]?.profile?.avatar || '';
|
|
81
|
+
}
|
|
82
|
+
if (unFriendListIndex !== -1) {
|
|
83
|
+
nick = unFriendList[unFriendListIndex]?.nick || '';
|
|
84
|
+
displayUserInfo = nick || defaultUserInfo.userId || '';
|
|
85
|
+
avatar = unFriendList[unFriendListIndex]?.avatar || '';
|
|
86
|
+
}
|
|
87
|
+
const userInfo = currentRemoteUserInfoList.find(subObj => subObj.userId === userId) || {};
|
|
88
|
+
return { ...defaultUserInfo, ...userInfo, remark, nick, displayUserInfo, avatar };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return remoteUserInfoList;
|
|
92
|
+
} else {
|
|
93
|
+
const res = await tim.getUserProfile({ userIDList: userIdList });
|
|
94
|
+
const currentRemoteUserInfoList = TUIStore?.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); // remoteUserInfoList may have been updated
|
|
95
|
+
|
|
96
|
+
remoteUserInfoList = userIdList.map((userId: string) => {
|
|
97
|
+
const defaultUserInfo: IUserInfo = setDefaultUserInfo(userId);
|
|
98
|
+
const userInfo = currentRemoteUserInfoList.find(subObj => subObj.userId === userId) || {};
|
|
99
|
+
const userData = (res.data || []).find(obj => obj.userID === userId) || {};
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
...defaultUserInfo,
|
|
103
|
+
...userInfo,
|
|
104
|
+
nick: userData?.nick || '',
|
|
105
|
+
displayUserInfo: userData?.nick || userId,
|
|
106
|
+
avatar: userData?.avatar || '',
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
return remoteUserInfoList;
|
|
110
|
+
}
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error(`${NAME.PREFIX}getRemoteUserProfile failed, error: ${error}.`);
|
|
113
|
+
return remoteUserInfoList;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// 生成弹框提示文案
|
|
117
|
+
export function generateText(key: string, prefix?: string, suffix?: string): string {
|
|
118
|
+
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP);
|
|
119
|
+
let callTips = `${t(key)}`;
|
|
120
|
+
if (isGroup) {
|
|
121
|
+
callTips = prefix ? `${prefix} ${callTips}` : callTips;
|
|
122
|
+
callTips = suffix ? `${callTips} ${suffix}` : callTips;
|
|
123
|
+
}
|
|
124
|
+
return callTips;
|
|
125
|
+
}
|
|
126
|
+
// 生成 statusChange 抛出的字符串
|
|
127
|
+
export function generateStatusChangeText(): string {
|
|
128
|
+
const callStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS);
|
|
129
|
+
if (callStatus === CallStatus.IDLE) {
|
|
130
|
+
return StatusChange.IDLE;
|
|
131
|
+
}
|
|
132
|
+
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP);
|
|
133
|
+
if (callStatus === CallStatus.CALLING) {
|
|
134
|
+
return isGroup ? StatusChange.DIALING_GROUP : StatusChange.DIALING_C2C;
|
|
135
|
+
}
|
|
136
|
+
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE);
|
|
137
|
+
if (isGroup) {
|
|
138
|
+
return callMediaType === CallMediaType.AUDIO ? StatusChange.CALLING_GROUP_AUDIO : StatusChange.CALLING_GROUP_VIDEO;
|
|
139
|
+
}
|
|
140
|
+
return callMediaType === CallMediaType.AUDIO ? StatusChange.CALLING_C2C_AUDIO : StatusChange.CALLING_C2C_VIDEO;
|
|
141
|
+
}
|
|
142
|
+
// 获取群组[offset, count + offset]区间成员
|
|
143
|
+
export async function getGroupMemberList(groupID: string, tim: any, count, offset) {
|
|
144
|
+
let groupMemberList = [];
|
|
145
|
+
try {
|
|
146
|
+
const res = await tim.getGroupMemberList({ groupID, count, offset });
|
|
147
|
+
if (res.code === 0) {
|
|
148
|
+
return res.data.memberList || groupMemberList;
|
|
149
|
+
}
|
|
150
|
+
} catch(error) {
|
|
151
|
+
console.error(`${NAME.PREFIX}getGroupMember failed, error: ${error}.`);
|
|
152
|
+
return groupMemberList;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// 获取 IM 群信息
|
|
156
|
+
export async function getGroupProfile(groupID: string, tim: any): Promise<any> {
|
|
157
|
+
let groupProfile = {};
|
|
158
|
+
try {
|
|
159
|
+
const res = await tim.getGroupProfile({ groupID });
|
|
160
|
+
return res.data.group || groupProfile;
|
|
161
|
+
} catch(error) {
|
|
162
|
+
console.warn(`${NAME.PREFIX}getGroupProfile failed, error: ${error}.`);
|
|
163
|
+
return groupProfile;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* update roomId and roomIdType
|
|
168
|
+
* @param {number} roomId number roomId
|
|
169
|
+
* @param {string} strRoomId string roomId
|
|
170
|
+
*/
|
|
171
|
+
export function updateRoomIdAndRoomIdType(roomId, strRoomId) {
|
|
172
|
+
if (roomId === 0 && strRoomId) { // use strRoomID
|
|
173
|
+
TUIStore.update(StoreName.CALL, NAME.ROOM_ID, strRoomId);
|
|
174
|
+
TUIStore.update(StoreName.CALL, NAME.ROOM_ID_TYPE, ROOM_ID_TYPE.STRING_ROOM_ID);
|
|
175
|
+
} else {
|
|
176
|
+
TUIStore.update(StoreName.CALL, NAME.ROOM_ID, roomId);
|
|
177
|
+
TUIStore.update(StoreName.CALL, NAME.ROOM_ID_TYPE, ROOM_ID_TYPE.NUMBER_ROOM_ID);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* web and miniProgram call engine throw event data structure are different
|
|
182
|
+
* @param {any} event call engine throw out data
|
|
183
|
+
* @returns {any} data
|
|
184
|
+
*/
|
|
185
|
+
export function analyzeEventData(event: any): any {
|
|
186
|
+
return event || {};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* delete user from remoteUserInfoList
|
|
190
|
+
* @param {string[]} userIdList to be deleted userIdList
|
|
191
|
+
* @param {ITUIStore} TUIStore TUIStore instance
|
|
192
|
+
*/
|
|
193
|
+
export function deleteRemoteUser(userIdList: string[]): void {
|
|
194
|
+
if (userIdList.length === 0) return;
|
|
195
|
+
let remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST);
|
|
196
|
+
userIdList.forEach((userId) => {
|
|
197
|
+
remoteUserInfoList = remoteUserInfoList.filter((obj: IUserInfo) => obj.userId !== userId);
|
|
198
|
+
});
|
|
199
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, remoteUserInfoList);
|
|
200
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, remoteUserInfoList);
|
|
201
|
+
}
|
|
202
|
+
export function updateDeviceList(tuiCallEngine) {
|
|
203
|
+
tuiCallEngine?.getDeviceList('speaker').then((result)=>{
|
|
204
|
+
const deviceList = TUIStore.getData(StoreName.CALL, NAME.DEVICE_LIST);
|
|
205
|
+
const currentSpeaker = result?.[0] || {};
|
|
206
|
+
TUIStore.update(
|
|
207
|
+
StoreName.CALL,
|
|
208
|
+
NAME.DEVICE_LIST,
|
|
209
|
+
{ ...deviceList, speakerList: result, currentSpeaker },
|
|
210
|
+
);
|
|
211
|
+
}).catch(error =>{
|
|
212
|
+
console.error(`${NAME.PREFIX}updateSpeakerList failed, error: ${JSON.stringify(error)}.`);
|
|
213
|
+
});
|
|
214
|
+
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE);
|
|
215
|
+
if (callMediaType === CallMediaType.VIDEO) {
|
|
216
|
+
tuiCallEngine?.getDeviceList('camera').then((result) => {
|
|
217
|
+
const deviceList = TUIStore.getData(StoreName.CALL, NAME.DEVICE_LIST);
|
|
218
|
+
const currentCamera = result?.[0] || {};
|
|
219
|
+
TUIStore.update(
|
|
220
|
+
StoreName.CALL,
|
|
221
|
+
NAME.DEVICE_LIST,
|
|
222
|
+
{ ...deviceList, cameraList: result, currentCamera },
|
|
223
|
+
);
|
|
224
|
+
}).catch(error => {
|
|
225
|
+
console.error(`${NAME.PREFIX}updateCameraList failed, error: ${error}.`);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
tuiCallEngine?.getDeviceList('microphones').then((result) => {
|
|
229
|
+
const deviceList = TUIStore.getData(StoreName.CALL, NAME.DEVICE_LIST);
|
|
230
|
+
const currentMicrophone = result?.[0] || {};
|
|
231
|
+
TUIStore.update(
|
|
232
|
+
StoreName.CALL,
|
|
233
|
+
NAME.DEVICE_LIST,
|
|
234
|
+
{ ...deviceList, microphoneList: result, currentMicrophone },
|
|
235
|
+
);
|
|
236
|
+
}).catch(error => {
|
|
237
|
+
console.error(`${NAME.PREFIX}updateMicrophoneList failed, error: ${error}.`);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* update the no device permission toast
|
|
242
|
+
* @param {any} error error
|
|
243
|
+
* @param {CallMediaType} type call midia type
|
|
244
|
+
* @param {any} tuiCallEngine TUICallEngine instance
|
|
245
|
+
*/
|
|
246
|
+
export function noDevicePermissionToast(error, type: CallMediaType, tuiCallEngine: any) {
|
|
247
|
+
let toastInfoKey = '';
|
|
248
|
+
if (handleNoDevicePermissionError(error)) {
|
|
249
|
+
if (type === CallMediaType.AUDIO) {
|
|
250
|
+
toastInfoKey = CallTips.NO_MICROPHONE_DEVICE_PERMISSION;
|
|
251
|
+
}
|
|
252
|
+
if (type === CallMediaType.VIDEO) {
|
|
253
|
+
toastInfoKey = CallTips.NO_CAMERA_DEVICE_PERMISSION;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const permission = tuiCallEngine?.getDevicePermission();
|
|
257
|
+
if (!permission?.audio) {
|
|
258
|
+
TUIStore.update(StoreName.CALL, NAME.SHOW_PERMISSION_TIP, true);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
toastInfoKey && TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { content: toastInfoKey, type: NAME.ERROR });
|
|
262
|
+
console.error(`${NAME.PREFIX}call failed, error: ${error.message}.`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* set localUserInfo audio/video available
|
|
267
|
+
* @param {boolean} isAvailable is available
|
|
268
|
+
* @param {string} type callMediaType 'audio' | 'video'
|
|
269
|
+
* @param {ITUIStore} TUIStore TUIStore instance
|
|
270
|
+
*/
|
|
271
|
+
export function setLocalUserInfoAudioVideoAvailable(isAvailable: boolean, type: string) {
|
|
272
|
+
let localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO);
|
|
273
|
+
if (type === NAME.AUDIO) {
|
|
274
|
+
localUserInfo = { ...localUserInfo, isAudioAvailable: isAvailable };
|
|
275
|
+
}
|
|
276
|
+
if (type === NAME.VIDEO) {
|
|
277
|
+
localUserInfo = { ...localUserInfo, isVideoAvailable: isAvailable };
|
|
278
|
+
}
|
|
279
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, localUserInfo);
|
|
280
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, localUserInfo);
|
|
281
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { APP_NAMESPACE, IS_PC, IS_H5, IN_WX_MINI_APP, IN_UNI_NATIVE_APP, IN_UNI_APP, IS_MAC, IS_WIN } from '../utils/env';
|
|
2
|
+
import { ITUIGlobal } from '../interface/ITUIGlobal';
|
|
3
|
+
|
|
4
|
+
export default class TUIGlobal implements ITUIGlobal {
|
|
5
|
+
static instance: TUIGlobal;
|
|
6
|
+
public global: any = APP_NAMESPACE;
|
|
7
|
+
public isPC: boolean = false;
|
|
8
|
+
public isH5: boolean = false;
|
|
9
|
+
public isWeChat: boolean = false;
|
|
10
|
+
public isApp: boolean = false;
|
|
11
|
+
public isUniPlatform: boolean = false;
|
|
12
|
+
public isOfficial: boolean = false;
|
|
13
|
+
public isWIN: boolean = false;
|
|
14
|
+
public isMAC: boolean = false;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.initEnv();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 获取 TUIGlobal 实例
|
|
21
|
+
* @returns {TUIGlobal}
|
|
22
|
+
*/
|
|
23
|
+
static getInstance() {
|
|
24
|
+
if (!TUIGlobal.instance) {
|
|
25
|
+
TUIGlobal.instance = new TUIGlobal();
|
|
26
|
+
}
|
|
27
|
+
return TUIGlobal.instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
initEnv() {
|
|
31
|
+
this.isPC = IS_PC;
|
|
32
|
+
this.isH5 = IS_H5;
|
|
33
|
+
this.isWeChat = IN_WX_MINI_APP;
|
|
34
|
+
this.isApp = IN_UNI_NATIVE_APP && !IN_WX_MINI_APP; // uniApp 打包小程序时 IN_UNI_NATIVE_APP 为 true,所以此处需要增加条件
|
|
35
|
+
this.isUniPlatform = IN_UNI_APP;
|
|
36
|
+
this.isWIN = IS_WIN;
|
|
37
|
+
this.isMAC = IS_MAC;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
initOfficial(SDKAppID: number) {
|
|
41
|
+
this.isOfficial = (SDKAppID === 1400187352 || SDKAppID === 1400188366);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CallStatus, CallRole, CallMediaType, VideoDisplayMode, VideoResolution, CameraPosition, LayoutMode, NAME } from '../const/index';
|
|
2
|
+
import { ICallStore } from '../interface/ICallStore';
|
|
3
|
+
import { t } from '../locales/index';
|
|
4
|
+
import { getLanguage } from '../utils/common-utils';
|
|
5
|
+
import { deepClone } from "../utils/index";
|
|
6
|
+
|
|
7
|
+
export default class CallStore {
|
|
8
|
+
public defaultStore: ICallStore = {
|
|
9
|
+
callStatus: CallStatus.IDLE,
|
|
10
|
+
callRole: CallRole.UNKNOWN,
|
|
11
|
+
callMediaType: CallMediaType.UNKNOWN,
|
|
12
|
+
localUserInfo: { userId: '' },
|
|
13
|
+
localUserInfoExcludeVolume: { userId: '' },
|
|
14
|
+
remoteUserInfoList: [],
|
|
15
|
+
remoteUserInfoExcludeVolumeList: [],
|
|
16
|
+
callerUserInfo: { userId: '' },
|
|
17
|
+
isGroup: false,
|
|
18
|
+
callDuration: '00:00:00', // 通话时长
|
|
19
|
+
callTips: '', // 通话提示的信息. 例如: '等待谁接听', 'xxx 拒绝通话', 'xxx 挂断通话'
|
|
20
|
+
toastInfo: { text: '' }, // 远端用户挂断、拒绝、超时、忙线等的 toast 提示信息
|
|
21
|
+
isMinimized: false, // 用来记录当前是否悬浮窗模式
|
|
22
|
+
enableFloatWindow: false, // 开启/关闭悬浮窗功能,设置为false,通话界面左上角的悬浮窗按钮会隐藏
|
|
23
|
+
bigScreenUserId: '', // 当前大屏幕显示的 userID 用户
|
|
24
|
+
language: getLanguage(), // en, zh-cn
|
|
25
|
+
isClickable: false, // 是否可点击, 用于按钮增加 loading 效果,不可点击
|
|
26
|
+
deviceList: { cameraList: [], microphoneList: [], currentCamera: {}, currentMicrophone: {} },
|
|
27
|
+
showPermissionTip: false,
|
|
28
|
+
netWorkQualityList: [], // 显示网络状态差的提示
|
|
29
|
+
isMuteSpeaker: false,
|
|
30
|
+
callID: '', // callEngine 3.1 support
|
|
31
|
+
groupID: '',
|
|
32
|
+
roomID: 0,
|
|
33
|
+
roomIdType: 0,
|
|
34
|
+
cameraPosition: CameraPosition.FRONT, // 前置或后置,值为front, back
|
|
35
|
+
groupCallMembers: [], // chat 群会话在的通话中的成员
|
|
36
|
+
// TUICallKit 组件上的属性
|
|
37
|
+
displayMode: VideoDisplayMode.COVER, // 设置预览远端的画面显示模式
|
|
38
|
+
videoResolution: VideoResolution.RESOLUTION_720P,
|
|
39
|
+
showSelectUser: false,
|
|
40
|
+
// 小程序相关属性
|
|
41
|
+
pusher: {},
|
|
42
|
+
player: [],
|
|
43
|
+
isEarPhone: false, // 是否是听筒, 默认: false
|
|
44
|
+
pusherId: NAME.INITIAL_PUSHER, // 重新渲染 live-Pusher 的标识位
|
|
45
|
+
// 是否开启虚拟背景, 目前仅 web 支持
|
|
46
|
+
isShowEnableVirtualBackground: false, // 是否显示虚拟背景图标, 默认: false
|
|
47
|
+
enableVirtualBackground: false, // 是否开启虚拟背景, 默认: false
|
|
48
|
+
// customUIConfig
|
|
49
|
+
customUIConfig: {
|
|
50
|
+
button: {},
|
|
51
|
+
viewBackground: {},
|
|
52
|
+
layoutMode: LayoutMode.RemoteInLargeView,
|
|
53
|
+
},
|
|
54
|
+
// translate function
|
|
55
|
+
translate: t,
|
|
56
|
+
isForceUseV2API: false,
|
|
57
|
+
};
|
|
58
|
+
public store: ICallStore = deepClone(this.defaultStore);
|
|
59
|
+
public prevStore: ICallStore = deepClone(this.defaultStore);
|
|
60
|
+
|
|
61
|
+
public update(key: keyof ICallStore, data: any): void {
|
|
62
|
+
switch (key) {
|
|
63
|
+
case NAME.CALL_TIPS:
|
|
64
|
+
const preData = this.getData(key);
|
|
65
|
+
(this.prevStore[key] as any) = preData;
|
|
66
|
+
default:
|
|
67
|
+
// resolve "Type 'any' is not assignable to type 'never'.ts", ref: https://github.com/microsoft/TypeScript/issues/31663
|
|
68
|
+
(this.store[key] as any) = data as any;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getPrevData(key: string | undefined): any {
|
|
73
|
+
if (!key) return this.prevStore;
|
|
74
|
+
return this.prevStore[key as keyof ICallStore];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public getData(key: string | undefined): any {
|
|
78
|
+
if (!key) return this.store;
|
|
79
|
+
return this.store[key as keyof ICallStore];
|
|
80
|
+
}
|
|
81
|
+
// reset call store
|
|
82
|
+
public reset(keyList: Array<string> = []) {
|
|
83
|
+
if (keyList.length === 0) {
|
|
84
|
+
keyList = Object.keys(this.store);
|
|
85
|
+
}
|
|
86
|
+
const resetToDefault = keyList.reduce((acc, key) => ({ ...acc, [key]: this.defaultStore[key as keyof ICallStore] }), {});
|
|
87
|
+
this.store = {
|
|
88
|
+
...this.defaultStore,
|
|
89
|
+
...this.store,
|
|
90
|
+
...resetToDefault,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { ITUIStore, IOptions, Task } from '../interface/ITUIStore';
|
|
2
|
+
import { StoreName, NAME } from '../const/index';
|
|
3
|
+
import CallStore from './callStore';
|
|
4
|
+
import { isString, isNumber, isBoolean } from '../utils/common-utils';
|
|
5
|
+
|
|
6
|
+
export default class TUIStore implements ITUIStore {
|
|
7
|
+
static instance: TUIStore;
|
|
8
|
+
public task: Task;
|
|
9
|
+
private storeMap: Partial<Record<StoreName, any>>;
|
|
10
|
+
private timerId: number = -1;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.storeMap = {
|
|
13
|
+
[StoreName.CALL]: new CallStore(),
|
|
14
|
+
};
|
|
15
|
+
// todo 此处后续优化结构后调整
|
|
16
|
+
this.task = {} as Task; // 保存监听回调列表
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 获取 TUIStore 实例
|
|
21
|
+
* @returns {TUIStore}
|
|
22
|
+
*/
|
|
23
|
+
static getInstance() {
|
|
24
|
+
if (!TUIStore.instance) {
|
|
25
|
+
TUIStore.instance = new TUIStore();
|
|
26
|
+
}
|
|
27
|
+
return TUIStore.instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* UI 组件注册监听回调
|
|
32
|
+
* @param {StoreName} storeName store 名称
|
|
33
|
+
* @param {IOptions} options 监听信息
|
|
34
|
+
* @param {Object} params 扩展参数
|
|
35
|
+
* @param {String} params.notifyRangeWhenWatch 注册时监听时的通知范围, 'all' - 通知所有注册该 key 的监听; 'myself' - 通知本次注册该 key 的监听; 默认不通知
|
|
36
|
+
*/
|
|
37
|
+
watch(storeName: StoreName, options: IOptions, params?: any) {
|
|
38
|
+
if (!this.task[storeName]) {
|
|
39
|
+
this.task[storeName] = {};
|
|
40
|
+
}
|
|
41
|
+
const watcher = this.task[storeName];
|
|
42
|
+
Object.keys(options).forEach((key) => {
|
|
43
|
+
const callback = options[key];
|
|
44
|
+
if (!watcher[key]) {
|
|
45
|
+
watcher[key] = new Map();
|
|
46
|
+
}
|
|
47
|
+
watcher[key].set(callback, 1);
|
|
48
|
+
const { notifyRangeWhenWatch } = params || {};
|
|
49
|
+
// 注册监听后, 通知所有注册该 key 的监听,使用 'all' 时要特别注意是否对其他地方的监听产生影响
|
|
50
|
+
if (notifyRangeWhenWatch === NAME.ALL) {
|
|
51
|
+
this.notify(storeName, key);
|
|
52
|
+
}
|
|
53
|
+
// 注册监听后, 仅通知自己本次监听该 key 的数据
|
|
54
|
+
if (notifyRangeWhenWatch === NAME.MYSELF) {
|
|
55
|
+
const data = this.getData(storeName, key);
|
|
56
|
+
callback.call(this, data);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* UI 取消组件监听回调
|
|
63
|
+
* @param {StoreName} storeName store 名称
|
|
64
|
+
* @param {IOptions} options 监听信息,包含需要取消的回掉等
|
|
65
|
+
*/
|
|
66
|
+
unwatch(storeName: StoreName, options: IOptions) {
|
|
67
|
+
// todo 该接口暂未支持,unwatch掉同一类,如仅传入store注销掉该store下的所有callback,同样options仅传入key注销掉该key下的所有callback
|
|
68
|
+
// options的callback function为必填参数,后续修改
|
|
69
|
+
if (!this.task[storeName]) {
|
|
70
|
+
return;
|
|
71
|
+
};
|
|
72
|
+
// if (isString(options)) {
|
|
73
|
+
// // 移除所有的监听
|
|
74
|
+
// if (options === '*') {
|
|
75
|
+
// const watcher = this.task[storeName];
|
|
76
|
+
// Object.keys(watcher).forEach(key => {
|
|
77
|
+
// watcher[key].clear();
|
|
78
|
+
// });
|
|
79
|
+
// } else {
|
|
80
|
+
// console.warn(`${NAME.PREFIX}unwatch warning: options is ${options}`);
|
|
81
|
+
// }
|
|
82
|
+
// return;
|
|
83
|
+
// }
|
|
84
|
+
const watcher = this.task[storeName];
|
|
85
|
+
Object.keys(options).forEach((key: string) => {
|
|
86
|
+
watcher[key].delete(options[key]);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 通用 store 数据更新,messageList 的变更需要单独处理
|
|
92
|
+
* @param {StoreName} storeName store 名称
|
|
93
|
+
* @param {string} key 变更的 key
|
|
94
|
+
* @param {unknown} data 变更的数据
|
|
95
|
+
*/
|
|
96
|
+
update(storeName: StoreName, key: string, data: unknown) {
|
|
97
|
+
// 基本数据类型时, 如果相等, 就不进行更新, 减少不必要的 notify
|
|
98
|
+
if (isString(data) || isNumber(data) || isBoolean(data)) {
|
|
99
|
+
const currentData = this.storeMap[storeName]['store'][key]; // eslint-disable-line
|
|
100
|
+
if (currentData === data) return;
|
|
101
|
+
}
|
|
102
|
+
this.storeMap[storeName]?.update(key, data);
|
|
103
|
+
this.notify(storeName, key);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 获取 Store 的上一个状态值
|
|
108
|
+
* @param {StoreName} storeName store 名称
|
|
109
|
+
* @param {string} key 待获取的 key
|
|
110
|
+
* @returns {Any}
|
|
111
|
+
*/
|
|
112
|
+
getPrevData(storeName: StoreName, key: string) {
|
|
113
|
+
return this.storeMap[storeName]?.getPrevData(key);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 获取 Store 数据
|
|
118
|
+
* @param {StoreName} storeName store 名称
|
|
119
|
+
* @param {string} key 待获取的 key
|
|
120
|
+
* @returns {Any}
|
|
121
|
+
*/
|
|
122
|
+
getData(storeName: StoreName, key: string) {
|
|
123
|
+
return this.storeMap[storeName]?.getData(key);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* UI 组件注册监听回调
|
|
128
|
+
* @param {StoreName} storeName store 名称
|
|
129
|
+
* @param {string} key 变更的 key
|
|
130
|
+
*/
|
|
131
|
+
private notify(storeName: StoreName, key: string) {
|
|
132
|
+
if (!this.task[storeName]) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const watcher = this.task[storeName];
|
|
136
|
+
if (watcher[key]) {
|
|
137
|
+
const callbackMap = watcher[key];
|
|
138
|
+
const data = this.getData(storeName, key);
|
|
139
|
+
for (const [callback] of callbackMap.entries()) {
|
|
140
|
+
callback.call(this, data);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public reset(storeName: StoreName, keyList: Array<string> = [], isNotificationNeeded = false) {
|
|
146
|
+
if (storeName in this.storeMap) {
|
|
147
|
+
const store = this.storeMap[storeName];
|
|
148
|
+
// reset all
|
|
149
|
+
if (keyList.length === 0) {
|
|
150
|
+
keyList = Object.keys(store?.store);
|
|
151
|
+
}
|
|
152
|
+
store.reset(keyList);
|
|
153
|
+
if (isNotificationNeeded) {
|
|
154
|
+
keyList.forEach((key) => {
|
|
155
|
+
this.notify(storeName, key);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// 批量修改多个 key-value
|
|
161
|
+
public updateStore(params: any, name?: StoreName): void {
|
|
162
|
+
const storeName = name ? name : StoreName.CALL;
|
|
163
|
+
Object.keys(params).forEach((key) => {
|
|
164
|
+
this.update(storeName, key, params[key]);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
Binary file
|
|
Binary file
|