Ver código fonte

企微选视频弹窗加测试入口:群体特征召回

仅非 prod 构建可见(IS_NON_PROD = !import.meta.env.PROD,
prod 构建会被 vite 静态消除)。
打开开关后改走 /contentPlatform/plan/demand/videoContentList,
请求体去掉 category,其它分页/搜索/选择逻辑复用。
刘立冬 23 horas atrás
pai
commit
8ff81fdc16

+ 1 - 0
src/http/api.ts

@@ -35,6 +35,7 @@ export const deleteQwPlanApi = `${import.meta.env.VITE_API_URL}/contentPlatform/
 export const getVideoContentCategoryListApi = `${import.meta.env.VITE_API_URL}/contentPlatform/plan/videoContentCategoryList`
 export const getVideoContentCoverFrameListApi = `${import.meta.env.VITE_API_URL}/contentPlatform/plan/videoContentCoverFrameList`
 export const getVideoContentListApi = `${import.meta.env.VITE_API_URL}/contentPlatform/plan/videoContentList`
+export const getDemandVideoContentListApi = `${import.meta.env.VITE_API_URL}/contentPlatform/plan/demand/videoContentList` // 群体特征召回(测试,仅企微)
 export const getShareQrPic = `${import.meta.env.VITE_API_URL}/contentPlatform/plan/qw/getSharePic`
 export const getShareQrLink = `${import.meta.env.VITE_API_URL}/contentPlatform/plan/getShareUrlLink`
 

+ 28 - 10
src/views/publishContent/weCom/components/videoSelectModal/index.tsx

@@ -8,6 +8,7 @@ import {
 	Typography,
 	Space,
 	Spin,
+	Switch,
 	Pagination,
 	message,
 	Modal,
@@ -15,11 +16,12 @@ import {
 import { CheckCircleFilled, CaretRightFilled } from '@ant-design/icons';
 import { VideoListResponse } from '@src/views/publishContent/weGZH/components/types';
 import http from '@src/http';
-import { getVideoContentListApi } from '@src/http/api';
+import { getVideoContentListApi, getDemandVideoContentListApi } from '@src/http/api';
 import { useVideoCategoryOptions } from '@src/views/publishContent/weGZH/hooks/useVideoCategoryOptions';
 import { WeComPlanType, WeVideoItem, VideoSearchPlanType } from '@src/views/publishContent/weCom/type'
 
 const { Text, Paragraph } = Typography;
+const IS_NON_PROD = !import.meta.env.PROD;
 
 type LoadMode = 'replace' | 'append' | 'jump';
 
@@ -55,6 +57,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 	const [playingVideo, setPlayingVideo] = useState<WeVideoItem | null>(null);
 	const [viewingPage, setViewingPage] = useState(1);
 	const [pageAnchors, setPageAnchors] = useState<Map<number, number>>(new Map()); // videoId -> page
+	const [useDemandRecall, setUseDemandRecall] = useState(false); // 测试入口:群体特征召回
 	const observerRef = useRef<IntersectionObserver | null>(null);
 	const pageObserverRef = useRef<IntersectionObserver | null>(null);
 	const passedPagesRef = useRef<Set<number>>(new Set());
@@ -82,16 +85,13 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 		}
 		setCurrentPage(pageNum);
 
-		const requestParams = {
-			category,
-			title: searchTerm,
-			sort,
-			type: planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复,
-			pageNum,
-			pageSize: PAGE_SIZE,
-		};
+		const type = planType === WeComPlanType.社群 ? VideoSearchPlanType.企微社群 : VideoSearchPlanType.企微自动回复;
+		const apiUrl = useDemandRecall ? getDemandVideoContentListApi : getVideoContentListApi;
+		const requestParams = useDemandRecall
+			? { title: searchTerm, sort, type, pageNum, pageSize: PAGE_SIZE }
+			: { category, title: searchTerm, sort, type, pageNum, pageSize: PAGE_SIZE };
 
-		const res = await http.post<VideoListResponse>(getVideoContentListApi, requestParams).catch(() => {
+		const res = await http.post<VideoListResponse>(apiUrl, requestParams).catch(() => {
 			message.error('获取视频列表失败');
 		}).finally(() => {
 			if (isAppend) {
@@ -210,6 +210,18 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 		getVideoList(1, 'replace');
 	};
 
+	const handleToggleDemandRecall = (checked: boolean) => {
+		setUseDemandRecall(checked);
+		setHasMore(true);
+		setVideoList([]);
+		setViewingPage(1);
+		setPageAnchors(new Map());
+		passedPagesRef.current.clear();
+		drawerBodyRef.current?.scrollTo({ top: 0 });
+		// 切换后重新请求(用最新 state 值)
+		setTimeout(() => getVideoListRef.current?.(1, 'replace'), 0);
+	};
+
 	const handleSelectVideo = (videoId: number) => {
 		setSelectedVideoIds(prev => {
 			const newSet = new Set(prev);
@@ -321,6 +333,12 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ visible, onClose, o
 						/>
 					</div>
 					<Button type="primary" loading={loading} onClick={handleSearch}>搜索</Button>
+					{IS_NON_PROD && (
+						<div className="flex items-center gap-2 ml-auto">
+							<span className="text-gray-600">群体召回(测试):</span>
+							<Switch checked={useDemandRecall} onChange={handleToggleDemandRecall} />
+						</div>
+					)}
 				</div>
 
 				<Spin spinning={loading}>