|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
|
|
|
|
|
+import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
|
|
import {
|
|
import {
|
|
|
Drawer,
|
|
Drawer,
|
|
|
Button,
|
|
Button,
|
|
@@ -18,6 +18,8 @@ import http from '@src/http';
|
|
|
import { getVideoContentListApi } from '@src/http/api';
|
|
import { getVideoContentListApi } from '@src/http/api';
|
|
|
import { useVideoCategoryOptions } from '@src/views/publishContent/weGZH/hooks/useVideoCategoryOptions';
|
|
import { useVideoCategoryOptions } from '@src/views/publishContent/weGZH/hooks/useVideoCategoryOptions';
|
|
|
import { WeComPlanType, WeVideoItem, VideoSearchPlanType } from '@src/views/publishContent/weCom/type'
|
|
import { WeComPlanType, WeVideoItem, VideoSearchPlanType } from '@src/views/publishContent/weCom/type'
|
|
|
|
|
+import useLogger from '@src/hooks/useLogger';
|
|
|
|
|
+import { debounce } from '@src/utils/helper';
|
|
|
|
|
|
|
|
const { Text, Paragraph } = Typography;
|
|
const { Text, Paragraph } = Typography;
|
|
|
|
|
|
|
@@ -66,6 +68,8 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
|
|
|
const currentPageRef = useRef(1);
|
|
const currentPageRef = useRef(1);
|
|
|
const getVideoListRef = useRef<(pageNum: number, mode: LoadMode) => Promise<void>>();
|
|
const getVideoListRef = useRef<(pageNum: number, mode: LoadMode) => Promise<void>>();
|
|
|
const MAX_SELECTION = 3;
|
|
const MAX_SELECTION = 3;
|
|
|
|
|
+ const { uploadLogVideoPlay, uploadLogVideoPlayEnd, uploadLogVideoCollect, uploadLogVideoListQuery } = useLogger();
|
|
|
|
|
+ const debouncedUploadLogVideoListQuery = useMemo(() => debounce(uploadLogVideoListQuery, 500), [uploadLogVideoListQuery]);
|
|
|
|
|
|
|
|
useEffect(() => { hasMoreRef.current = hasMore; }, [hasMore]);
|
|
useEffect(() => { hasMoreRef.current = hasMore; }, [hasMore]);
|
|
|
useEffect(() => { loadingRef.current = loading; }, [loading]);
|
|
useEffect(() => { loadingRef.current = loading; }, [loading]);
|
|
@@ -82,6 +86,16 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
|
|
|
}
|
|
}
|
|
|
setCurrentPage(pageNum);
|
|
setCurrentPage(pageNum);
|
|
|
|
|
|
|
|
|
|
+ // 上报视频列表查询日志(使用防抖)
|
|
|
|
|
+ debouncedUploadLogVideoListQuery({
|
|
|
|
|
+ traceId: Date.now(),
|
|
|
|
|
+ planType: planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
|
|
|
|
|
+ subChannel: 'weCom',
|
|
|
|
|
+ category: category ?? '',
|
|
|
|
|
+ title: searchTerm,
|
|
|
|
|
+ sortType: sort,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
const requestParams = {
|
|
const requestParams = {
|
|
|
category,
|
|
category,
|
|
|
title: searchTerm,
|
|
title: searchTerm,
|
|
@@ -215,12 +229,28 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
|
|
|
const newSet = new Set(prev);
|
|
const newSet = new Set(prev);
|
|
|
if (newSet.has(videoId)) {
|
|
if (newSet.has(videoId)) {
|
|
|
newSet.delete(videoId);
|
|
newSet.delete(videoId);
|
|
|
|
|
+ // 上报取消收藏日志
|
|
|
|
|
+ uploadLogVideoCollect({
|
|
|
|
|
+ videoId,
|
|
|
|
|
+ traceId: Date.now(),
|
|
|
|
|
+ collect: 0,
|
|
|
|
|
+ planType: planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
|
|
|
|
|
+ subChannel: 'weCom',
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
if (newSet.size >= MAX_SELECTION) {
|
|
if (newSet.size >= MAX_SELECTION) {
|
|
|
message.warning(`最多只能选择 ${MAX_SELECTION} 条视频`);
|
|
message.warning(`最多只能选择 ${MAX_SELECTION} 条视频`);
|
|
|
return prev;
|
|
return prev;
|
|
|
}
|
|
}
|
|
|
newSet.add(videoId);
|
|
newSet.add(videoId);
|
|
|
|
|
+ // 上报收藏日志
|
|
|
|
|
+ uploadLogVideoCollect({
|
|
|
|
|
+ videoId,
|
|
|
|
|
+ traceId: Date.now(),
|
|
|
|
|
+ collect: 1,
|
|
|
|
|
+ planType: planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
|
|
|
|
|
+ subChannel: 'weCom',
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
return newSet;
|
|
return newSet;
|
|
|
});
|
|
});
|
|
@@ -237,9 +267,26 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
|
|
|
|
|
|
|
|
const playVideo = (video: WeVideoItem) => {
|
|
const playVideo = (video: WeVideoItem) => {
|
|
|
setPlayingVideo(video);
|
|
setPlayingVideo(video);
|
|
|
|
|
+ // 上报视频播放日志
|
|
|
|
|
+ uploadLogVideoPlay({
|
|
|
|
|
+ videoId: video.videoId,
|
|
|
|
|
+ traceId: Date.now(),
|
|
|
|
|
+ planType: planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
|
|
|
|
|
+ subChannel: 'weCom',
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const closeVideoPlayer = () => {
|
|
const closeVideoPlayer = () => {
|
|
|
|
|
+ if (playingVideo) {
|
|
|
|
|
+ // 上报视频播放结束日志
|
|
|
|
|
+ uploadLogVideoPlayEnd({
|
|
|
|
|
+ videoId: playingVideo.videoId,
|
|
|
|
|
+ playTime: 0, // 实际播放时间可以从视频元素中获取,这里暂时设为0
|
|
|
|
|
+ traceId: Date.now(),
|
|
|
|
|
+ planType: planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
|
|
|
|
|
+ subChannel: 'weCom',
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
setPlayingVideo(null);
|
|
setPlayingVideo(null);
|
|
|
};
|
|
};
|
|
|
|
|
|