|
@@ -4,17 +4,15 @@ import type { TableProps } from 'antd';
|
|
import styles from './index.module.css';
|
|
import styles from './index.module.css';
|
|
import { WeComPlan, WeComPlanListResponse, WeComPlanType, WeVideoItem } from './type';
|
|
import { WeComPlan, WeComPlanListResponse, WeComPlanType, WeVideoItem } from './type';
|
|
import request from '@src/http/index';
|
|
import request from '@src/http/index';
|
|
-import { getQwPlanListApi, saveQwPlanApi } from "@src/http/api"
|
|
|
|
|
|
+import { getQwPlanListApi, getShareQrPic, saveQwPlanApi } from "@src/http/api"
|
|
import VideoSelectModal from './components/videoSelectModal';
|
|
import VideoSelectModal from './components/videoSelectModal';
|
|
import LinkDetailModal from './components/linkDetailModal';
|
|
import LinkDetailModal from './components/linkDetailModal';
|
|
|
|
+import PlanDetailModal from './components/planDetailModal';
|
|
import http from '@src/http/index';
|
|
import http from '@src/http/index';
|
|
-
|
|
|
|
|
|
+import copy from 'copy-to-clipboard';
|
|
|
|
+import VideoPlayModal from './components/videoPlayModal';
|
|
|
|
+import modal from 'antd/es/modal';
|
|
// Define a type for the expected API response (adjust if needed based on actual API)
|
|
// Define a type for the expected API response (adjust if needed based on actual API)
|
|
-interface SaveQwPlanResponse {
|
|
|
|
- // Assuming the response has a data field containing the created items
|
|
|
|
- // And each item is like WeVideoItem but includes a pageUrl
|
|
|
|
- createdLinks: (WeVideoItem & { pageUrl: string })[];
|
|
|
|
-}
|
|
|
|
|
|
|
|
const WeGZHContent: React.FC = () => {
|
|
const WeGZHContent: React.FC = () => {
|
|
// 状态管理
|
|
// 状态管理
|
|
@@ -30,8 +28,12 @@ const WeGZHContent: React.FC = () => {
|
|
|
|
|
|
// State for the new modal
|
|
// State for the new modal
|
|
const [isLinkDetailModalVisible, setIsLinkDetailModalVisible] = useState<boolean>(false);
|
|
const [isLinkDetailModalVisible, setIsLinkDetailModalVisible] = useState<boolean>(false);
|
|
- // State to hold data for the new modal (adjust type if needed)
|
|
|
|
- const [createdVideoLinks, setCreatedVideoLinks] = useState<(WeVideoItem & { pushLink?: string })[]>([]);
|
|
|
|
|
|
+ const [createdVideoLinks, setCreatedVideoLinks] = useState<WeComPlan[]>([]);
|
|
|
|
+
|
|
|
|
+ // State for the Plan Detail modal
|
|
|
|
+ const [isPlanDetailModalVisible, setIsPlanDetailModalVisible] = useState<boolean>(false);
|
|
|
|
+
|
|
|
|
+ const [isVideoPlayModalVisible, setIsVideoPlayModalVisible] = useState<boolean>(false);
|
|
|
|
|
|
const getTableData = (_pageNum?: number) => {
|
|
const getTableData = (_pageNum?: number) => {
|
|
setPageNum(_pageNum || 1);
|
|
setPageNum(_pageNum || 1);
|
|
@@ -60,6 +62,7 @@ const WeGZHContent: React.FC = () => {
|
|
title: '创建时间',
|
|
title: '创建时间',
|
|
dataIndex: 'createTimestamp',
|
|
dataIndex: 'createTimestamp',
|
|
key: 'createTimestamp',
|
|
key: 'createTimestamp',
|
|
|
|
+ width: 200,
|
|
render: (_, record) => {
|
|
render: (_, record) => {
|
|
return record.createTimestamp ? new Date(record.createTimestamp).toLocaleString() : '';
|
|
return record.createTimestamp ? new Date(record.createTimestamp).toLocaleString() : '';
|
|
}
|
|
}
|
|
@@ -74,6 +77,7 @@ const WeGZHContent: React.FC = () => {
|
|
title: '场景',
|
|
title: '场景',
|
|
dataIndex: 'scene',
|
|
dataIndex: 'scene',
|
|
key: 'scene',
|
|
key: 'scene',
|
|
|
|
+ width: 100,
|
|
render: (_, record) => {
|
|
render: (_, record) => {
|
|
if (activeKey === WeComPlanType.每日推送) {
|
|
if (activeKey === WeComPlanType.每日推送) {
|
|
return record.scene === 0 ? '群发' : '单发';
|
|
return record.scene === 0 ? '群发' : '单发';
|
|
@@ -85,27 +89,32 @@ const WeGZHContent: React.FC = () => {
|
|
{
|
|
{
|
|
title: '操作',
|
|
title: '操作',
|
|
key: 'action',
|
|
key: 'action',
|
|
|
|
+ width: 500,
|
|
render: (_, record) => (
|
|
render: (_, record) => (
|
|
<Space size="middle" wrap>
|
|
<Space size="middle" wrap>
|
|
- <Button type="link" onClick={() => window.open(record.video, '_blank')}>播放</Button>
|
|
|
|
|
|
+ <Button type="link" onClick={() => playVideo(record)}>播放</Button>
|
|
<Button type="link" onClick={() => downloadFile(record.cover, record.title + '_cover')}>下载封面</Button>
|
|
<Button type="link" onClick={() => downloadFile(record.cover, record.title + '_cover')}>下载封面</Button>
|
|
- <Button type="link" onClick={() => showQrCodeModal(record.pageUrl, record.title)}>二维码</Button>
|
|
|
|
|
|
+ <Button type="link" onClick={() => showQrCodeModal(record.pageUrl)}>二维码</Button>
|
|
<Button type="link" onClick={() => copyToClipboard(record.pageUrl)}>复制链接</Button>
|
|
<Button type="link" onClick={() => copyToClipboard(record.pageUrl)}>复制链接</Button>
|
|
|
|
+ <Button type="link" onClick={() => showDetailModal(record)}>详情</Button>
|
|
</Space>
|
|
</Space>
|
|
),
|
|
),
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ const playVideo = (record: WeComPlan) => {
|
|
|
|
+ setEditPlanData(record);
|
|
|
|
+ setIsVideoPlayModalVisible(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const showDetailModal = (record: WeComPlan) => {
|
|
|
|
+ setEditPlanData(record);
|
|
|
|
+ setIsPlanDetailModalVisible(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
const copyToClipboard = (text: string) => {
|
|
const copyToClipboard = (text: string) => {
|
|
- if (text && navigator.clipboard) {
|
|
|
|
- navigator.clipboard.writeText(text).then(() => {
|
|
|
|
- message.success('链接已复制');
|
|
|
|
- }, (err) => {
|
|
|
|
- message.error('复制失败: ' + err);
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- message.warning('无链接可复制或浏览器不支持');
|
|
|
|
- }
|
|
|
|
|
|
+ copy(text);
|
|
|
|
+ message.success('复制成功');
|
|
};
|
|
};
|
|
|
|
|
|
const downloadFile = (url: string, filename: string) => {
|
|
const downloadFile = (url: string, filename: string) => {
|
|
@@ -124,12 +133,20 @@ const WeGZHContent: React.FC = () => {
|
|
message.success('开始下载...');
|
|
message.success('开始下载...');
|
|
};
|
|
};
|
|
|
|
|
|
- const showQrCodeModal = (url: string, title: string) => {
|
|
|
|
- if (!url) {
|
|
|
|
- message.warning('无链接生成二维码');
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- message.info(`显示 ${title} 的二维码 (功能待实现)`);
|
|
|
|
|
|
+ const showQrCodeModal = (pageUrl: string) => {
|
|
|
|
+ http.get<string>(getShareQrPic, {
|
|
|
|
+ params: {
|
|
|
|
+ pageUrl,
|
|
|
|
+ }
|
|
|
|
+ }).then(res => {
|
|
|
|
+ modal.info({
|
|
|
|
+ title: '二维码',
|
|
|
|
+ content: <img src={res.data} alt="二维码" />,
|
|
|
|
+ });
|
|
|
|
+ }).catch(err => {
|
|
|
|
+ message.error(err.msg || '获取二维码失败');
|
|
|
|
+ });
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
const addPunlishPlan = () => {
|
|
const addPunlishPlan = () => {
|
|
@@ -137,17 +154,13 @@ const WeGZHContent: React.FC = () => {
|
|
}
|
|
}
|
|
|
|
|
|
const handleOk = (selectedVideos: WeVideoItem[]) => {
|
|
const handleOk = (selectedVideos: WeVideoItem[]) => {
|
|
- http.post<SaveQwPlanResponse>(saveQwPlanApi, {
|
|
|
|
|
|
+ http.post<WeComPlan[]>(saveQwPlanApi, {
|
|
type: +activeKey,
|
|
type: +activeKey,
|
|
videoList: selectedVideos,
|
|
videoList: selectedVideos,
|
|
}).then(res => {
|
|
}).then(res => {
|
|
- if (res.code === 0 &&res.data && Array.isArray(res.data.createdLinks) && res.data.createdLinks.length > 0) {
|
|
|
|
- const linksForModal = res.data.createdLinks.map(item => ({
|
|
|
|
- ...item,
|
|
|
|
- pushLink: item.pageUrl
|
|
|
|
- }));
|
|
|
|
|
|
+ if (res.code === 0) {
|
|
message.success('创建成功');
|
|
message.success('创建成功');
|
|
- setCreatedVideoLinks(linksForModal);
|
|
|
|
|
|
+ setCreatedVideoLinks(res.data);
|
|
setIsLinkDetailModalVisible(true);
|
|
setIsLinkDetailModalVisible(true);
|
|
setIsShowAddPunlishPlan(false);
|
|
setIsShowAddPunlishPlan(false);
|
|
getTableData();
|
|
getTableData();
|
|
@@ -239,6 +252,20 @@ const WeGZHContent: React.FC = () => {
|
|
onClose={() => setIsLinkDetailModalVisible(false)}
|
|
onClose={() => setIsLinkDetailModalVisible(false)}
|
|
videos={createdVideoLinks}
|
|
videos={createdVideoLinks}
|
|
/>
|
|
/>
|
|
|
|
+ <PlanDetailModal
|
|
|
|
+ visible={isPlanDetailModalVisible}
|
|
|
|
+ onClose={() => {
|
|
|
|
+ setIsPlanDetailModalVisible(false);
|
|
|
|
+ setEditPlanData(undefined);
|
|
|
|
+ }}
|
|
|
|
+ planData={editPlanData}
|
|
|
|
+ />
|
|
|
|
+ <VideoPlayModal
|
|
|
|
+ visible={isVideoPlayModalVisible}
|
|
|
|
+ onClose={() => setIsVideoPlayModalVisible(false)}
|
|
|
|
+ videoUrl={editPlanData?.video || ''}
|
|
|
|
+ title={editPlanData?.title || ''}
|
|
|
|
+ />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|