Skip to content

Let's use AI to Earn!

fix: 视频发布冗余代码删除

gaoSir97d232958306
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index 0277367c..ea212b9b 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -46,7 +46,6 @@ import VideoPubSetModalVideo, {
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo';
import { usePubStroe } from '../../../../../../store/pubStroe';
-import { IVideoChooseItem } from '../../videoPage';
import usePubParamsVerify, {
PubParamsVerifyInfo,
} from '../../../../hooks/usePubParamsVerify';
@@ -58,20 +57,22 @@ export interface IVideoPubSetModalProps {
onClose: (open: boolean) => void;
}
-const PubSetModalChild = ({
- currChooseAccount,
-}: {
- currChooseAccount: IVideoChooseItem;
-}) => {
+const PubSetModalChild = ({}: {}) => {
+ const { currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ currChooseAccount: state.currChooseAccount,
+ })),
+ );
+
switch (currChooseAccount?.account?.type) {
case AccountType.KWAI:
- return <VideoPubSetModal_KWAI currChooseAccount={currChooseAccount} />;
+ return <VideoPubSetModal_KWAI />;
case AccountType.Douyin:
- return <VideoPubSetModal_DouYin currChooseAccount={currChooseAccount} />;
+ return <VideoPubSetModal_DouYin />;
case AccountType.Xhs:
- return <VideoPubSetModal_XSH currChooseAccount={currChooseAccount} />;
+ return <VideoPubSetModal_XSH />;
case AccountType.WxSph:
- return <VideoPubSetModal_WxSph currChooseAccount={currChooseAccount} />;
+ return <VideoPubSetModal_WxSph />;
}
return <></>;
};
@@ -95,6 +96,7 @@ const VideoPubSetModal = memo(
accountRestart,
commonPubParams,
clear,
+ setCurrChooseAccount,
} = useVideoPageStore(
useShallow((state) => ({
videoListChoose: state.videoListChoose,
@@ -107,6 +109,7 @@ const VideoPubSetModal = memo(
accountRestart: state.accountRestart,
clear: state.clear,
commonPubParams: state.commonPubParams,
+ setCurrChooseAccount: state.setCurrChooseAccount,
})),
);
const { moreParamsOpen, setMoreParamsOpen } = usePubStroe(
@@ -168,6 +171,10 @@ const VideoPubSetModal = memo(
return videoListChoose.find((v) => v.id === currChooseAccountId);
}, [currChooseAccountId, videoListChoose]);
+ useEffect(() => {
+ if (currChooseAccount) setCurrChooseAccount(currChooseAccount);
+ }, [currChooseAccount]);
+
const pubCore = async () => {
setLoading(false);
const err = () => {
@@ -389,16 +396,11 @@ const VideoPubSetModal = memo(
}}
/>
- {currChooseAccount && (
- <PubSetModalChild currChooseAccount={currChooseAccount} />
- )}
+ {currChooseAccount && <PubSetModalChild />}
</div>
<div className="videoPubSetModal_con-right">
{currChooseAccount && (
- <VideoPubSetModalVideo
- ref={videoPubSetModalVideoRef}
- chooseAccountItem={currChooseAccount}
- />
+ <VideoPubSetModalVideo ref={videoPubSetModalVideoRef} />
)}
</div>
</div>
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 f1c1024a..7de5fed0 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
@@ -13,6 +13,7 @@ import {
DescTextArea,
ScheduledTimeSelect,
TitleInput,
+ VideoPubMixSelect,
VideoPubPermission,
VideoPubRestartLogin,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
@@ -25,10 +26,11 @@ import {
import { ILableValue } from '../../../../../../../../electron/db/models/workData';
import useVideoPubSetModal from './hooks/useVideoPubSetModal';
-const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
- const { setOnePubParams } = useVideoPageStore(
+const HotspotSelect = ({}: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount!,
})),
);
@@ -52,8 +54,9 @@ const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
);
};
-const ActivitySelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
- const { setOnePubParams, platInfo } = useVideoPubSetModal(currChooseAccount);
+const ActivitySelect = ({}: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
const { topicMax } = platInfo.commonPubParamsConfig;
return (
@@ -75,7 +78,7 @@ const ActivitySelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
);
}}
>
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
+ <VideoPubRestartLogin />
</CommonActivitySelect>
);
};
@@ -86,23 +89,15 @@ const VideoPubSetModal_DouYin = memo(
props: IVideoPubSetModalChildProps,
ref: ForwardedRef<IVideoPubSetModalChildRef>,
) => {
- const { currChooseAccount } = props;
- const { setOnePubParams, platInfo } =
- useVideoPubSetModal(currChooseAccount);
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
const { topicMax } = platInfo.commonPubParamsConfig;
return (
<>
- <TitleInput
- placeholder="好的标题可以获得更多浏览"
- currChooseAccount={currChooseAccount}
- />
+ <TitleInput placeholder="好的标题可以获得更多浏览" />
- <DescTextArea
- placeholder="添加作品简介"
- currChooseAccount={currChooseAccount}
- maxLength={1000}
- />
+ <DescTextArea placeholder="添加作品简介" maxLength={1000} />
<TopicSelect
maxCount={
@@ -110,23 +105,19 @@ const VideoPubSetModal_DouYin = memo(
currChooseAccount.pubParams!.diffParams![AccountType.Douyin]!
.activitys!.length
}
- currChooseAccount={currChooseAccount}
tips={`最多可添加${topicMax}个话题(包含活动奖励)`}
/>
- <ActivitySelect currChooseAccount={currChooseAccount} />
+ <ActivitySelect />
- <UserSelect
- currChooseAccount={currChooseAccount}
- maxCount={100}
- tips="您可以添加100个好友"
- title="@好友"
- />
+ <UserSelect maxCount={100} tips="您可以添加100个好友" title="@好友" />
<HotspotSelect {...props} />
- <LocationSelect currChooseAccount={currChooseAccount} />
+ <LocationSelect />
- <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
+ <ScheduledTimeSelect />
+
+ <VideoPubMixSelect />
<h1>自主声明</h1>
<Select
@@ -177,10 +168,7 @@ const VideoPubSetModal_DouYin = memo(
}}
/>
- <VideoPubPermission
- currChooseAccount={currChooseAccount}
- title="谁可以看"
- />
+ <VideoPubPermission title="谁可以看" />
</>
);
},
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 176ae7f8..a999ec65 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
@@ -11,39 +11,34 @@ import {
ScheduledTimeSelect,
VideoPubPermission,
} from '../components/VideoPubSetModalCommon';
-import useVideoPubSetModal from './hooks/useVideoPubSetModal';
const VideoPubSetModal_KWAI = memo(
forwardRef(
(
- { currChooseAccount }: IVideoPubSetModalChildProps,
+ {}: IVideoPubSetModalChildProps,
ref: ForwardedRef<IVideoPubSetModalChildRef>,
) => {
- const { setOnePubParams } = useVideoPubSetModal(currChooseAccount);
-
return (
<>
<DescTextArea
placeholder="填写合适的话题和描述,作品能获得更多推荐~"
- currChooseAccount={currChooseAccount}
maxLength={500}
/>
- <TopicSelect currChooseAccount={currChooseAccount} />
+ <TopicSelect />
<UserSelect
- currChooseAccount={currChooseAccount}
maxCount={3}
title="@好友"
tips="您可以添加3个好友"
showSearch={false}
/>
- <LocationSelect currChooseAccount={currChooseAccount} />
+ <LocationSelect />
- <VideoPubPermission currChooseAccount={currChooseAccount} />
+ <VideoPubPermission />
- <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
+ <ScheduledTimeSelect />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
index 933e53d1..35bb8da7 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
@@ -21,13 +21,15 @@ import { WxSphEventList } from '../../../../../../../../electron/plat/shipinhao/
import UserSelect from '../components/UserSelect';
import useVideoPubSetModal from './hooks/useVideoPubSetModal';
-const WXSphActivity = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
- const { setOnePubParams, updateAccounts } = useVideoPageStore(
- useShallow((state) => ({
- setOnePubParams: state.setOnePubParams,
- updateAccounts: state.updateAccounts,
- })),
- );
+const WXSphActivity = ({}: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams, updateAccounts, currChooseAccount } =
+ useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ currChooseAccount: state.currChooseAccount!,
+ })),
+ );
const { fetching, options, debounceFetcher } =
useDebounceFetcher<WxSphEventList>(async (keywords) => {
@@ -77,7 +79,7 @@ const WXSphActivity = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
);
}}
/>
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
+ <VideoPubRestartLogin />
</>
);
};
@@ -85,11 +87,11 @@ const WXSphActivity = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
const VideoPubSetModal_WxSph = memo(
forwardRef(
(
- { currChooseAccount }: IVideoPubSetModalChildProps,
+ {}: IVideoPubSetModalChildProps,
ref: ForwardedRef<IVideoPubSetModalChildRef>,
) => {
- const { setOnePubParams, platInfo } =
- useVideoPubSetModal(currChooseAccount);
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
const { topicMax } = platInfo.commonPubParamsConfig;
const [topicSearch, setTopicSearch] = useState('');
@@ -99,12 +101,10 @@ const VideoPubSetModal_WxSph = memo(
title="短标题"
tips="短标题会出现在搜索、话题、活动、地点、订阅号消息、发现页红点等场景"
placeholder="概况视频的主要内容。字数建议6-16个字符"
- currChooseAccount={currChooseAccount}
/>
<DescTextArea
placeholder="填写更全面的描述信息,让更多人看到你吧!"
- currChooseAccount={currChooseAccount}
maxLength={1000}
/>
@@ -143,15 +143,14 @@ const VideoPubSetModal_WxSph = memo(
</p>
<UserSelect
- currChooseAccount={currChooseAccount}
maxCount={10}
tips="您可以添加10个视频号"
title="@视频号"
/>
- <LocationSelect currChooseAccount={currChooseAccount} />
+ <LocationSelect />
- <WXSphActivity currChooseAccount={currChooseAccount} />
+ <WXSphActivity />
<h1>扩展链接</h1>
<Input
@@ -192,7 +191,7 @@ const VideoPubSetModal_WxSph = memo(
声明后,作品将展示原创标记,有机会获得广告收入
</Checkbox>
- <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
+ <ScheduledTimeSelect />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
index 12f995c6..454d5d20 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
@@ -12,43 +12,30 @@ import {
VideoPubPermission,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
import UserSelect from '../components/UserSelect';
-import useVideoPubSetModal from './hooks/useVideoPubSetModal';
const VideoPubSetModal_WxSph = memo(
forwardRef(
(
- { currChooseAccount }: IVideoPubSetModalChildProps,
+ {}: IVideoPubSetModalChildProps,
ref: ForwardedRef<IVideoPubSetModalChildRef>,
) => {
- const { setOnePubParams, platInfo } =
- useVideoPubSetModal(currChooseAccount);
- const { topicMax } = platInfo.commonPubParamsConfig;
-
return (
<>
- <TitleInput
- title="标题"
- placeholder="填写标题,可能会有更多赞哦"
- currChooseAccount={currChooseAccount}
- />
+ <TitleInput title="标题" placeholder="填写标题,可能会有更多赞哦" />
<DescTextArea
placeholder="填写更全面的描述信息,让更多人看到你吧!"
- currChooseAccount={currChooseAccount}
maxLength={1000}
/>
- <TopicSelect currChooseAccount={currChooseAccount} />
+ <TopicSelect />
- <UserSelect currChooseAccount={currChooseAccount} title="@用户" />
+ <UserSelect title="@用户" />
- <LocationSelect currChooseAccount={currChooseAccount} />
+ <LocationSelect />
- <VideoPubPermission
- currChooseAccount={currChooseAccount}
- title="谁可以看"
- />
- <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
+ <VideoPubPermission title="谁可以看" />
+ <ScheduledTimeSelect />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx
index 9be69557..da3d3661 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx
@@ -1,20 +1,18 @@
import { useVideoPageStore } from '../../../../useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
-import { IVideoChooseItem } from '../../../../videoPage';
import { AccountPlatInfoMap } from '../../../../../../../account/comment';
-export default function useVideoPubSetModal(
- currChooseAccount: IVideoChooseItem,
-) {
- const { setOnePubParams } = useVideoPageStore(
+export default function useVideoPubSetModal() {
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
- videoListChoose: state.videoListChoose,
+ currChooseAccount: state.currChooseAccount,
})),
);
return {
setOnePubParams,
- platInfo: AccountPlatInfoMap.get(currChooseAccount.account!.type)!,
+ platInfo: AccountPlatInfoMap.get(currChooseAccount!.account!.type)!,
+ currChooseAccount: currChooseAccount!,
};
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
index 75f579c9..adf2f7e4 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
@@ -1,20 +1,17 @@
import React from 'react';
import { SelectProps } from 'antd';
import { ILocationDataItem } from '../../../../../../../../electron/main/plat/plat.type';
-import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
import CommonLocationSelect from '../../../../../components/CommonComponents/CommonLocationSelect';
import { useVideoPageStore } from '../../../useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { VideoPubRestartLogin } from './VideoPubSetModalCommon';
+import useVideoPubSetModal from '../children/hooks/useVideoPubSetModal';
interface DebounceSelectProps<ValueType = any>
- extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
- currChooseAccount: IVideoChooseItem;
-}
+ extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {}
// 位置选择器
export default function LocationSelect({
- currChooseAccount,
...props
}: DebounceSelectProps<ILocationDataItem>) {
const { setOnePubParams, updateAccounts } = useVideoPageStore(
@@ -23,6 +20,7 @@ export default function LocationSelect({
updateAccounts: state.updateAccounts,
})),
);
+ const { currChooseAccount } = useVideoPubSetModal();
return (
<CommonLocationSelect
@@ -41,7 +39,7 @@ export default function LocationSelect({
);
}}
>
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
+ <VideoPubRestartLogin />
</CommonLocationSelect>
);
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
index 3e34de65..6bd47d67 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
@@ -3,28 +3,23 @@ import CommonTopicSelect, {
CommonTopicSelectProps,
CommonTopicSelectValueType,
} from '../../../../../components/CommonComponents/CommonTopicSelect';
-import { IVideoChooseItem } from '../../../videoPage';
import { useVideoPageStore } from '../../../useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { VideoPubRestartLogin } from './VideoPubSetModalCommon';
import useVideoPubSetModal from '../children/hooks/useVideoPubSetModal';
interface DebounceSelectProps
- extends CommonTopicSelectProps<CommonTopicSelectValueType> {
- currChooseAccount: IVideoChooseItem;
-}
+ extends CommonTopicSelectProps<CommonTopicSelectValueType> {}
// 话题选择器
-export default function TopicSelect({
- currChooseAccount,
- ...props
-}: DebounceSelectProps) {
+export default function TopicSelect({ ...props }: DebounceSelectProps) {
const { updateAccounts } = useVideoPageStore(
useShallow((state) => ({
updateAccounts: state.updateAccounts,
})),
);
- const { setOnePubParams, platInfo } = useVideoPubSetModal(currChooseAccount);
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
const { topicMax } = platInfo.commonPubParamsConfig;
props.maxCount = props.maxCount || topicMax;
props.tips = props.tips || `您可以添加${topicMax}个话题`;
@@ -56,7 +51,7 @@ export default function TopicSelect({
);
}}
>
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
+ <VideoPubRestartLogin />
</CommonTopicSelect>
);
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
index aa994685..1f839b9e 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
@@ -1,4 +1,3 @@
-import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
import CommonUserSelect, {
CommonUserSelectProps,
} from '../../../../../components/CommonComponents/CommonUserSelect';
@@ -9,21 +8,16 @@ import { VideoPubRestartLogin } from './VideoPubSetModalCommon';
import React from 'react';
import useVideoPubSetModal from '../children/hooks/useVideoPubSetModal';
-interface DebounceSelectProps extends CommonUserSelectProps<IUsersItem> {
- currChooseAccount: IVideoChooseItem;
-}
+interface DebounceSelectProps extends CommonUserSelectProps<IUsersItem> {}
// 视频发布用户选择器
-export default function UserSelect({
- currChooseAccount,
- ...props
-}: DebounceSelectProps) {
+export default function UserSelect({ ...props }: DebounceSelectProps) {
const { updateAccounts } = useVideoPageStore(
useShallow((state) => ({
updateAccounts: state.updateAccounts,
})),
);
- const { setOnePubParams } = useVideoPubSetModal(currChooseAccount);
+ const { setOnePubParams, currChooseAccount } = useVideoPubSetModal();
return (
<CommonUserSelect
@@ -59,7 +53,7 @@ export default function UserSelect({
);
}}
>
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
+ <VideoPubRestartLogin />
</CommonUserSelect>
);
}
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 56ad91bd..c94d83d0 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
@@ -1,6 +1,5 @@
import { Input, Tooltip } from 'antd';
import React from 'react';
-import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import dayjs from 'dayjs';
@@ -13,6 +12,7 @@ import CommonScheduledTimeSelect, {
} from '../../../../../components/CommonComponents/CommonScheduledTimeSelect';
import {
AccountRestartLogin,
+ CommonMixSelect,
PubPermission,
PubPermissionProps,
} from '../../../../../components/CommonComponents/CommonComponents';
@@ -20,14 +20,11 @@ import useVideoPubSetModal from '../children/hooks/useVideoPubSetModal';
const { TextArea } = Input;
-export const VideoPubRestartLogin = ({
- currChooseAccount,
-}: {
- currChooseAccount: IVideoChooseItem;
-}) => {
- const { accountRestart } = useVideoPageStore(
+export const VideoPubRestartLogin = () => {
+ const { accountRestart, currChooseAccount } = useVideoPageStore(
useShallow((state) => ({
accountRestart: state.accountRestart,
+ currChooseAccount: state.currChooseAccount!,
})),
);
@@ -43,15 +40,13 @@ export const VideoPubRestartLogin = ({
// 定时发布
export const ScheduledTimeSelect = ({
- currChooseAccount,
...props
-}: ICommonScheduledTimeSelectProps & {
- currChooseAccount?: IVideoChooseItem;
-}) => {
+}: ICommonScheduledTimeSelectProps) => {
const { value, onChange } = props;
- const { setOnePubParams } = useVideoPageStore(
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
})),
);
@@ -86,19 +81,18 @@ export const ScheduledTimeSelect = ({
// 标题
export const TitleInput = ({
- currChooseAccount,
placeholder,
tips,
title = '标题',
}: {
- currChooseAccount?: IVideoChooseItem;
placeholder: string;
tips?: string;
title?: string;
}) => {
- const { setOnePubParams } = useVideoPageStore(
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
})),
);
if (!currChooseAccount) return '';
@@ -149,20 +143,19 @@ export const TitleInput = ({
// 描述
export const DescTextArea = ({
- currChooseAccount,
placeholder,
title = '描述',
maxLength,
}: {
- currChooseAccount?: IVideoChooseItem;
placeholder: string;
tips?: string;
title?: string;
maxLength: number;
}) => {
- const { setOnePubParams } = useVideoPageStore(
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
})),
);
if (!currChooseAccount) return '';
@@ -203,14 +196,8 @@ export const DescTextArea = ({
};
// 可见性
-export const VideoPubPermission = ({
- currChooseAccount,
- ...props
-}: PubPermissionProps & {
- currChooseAccount?: IVideoChooseItem;
-}) => {
- if (!currChooseAccount) return;
- const { setOnePubParams } = useVideoPubSetModal(currChooseAccount);
+export const VideoPubPermission = ({ ...props }: PubPermissionProps) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPubSetModal();
return (
<PubPermission
onChange={(e) => {
@@ -226,3 +213,14 @@ export const VideoPubPermission = ({
/>
);
};
+
+// 合集
+export const VideoPubMixSelect = ({}: {}) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPubSetModal();
+ return (
+ <CommonMixSelect
+ account={currChooseAccount.account}
+ onAccountChange={() => {}}
+ />
+ );
+};
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx
index 5d8d06d3..9fe3ad47 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx
@@ -6,7 +6,6 @@ import {
useRef,
useState,
} from 'react';
-import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
import { Avatar, Segmented } from 'antd';
import { HeartFilled } from '@ant-design/icons';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
@@ -17,9 +16,7 @@ export interface IVideoPubSetModalVideoRef {
pause: () => void;
}
-export interface IVideoPubSetModalVideoProps {
- chooseAccountItem: IVideoChooseItem;
-}
+export interface IVideoPubSetModalVideoProps {}
const CoverPreview = ({
avatar,
@@ -60,14 +57,14 @@ const CoverPreview = ({
const VideoPubSetModalVideo = memo(
forwardRef(
(
- { chooseAccountItem }: IVideoPubSetModalVideoProps,
+ {}: IVideoPubSetModalVideoProps,
ref: ForwardedRef<IVideoPubSetModalVideoRef>,
) => {
const videoRef = useRef<HTMLVideoElement>(null);
const [active, setActive] = useState(1);
- const { videoListChoose } = useVideoPageStore(
+ const { chooseAccountItem } = useVideoPageStore(
useShallow((state) => ({
- videoListChoose: state.videoListChoose,
+ chooseAccountItem: state.currChooseAccount!,
})),
);
const imperativeMethods: IVideoPubSetModalVideoRef = {
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts b/src/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts
index fa35e44b..8377be22 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts
@@ -1,8 +1,3 @@
-import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
-
export interface IVideoPubSetModalChildRef {}
-export interface IVideoPubSetModalChildProps {
- // 当前选择的账户数据
- currChooseAccount: IVideoChooseItem;
-}
+export interface IVideoPubSetModalChildProps {}
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index da9f6260..35406896 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -34,6 +34,8 @@ export interface IVideoPageStore {
* 每次操作都会分配一个操作ID
*/
operateId: string;
+ // 当前选择的账户数据
+ currChooseAccount?: IVideoChooseItem;
}
const store: IVideoPageStore = {
@@ -63,6 +65,7 @@ const store: IVideoPageStore = {
},
loadingPageLoading: false,
operateId: '',
+ currChooseAccount: undefined,
};
const getStore = () => {
@@ -88,6 +91,13 @@ export const useVideoPageStore = create(
};
const methods = {
+ // 设置当前的账户数据
+ setCurrChooseAccount(currChooseAccount: IVideoChooseItem) {
+ set({
+ currChooseAccount,
+ });
+ },
+
// 设置操作ID
setOperateId(operateId?: string) {
// if (get().operateId) return;
diff --git a/src/views/publish/comment.ts b/src/views/publish/comment.ts
index 2e8de9d8..430f0ea3 100644
--- a/src/views/publish/comment.ts
+++ b/src/views/publish/comment.ts
@@ -7,5 +7,31 @@
*/
import { PubRecordModel as PubRecordModelLast } from '../../../electron/db/models/pubRecord';
+import { AccountStatus } from '../../../commont/AccountEnum';
+import { ipcUpdateAccountStatus } from '../../icp/account';
+import { AccountInfo } from '../account/comment';
export type PubRecordModel = PubRecordModelLast;
+
+// 接口失效处理
+export async function accountFailureDispose<T>(
+ {
+ status,
+ data,
+ }: {
+ status: number;
+ data?: T;
+ },
+ account: AccountInfo,
+ callback: (account: AccountInfo) => void,
+) {
+ if (status !== 200 && status !== 201) {
+ if (status === 401) {
+ account.status = AccountStatus.DISABLE;
+ callback(account);
+ await ipcUpdateAccountStatus(account.id, AccountStatus.DISABLE);
+ }
+ return [];
+ }
+ return data || [];
+}
diff --git a/src/views/publish/components/CommonComponents/CommonComponents.tsx b/src/views/publish/components/CommonComponents/CommonComponents.tsx
index 279c8494..aa453c2d 100644
--- a/src/views/publish/components/CommonComponents/CommonComponents.tsx
+++ b/src/views/publish/components/CommonComponents/CommonComponents.tsx
@@ -1,12 +1,16 @@
-import { Button, Radio, Select } from "antd";
+import { Button, Radio, Select, SelectProps } from 'antd';
import styles from './commonComponents.module.scss';
-import React, { useState } from 'react';
+import React, { useEffect, useState } from 'react';
import { Outlet } from 'react-router-dom';
import { PlusOutlined, UserAddOutlined } from '@ant-design/icons';
import { AccountInfo } from '../../../account/comment';
import { AccountStatus } from '../../../../../commont/AccountEnum';
import { VisibleTypeEnum } from '../../../../../commont/publish/PublishEnum';
+import { icpGetMixList } from '../../../../icp/publish';
+import { accountFailureDispose } from '../../comment';
+import { onAccountLoginFinish } from '../../../../icp/receiveMsg';
+import { IMixItem } from '../../../../../electron/main/plat/plat.type';
// 本地上传、素材上传展示的块
export const ChooseChunk = ({
@@ -134,6 +138,59 @@ export const AccountRestartLogin = ({
};
// 合集
-export const CommonMixSelect = ({ account }: { account: AccountInfo }) => {
- return <Select></Select>;
+export const CommonMixSelect = ({
+ account,
+ onAccountChange,
+ ...props
+}: {
+ account?: AccountInfo;
+ onAccountChange?: (account: AccountInfo) => void;
+} & SelectProps) => {
+ if (!account || !onAccountChange) return '';
+
+ const [options, setOptions] = useState<IMixItem[]>([]);
+
+ const getList = async () => {
+ const res = await icpGetMixList(account);
+ const data = await accountFailureDispose(res, account, onAccountChange);
+ setOptions(data);
+ console.log('111data', data);
+ };
+
+ useEffect(() => {
+ getList();
+ onAccountLoginFinish(() => {
+ getList();
+ });
+ }, []);
+
+ return (
+ <>
+ <h1>合集</h1>
+ <Select
+ options={options}
+ allowClear
+ style={{ width: '100%' }}
+ placeholder="选择合集"
+ fieldNames={{
+ label: 'name',
+ value: 'id',
+ }}
+ optionRender={({ data }) => {
+ return (
+ <div className={styles.mixSelectItem}>
+ <div className="mixSelectItem-left">
+ {data.coverImg && <img src={data.coverImg} />}
+ {data.name}
+ </div>
+ <div className="mixSelectItem-right">
+ 共{data.feedCount}个作品
+ </div>
+ </div>
+ );
+ }}
+ {...props}
+ />
+ </>
+ );
};
diff --git a/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx b/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx
index 7198623d..11f6c986 100644
--- a/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx
+++ b/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx
@@ -1,13 +1,12 @@
import React, { useEffect, useRef } from 'react';
import { Select, SelectProps, Spin } from 'antd';
import { icpGetLocationData } from '@/icp/publish';
-import { AccountStatus } from '@@/AccountEnum';
-import { ipcUpdateAccountStatus } from '@/icp/account';
import { ILocationDataItem } from '@/../electron/main/plat/plat.type';
import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
import styles from './commonComponents.module.scss';
import { icpGetLocation } from '@/icp/view';
import { AccountInfo } from '../../../account/comment';
+import { accountFailureDispose } from '../../comment';
interface CommonLocationSelectProps<ValueType = any>
extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
@@ -35,15 +34,11 @@ export default function CommonLocationSelect({
longitude: location.current.loca[0],
cityName: location.current.city,
});
- if (locationData.status !== 200 && locationData.status !== 201) {
- if (locationData.status === 401 || locationData.data === undefined) {
- account!.status = AccountStatus.DISABLE;
- onAccountChange(account);
- await ipcUpdateAccountStatus(account!.id, AccountStatus.DISABLE);
- }
- return [];
- }
- return locationData.data || [];
+ return await accountFailureDispose(
+ locationData,
+ account,
+ onAccountChange,
+ );
});
// 位置 0=经度 1=纬度
const location = useRef<{
diff --git a/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx b/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx
index e1d38360..b536fb0a 100644
--- a/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx
+++ b/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx
@@ -7,6 +7,7 @@ import { ipcUpdateAccountStatus } from '@/icp/account';
import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
import { AccountInfo } from '../../../account/comment';
import styles from './commonComponents.module.scss';
+import { accountFailureDispose } from '../../comment';
export interface CommonTopicSelectProps<ValueType = any>
extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
@@ -35,15 +36,13 @@ export default function CommonTopicSelect({
useDebounceFetcher<CommonTopicSelectValueType>(
async (keyword: string): Promise<CommonTopicSelectValueType[]> => {
const topics = await icpGetTopic(account!, keyword);
- if (topics.status !== 200 && topics.status !== 201) {
- if (topics.status === 401) {
- account!.status = AccountStatus.DISABLE;
- onAccountChange(account);
- await ipcUpdateAccountStatus(account!.id, AccountStatus.DISABLE);
- }
- return [];
- }
- return topics.data!.map((v) => {
+
+ const res = await accountFailureDispose(
+ topics,
+ account,
+ onAccountChange,
+ );
+ return res!.map((v) => {
return {
label: v.name,
value: v.name,
diff --git a/src/views/publish/components/CommonComponents/CommonUserSelect.tsx b/src/views/publish/components/CommonComponents/CommonUserSelect.tsx
index a5f7db25..03b00fff 100644
--- a/src/views/publish/components/CommonComponents/CommonUserSelect.tsx
+++ b/src/views/publish/components/CommonComponents/CommonUserSelect.tsx
@@ -4,11 +4,10 @@ import { IUsersItem } from '@/../electron/main/plat/plat.type';
import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
import styles from './commonComponents.module.scss';
import { icpGetUsers } from '@/icp/publish';
-import { AccountStatus } from '@/../commont/AccountEnum';
-import { ipcUpdateAccountStatus } from '@/icp/account';
import { describeNumber } from '@/utils';
import { onAccountLoginFinish } from '@/icp/receiveMsg';
import { AccountInfo } from '../../../account/comment';
+import { accountFailureDispose } from '../../comment';
export interface CommonUserSelectProps<ValueType = any>
extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
@@ -39,27 +38,16 @@ export default function CommonUserSelect({
keyword: keywords || '',
account: account,
});
- if (res.status !== 200 && res.status !== 201) {
- if (res.status === 401) {
- account.status = AccountStatus.DISABLE;
- onAccountChange(account);
- await ipcUpdateAccountStatus(account.id, AccountStatus.DISABLE);
- }
- return [];
- }
- return res.data || [];
+ const data = await accountFailureDispose(res, account, onAccountChange);
+ setOptions(data);
};
useEffect(() => {
if (props.showSearch === false) {
- getList().then((res) => {
- setOptions(res);
- });
+ getList();
onAccountLoginFinish(() => {
- getList().then((res) => {
- setOptions(res);
- });
+ getList();
});
}
}, []);
diff --git a/src/views/publish/components/CommonComponents/commonComponents.module.scss b/src/views/publish/components/CommonComponents/commonComponents.module.scss
index 98fb8a16..c242f491 100644
--- a/src/views/publish/components/CommonComponents/commonComponents.module.scss
+++ b/src/views/publish/components/CommonComponents/commonComponents.module.scss
@@ -250,3 +250,21 @@
height: auto;
}
}
+
+.mixSelectItem {
+ justify-content: space-between;
+ align-items: center;
+ display: flex;
+ :global {
+ .mixSelectItem-left {
+ display: flex;
+ align-items: center;
+ img {
+ height: 100%;
+ width: 30px;
+ object-fit: contain;
+ margin-right: 8px;
+ }
+ }
+ }
+}