| 1 | import { ForwardedRef, forwardRef, memo, useRef, useState } from 'react'; |
| 2 | import VideoChoose from '@/components/Choose/VideoChoose'; |
| 3 | import SupportPlat from '../../../components/SupportPlat/SupportPlat'; |
| 4 | import { PubType } from '../../../../../../commont/publish/PublishEnum'; |
| 5 | import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore'; |
| 6 | import { useShallow } from 'zustand/react/shallow'; |
| 7 | import localUpload from '../images/localUpload.png'; |
| 8 | import importRecord from '../images/importRecord.png'; |
| 9 | import { Alert, message, Modal } from 'antd'; |
| 10 | import PubRecord from '../../pubRecord/page'; |
| 11 | import { icpGetPubVideoRecord } from '../../../../../icp/publish'; |
| 12 | import { useAccountStore } from '../../../../../store/account'; |
| 13 | import { ChooseChunk } from '../../../components/CommonComponents/CommonComponents'; |
| 14 | import { PubRecordModel } from '../../../comment'; |
| 15 | |
| 16 | export interface INoChoosePageRef {} |
| 17 | |
| 18 | export interface INoChoosePageProps {} |
| 19 | |
| 20 | // 未选择视频时暂时的组件 |
| 21 | const NoChoosePage = memo( |
| 22 | forwardRef(({}: INoChoosePageProps, ref: ForwardedRef<INoChoosePageRef>) => { |
| 23 | const { addVideos, setLoadingPageLoading, setOperateId, restartPub } = |
| 24 | useVideoPageStore( |
| 25 | useShallow((state) => ({ |
| 26 | addVideos: state.addVideos, |
| 27 | setLoadingPageLoading: state.setLoadingPageLoading, |
| 28 | setOperateId: state.setOperateId, |
| 29 | restartPub: state.restartPub, |
| 30 | })), |
| 31 | ); |
| 32 | const [importPubRecordOpen, setImportPubRecordOpen] = useState(false); |
| 33 | const pubRecord = useRef<PubRecordModel>(); |
| 34 | const { accountMap } = useAccountStore( |
| 35 | useShallow((state) => ({ |
| 36 | accountMap: state.accountMap, |
| 37 | })), |
| 38 | ); |
| 39 | |
| 40 | return ( |
| 41 | <div className="video-pubBefore"> |
| 42 | <Modal |
| 43 | open={importPubRecordOpen} |
| 44 | width="90%" |
| 45 | title="导入发布记录" |
| 46 | okText="确认导入" |
| 47 | onCancel={() => setImportPubRecordOpen(false)} |
| 48 | onOk={async () => { |
| 49 | if (!pubRecord.current) { |
| 50 | return message.warning('未选择任何数据'); |
| 51 | } |
| 52 | const res = await icpGetPubVideoRecord(pubRecord.current.id); |
| 53 | restartPub( |
| 54 | res, |
| 55 | res.map((k) => accountMap.get(k.accountId)!), |
| 56 | pubRecord.current, |
| 57 | ); |
| 58 | setImportPubRecordOpen(false); |
| 59 | }} |
| 60 | > |
| 61 | <Alert message="选择一条发布记录" /> |
| 62 | <PubRecord |
| 63 | hegiht="55vh" |
| 64 | defaultPubType={PubType.VIDEO} |
| 65 | onChange={async (pubRecordModel) => { |
| 66 | pubRecord.current = pubRecordModel; |
| 67 | }} |
| 68 | /> |
| 69 | </Modal> |
| 70 | |
| 71 | <h1>视频发布</h1> |
| 72 | <p className="video-pubBefore-tip"> |
| 73 | 支持多视频、多平台、多账号同时发布 |
| 74 | </p> |
| 75 | |
| 76 | <div className="video-pubBefore-con"> |
| 77 | <VideoChoose |
| 78 | onMultipleChoose={(videoFiles) => { |
| 79 | setOperateId(); |
| 80 | addVideos(videoFiles); |
| 81 | }} |
| 82 | onStartShoose={() => { |
| 83 | setLoadingPageLoading(true); |
| 84 | }} |
| 85 | onChooseFail={() => { |
| 86 | setLoadingPageLoading(false); |
| 87 | }} |
| 88 | > |
| 89 | <ChooseChunk |
| 90 | text="本地上传" |
| 91 | imgUrl={localUpload} |
| 92 | color="linear-gradient(to right, rgb(255, 142, 28), rgb(255, 124, 24))" |
| 93 | hoverColor="rgb(255, 142, 28)" |
| 94 | style={{ marginRight: '15px' }} |
| 95 | /> |
| 96 | </VideoChoose> |
| 97 | |
| 98 | <ChooseChunk |
| 99 | text="导入发布记录" |
| 100 | imgUrl={importRecord} |
| 101 | color="#a66ae4" |
| 102 | onClick={() => { |
| 103 | setImportPubRecordOpen(true); |
| 104 | }} |
| 105 | /> |
| 106 | </div> |
| 107 | |
| 108 | <SupportPlat pubType={PubType.VIDEO} style={{ marginTop: '15px' }} /> |
| 109 | </div> |
| 110 | ); |
| 111 | }), |
| 112 | ); |
| 113 | NoChoosePage.displayName = 'NoChoosePage'; |
| 114 | |
| 115 | export default NoChoosePage; |
| 116 |