Skip to content

Let's use AI to Earn!

草稿箱组问题

daoyianab84a5e0f623
diff --git a/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx b/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
index b8648ebe..8f89c10f 100644
--- a/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
+++ b/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
@@ -66,6 +66,17 @@ export default function CgMaterialPageCore() {
const [mediaList, setMediaList] = useState<any[]>([]);
const [selectedCover, setSelectedCover] = useState<string | null>(null);
const [selectedMaterials, setSelectedMaterials] = useState<string[]>([]);
+
+ // 视频组专用:封面组和视频组分别选择
+ const [coverGroupModal, setCoverGroupModal] = useState(false);
+ const [videoGroupModal, setVideoGroupModal] = useState(false);
+ const [coverGroups, setCoverGroups] = useState<any[]>([]);
+ const [videoGroups, setVideoGroups] = useState<any[]>([]);
+ const [selectedCoverGroup, setSelectedCoverGroup] = useState<any>(null);
+ const [selectedVideoGroup, setSelectedVideoGroup] = useState<any>(null);
+ const [coverList, setCoverList] = useState<any[]>([]);
+ const [videoList, setVideoList] = useState<any[]>([]);
+
// 单个素材位置
const [singleLocation, setSingleLocation] = useState<[number, number]>([0, 0]);
@@ -109,6 +120,18 @@ export default function CgMaterialPageCore() {
const [editMaterialSelectedCover, setEditMaterialSelectedCover] = useState<string | null>(null);
const [editMaterialSelectedMaterials, setEditMaterialSelectedMaterials] = useState<string[]>([]);
const [editMaterialLocation, setEditMaterialLocation] = useState<[number, number]>([0, 0]);
+
+ // 编辑素材:视频组专用状态
+ const [editMaterialCoverGroups, setEditMaterialCoverGroups] = useState<any[]>([]);
+ const [editMaterialVideoGroups, setEditMaterialVideoGroups] = useState<any[]>([]);
+ const [editMaterialSelectedCoverGroup, setEditMaterialSelectedCoverGroup] = useState<any>(null);
+ const [editMaterialSelectedVideoGroup, setEditMaterialSelectedVideoGroup] = useState<any>(null);
+ const [editMaterialCoverList, setEditMaterialCoverList] = useState<any[]>([]);
+ const [editMaterialVideoList, setEditMaterialVideoList] = useState<any[]>([]);
+
+ // 编辑素材弹窗状态
+ const [editMaterialCoverGroupModal, setEditMaterialCoverGroupModal] = useState(false);
+ const [editMaterialVideoGroupModal, setEditMaterialVideoGroupModal] = useState(false);
// 记录显示操作按钮的组id
const [showActionsId, setShowActionsId] = useState<string | null>(null);
@@ -194,8 +217,35 @@ export default function CgMaterialPageCore() {
setMediaList([]);
setSelectedCover(null);
setSelectedMaterials([]);
+
+ // 重置视频组专用状态
+ setSelectedCoverGroup(null);
+ setSelectedVideoGroup(null);
+ setCoverList([]);
+ setVideoList([]);
+
+ // 根据草稿箱组类型过滤媒体组
const res = await getMediaGroupList(1, 50);
- setMediaGroups(((res?.data as any)?.list as any[]) || []);
+ const allGroups = ((res?.data as any)?.list as any[]) || [];
+
+ // 根据当前选中的草稿箱组类型过滤媒体组
+ if (selectedGroup) {
+ if (selectedGroup.type === PubType.ImageText) {
+ // 图文组:只能选择图片组
+ const filteredGroups = allGroups.filter((g: any) => g.type === 'img');
+ setMediaGroups(filteredGroups);
+ } else if (selectedGroup.type === PubType.VIDEO) {
+ // 视频组:分别设置封面组(图片组)和视频组
+ const imgGroups = allGroups.filter((g: any) => g.type === 'img');
+ const videoGroups = allGroups.filter((g: any) => g.type === 'video');
+ setCoverGroups(imgGroups);
+ setVideoGroups(videoGroups);
+ setMediaGroups([]); // 清空普通媒体组
+ }
+ } else {
+ setMediaGroups(allGroups);
+ }
+
// 获取地理位置
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
@@ -225,20 +275,93 @@ export default function CgMaterialPageCore() {
setSelectedMaterials([]);
}
+ // 选择封面组后,加载封面资源
+ async function handleSelectCoverGroup(group: any) {
+ setSelectedCoverGroup(group);
+ setCoverGroupModal(false);
+ const res = await getMediaList(group._id, 1, 100);
+ // @ts-ignore
+ setCoverList(res?.data?.list || []);
+ setSelectedCover(null);
+ }
+
+ // 选择视频组后,加载视频资源
+ async function handleSelectVideoGroup(group: any) {
+ setSelectedVideoGroup(group);
+ setVideoGroupModal(false);
+ const res = await getMediaList(group._id, 1, 100);
+ // @ts-ignore
+ setVideoList(res?.data?.list || []);
+ setSelectedMaterials([]);
+ }
+
// 创建单个素材
async function handleCreateMaterial() {
await form.validateFields(); // 先校验
const values = form.getFieldsValue(); // 再获取所有值
- if (!selectedMediaGroup || !selectedCover || selectedMaterials.length === 0) {
- message.warning('请完整选择媒体组、封面和素材');
- return;
+
+ // 根据草稿箱组类型进行不同的验证
+ if (selectedGroup.type === PubType.ImageText) {
+ // 图文组:必须有媒体组、封面和素材,且都是图片
+ if (!selectedMediaGroup) {
+ message.warning('请选择媒体组');
+ return;
+ }
+ if (!selectedCover || selectedMaterials.length === 0) {
+ message.warning('请完整选择封面和素材');
+ return;
+ }
+ // 检查是否都是图片类型
+ const selectedMediaItems = mediaList.filter((m: any) =>
+ selectedMaterials.includes(m.url) || selectedCover === m.url
+ );
+ const hasVideo = selectedMediaItems.some((m: any) => m.type === 'video');
+ if (hasVideo) {
+ message.warning('图文组不能选择视频素材');
+ return;
+ }
+ } else if (selectedGroup.type === PubType.VIDEO) {
+ // 视频组:必须有封面组、视频组、封面和视频素材
+ if (!selectedCoverGroup) {
+ message.warning('请选择封面组(图片组)');
+ return;
+ }
+ if (!selectedVideoGroup) {
+ message.warning('请选择视频组');
+ return;
+ }
+ if (!selectedCover) {
+ message.warning('请选择封面(图片)');
+ return;
+ }
+ if (selectedMaterials.length === 0) {
+ message.warning('请选择视频素材');
+ return;
+ }
+ // 检查封面是否为图片
+ const coverItem = coverList.find((m: any) => m.url === selectedCover);
+ if (coverItem && coverItem.type !== 'img') {
+ message.warning('封面必须是图片');
+ return;
+ }
+ // 检查素材是否都是视频
+ const selectedMediaItems = videoList.filter((m: any) => selectedMaterials.includes(m.url));
+ const hasImage = selectedMediaItems.some((m: any) => m.type === 'img');
+ if (hasImage) {
+ message.warning('视频组只能选择视频素材');
+ return;
+ }
}
+
setCreating(true);
try {
+ // 根据类型使用不同的媒体列表
+ const finalMediaList = selectedGroup.type === PubType.VIDEO ? videoList : mediaList;
+
await apiCreateMaterial({
groupId: selectedGroup._id,
- coverUrl: selectedCover,
- mediaList: mediaList
+ coverUrl: selectedCover || undefined,
+ mediaList: finalMediaList
.filter((m: any) => selectedMaterials.includes(m.url))
.map((m: any) => ({
url: m.url,
@@ -252,8 +375,20 @@ export default function CgMaterialPageCore() {
});
message.success('创建素材成功');
setCreateModal(false);
- fetchMaterialList(selectedGroup._id);
+ // 重置创建素材相关状态
+ setSelectedMediaGroup(null);
+ setMediaList([]);
+ setSelectedCover(null);
+ setSelectedMaterials([]);
+ setSelectedCoverGroup(null);
+ setSelectedVideoGroup(null);
+ setCoverList([]);
+ setVideoList([]);
+ setMediaGroupModal(false);
+ setCoverGroupModal(false);
+ setVideoGroupModal(false);
form.resetFields();
+ fetchMaterialList(selectedGroup._id);
} catch (e) {
message.error('创建素材失败');
} finally {
@@ -388,9 +523,33 @@ export default function CgMaterialPageCore() {
setEditingMaterial(material);
setEditMaterialModal(true);
+ // 重置视频组专用状态
+ setEditMaterialSelectedCoverGroup(null);
+ setEditMaterialSelectedVideoGroup(null);
+ setEditMaterialCoverList([]);
+ setEditMaterialVideoList([]);
+
// 加载媒体组
const res = await getMediaGroupList(1, 50);
- setEditMaterialMediaGroups(((res?.data as any)?.list as any[]) || []);
+ const allGroups = ((res?.data as any)?.list as any[]) || [];
+
+ // 根据草稿箱组类型过滤媒体组
+ if (selectedGroup) {
+ if (selectedGroup.type === PubType.ImageText) {
+ // 图文组:只能选择图片组
+ const filteredGroups = allGroups.filter((g: any) => g.type === 'img');
+ setEditMaterialMediaGroups(filteredGroups);
+ } else if (selectedGroup.type === PubType.VIDEO) {
+ // 视频组:分别设置封面组(图片组)和视频组
+ const imgGroups = allGroups.filter((g: any) => g.type === 'img');
+ const videoGroups = allGroups.filter((g: any) => g.type === 'video');
+ setEditMaterialCoverGroups(imgGroups);
+ setEditMaterialVideoGroups(videoGroups);
+ setEditMaterialMediaGroups([]); // 清空普通媒体组
+ }
+ } else {
+ setEditMaterialMediaGroups(allGroups);
+ }
// 设置表单初始值
editMaterialForm.setFieldsValue({
@@ -429,21 +588,88 @@ export default function CgMaterialPageCore() {
setEditMaterialMediaList(((res?.data as any)?.list as any[]) || []);
}
+ // 选择编辑素材的封面组
+ async function handleEditMaterialSelectCoverGroup(group: any) {
+ setEditMaterialSelectedCoverGroup(group);
+ setEditMaterialCoverGroupModal(false);
+ const res = await getMediaList(group._id, 1, 100);
+ setEditMaterialCoverList(((res?.data as any)?.list as any[]) || []);
+ }
+
+ // 选择编辑素材的视频组
+ async function handleEditMaterialSelectVideoGroup(group: any) {
+ setEditMaterialSelectedVideoGroup(group);
+ setEditMaterialVideoGroupModal(false);
+ const res = await getMediaList(group._id, 1, 100);
+ setEditMaterialVideoList(((res?.data as any)?.list as any[]) || []);
+ }
+
// 更新素材
async function handleUpdateMaterial() {
await editMaterialForm.validateFields();
const values = editMaterialForm.getFieldsValue();
- if (!editMaterialSelectedCover || editMaterialSelectedMaterials.length === 0) {
- message.warning('请完整选择封面和素材');
- return;
+ // 根据草稿箱组类型进行不同的验证
+ if (selectedGroup.type === PubType.ImageText) {
+ // 图文组:必须有媒体组、封面和素材,且都是图片
+ if (!editMaterialSelectedGroup) {
+ message.warning('请选择媒体组');
+ return;
+ }
+ if (!editMaterialSelectedCover || editMaterialSelectedMaterials.length === 0) {
+ message.warning('请完整选择封面和素材');
+ return;
+ }
+ // 检查是否都是图片类型
+ const selectedMediaItems = editMaterialMediaList.filter((m: any) =>
+ editMaterialSelectedMaterials.includes(m.url) || editMaterialSelectedCover === m.url
+ );
+ const hasVideo = selectedMediaItems.some((m: any) => m.type === 'video');
+ if (hasVideo) {
+ message.warning('图文组不能选择视频素材');
+ return;
+ }
+ } else if (selectedGroup.type === PubType.VIDEO) {
+ // 视频组:必须有封面组、视频组、封面和视频素材
+ if (!editMaterialSelectedCoverGroup) {
+ message.warning('请选择封面组(图片组)');
+ return;
+ }
+ if (!editMaterialSelectedVideoGroup) {
+ message.warning('请选择视频组');
+ return;
+ }
+ if (!editMaterialSelectedCover) {
+ message.warning('请选择封面(图片)');
+ return;
+ }
+ if (editMaterialSelectedMaterials.length === 0) {
+ message.warning('请选择视频素材');
+ return;
+ }
+ // 检查封面是否为图片
+ const coverItem = editMaterialCoverList.find((m: any) => m.url === editMaterialSelectedCover);
+ if (coverItem && coverItem.type !== 'img') {
+ message.warning('封面必须是图片');
+ return;
+ }
+ // 检查素材是否都是视频
+ const selectedMediaItems = editMaterialVideoList.filter((m: any) => editMaterialSelectedMaterials.includes(m.url));
+ const hasImage = selectedMediaItems.some((m: any) => m.type === 'img');
+ if (hasImage) {
+ message.warning('视频组只能选择视频素材');
+ return;
+ }
}
setEditMaterialLoading(true);
try {
+ // 根据类型使用不同的媒体列表
+ const finalMediaList = selectedGroup.type === PubType.VIDEO ? editMaterialVideoList : editMaterialMediaList;
+
await apiUpdateMaterial(editingMaterial._id, {
- coverUrl: editMaterialSelectedCover,
- mediaList: editMaterialMediaList
+ coverUrl: editMaterialSelectedCover || undefined,
+ mediaList: finalMediaList
.filter((m: any) => editMaterialSelectedMaterials.includes(m.url))
.map((m: any) => ({
url: m.url,
@@ -459,6 +685,17 @@ export default function CgMaterialPageCore() {
message.success('更新素材成功');
setEditMaterialModal(false);
setEditingMaterial(null);
+ // 重置编辑素材相关状态
+ setEditMaterialSelectedGroup(null);
+ setEditMaterialMediaList([]);
+ setEditMaterialSelectedCover(null);
+ setEditMaterialSelectedMaterials([]);
+ setEditMaterialSelectedCoverGroup(null);
+ setEditMaterialSelectedVideoGroup(null);
+ setEditMaterialCoverList([]);
+ setEditMaterialVideoList([]);
+ setEditMaterialCoverGroupModal(false);
+ setEditMaterialVideoGroupModal(false);
editMaterialForm.resetFields();
fetchMaterialList(selectedGroup._id);
} catch (e) {
@@ -771,11 +1008,27 @@ export default function CgMaterialPageCore() {
onClick={() => { setDetailData(item); setDetailModal(true); }}
>
{item.coverUrl && (
- <img
- src={getOssUrl(item.coverUrl)}
- alt="cover"
- className={styles.cardCover}
- />
+ selectedGroup?.type === PubType.VIDEO && item.mediaList?.some((m: any) => m.type === 'video') ? (
+ // <video
+ // src={getOssUrl(item.coverUrl)}
+ // className={styles.cardCover}
+ // muted
+ // loop
+ // onMouseEnter={(e) => (e.target as HTMLVideoElement).play()}
+ // onMouseLeave={(e) => (e.target as HTMLVideoElement).pause()}
+ // />
+ <img
+ src={getOssUrl(item.coverUrl)}
+ alt="cover"
+ className={styles.cardCover}
+ />
+ ) : (
+ <img
+ src={getOssUrl(item.coverUrl)}
+ alt="cover"
+ className={styles.cardCover}
+ />
+ )
)}
<div className={styles.cardContent}>
<div className={styles.cardTitle}>{item.title}</div>
@@ -967,140 +1220,412 @@ export default function CgMaterialPageCore() {
open={createModal}
title="创建素材"
onOk={handleCreateMaterial}
- onCancel={()=>setCreateModal(false)}
+ onCancel={() => {
+ setCreateModal(false);
+ // 重置创建素材相关状态
+ setSelectedMediaGroup(null);
+ setMediaList([]);
+ setSelectedCover(null);
+ setSelectedMaterials([]);
+ setSelectedCoverGroup(null);
+ setSelectedVideoGroup(null);
+ setCoverList([]);
+ setVideoList([]);
+ setMediaGroupModal(false);
+ setCoverGroupModal(false);
+ setVideoGroupModal(false);
+ form.resetFields();
+ }}
confirmLoading={creating}
width={700}
>
- {/* 媒体组选择弹窗 */}
- <Modal
- open={mediaGroupModal}
- title={t('selectMediaGroup')}
- onCancel={() => setMediaGroupModal(false)}
- footer={null}
- width={700}
- >
- <div style={{ marginBottom: 16 }}>
- <div style={{ color: '#666', fontSize: 14 }}>
- {t('selectMediaGroupDesc')}
+ {/* 图文组:媒体组选择弹窗 */}
+ {selectedGroup?.type === PubType.ImageText && (
+ <Modal
+ open={mediaGroupModal}
+ title={t('selectMediaGroup')}
+ onCancel={() => setMediaGroupModal(false)}
+ footer={null}
+ width={700}
+ >
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ color: '#666', fontSize: 14 }}>
+ {t('selectMediaGroupDesc')}
+ </div>
</div>
- </div>
- <List
- grid={{ gutter: 16, column: 2 }}
- dataSource={mediaGroups}
- renderItem={item => (
- <List.Item>
- <div
- className={styles.mediaCard}
- style={{
- background: selectedMediaGroup?._id === item._id ?
- 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
- '#FAEFFC',
- border: selectedMediaGroup?._id === item._id ?
- '2px solid #667eea' : '2px solid transparent',
- padding: '20px',
- borderRadius: '12px',
- cursor: 'pointer',
- transition: 'all 0.3s ease',
- minHeight: '100px',
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'center',
- textAlign: 'center'
- }}
- onClick={() => handleSelectMediaGroup(item)}
- onMouseEnter={(e) => {
- if (selectedMediaGroup?._id !== item._id) {
- e.currentTarget.style.transform = 'translateY(-2px)';
- e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
- }
- }}
- onMouseLeave={(e) => {
- if (selectedMediaGroup?._id !== item._id) {
- e.currentTarget.style.transform = 'translateY(0)';
- e.currentTarget.style.boxShadow = 'none';
- }
- }}
- >
- <div style={{
- fontSize: 24,
- marginBottom: 8,
- color: selectedMediaGroup?._id === item._id ? '#667eea' : '#bdc3c7'
- }}>
- <FolderOpenOutlined />
- </div>
- <div style={{
- fontWeight: 600,
- fontSize: 16,
- color: '#2c3e50',
- marginBottom: 4
- }}>
- {item.title}
- </div>
- {/* 类型标签 */}
- <div style={{
- position: 'absolute',
- top: 8,
- left: 8,
- padding: '2px 8px',
- borderRadius: '12px',
- fontSize: '10px',
- fontWeight: '500',
- color: '#fff',
- background: item.type === 'img' ? '#52c41a' :
- item.type === 'video' ? '#1890ff' : '#722ed1',
- zIndex: 1
- }}>
- {item.type === 'img' ? t('mediaGroupType.img') :
- item.type === 'video' ? t('mediaGroupType.video') : t('mediaGroupType.mixed')}
- </div>
- {item.desc && (
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={mediaGroups}
+ renderItem={item => (
+ <List.Item>
+ <div
+ className={styles.mediaCard}
+ style={{
+ background: selectedMediaGroup?._id === item._id ?
+ 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
+ '#FAEFFC',
+ border: selectedMediaGroup?._id === item._id ?
+ '2px solid #667eea' : '2px solid transparent',
+ padding: '20px',
+ borderRadius: '12px',
+ cursor: 'pointer',
+ transition: 'all 0.3s ease',
+ minHeight: '100px',
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'center',
+ alignItems: 'center',
+ textAlign: 'center'
+ }}
+ onClick={() => handleSelectMediaGroup(item)}
+ onMouseEnter={(e) => {
+ if (selectedMediaGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(-2px)';
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (selectedMediaGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(0)';
+ e.currentTarget.style.boxShadow = 'none';
+ }
+ }}
+ >
+ <div style={{
+ fontSize: 24,
+ marginBottom: 8,
+ color: selectedMediaGroup?._id === item._id ? '#667eea' : '#bdc3c7'
+ }}>
+ <FolderOpenOutlined />
+ </div>
<div style={{
- fontSize: 12,
- color: '#7f8c8d',
- lineHeight: 1.4,
+ fontWeight: 600,
+ fontSize: 16,
+ color: '#2c3e50',
+ marginBottom: 4
+ }}>
+ {item.title}
+ </div>
+ {/* 类型标签 */}
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ left: 8,
+ padding: '2px 8px',
+ borderRadius: '12px',
+ fontSize: '10px',
+ fontWeight: '500',
+ color: '#fff',
+ background: item.type === 'img' ? '#52c41a' :
+ item.type === 'video' ? '#1890ff' : '#722ed1',
+ zIndex: 1
+ }}>
+ {item.type === 'img' ? t('mediaGroupType.img') :
+ item.type === 'video' ? t('mediaGroupType.video') : t('mediaGroupType.mixed')}
+ </div>
+ {item.desc && (
+ <div style={{
+ fontSize: 12,
+ color: '#7f8c8d',
+ lineHeight: 1.4,
+ marginTop: 4
+ }}>
+ {item.desc}
+ </div>
+ )}
+ {/* 资源数量 */}
+ <div style={{
+ fontSize: 11,
+ color: '#95a5a6',
marginTop: 4
}}>
- {item.desc}
+ {item.mediaCount || 0} {t('mediaCount')}
</div>
- )}
- {/* 资源数量 */}
- <div style={{
- fontSize: 11,
- color: '#95a5a6',
- marginTop: 4
- }}>
- {item.mediaCount || 0} {t('mediaCount')}
+ {selectedMediaGroup?._id === item._id && (
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ right: 8,
+ width: 20,
+ height: 20,
+ borderRadius: '50%',
+ background: '#667eea',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ color: 'white',
+ fontSize: 12,
+ zIndex: 2
+ }}>
+ ✓
+ </div>
+ )}
</div>
- {selectedMediaGroup?._id === item._id && (
+ </List.Item>
+ )}
+ />
+ </Modal>
+ )}
+
+ {/* 视频组:封面组选择弹窗 */}
+ {selectedGroup?.type === PubType.VIDEO && (
+ <Modal
+ open={coverGroupModal}
+ title="选择封面组(图片组)"
+ onCancel={() => setCoverGroupModal(false)}
+ footer={null}
+ width={700}
+ >
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ color: '#666', fontSize: 14 }}>
+ 选择一个图片组作为封面来源
+ </div>
+ </div>
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={coverGroups}
+ renderItem={item => (
+ <List.Item>
+ <div
+ className={styles.mediaCard}
+ style={{
+ background: selectedCoverGroup?._id === item._id ?
+ 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
+ '#FAEFFC',
+ border: selectedCoverGroup?._id === item._id ?
+ '2px solid #667eea' : '2px solid transparent',
+ padding: '20px',
+ borderRadius: '12px',
+ cursor: 'pointer',
+ transition: 'all 0.3s ease',
+ minHeight: '100px',
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'center',
+ alignItems: 'center',
+ textAlign: 'center'
+ }}
+ onClick={() => handleSelectCoverGroup(item)}
+ onMouseEnter={(e) => {
+ if (selectedCoverGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(-2px)';
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (selectedCoverGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(0)';
+ e.currentTarget.style.boxShadow = 'none';
+ }
+ }}
+ >
+ <div style={{
+ fontSize: 24,
+ marginBottom: 8,
+ color: selectedCoverGroup?._id === item._id ? '#667eea' : '#bdc3c7'
+ }}>
+ <FolderOpenOutlined />
+ </div>
+ <div style={{
+ fontWeight: 600,
+ fontSize: 16,
+ color: '#2c3e50',
+ marginBottom: 4
+ }}>
+ {item.title}
+ </div>
+ {/* 类型标签 */}
<div style={{
position: 'absolute',
top: 8,
- right: 8,
- width: 20,
- height: 20,
- borderRadius: '50%',
- background: '#667eea',
+ left: 8,
+ padding: '2px 8px',
+ borderRadius: '12px',
+ fontSize: '10px',
+ fontWeight: '500',
+ color: '#fff',
+ background: '#52c41a',
+ zIndex: 1
+ }}>
+ {t('mediaGroupType.img')}
+ </div>
+ {item.desc && (
+ <div style={{
+ fontSize: 12,
+ color: '#7f8c8d',
+ lineHeight: 1.4,
+ marginTop: 4
+ }}>
+ {item.desc}
+ </div>
+ )}
+ {/* 资源数量 */}
+ <div style={{
+ fontSize: 11,
+ color: '#95a5a6',
+ marginTop: 4
+ }}>
+ {item.mediaCount || 0} {t('mediaCount')}
+ </div>
+ {selectedCoverGroup?._id === item._id && (
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ right: 8,
+ width: 20,
+ height: 20,
+ borderRadius: '50%',
+ background: '#667eea',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ color: 'white',
+ fontSize: 12,
+ zIndex: 2
+ }}>
+ ✓
+ </div>
+ )}
+ </div>
+ </List.Item>
+ )}
+ />
+ </Modal>
+ )}
+
+ {/* 视频组:视频组选择弹窗 */}
+ {selectedGroup?.type === PubType.VIDEO && (
+ <Modal
+ open={videoGroupModal}
+ title="选择视频组"
+ onCancel={() => setVideoGroupModal(false)}
+ footer={null}
+ width={700}
+ >
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ color: '#666', fontSize: 14 }}>
+ 选择一个视频组作为视频素材来源
+ </div>
+ </div>
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={videoGroups}
+ renderItem={item => (
+ <List.Item>
+ <div
+ className={styles.mediaCard}
+ style={{
+ background: selectedVideoGroup?._id === item._id ?
+ 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
+ '#FAEFFC',
+ border: selectedVideoGroup?._id === item._id ?
+ '2px solid #667eea' : '2px solid transparent',
+ padding: '20px',
+ borderRadius: '12px',
+ cursor: 'pointer',
+ transition: 'all 0.3s ease',
+ minHeight: '100px',
display: 'flex',
- alignItems: 'center',
+ flexDirection: 'column',
justifyContent: 'center',
- color: 'white',
- fontSize: 12,
- zIndex: 2
+ alignItems: 'center',
+ textAlign: 'center'
+ }}
+ onClick={() => handleSelectVideoGroup(item)}
+ onMouseEnter={(e) => {
+ if (selectedVideoGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(-2px)';
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (selectedVideoGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(0)';
+ e.currentTarget.style.boxShadow = 'none';
+ }
+ }}
+ >
+ <div style={{
+ fontSize: 24,
+ marginBottom: 8,
+ color: selectedVideoGroup?._id === item._id ? '#667eea' : '#bdc3c7'
}}>
- ✓
+ <VideoCameraOutlined />
</div>
- )}
- </div>
- </List.Item>
- )}
- />
- </Modal>
- {/* 资源选择区 */}
- {selectedMediaGroup && (
+ <div style={{
+ fontWeight: 600,
+ fontSize: 16,
+ color: '#2c3e50',
+ marginBottom: 4
+ }}>
+ {item.title}
+ </div>
+ {/* 类型标签 */}
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ left: 8,
+ padding: '2px 8px',
+ borderRadius: '12px',
+ fontSize: '10px',
+ fontWeight: '500',
+ color: '#fff',
+ background: '#1890ff',
+ zIndex: 1
+ }}>
+ {t('mediaGroupType.video')}
+ </div>
+ {item.desc && (
+ <div style={{
+ fontSize: 12,
+ color: '#7f8c8d',
+ lineHeight: 1.4,
+ marginTop: 4
+ }}>
+ {item.desc}
+ </div>
+ )}
+ {/* 资源数量 */}
+ <div style={{
+ fontSize: 11,
+ color: '#95a5a6',
+ marginTop: 4
+ }}>
+ {item.mediaCount || 0} {t('mediaCount')}
+ </div>
+ {selectedVideoGroup?._id === item._id && (
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ right: 8,
+ width: 20,
+ height: 20,
+ borderRadius: '50%',
+ background: '#667eea',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ color: 'white',
+ fontSize: 12,
+ zIndex: 2
+ }}>
+ ✓
+ </div>
+ )}
+ </div>
+ </List.Item>
+ )}
+ />
+ </Modal>
+ )}
+
+ {/* 图文组:资源选择区 */}
+ {selectedGroup?.type === PubType.ImageText && selectedMediaGroup && (
<>
<div style={{ marginBottom: 12 }}>
- <div style={{ fontWeight: 500, marginBottom: 8 }}>{t('selectCover')}</div>
+ <div style={{ fontWeight: 500, marginBottom: 8 }}>
+ {t('selectCover')}
+ </div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{mediaList.map((media: any) => (
<img
@@ -1121,7 +1646,9 @@ export default function CgMaterialPageCore() {
</div>
</div>
<div style={{ marginBottom: 12 }}>
- <div style={{ fontWeight: 500, marginBottom: 8 }}>{t('selectMaterials')}</div>
+ <div style={{ fontWeight: 500, marginBottom: 8 }}>
+ {t('selectMaterials')}
+ </div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{mediaList.map((media: any) => (
<img
@@ -1151,6 +1678,150 @@ export default function CgMaterialPageCore() {
</div>
</>
)}
+
+ {/* 视频组:资源选择区 */}
+ {selectedGroup?.type === PubType.VIDEO && (
+ <>
+ {/* 封面组选择按钮 */}
+ {!selectedCoverGroup && (
+ <div style={{ marginBottom: 16 }}>
+ <Button
+ type="dashed"
+ onClick={() => setCoverGroupModal(true)}
+ style={{ width: '100%', height: 60 }}
+ >
+ <FolderOpenOutlined style={{ marginRight: 8 }} />
+ 选择封面组(图片组)
+ </Button>
+ </div>
+ )}
+
+ {/* 视频组选择按钮 */}
+ {!selectedVideoGroup && (
+ <div style={{ marginBottom: 16 }}>
+ <Button
+ type="dashed"
+ onClick={() => setVideoGroupModal(true)}
+ style={{ width: '100%', height: 60 }}
+ >
+ <VideoCameraOutlined style={{ marginRight: 8 }} />
+ 选择视频组
+ </Button>
+ </div>
+ )}
+
+ {/* 封面选择区 */}
+ {selectedCoverGroup && (
+ <div style={{ marginBottom: 12 }}>
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
+ <div style={{ fontWeight: 500 }}>
+ 选择封面(图片,单选)
+ </div>
+ <Button
+ type="link"
+ size="small"
+ onClick={() => {
+ setSelectedCoverGroup(null);
+ setCoverList([]);
+ setSelectedCover(null);
+ }}
+ >
+ 重新选择封面组
+ </Button>
+ </div>
+ <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
+ {coverList.map((media: any) => (
+ <img
+ key={media._id}
+ src={getOssUrl(media.url)}
+ alt=""
+ style={{
+ width: 60,
+ height: 60,
+ border: selectedCover === media.url ? '2px solid #1677ff' : '1px solid #eee',
+ borderRadius: 4,
+ cursor: 'pointer',
+ objectFit: 'cover',
+ opacity: media.type !== 'img' ? 0.3 : 1,
+ }}
+ onClick={() => {
+ if (media.type !== 'img') {
+ message.warning('封面必须是图片');
+ return;
+ }
+ setSelectedCover(media.url);
+ }}
+ />
+ ))}
+ </div>
+ </div>
+ )}
+
+ {/* 视频素材选择区 */}
+ {selectedVideoGroup && (
+ <div style={{ marginBottom: 12 }}>
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
+ <div style={{ fontWeight: 500 }}>
+ 选择视频素材(单选)
+ </div>
+ <Button
+ type="link"
+ size="small"
+ onClick={() => {
+ setSelectedVideoGroup(null);
+ setVideoList([]);
+ setSelectedMaterials([]);
+ }}
+ >
+ 重新选择视频组
+ </Button>
+ </div>
+ <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
+ {videoList.map((media: any) => (
+ media.type === 'video' ? (
+ <video
+ key={media._id}
+ src={getOssUrl(media.url)}
+ style={{
+ width: 60,
+ height: 60,
+ border: selectedMaterials.includes(media.url) ? '2px solid #1677ff' : '1px solid #eee',
+ borderRadius: 4,
+ cursor: 'pointer',
+ objectFit: 'cover',
+ }}
+ onClick={() => setSelectedMaterials([media.url])}
+ muted
+ loop
+ onMouseEnter={(e) => (e.target as HTMLVideoElement).play()}
+ onMouseLeave={(e) => (e.target as HTMLVideoElement).pause()}
+ />
+ ) : (
+ <img
+ key={media._id}
+ src={getOssUrl(media.url)}
+ alt=""
+ style={{
+ width: 60,
+ height: 60,
+ border: selectedMaterials.includes(media.url) ? '2px solid #1677ff' : '1px solid #eee',
+ borderRadius: 4,
+ cursor: 'pointer',
+ objectFit: 'cover',
+ opacity: 0.3,
+ }}
+ onClick={() => {
+ message.warning('视频组只能选择视频素材');
+ }}
+ />
+ )
+ ))}
+ </div>
+ </div>
+ )}
+ </>
+ )}
+
{/* 表单区 */}
<Form form={form} layout="vertical">
<Form.Item label={t('title')} name="title" rules={[{ required: true, message: '请输入标题' }]}>
@@ -1292,11 +1963,13 @@ export default function CgMaterialPageCore() {
<b>封面:</b>
<div style={{marginTop:4}}>
{detailData.coverUrl && (
- <img
- src={getOssUrl(detailData.coverUrl)}
- alt="cover"
- style={{width:'100%',maxWidth:320,height:120,objectFit:'cover',borderRadius:8,display:'block'}}
- />
+
+ <img
+ src={getOssUrl(detailData.coverUrl)}
+ alt="cover"
+ style={{maxWidth:320, objectFit:'cover',borderRadius:8,display:'block'}}
+ />
+
)}
</div>
</div>
@@ -1306,11 +1979,19 @@ export default function CgMaterialPageCore() {
<Carousel dots style={{marginTop:8}}>
{detailData.mediaList.map((media: any, idx: number) => (
<div key={idx}>
- <img
- src={getOssUrl(media.url)}
- alt="素材图片"
- style={{width:'100%',height:'320px',objectFit:'cover',borderRadius:8}}
- />
+ {media.type === 'video' ? (
+ <video
+ src={getOssUrl(media.url)}
+ controls
+ style={{width:'100%',height:'320px',objectFit:'cover',borderRadius:8}}
+ />
+ ) : (
+ <img
+ src={getOssUrl(media.url)}
+ alt="素材图片"
+ style={{width:'100%',height:'320px',objectFit:'cover',borderRadius:8}}
+ />
+ )}
</div>
))}
</Carousel>
@@ -1351,104 +2032,370 @@ export default function CgMaterialPageCore() {
setEditMaterialModal(false);
setEditingMaterial(null);
editMaterialForm.resetFields();
+ // 重置编辑素材相关状态
+ setEditMaterialSelectedGroup(null);
+ setEditMaterialMediaList([]);
+ setEditMaterialSelectedCover(null);
+ setEditMaterialSelectedMaterials([]);
+ setEditMaterialSelectedCoverGroup(null);
+ setEditMaterialSelectedVideoGroup(null);
+ setEditMaterialCoverList([]);
+ setEditMaterialVideoList([]);
+ setEditMaterialCoverGroupModal(false);
+ setEditMaterialVideoGroupModal(false);
}}
confirmLoading={editMaterialLoading}
width={700}
>
- {/* 媒体组选择 */}
- <div style={{ marginBottom: 16 }}>
- <div style={{ fontWeight: 500, marginBottom: 8 }}>选择媒体组</div>
- <List
- grid={{ gutter: 16, column: 2 }}
- dataSource={editMaterialMediaGroups}
- renderItem={item => (
- <List.Item>
- <div
- className={styles.mediaCard}
- style={{
- background: editMaterialSelectedGroup?._id === item._id ?
- 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
- '#FAEFFC',
- border: editMaterialSelectedGroup?._id === item._id ?
- '2px solid #667eea' : '2px solid transparent',
- padding: '20px',
- borderRadius: '12px',
- cursor: 'pointer',
- transition: 'all 0.3s ease',
- minHeight: '100px',
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'center',
- textAlign: 'center'
- }}
- onClick={() => handleEditMaterialSelectGroup(item)}
- onMouseEnter={(e) => {
- if (editMaterialSelectedGroup?._id !== item._id) {
- e.currentTarget.style.transform = 'translateY(-2px)';
- e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
- }
- }}
- onMouseLeave={(e) => {
- if (editMaterialSelectedGroup?._id !== item._id) {
- e.currentTarget.style.transform = 'translateY(0)';
- e.currentTarget.style.boxShadow = 'none';
- }
- }}
- >
- <div style={{
- fontSize: 24,
- marginBottom: 8,
- color: editMaterialSelectedGroup?._id === item._id ? '#667eea' : '#bdc3c7'
- }}>
- <FolderOpenOutlined />
- </div>
- <div style={{
- fontWeight: 600,
- fontSize: 16,
- color: '#2c3e50',
- marginBottom: 4
- }}>
- {item.title}
- </div>
- {item.desc && (
+ {/* 编辑素材:封面组选择弹窗 */}
+ {selectedGroup?.type === PubType.VIDEO && (
+ <Modal
+ open={editMaterialCoverGroupModal}
+ title="选择封面组(图片组)"
+ onCancel={() => setEditMaterialCoverGroupModal(false)}
+ footer={null}
+ width={700}
+ >
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ color: '#666', fontSize: 14 }}>
+ 选择一个图片组作为封面来源
+ </div>
+ </div>
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={editMaterialCoverGroups}
+ renderItem={item => (
+ <List.Item>
+ <div
+ className={styles.mediaCard}
+ style={{
+ background: editMaterialSelectedCoverGroup?._id === item._id ?
+ 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
+ '#FAEFFC',
+ border: editMaterialSelectedCoverGroup?._id === item._id ?
+ '2px solid #667eea' : '2px solid transparent',
+ padding: '20px',
+ borderRadius: '12px',
+ cursor: 'pointer',
+ transition: 'all 0.3s ease',
+ minHeight: '100px',
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'center',
+ alignItems: 'center',
+ textAlign: 'center'
+ }}
+ onClick={() => handleEditMaterialSelectCoverGroup(item)}
+ onMouseEnter={(e) => {
+ if (editMaterialSelectedCoverGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(-2px)';
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (editMaterialSelectedCoverGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(0)';
+ e.currentTarget.style.boxShadow = 'none';
+ }
+ }}
+ >
<div style={{
- fontSize: 12,
- color: '#7f8c8d',
- lineHeight: 1.4
+ fontSize: 24,
+ marginBottom: 8,
+ color: editMaterialSelectedCoverGroup?._id === item._id ? '#667eea' : '#bdc3c7'
}}>
- {item.desc}
+ <FolderOpenOutlined />
</div>
- )}
- {editMaterialSelectedGroup?._id === item._id && (
+ <div style={{
+ fontWeight: 600,
+ fontSize: 16,
+ color: '#2c3e50',
+ marginBottom: 4
+ }}>
+ {item.title}
+ </div>
+ {/* 类型标签 */}
<div style={{
position: 'absolute',
top: 8,
- right: 8,
- width: 20,
- height: 20,
- borderRadius: '50%',
- background: '#667eea',
+ left: 8,
+ padding: '2px 8px',
+ borderRadius: '12px',
+ fontSize: '10px',
+ fontWeight: '500',
+ color: '#fff',
+ background: '#52c41a',
+ zIndex: 1
+ }}>
+ {t('mediaGroupType.img')}
+ </div>
+ {item.desc && (
+ <div style={{
+ fontSize: 12,
+ color: '#7f8c8d',
+ lineHeight: 1.4,
+ marginTop: 4
+ }}>
+ {item.desc}
+ </div>
+ )}
+ {/* 资源数量 */}
+ <div style={{
+ fontSize: 11,
+ color: '#95a5a6',
+ marginTop: 4
+ }}>
+ {item.mediaCount || 0} {t('mediaCount')}
+ </div>
+ {editMaterialSelectedCoverGroup?._id === item._id && (
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ right: 8,
+ width: 20,
+ height: 20,
+ borderRadius: '50%',
+ background: '#667eea',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ color: 'white',
+ fontSize: 12,
+ zIndex: 2
+ }}>
+ ✓
+ </div>
+ )}
+ </div>
+ </List.Item>
+ )}
+ />
+ </Modal>
+ )}
+
+ {/* 编辑素材:视频组选择弹窗 */}
+ {selectedGroup?.type === PubType.VIDEO && (
+ <Modal
+ open={editMaterialVideoGroupModal}
+ title="选择视频组"
+ onCancel={() => setEditMaterialVideoGroupModal(false)}
+ footer={null}
+ width={700}
+ >
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ color: '#666', fontSize: 14 }}>
+ 选择一个视频组作为视频素材来源
+ </div>
+ </div>
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={editMaterialVideoGroups}
+ renderItem={item => (
+ <List.Item>
+ <div
+ className={styles.mediaCard}
+ style={{
+ background: editMaterialSelectedVideoGroup?._id === item._id ?
+ 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
+ '#FAEFFC',
+ border: editMaterialSelectedVideoGroup?._id === item._id ?
+ '2px solid #667eea' : '2px solid transparent',
+ padding: '20px',
+ borderRadius: '12px',
+ cursor: 'pointer',
+ transition: 'all 0.3s ease',
+ minHeight: '100px',
display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'center',
alignItems: 'center',
+ textAlign: 'center'
+ }}
+ onClick={() => handleEditMaterialSelectVideoGroup(item)}
+ onMouseEnter={(e) => {
+ if (editMaterialSelectedVideoGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(-2px)';
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (editMaterialSelectedVideoGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(0)';
+ e.currentTarget.style.boxShadow = 'none';
+ }
+ }}
+ >
+ <div style={{
+ fontSize: 24,
+ marginBottom: 8,
+ color: editMaterialSelectedVideoGroup?._id === item._id ? '#667eea' : '#bdc3c7'
+ }}>
+ <VideoCameraOutlined />
+ </div>
+ <div style={{
+ fontWeight: 600,
+ fontSize: 16,
+ color: '#2c3e50',
+ marginBottom: 4
+ }}>
+ {item.title}
+ </div>
+ {/* 类型标签 */}
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ left: 8,
+ padding: '2px 8px',
+ borderRadius: '12px',
+ fontSize: '10px',
+ fontWeight: '500',
+ color: '#fff',
+ background: '#1890ff',
+ zIndex: 1
+ }}>
+ {t('mediaGroupType.video')}
+ </div>
+ {item.desc && (
+ <div style={{
+ fontSize: 12,
+ color: '#7f8c8d',
+ lineHeight: 1.4,
+ marginTop: 4
+ }}>
+ {item.desc}
+ </div>
+ )}
+ {/* 资源数量 */}
+ <div style={{
+ fontSize: 11,
+ color: '#95a5a6',
+ marginTop: 4
+ }}>
+ {item.mediaCount || 0} {t('mediaCount')}
+ </div>
+ {editMaterialSelectedVideoGroup?._id === item._id && (
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ right: 8,
+ width: 20,
+ height: 20,
+ borderRadius: '50%',
+ background: '#667eea',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ color: 'white',
+ fontSize: 12,
+ zIndex: 2
+ }}>
+ ✓
+ </div>
+ )}
+ </div>
+ </List.Item>
+ )}
+ />
+ </Modal>
+ )}
+ {/* 图文组:媒体组选择 */}
+ {selectedGroup?.type === PubType.ImageText && (
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ fontWeight: 500, marginBottom: 8 }}>选择媒体组</div>
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={editMaterialMediaGroups}
+ renderItem={item => (
+ <List.Item>
+ <div
+ className={styles.mediaCard}
+ style={{
+ background: editMaterialSelectedGroup?._id === item._id ?
+ 'linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%)' :
+ '#FAEFFC',
+ border: editMaterialSelectedGroup?._id === item._id ?
+ '2px solid #667eea' : '2px solid transparent',
+ padding: '20px',
+ borderRadius: '12px',
+ cursor: 'pointer',
+ transition: 'all 0.3s ease',
+ minHeight: '100px',
+ display: 'flex',
+ flexDirection: 'column',
justifyContent: 'center',
- color: 'white',
- fontSize: 12
+ alignItems: 'center',
+ textAlign: 'center'
+ }}
+ onClick={() => handleEditMaterialSelectGroup(item)}
+ onMouseEnter={(e) => {
+ if (editMaterialSelectedGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(-2px)';
+ e.currentTarget.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.2)';
+ }
+ }}
+ onMouseLeave={(e) => {
+ if (editMaterialSelectedGroup?._id !== item._id) {
+ e.currentTarget.style.transform = 'translateY(0)';
+ e.currentTarget.style.boxShadow = 'none';
+ }
+ }}
+ >
+ <div style={{
+ fontSize: 24,
+ marginBottom: 8,
+ color: editMaterialSelectedGroup?._id === item._id ? '#667eea' : '#bdc3c7'
}}>
- ✓
+ <FolderOpenOutlined />
</div>
- )}
- </div>
- </List.Item>
- )}
- />
- </div>
+ <div style={{
+ fontWeight: 600,
+ fontSize: 16,
+ color: '#2c3e50',
+ marginBottom: 4
+ }}>
+ {item.title}
+ </div>
+ {item.desc && (
+ <div style={{
+ fontSize: 12,
+ color: '#7f8c8d',
+ lineHeight: 1.4
+ }}>
+ {item.desc}
+ </div>
+ )}
+ {editMaterialSelectedGroup?._id === item._id && (
+ <div style={{
+ position: 'absolute',
+ top: 8,
+ right: 8,
+ width: 20,
+ height: 20,
+ borderRadius: '50%',
+ background: '#667eea',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ color: 'white',
+ fontSize: 12
+ }}>
+ ✓
+ </div>
+ )}
+ </div>
+ </List.Item>
+ )}
+ />
+ </div>
+ )}
- {/* 资源选择区 */}
- {editMaterialSelectedGroup && (
+ {/* 图文组:资源选择区 */}
+ {selectedGroup?.type === PubType.ImageText && editMaterialSelectedGroup && (
<>
<div style={{ marginBottom: 12 }}>
- <div style={{ fontWeight: 500, marginBottom: 8 }}>选择封面(单选)</div>
+ <div style={{ fontWeight: 500, marginBottom: 8 }}>
+ 选择封面(单选)
+ </div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{editMaterialMediaList.map((media: any) => (
<img
@@ -1469,7 +2416,9 @@ export default function CgMaterialPageCore() {
</div>
</div>
<div style={{ marginBottom: 12 }}>
- <div style={{ fontWeight: 500, marginBottom: 8 }}>选择素材(多选)</div>
+ <div style={{ fontWeight: 500, marginBottom: 8 }}>
+ 选择素材(多选)
+ </div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{editMaterialMediaList.map((media: any) => (
<img
@@ -1500,6 +2449,149 @@ export default function CgMaterialPageCore() {
</>
)}
+ {/* 视频组:资源选择区 */}
+ {selectedGroup?.type === PubType.VIDEO && (
+ <>
+ {/* 封面组选择按钮 */}
+ {!editMaterialSelectedCoverGroup && (
+ <div style={{ marginBottom: 16 }}>
+ <Button
+ type="dashed"
+ onClick={() => setEditMaterialCoverGroupModal(true)}
+ style={{ width: '100%', height: 60 }}
+ >
+ <FolderOpenOutlined style={{ marginRight: 8 }} />
+ 选择封面组(图片组)
+ </Button>
+ </div>
+ )}
+
+ {/* 视频组选择按钮 */}
+ {!editMaterialSelectedVideoGroup && (
+ <div style={{ marginBottom: 16 }}>
+ <Button
+ type="dashed"
+ onClick={() => setEditMaterialVideoGroupModal(true)}
+ style={{ width: '100%', height: 60 }}
+ >
+ <VideoCameraOutlined style={{ marginRight: 8 }} />
+ 选择视频组
+ </Button>
+ </div>
+ )}
+
+ {/* 封面选择区 */}
+ {editMaterialSelectedCoverGroup && (
+ <div style={{ marginBottom: 12 }}>
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
+ <div style={{ fontWeight: 500 }}>
+ 选择封面(图片,单选)
+ </div>
+ <Button
+ type="link"
+ size="small"
+ onClick={() => {
+ setEditMaterialSelectedCoverGroup(null);
+ setEditMaterialCoverList([]);
+ setEditMaterialSelectedCover(null);
+ }}
+ >
+ 重新选择封面组
+ </Button>
+ </div>
+ <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
+ {editMaterialCoverList.map((media: any) => (
+ <img
+ key={media._id}
+ src={getOssUrl(media.url)}
+ alt=""
+ style={{
+ width: 60,
+ height: 60,
+ border: editMaterialSelectedCover === media.url ? '2px solid #1677ff' : '1px solid #eee',
+ borderRadius: 4,
+ cursor: 'pointer',
+ objectFit: 'cover',
+ opacity: media.type !== 'img' ? 0.3 : 1,
+ }}
+ onClick={() => {
+ if (media.type !== 'img') {
+ message.warning('封面必须是图片');
+ return;
+ }
+ setEditMaterialSelectedCover(media.url);
+ }}
+ />
+ ))}
+ </div>
+ </div>
+ )}
+
+ {/* 视频素材选择区 */}
+ {editMaterialSelectedVideoGroup && (
+ <div style={{ marginBottom: 12 }}>
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
+ <div style={{ fontWeight: 500 }}>
+ 选择视频素材(单选)
+ </div>
+ <Button
+ type="link"
+ size="small"
+ onClick={() => {
+ setEditMaterialSelectedVideoGroup(null);
+ setEditMaterialVideoList([]);
+ setEditMaterialSelectedMaterials([]);
+ }}
+ >
+ 重新选择视频组
+ </Button>
+ </div>
+ <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
+ {editMaterialVideoList.map((media: any) => (
+ media.type === 'video' ? (
+ <video
+ key={media._id}
+ src={getOssUrl(media.url)}
+ style={{
+ width: 60,
+ height: 60,
+ border: editMaterialSelectedMaterials.includes(media.url) ? '2px solid #1677ff' : '1px solid #eee',
+ borderRadius: 4,
+ cursor: 'pointer',
+ objectFit: 'cover',
+ }}
+ onClick={() => setEditMaterialSelectedMaterials([media.url])}
+ muted
+ loop
+ onMouseEnter={(e) => (e.target as HTMLVideoElement).play()}
+ onMouseLeave={(e) => (e.target as HTMLVideoElement).pause()}
+ />
+ ) : (
+ <img
+ key={media._id}
+ src={getOssUrl(media.url)}
+ alt=""
+ style={{
+ width: 60,
+ height: 60,
+ border: editMaterialSelectedMaterials.includes(media.url) ? '2px solid #1677ff' : '1px solid #eee',
+ borderRadius: 4,
+ cursor: 'pointer',
+ objectFit: 'cover',
+ opacity: 0.3,
+ }}
+ onClick={() => {
+ message.warning('视频组只能选择视频素材');
+ }}
+ />
+ )
+ ))}
+ </div>
+ </div>
+ )}
+ </>
+ )}
+
{/* 表单区 */}
<Form form={editMaterialForm} layout="vertical">
<Form.Item label="标题" name="title" rules={[{ required: true, message: '请输入标题' }]}>