Sfoglia il codice sorgente

重复上报问题

nieyuge 17 ore fa
parent
commit
26ffc36533

+ 11 - 11
src/hooks/useLogger.ts

@@ -2,7 +2,7 @@ import http from '@src/http';
 import { uploadLogApi } from '@src/http/api';
 import sso from '@src/http/sso';
 import { VideoItem } from '@src/views/publishContent/types';
-import { RecentNotUsedType, SortTypeEnum, TagType, VideoLibraryType } from '@src/views/publishContent/weCom/components/videoSelectModal';
+import { VideoLibraryType, VideoSortType } from '@src/views/publishContent/weCom/components/videoSelectModal';
 import { VideoSearchPlanType } from '@src/views/publishContent/weCom/type';
 
 type NormalLogParams = {
@@ -16,16 +16,16 @@ type NormalLogParams = {
 type VideoListQueryLogParams = {
 	category?: string;
 	title?: string;
-	recentNotUsed?: RecentNotUsedType;
-	sortType?: SortTypeEnum;
-	tags?: TagType[];
+	recentNotUsed?: number;
+	sortType?: VideoSortType;
+	tags?: string[];
 	videoLibraryType?: VideoLibraryType;
 } & NormalLogParams;
 
 type VideoLogParams = {
 	videoId: number;
 	score?: number;
-	tags?: TagType[];
+	tags?: string[];
 	title?: string;
 	cover?: string;
 	libraryType?: VideoLibraryType;
@@ -76,7 +76,7 @@ const useLogger = () => {
 		sortType,
 		tags,
 		videoLibraryType,
-	}:VideoListQueryLogParams) => { 
+	}:VideoListQueryLogParams) => {
 		return uploadLog({
 			businessType: 'video_list_query',
 			objectType: 'video_list',
@@ -96,7 +96,7 @@ const useLogger = () => {
 		});
 	}
 
-	const uploadLogVideoPlay = ({videoId, traceId, requestId, planType, gzhAccountId, subChannel}: VideoLogParams) => { 
+	const uploadLogVideoPlay = ({videoId, traceId, requestId, planType, gzhAccountId, subChannel}: VideoLogParams) => {
 		return uploadLog({
 			businessType: 'video_play',
 			objectType: 'video',
@@ -111,7 +111,7 @@ const useLogger = () => {
 		});
 	}
 
-	const uploadLogVideoPlayEnd = ({videoId, playTime, traceId, requestId, planType, gzhAccountId, subChannel}: VideoLogParams) => { 
+	const uploadLogVideoPlayEnd = ({videoId, playTime, traceId, requestId, planType, gzhAccountId, subChannel}: VideoLogParams) => {
 		return uploadLog({
 			businessType: 'video_play_end',
 			objectType: 'video',
@@ -127,7 +127,7 @@ const useLogger = () => {
 		});
 	}
 
-	const uploadLogVideoView = ({videoId, idx, score, tags, title, cover, libraryType, traceId, requestId, planType, gzhAccountId, subChannel}: VideoLogParams) => { 
+	const uploadLogVideoView = ({videoId, idx, score, tags, title, cover, libraryType, traceId, requestId, planType, gzhAccountId, subChannel}: VideoLogParams) => {
 		return uploadLog({
 			businessType: 'video_view',
 			objectType: 'video',
@@ -148,7 +148,7 @@ const useLogger = () => {
 		});
 	}
 
-	const uploadLogVideoCollect = ({videoId, traceId, requestId, collect, planType, gzhAccountId, subChannel}: VideoLogParams) => { 
+	const uploadLogVideoCollect = ({videoId, traceId, requestId, collect, planType, gzhAccountId, subChannel}: VideoLogParams) => {
 		return uploadLog({
 			businessType: 'video_collect',
 			objectType: 'video',
@@ -171,7 +171,7 @@ const useLogger = () => {
 		planType,
 		gzhAccountId,
 		subChannel
-	}: PublishPlanLogParams) => { 
+	}: PublishPlanLogParams) => {
 		return uploadLog({
 			businessType: 'publish_plan_create',
 			objectType: 'publish_plan',

+ 2 - 2
src/views/publishContent/types.ts

@@ -1,4 +1,4 @@
-import { TagType } from "./weCom/components/videoSelectModal";
+
 
 export enum CollectedStatusEnum {
 	已收藏 = 1,
@@ -24,7 +24,7 @@ export interface VideoItem {
   channelFissionRate?: number;
   videoLibraryType?: number;
   recommendScore?: number;
-  tags?: TagType[];
+  tags?: string[];
 	scene?: 0 | 1;
 	collect?: CollectedStatusEnum;
 	status?: VideoStatusEnum;

+ 2 - 2
src/views/publishContent/weCom/components/addPlanModal/index.tsx

@@ -2,7 +2,7 @@
 
 import React, { useEffect, useState } from 'react';
 import { Modal, Form, Input, Select, Button, Card, Typography, message } from 'antd';
-import { WeComPlanType, WeVideoItem, AddWeComPlanParam } from '../../type';
+import { WeComPlanType, WeVideoItem, AddWeComPlanParam, VideoSearchPlanType } from '../../type';
 import { CloseOutlined, PlusOutlined, CaretRightFilled } from '@ant-design/icons';
 import VideoSelectModal from '../videoSelectModal';
 import VideoPlayModal from '../videoPlayModal';
@@ -58,7 +58,7 @@ const AddPlanModal: React.FC<{
 				videoList: selectedVideos,
 				traceId: Date.now(),
 				requestId: Date.now(),
-				planType: type === WeComPlanType.社群 ? '企微社群' : '企微自动回复',
+				planType: type === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
 				subChannel: values.subChannel || 'weCom',
 			});
 			onOk({

+ 5 - 7
src/views/publishContent/weCom/components/videoSelectModal/index.tsx

@@ -57,7 +57,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 	const [playingVideo, setPlayingVideo] = useState<WeVideoItem | null>(null);
 	const [videoLibraryType, setVideoLibraryType] = useState<VideoLibraryType>(VideoLibraryType.平台视频库);
 	const MAX_SELECTION = 3;
-	const { uploadLogVideoPlay, uploadLogVideoPlayEnd, uploadLogVideoCollect, uploadLogVideoListQuery, uploadLogVideoView } = useLogger();
+	const { uploadLogVideoPlay, uploadLogVideoPlayEnd, uploadLogVideoCollect, uploadLogVideoListQuery } = useLogger();
 
 	const getVideoList = async (pageNum?: number, _pageSize?: number) => {
 		setLoading(true);
@@ -103,12 +103,10 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 
 	// 监听视频库类型变化,重新加载数据
 	useEffect(() => {
-		getVideoList();
-	}, [videoLibraryType]);
-
-	useEffect(() => {
-		getVideoList();
-	}, []);
+		if (visible) {
+			getVideoList();
+		}
+	}, [videoLibraryType, visible]);
 
 	useEffect(() => {
 		if (visible) {

+ 19 - 8
src/views/publishContent/weGZH/components/publishPlanModal/index.tsx

@@ -8,6 +8,7 @@ import { VideoItem } from '../types'; // Import from common types
 import { GzhPlanDataType, GzhPlanType } from '../../hooks/useGzhPlanList';
 import { useAccountOptions } from '../../hooks/useAccountOptions';
 import { VideoLibraryType } from '@src/views/publishContent/weCom/components/videoSelectModal';
+import { VideoSearchPlanType } from '@src/views/publishContent/weCom/type';
 import useLogger from '@src/hooks/useLogger';
 
 const { Option } = Select;
@@ -38,6 +39,16 @@ const AddPunlishPlanModal: React.FC<AddPunlishPlanModalProps> = ({ visible, isSu
 	const { accountOptions, getAccountList } = useAccountOptions();
 	const { uploadLogVideoCreatePublish } = useLogger();
 
+	const getVideoListType = (planType: GzhPlanType) => {
+		if (planType === GzhPlanType.自动回复) {
+			return VideoSearchPlanType.自动回复;
+		} else if (planType === GzhPlanType.公众号推送) {
+			return VideoSearchPlanType.公众号推送;
+		} else {
+			return VideoSearchPlanType.服务号推送;
+		}
+	};
+
 	// 处理code参数
 	useEffect(() => {
 		if (code) {
@@ -102,14 +113,14 @@ const AddPunlishPlanModal: React.FC<AddPunlishPlanModalProps> = ({ visible, isSu
 				}
 				formData.videoList = selectedVideos;
 				// 上报日志
-				uploadLogVideoCreatePublish({
-					videoList: selectedVideos,
-					traceId: Date.now(),
-					requestId: Date.now(),
-					planType: planType,
-					gzhAccountId: formData.accountId,
-					subChannel: 'weGZH'
-				});
+			uploadLogVideoCreatePublish({
+				videoList: selectedVideos,
+				traceId: Date.now(),
+				requestId: Date.now(),
+				planType: getVideoListType(planType),
+				gzhAccountId: formData.accountId,
+				subChannel: 'weGZH'
+			});
 				onOk(formData);
 			})
 			.catch((info) => {

+ 2 - 8
src/views/publishContent/weGZH/components/videoSelectModal/index.tsx

@@ -112,20 +112,14 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
 		}
 	}
 
-	// 监听视频库类型变化,重新加载数据
-	useEffect(() => {
-		if (visible) {
-			getVideoList();
-		}
-	}, [videoLibraryType, visible]);
-
+	// 监听visible和videoLibraryType变化,重新加载数据
 	useEffect(() => {
 		if (visible) {
 			setVideoList(selectedVideos);
 			setVideoListAll(selectedVideos);
 			getVideoList();
 		}
-	}, [visible]);
+	}, [visible, videoLibraryType, selectedVideos]);
 
 	useEffect(() => {
 		if (visible) {