Skip to content

Let's use AI to Earn!

feat: 添加根据发布记录重新发布的逻辑

gaoSir94a2de49f2af
diff --git a/commont/publish/PublishEnum.ts b/commont/publish/PublishEnum.ts
index ca5d3a3e..c249f32a 100644
--- a/commont/publish/PublishEnum.ts
+++ b/commont/publish/PublishEnum.ts
@@ -29,3 +29,4 @@ export enum DouyinDeclareEnum {
// 危险行为,请勿模仿
Danger = 6,
}
+
diff --git a/electron/main/views.ts b/electron/main/views.ts
index fcd01f52..1b541163 100644
--- a/electron/main/views.ts
+++ b/electron/main/views.ts
@@ -25,13 +25,18 @@ export interface ISaveFileParams {
export function views(win: Electron.BrowserWindow) {
// 获取经纬度
ipcMain.handle('GET_LOCATION', async () => {
- const res = await requestNet({
- url: `https://map.baidu.com/?qt=ipLocation&t=${Date.now()}`,
- headers: {
- cookie: `BAIDUID=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDUID_BFESS=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDU_WISE_UID=wapp_1740893445646_358; ZFY=gFmlsByYQo2uV:A8KgAXQ5Ou6usNB8S4rufvkkSZ9WfE:C; arialoadData=false; RT="z=1&dm=baidu.com&si=6acd8df5-273b-4d7b-a273-72762d6a27a7&ss=m7snsitx&sl=0&tt=0&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&r=32ngg0aq&ul=3pfv&hd=3pg5"; PSTM=1740990133; H_PS_PSSID=61027_61680_62126_62169_62200_62278_62325_62344_62345_62328_62367_62369_62372_62246_62391; BA_HECTOR=24a02la1al052hag8g01a0a1bclj991jsaplo1v; BIDUPSID=256707C2A28F613DE9EA4FC5C7347285`,
- },
- method: 'GET',
- });
+ let res: any;
+
+ for (let i = 0; i < 10; i++) {
+ res = await requestNet({
+ url: `https://map.baidu.com/?qt=ipLocation&t=${Date.now()}`,
+ headers: {
+ cookie: `BAIDUID=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDUID_BFESS=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDU_WISE_UID=wapp_1740893445646_358; ZFY=gFmlsByYQo2uV:A8KgAXQ5Ou6usNB8S4rufvkkSZ9WfE:C; arialoadData=false; RT="z=1&dm=baidu.com&si=6acd8df5-273b-4d7b-a273-72762d6a27a7&ss=m7snsitx&sl=0&tt=0&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&r=32ngg0aq&ul=3pfv&hd=3pg5"; PSTM=1740990133; H_PS_PSSID=61027_61680_62126_62169_62200_62278_62325_62344_62345_62328_62367_62369_62372_62246_62391; BA_HECTOR=24a02la1al052hag8g01a0a1bclj991jsaplo1v; BIDUPSID=256707C2A28F613DE9EA4FC5C7347285`,
+ },
+ method: 'GET',
+ });
+ if (res?.data?.rgc?.result) break;
+ }
const { lat, lng } = res.data.rgc.result.location;
const gcj02 = coordtransform.bd09togcj02(lng, lat);
return {
diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsx
index 0143a4f6..9ed0198e 100644
--- a/src/views/publish/children/pubRecord/page.tsx
+++ b/src/views/publish/children/pubRecord/page.tsx
@@ -8,6 +8,9 @@ import { formatTime, getFilePathName } from '@/utils';
import { VideoPul } from '@/views/publish/children/videoPage/comment';
import { icpGetAccountList } from '@/icp/account';
import { AccountInfo, AccountPlatInfoMap } from '@/views/account/comment';
+import { useVideoPageStore } from '../videoPage/useVideoPageStore';
+import { useShallow } from 'zustand/react/shallow';
+import { useNavigate } from 'react-router-dom';
const PubCon = ({ prm }: { prm: PubRecordModel }) => {
const [imgFile, setImgFile] = useState<IImgFile>();
@@ -38,6 +41,13 @@ export default function Page() {
const [pubRecordList, setPubRecordList] = useState<VideoPul[]>([]);
// id=账户id,val=账户item数据
const accountMap = useRef<Map<number, AccountInfo>>(new Map());
+ const navigate = useNavigate();
+
+ const { restartPub } = useVideoPageStore(
+ useShallow((state) => ({
+ restartPub: state.restartPub,
+ })),
+ );
const columns: TableProps<PubRecordModel>['columns'] = [
{
@@ -145,13 +155,34 @@ export default function Page() {
</Tooltip>
) : (
<p className="pubRecord-record-item-userinfo-time">
- {formatTime(v.publishTime)}
+ {formatTime(v.publishTime!)}
</p>
)}
</div>
</div>
<div className="pubRecord-record-item-btns">
- <Button type="link">查看</Button>
+ {/*<Button type="link">查看</Button>*/}
+ {v.status === 2 && (
+ <Button
+ type="link"
+ onClick={() => {
+ setRecordLoaidng(true);
+ const prl = pubRecordList.filter(
+ (v) => v.status === 2,
+ );
+ restartPub(
+ prl,
+ prl.map(
+ (k) => accountMap.current.get(k.accountId)!,
+ ),
+ );
+ setRecordLoaidng(false);
+ navigate('/publish/video');
+ }}
+ >
+ 重新发布
+ </Button>
+ )}
</div>
</li>
);
diff --git a/src/views/publish/children/pubRecord/pubRecord.module.scss b/src/views/publish/children/pubRecord/pubRecord.module.scss
index 14958851..0b9172e9 100644
--- a/src/views/publish/children/pubRecord/pubRecord.module.scss
+++ b/src/views/publish/children/pubRecord/pubRecord.module.scss
@@ -37,6 +37,10 @@
&-btns {
display: flex;
justify-content: right;
+ button {
+ margin: 0;
+ padding: 0;
+ }
}
&-status {
position: absolute;
diff --git a/src/views/publish/children/videoPage/comment.ts b/src/views/publish/children/videoPage/comment.ts
index 3b9c75db..aa15b923 100644
--- a/src/views/publish/children/videoPage/comment.ts
+++ b/src/views/publish/children/videoPage/comment.ts
@@ -6,30 +6,6 @@
* @Description:
*/
-import { AccountType } from '../../../../../commont/AccountEnum';
-import { VisibleTypeEnum } from '../../../../../commont/publish/PublishEnum';
-import {
- DiffParmasType,
- TopicsArrType,
-} from '../../../../../electron/db/models/video';
+import { VideoModel } from '../../../../../electron/db/models/video';
-export interface VideoPul {
- id: number;
- userId: string;
- type: AccountType;
- accountId: number;
- pubRecordId: number;
- title: string;
- desc: string;
- publishTime: Date;
- failMsg: string;
- videoPath: string;
- coverPath: string;
- otherInfo: Record<string, any>;
- createTime?: Date;
- updateTime?: Date;
- status: number;
- visibleType: VisibleTypeEnum;
- topics: TopicsArrType;
- diffParams?: DiffParmasType;
-}
+export type VideoPul = VideoModel;
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
index 98be6960..f5fcfceb 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
@@ -360,30 +360,6 @@ const VideoPubSetModal_KWAI = memo(
<LocationSelect currChooseAccount={currChooseAccount} />
- <h1>谁可以看</h1>
- <Radio.Group
- options={[
- {
- label: '公开(所有人可见)',
- value: VisibleTypeEnum.Public,
- },
- { label: '好友可见', value: VisibleTypeEnum.Friend },
- {
- label: '私密(仅自己可见)',
- value: VisibleTypeEnum.Private,
- },
- ]}
- onChange={(e) => {
- setOnePubParams(
- {
- visibleType: e.target.value,
- },
- currChooseAccount!.id,
- );
- }}
- value={currChooseAccount?.pubParams.visibleType}
- />
-
<HotspotSelect {...props} />
<ScheduledTimeSelect
@@ -439,6 +415,30 @@ const VideoPubSetModal_KWAI = memo(
);
}}
/>
+
+ <h1>谁可以看</h1>
+ <Radio.Group
+ options={[
+ {
+ label: '公开(所有人可见)',
+ value: VisibleTypeEnum.Public,
+ },
+ { label: '好友可见', value: VisibleTypeEnum.Friend },
+ {
+ label: '私密(仅自己可见)',
+ value: VisibleTypeEnum.Private,
+ },
+ ]}
+ onChange={(e) => {
+ setOnePubParams(
+ {
+ visibleType: e.target.value,
+ },
+ currChooseAccount!.id,
+ );
+ }}
+ value={currChooseAccount?.pubParams.visibleType}
+ />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
index d7a5e1b6..5bc858e1 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
@@ -9,7 +9,7 @@ import { useShallow } from 'zustand/react/shallow';
import { VisibleTypeEnum } from '@@/publish/PublishEnum';
import TopicSelect from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect';
import LocationSelect from '../components/LocationSelect';
-import UserSelect from "../components/UserSelect";
+import UserSelect from '../components/UserSelect';
const { TextArea } = Input;
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
index ff8f7b4e..8bcea68e 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
@@ -65,7 +65,7 @@ export const ScheduledTimeSelect = ({
onChange={(e) => {
setOnePubParams(
{
- timingTime: e ? e.toDate() : null,
+ timingTime: e ? e.toDate() : undefined,
},
currChooseAccount!.id,
);
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index 3711cc14..5a4b0e47 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -6,12 +6,15 @@ import {
} from '@/views/publish/children/videoPage/videoPage';
import { generateUUID } from '@/utils';
import { AccountInfo } from '@/views/account/comment';
-import { IVideoFile } from '@/components/Choose/VideoChoose';
+import { getVideoFile, IVideoFile } from '@/components/Choose/VideoChoose';
import { accountLogin } from '@/icp/account';
import { AccountType } from '../../../../../commont/AccountEnum';
import { message } from 'antd';
import { VisibleTypeEnum } from '../../../../../commont/publish/PublishEnum';
import lodash from 'lodash';
+import { VideoModel } from '../../../../../electron/db/models/video';
+import { getImgFile } from '../../../../components/Choose/ImgChoose';
+import router from '@/router/index';
interface IVideoPageStore {
// 选择的视频数据
@@ -62,9 +65,7 @@ const store: IVideoPageStore = {
operateId: '',
};
-/**
- * 视频发布所有组件的共享状态和方法
- */
+// 视频发布所有组件的共享状态和方法
export const useVideoPageStore = create(
combine(
{
@@ -352,6 +353,35 @@ export const useVideoPageStore = create(
});
},
+ // 重新发布设置参数
+ async restartPub(pubRecordList: VideoModel[], accounts: AccountInfo[]) {
+ const videoListChoose: IVideoChooseItem[] = [];
+ methods.setOperateId();
+
+ for (let i = 0; i < pubRecordList.length; i++) {
+ const pubRecord = pubRecordList[i];
+ const account = accounts[i];
+ const video = await getVideoFile(pubRecord.videoPath!);
+ const cover = await getImgFile(pubRecord.coverPath!);
+
+ videoListChoose.push({
+ id: generateUUID(),
+ account,
+ video,
+ pubParams: {
+ ...pubRecord,
+ cover: cover,
+ describe: pubRecord.desc,
+ },
+ });
+ }
+
+ console.log(videoListChoose);
+ set({
+ videoListChoose,
+ });
+ },
+
/**
* 账户重新登录。登录成功后会自动更新该条账户数据
*/
diff --git a/src/views/publish/children/videoPage/videoPage.d.ts b/src/views/publish/children/videoPage/videoPage.d.ts
index cdcee18a..e4fc7463 100644
--- a/src/views/publish/children/videoPage/videoPage.d.ts
+++ b/src/views/publish/children/videoPage/videoPage.d.ts
@@ -25,7 +25,7 @@ export interface IPubParams {
// 位置
location?: ILocationDataItem;
// 定时发布日期
- timingTime?: Date | null;
+ timingTime?: Date;
// @用户
mentionedUserInfo?: ILableValue[];
}