Skip to content

Let's use AI to Earn!

feat: 导入历史记录通用参数保存及恢复

gaoSir560f6a964225
diff --git a/electron/db/models/pubRecord.ts b/electron/db/models/pubRecord.ts
index 5a562405..930af1b3 100644
--- a/electron/db/models/pubRecord.ts
+++ b/electron/db/models/pubRecord.ts
@@ -48,9 +48,13 @@ export class PubRecordModel extends TempModel {
timingTime?: Date;
// 封面路径
- @Column({ type: 'varchar', nullable: false, comment: '封面路径' })
+ @Column({ type: 'varchar', nullable: false, comment: '封面路径,展示给前台用' })
coverPath!: string;
+ // 通用封面路径
+ @Column({ type: 'varchar', nullable: false, comment: '通用封面路径' })
+ commonCoverPath!: string;
+
// 发布时间
@Column({ type: 'datetime', nullable: false, comment: '发布时间' })
publishTime!: Date;
diff --git a/src/App.tsx b/src/App.tsx
index 31cc2c4c..d515242c 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -15,7 +15,7 @@ import { useAccountStore } from './store/commont';
const App = () => {
const [api, contextHolder] = notification.useNotification({
- top: 70,
+ top: 74,
});
useEffect(() => {
diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsx
index 2b9e1921..7e48f4e0 100644
--- a/src/views/publish/children/pubRecord/page.tsx
+++ b/src/views/publish/children/pubRecord/page.tsx
@@ -62,7 +62,7 @@ export default function Page({
onChange,
}: {
hegiht?: string;
- onChange?: (ids: number[]) => void;
+ onChange?: (pubRecordModel: PubRecordModel) => void;
}) {
const [pulRecardList, setRecardList] = useState<PubRecordModel[]>([]);
const [open, setOpen] = useState(false);
@@ -179,7 +179,8 @@ export default function Page({
};
useEffect(() => {
- if (onChange) onChange(selectedRowKeys);
+ if (onChange)
+ onChange(pulRecardList.find((v) => v.id === selectedRowKeys[0])!);
}, [selectedRowKeys]);
const rowSelection: TableProps<PubRecordModel>['rowSelection'] = {
diff --git a/src/views/publish/children/videoPage/components/CommonPubSetting.tsx b/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
index b660583f..7b05add8 100644
--- a/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
+++ b/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
@@ -1,16 +1,9 @@
-import React, {
- ForwardedRef,
- forwardRef,
- memo,
- useMemo,
- useState,
-} from 'react';
+import React, { ForwardedRef, forwardRef, memo, useMemo } from 'react';
import VideoCoverSeting from '@/views/publish/children/videoPage/components/VideoCoverSeting';
import { Input, Tooltip } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
-import { IImgFile } from '@/components/Choose/ImgChoose';
import { ScheduledTimeSelect } from './VideoPubSetModal/components/VideoPubSetModalCommon';
import {
AccountPlatInfoMap,
@@ -43,8 +36,6 @@ const CommonPubSetting = memo(
commonPubParams: state.commonPubParams,
})),
);
- // 当前选择的通用封面
- const [cover, setCover] = useState<IImgFile>();
// 获取选择的账户的所有相关平台
const getChoosedAccountPlatList = useMemo(() => {
@@ -85,17 +76,15 @@ const CommonPubSetting = memo(
<h2>通用封面</h2>
<VideoCoverSeting
videoFile={videoListChoose.find((v) => v.video)?.video}
- value={cover}
+ value={commonPubParams.cover}
saveImgId="common"
onClose={() => {
- setCover(undefined);
setPubParams({
cover: undefined,
});
setVideoCoverFirst(true);
}}
onChoosed={(imgFile) => {
- setCover(imgFile);
setPubParams({
cover: imgFile,
});
diff --git a/src/views/publish/children/videoPage/components/NoChoosePage.tsx b/src/views/publish/children/videoPage/components/NoChoosePage.tsx
index 91c1e98e..684ddd47 100644
--- a/src/views/publish/children/videoPage/components/NoChoosePage.tsx
+++ b/src/views/publish/children/videoPage/components/NoChoosePage.tsx
@@ -11,6 +11,7 @@ import PubRecord from '../../pubRecord/page';
import { icpGetPubVideoRecord } from '../../../../../icp/publish';
import { useAccountStore } from '../../../../../store/account';
import { ChooseChunk } from '../../../components/CommonComponents/CommonComponents';
+import { PubRecordModel } from '../../../comment';
export interface INoChoosePageRef {}
@@ -29,7 +30,7 @@ const NoChoosePage = memo(
})),
);
const [importPubRecordOpen, setImportPubRecordOpen] = useState(false);
- const pubRecordIds = useRef<number[]>([]);
+ const pubRecord = useRef<PubRecordModel>();
const { accountMap } = useAccountStore(
useShallow((state) => ({
accountMap: state.accountMap,
@@ -45,13 +46,14 @@ const NoChoosePage = memo(
okText="确认导入"
onCancel={() => setImportPubRecordOpen(false)}
onOk={async () => {
- if (pubRecordIds.current.length === 0) {
+ if (!pubRecord.current) {
return message.warning('未选择任何数据');
}
- const res = await icpGetPubVideoRecord(pubRecordIds.current[0]);
+ const res = await icpGetPubVideoRecord(pubRecord.current.id);
restartPub(
res,
res.map((k) => accountMap.get(k.accountId)!),
+ pubRecord.current,
);
setImportPubRecordOpen(false);
}}
@@ -59,8 +61,8 @@ const NoChoosePage = memo(
<Alert message="选择一条发布记录" />
<PubRecord
hegiht="55vh"
- onChange={async (ids) => {
- pubRecordIds.current = ids;
+ onChange={async (pubRecordModel) => {
+ pubRecord.current = pubRecordModel;
}}
/>
</Modal>
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index 5051c0fc..ee49632e 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -182,6 +182,7 @@ const VideoPubSetModal = memo(
timingTime: commonPubParams.timingTime,
videoPath: videoListChoose[0].video?.videoPath,
coverPath: videoListChoose[0].pubParams.cover?.imgPath,
+ commonCoverPath: commonPubParams.cover?.imgPath,
});
if (!recordRes) return err();
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index a6e7dfc6..92ef2249 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -16,6 +16,7 @@ import { VideoModel } from '../../../../../electron/db/models/video';
import { getImgFile, IImgFile } from '../../../../components/Choose/ImgChoose';
import { useAICreateTitleStore } from '../../components/AICreateTitle/useAICreateTitle';
import { usePubStroe } from '../../../../store/pubStroe';
+import { PubRecordModel } from '../../comment';
export interface IVideoPageStore {
// 选择的视频数据
@@ -362,12 +363,17 @@ export const useVideoPageStore = create(
},
// 根据发布记录重新发布设置参数
- async restartPub(pubRecordList: VideoModel[], accounts: AccountInfo[]) {
+ async restartPub(
+ pubRecordList: VideoModel[],
+ accounts: AccountInfo[],
+ pubRecord: PubRecordModel,
+ ) {
set({
loadingPageLoading: true,
});
const videoListChoose: IVideoChooseItem[] = [];
+ let commonPubParams: IPubParams = { ...get().commonPubParams };
const error = (msg: string) => {
set({
@@ -379,6 +385,12 @@ export const useVideoPageStore = create(
try {
methods.setOperateId();
+ const cover = await getImgFile(pubRecord.commonCoverPath);
+ commonPubParams = {
+ ...pubRecord,
+ cover,
+ };
+
// key=视频路径 val=视频文件,防止多个相同视频重复取视频文件
const videoFileMap = new Map<string, IVideoFile>();
const coverFileMap = new Map<string, IImgFile>();
@@ -435,6 +447,7 @@ export const useVideoPageStore = create(
set({
videoListChoose,
loadingPageLoading: false,
+ commonPubParams,
});
},