|
|
@@ -20,6 +20,7 @@ import { VideoSortType, VideoLibraryType } from '@src/views/publishContent/weCom
|
|
|
import { GzhPlanType } from '../../hooks/useGzhPlanList';
|
|
|
import { VideoSearchPlanType } from '@src/views/publishContent/weCom/type';
|
|
|
import { enumToOptions } from '@src/utils/helper';
|
|
|
+import useLogger from '@src/hooks/useLogger';
|
|
|
|
|
|
const { Paragraph, Text } = Typography;
|
|
|
|
|
|
@@ -35,6 +36,7 @@ interface VideoSelectModalProps {
|
|
|
|
|
|
const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible, onClose, onOk, initialSelectedIds = [], selectedVideos = [], defaultVideoLibraryType }) => {
|
|
|
const { videoCategoryOptions } = useVideoCategoryOptions();
|
|
|
+ const { uploadLogVideoListQuery, uploadLogVideoPlay, uploadLogVideoPlayEnd, uploadLogVideoCollect } = useLogger();
|
|
|
const [category, setCategory] = useState<string>();
|
|
|
const [sort, setSort] = useState<VideoSortType>(VideoSortType.推荐指数);
|
|
|
const [searchTerm, setSearchTerm] = useState<string>('');
|
|
|
@@ -70,6 +72,17 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
setLoading(true);
|
|
|
setCurrentPage(pageNum || currentPage);
|
|
|
setPageSize(_pageSize || pageSize);
|
|
|
+ // 上报视频列表查询日志
|
|
|
+ uploadLogVideoListQuery({
|
|
|
+ traceId: Date.now(),
|
|
|
+ requestId: Date.now(),
|
|
|
+ planType: getVideoListType(planType),
|
|
|
+ subChannel: 'weGZH',
|
|
|
+ category,
|
|
|
+ title: searchTerm,
|
|
|
+ sortType: sort,
|
|
|
+ videoLibraryType,
|
|
|
+ });
|
|
|
// 根据视频库类型选择不同的API
|
|
|
const apiUrl = videoLibraryType === VideoLibraryType.平台视频库 ? getVideoContentListApi : getUploadVideoContentListApi;
|
|
|
|
|
|
@@ -89,8 +102,12 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
});
|
|
|
if (res && res.code === 0) {
|
|
|
selectedVideos = selectedVideos.filter(item => item.videoLibraryType === videoLibraryType)
|
|
|
- setVideoList([...selectedVideos, ...res.data.objs.filter(v => !selectedVideos.find(ov => ov.videoId === v.videoId))]);
|
|
|
- setVideoListAll(old => [...old, ...res.data.objs.filter(v => !old.find(ov => ov.videoId === v.videoId))]);
|
|
|
+ const newVideos = res.data.objs.filter(v => !selectedVideos.find(ov => ov.videoId === v.videoId));
|
|
|
+ setVideoList([...selectedVideos, ...newVideos]);
|
|
|
+ // 仅在第一页加载时更新videoListAll,避免重复添加
|
|
|
+ if ((pageNum || currentPage) === 1) {
|
|
|
+ setVideoListAll([...selectedVideos, ...newVideos]);
|
|
|
+ }
|
|
|
setTotal(res.data.totalSize);
|
|
|
}
|
|
|
}
|
|
|
@@ -106,7 +123,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
if (visible) {
|
|
|
setVideoList(selectedVideos);
|
|
|
setVideoListAll(selectedVideos);
|
|
|
- getVideoList(0);
|
|
|
+ getVideoList();
|
|
|
}
|
|
|
}, [visible]);
|
|
|
|
|
|
@@ -128,12 +145,30 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
const newSet = new Set(prev);
|
|
|
if (newSet.has(videoId)) {
|
|
|
newSet.delete(videoId);
|
|
|
+ // 上报取消收藏日志
|
|
|
+ uploadLogVideoCollect({
|
|
|
+ videoId,
|
|
|
+ traceId: Date.now(),
|
|
|
+ requestId: Date.now(),
|
|
|
+ collect: 0,
|
|
|
+ planType: getVideoListType(planType),
|
|
|
+ subChannel: 'weGZH',
|
|
|
+ });
|
|
|
} else {
|
|
|
if (newSet.size >= MAX_SELECTION) {
|
|
|
message.warning(`最多只能选择 ${MAX_SELECTION} 条视频`);
|
|
|
return prev;
|
|
|
}
|
|
|
newSet.add(videoId);
|
|
|
+ // 上报收藏日志
|
|
|
+ uploadLogVideoCollect({
|
|
|
+ videoId,
|
|
|
+ traceId: Date.now(),
|
|
|
+ requestId: Date.now(),
|
|
|
+ collect: 1,
|
|
|
+ planType: getVideoListType(planType),
|
|
|
+ subChannel: 'weGZH',
|
|
|
+ });
|
|
|
}
|
|
|
return newSet;
|
|
|
});
|
|
|
@@ -152,10 +187,29 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
};
|
|
|
|
|
|
const playVideo = (video: VideoItem) => {
|
|
|
+ // 上报视频播放日志
|
|
|
+ uploadLogVideoPlay({
|
|
|
+ videoId: video.videoId,
|
|
|
+ traceId: Date.now(),
|
|
|
+ requestId: Date.now(),
|
|
|
+ planType: getVideoListType(planType),
|
|
|
+ subChannel: 'weGZH',
|
|
|
+ });
|
|
|
setPlayingVideo(video);
|
|
|
};
|
|
|
|
|
|
const closeVideoPlayer = () => {
|
|
|
+ if (playingVideo) {
|
|
|
+ // 上报视频播放结束日志
|
|
|
+ uploadLogVideoPlayEnd({
|
|
|
+ videoId: playingVideo.videoId,
|
|
|
+ playTime: 0,
|
|
|
+ traceId: Date.now(),
|
|
|
+ requestId: Date.now(),
|
|
|
+ planType: getVideoListType(planType),
|
|
|
+ subChannel: 'weGZH',
|
|
|
+ });
|
|
|
+ }
|
|
|
setPlayingVideo(null);
|
|
|
};
|
|
|
|