jihuaqiang 1 tydzień temu
rodzic
commit
8f9b5f200c

+ 35 - 15
src/views/publishContent/weGZH/components/editTitleCoverModal/index.tsx

@@ -16,6 +16,7 @@ import { VideoItem } from '../types';
 import { getAccessToken } from '@src/http/sso';
 import { adFileUpload, getVideoContentCoverFrameListApi } from '@src/http/api';
 import http from '@src/http';
+import { isNil } from 'lodash-es';
 
 const { TextArea } = Input;
 
@@ -41,22 +42,22 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 	useEffect(() => {
 		if (video && visible) {
 			// Reset form based on incoming video data
-			const hasCustomTitle = video.titleIsEdit === 1;
-			const isCustomCover = video.coverIsEdit === 1;
-			const isScreenshotCover = screenshotImagesList?.includes(video.cover || '');
+			const hasCustomTitle = !isNil(video.customTitle);
+			const isCustomCover = !isNil(video.customCover);
+			const isScreenshotCover = video.customCoverType === 1;
 
 			const initialTitleType = hasCustomTitle ? 'custom' : 'original';
 			let initialCoverType: 'original' | 'screenshot' | 'upload' = 'original';
 			if (isCustomCover) {
 				if (isScreenshotCover) {
 					initialCoverType = 'screenshot';
-					setSelectedScreenshot(video.cover || null);
+					setSelectedScreenshot(video.customCover || null);
 					setFileList([]);
 				} else {
 					initialCoverType = 'upload';
 					setSelectedScreenshot(null);
 					// Assume customThumbnail for upload is a URL, create UploadFile structure
-					setFileList([{ uid: '-1', name: 'custom_cover.png', status: 'done', url: video.cover }]);
+					setFileList([{ uid: '-1', name: 'custom_cover.png', status: 'done', url: video.customCover }]);
 				}
 			} else {
 				setSelectedScreenshot(null);
@@ -67,8 +68,12 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 			setCoverType(initialCoverType);
 			form.setFieldsValue({
 				titleType: initialTitleType,
-				title: hasCustomTitle ? video.title : '',
+				title: video.title,
+				cover: video.cover,
 				coverType: initialCoverType,
+				customCover: video.customCover,
+				customCoverType: video.customCoverType,
+				customTitle: video.customTitle,
 			});
 		} else {
 			// Reset form when modal closes or no video
@@ -94,10 +99,9 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 
 			// Handle Title
 			if (values.titleType === 'custom') {
-				updatedData.titleIsEdit = 1;
-				updatedData.title = values.title || '';
+				updatedData.customTitle = values.customTitle || '';
 			} else {
-				updatedData.titleIsEdit = 0;
+				updatedData.customTitle = '';
 				updatedData.title = video?.title; // Revert to original if selected
 			}
 
@@ -107,8 +111,8 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 					message.error('请选择一个视频截图作为封面');
 					return;
 				}
-				updatedData.coverIsEdit = 1;
-				updatedData.cover = selectedScreenshot;
+				updatedData.customCoverType = 1;
+				updatedData.customCover = selectedScreenshot;
 			} else if (values.coverType === 'upload') {
 				if (fileList.length === 0 || !fileList[0].url) {
 					// If using status, check for 'done' status and response URL
@@ -117,9 +121,11 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 				}
 				// Assuming the upload process directly provides the final URL in fileList[0].url
 				// In a real app, you might get this from upload response
-				updatedData.cover = fileList[0].url;
-				updatedData.coverIsEdit = 1;
+				updatedData.customCover = fileList[0].url;
+				updatedData.customCoverType = 2;
 			} else { // Original
+				updatedData.customCover = '';
+				updatedData.customCoverType = 0;
 				updatedData.cover = video?.cover; // Revert to original
 			}
 
@@ -202,14 +208,22 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 					</Radio.Group>
 				</Form.Item>
 
-				{titleType === 'custom' && (
+				{titleType === 'custom' ? (
 					<Form.Item
 						label="自定义标题"
-						name="title"
+						name="customTitle"
 						rules={[{ required: true, message: '请输入自定义标题' }]}
 					>
 						<TextArea rows={2} maxLength={50} showCount placeholder="请输入标题" />
 					</Form.Item>
+				) : (
+					<Form.Item
+						label="自定义标题"
+						name="title"
+						rules={[{ required: true, message: '请输入自定义标题' }]}
+					>
+						<TextArea disabled rows={2} maxLength={50} showCount placeholder="请输入标题" />
+					</Form.Item>
 				)}
 
 				{/* Cover Section */}
@@ -221,6 +235,12 @@ const EditTitleCoverModal: React.FC<EditTitleCoverModalProps> = ({ visible, onCa
 					</Radio.Group>
 				</Form.Item>
 
+				{ 
+					coverType === 'original' && (
+						<img src={video?.cover} referrerPolicy="no-referrer" className="w-200 h-100 object-cover" />
+					)
+				}
+
 				{/* Screenshot Selection */}
 				{coverType === 'screenshot' && (
 					<Form.Item label="视频截图" wrapperCol={{ offset: 4, span: 20 }}>

+ 3 - 9
src/views/publishContent/weGZH/components/publishPlanModal/index.tsx

@@ -43,13 +43,7 @@ const AddPunlishPlanModal: React.FC<AddPunlishPlanModalProps> = ({ visible, isSu
 					message.error('请至少选择一个视频'); // Use Antd message
 					return;
 				}
-				// Prepare data with potentially updated titles/thumbnails
-				const videosToSubmit = selectedVideos.map(v => ({
-					...v,
-					title: v.customTitle || v.title,
-					cover: v.customCover || v.cover,
-				}));
-				onOk({ ...values, scene: 0, videoList: videosToSubmit });
+				onOk({ ...values, scene: 0, videoList: selectedVideos });
 			})
 			.catch((info) => {
 				console.log('Validate Failed:', info);
@@ -196,7 +190,7 @@ const AddPunlishPlanModal: React.FC<AddPunlishPlanModalProps> = ({ visible, isSu
 									/>
 									<div className="p-0">
 										<Text type="secondary" className="text-xs">票圈 | 3亿人喜欢的视频平台</Text>
-										<Text className="block mt-1 mb-2 leading-tight line-clamp-2" title={video.title}>{video.title}</Text>
+										<Text className="block mt-1 mb-2 leading-tight line-clamp-2" title={video.customTitle || video.title}>{video.customTitle || video.title}</Text>
 									</div>
 									<div
 										className="relative h-[120px] bg-gray-200 cursor-pointer group/thumb"
@@ -205,7 +199,7 @@ const AddPunlishPlanModal: React.FC<AddPunlishPlanModalProps> = ({ visible, isSu
 											playVideo(video);
 										}}
 									>
-										<img src={video.cover} referrerPolicy="no-referrer" alt={video.title} className="w-full h-full object-cover" />
+										<img src={video.customCover || video.cover} referrerPolicy="no-referrer" className="w-full h-full object-cover" />
 										<div className="absolute inset-0 flex justify-center items-center cursor-pointer">
 											<CaretRightFilled className="!text-white text-4xl bg-black/20 rounded-full p-1 pl-2" />
 										</div>

+ 3 - 4
src/views/publishContent/weGZH/components/types.ts

@@ -1,13 +1,12 @@
 export interface VideoItem {
 	cover: string,
-	coverIsEdit: number,
+	customCover: string,
+	customCoverType: number,
 	score: number,
 	title: string,
-	titleIsEdit: number,
+	customTitle: string,
 	video: string,
 	videoId: number,
-	customCover: string,
-	customTitle: string,
 } 
 
 export interface VideoListResponse {