|
@@ -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 }}>
|