Skip to content

Let's use AI to Earn!

feat(发布):1. b站添加是否转载、选择分区参数。 2. 发布记录展示时间修复,将后端返回的时间转为当前时区给用户展示。 3. b站添加强制拦截,分区、转载不选择会强制拦截用户。

gaoSir66bc1b6e4e83
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4103a748..64f4ef36 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,23 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(发布):b站添加标题参数">
+ <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(发布):b站">
+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialogData.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/index.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/api/bilibili.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api/plat/bilibili.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/api/plat/types/publish.types.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api/plat/types/publish.types.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/api/tools.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api/tools.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/plat/BilibiliLogin.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/plat/BilibiliLogin.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/config/platConfig.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/config/platConfig.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogPreview.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogPreview.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/hooks/usePubParamsVerify.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/hooks/usePubParamsVerify.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.type.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.type.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -61,6 +74,7 @@
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
+ &quot;last_opened_file_path&quot;: &quot;E:/project-dev/web/艺咖/aitoearn-web/src/api/plat&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
@@ -80,6 +94,11 @@
</map>
</option>
</component>
+ <component name="RecentsManager">
+ <key name="MoveFile.RECENT_KEYS">
+ <recent name="E:\project-dev\web\艺咖\aitoearn-web\src\api\plat" />
+ </key>
+ </component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
@@ -95,7 +114,7 @@
<workItem from="1752130881346" duration="11774000" />
<workItem from="1752200550278" duration="253000" />
<workItem from="1752200816463" duration="23828000" />
- <workItem from="1752459064500" duration="2377000" />
+ <workItem from="1752459064500" duration="8438000" />
</task>
<task id="LOCAL-00001" summary="feat(CalendarTiming): 优化发布记录列表展示&#10;- 调整日历记录项的样式和布局&#10;- 优化 RecordCore组件,添加平台图标和时间显示&#10;- 修改 CalendarTimingItem 组件,移除不必要的 Fragment&#10;-调整 index.tsx 中的日期格式化逻辑">
<option name="closed" value="true" />
@@ -257,7 +276,15 @@
<option name="project" value="LOCAL" />
<updated>1752247253122</updated>
</task>
- <option name="localTasksCounter" value="21" />
+ <task id="LOCAL-00021" summary="feat(发布):发布记录添加账户筛选API">
+ <option name="closed" value="true" />
+ <created>1752479070015</created>
+ <option name="number" value="00021" />
+ <option name="presentableId" value="LOCAL-00021" />
+ <option name="project" value="LOCAL" />
+ <updated>1752479070015</updated>
+ </task>
+ <option name="localTasksCounter" value="22" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -297,6 +324,7 @@
<MESSAGE value="chore(发布弹框): 拖动修改发布时间完成" />
<MESSAGE value="fix(日历): 修复更新的问题" />
<MESSAGE value="feat(发布):b站添加标题参数" />
- <option name="LAST_COMMIT_MESSAGE" value="feat(发布):b站添加标题参数" />
+ <MESSAGE value="feat(发布):发布记录添加账户筛选API" />
+ <option name="LAST_COMMIT_MESSAGE" value="feat(发布):发布记录添加账户筛选API" />
</component>
</project>
\ No newline at end of file
diff --git a/src/api/bilibili.ts b/src/api/bilibili.ts
deleted file mode 100644
index 8ad60a54..00000000
--- a/src/api/bilibili.ts
+++ /dev/null
@@ -1,145 +0,0 @@
-// 创建或更新账户
-import http from "@/utils/request";
-import { request } from "@/utils/request";
-
-/**
- * 获取B站登录地址
- * @returns
- */
-export const apiGetBilibiliLoginUrl = (type: "h5" | "pc") => {
- return http.get<{ code: number; data: { taskId: string; url: string } }>(
- `plat/bilibili/auth/url/${type}`,
- );
-};
-
-/**
- * 检查B站授权状态
- * @param accointId 账号ID
- * @returns
- */
-export const apiCheckAccountAuthStatus = (accointId: string) => {
- return http.get<{ code: number; data: boolean }>(
- `plat/bilibili/auth/status/${accointId}`,
- );
-};
-
-/**
- * 获取B站授权状态
- * @param taskId 任务ID
- * @returns
- */
-export const apiCheckBilibiliAuth = (taskId: string) => {
- return http.post<{ code: number; data: any }>(
- `plat/bilibili/auth/create-account/${taskId}`,
- );
-};
-
-/**
- * 初始化视频
- * @param accountId 账户ID
- * @returns
- */
-export const apiInitBilibiliVideo = (data: any) => {
- return http.post<{ code: number; data: any }>(
- `plat/bilibili/video/init`,
- data,
- );
-};
-
-/**
- * 上传B站视频封面
- * @param accountId 账户ID
- * @param file 封面文件
- * @returns
- */
-export const apiUploadBilibiliCover = (accountId: string, data: any) => {
- return request({
- url: `plat/bilibili/cover/upload/${accountId}`,
- method: "POST",
- body: data,
- });
-};
-
-// 上傳視頻到bilibili
-export const apiUploadBilibilivideo = (
- accountId: string,
- upload_token: string,
- data: any,
-) => {
- return request({
- url: `plat/bilibili/video/upload/${accountId}?uploadToken=${upload_token}`,
- method: "POST",
- body: data,
- });
-};
-
-/**
- * 提交B站稿件
- * @param accountId 账户ID
- * @param data 稿件数据
- * @returns
- */
-export const apiSubmitBilibiliArchive = (data: any) => {
- return http.post<{ code: number; data: any }>(
- `plat/bilibili/archive/add-by-utoken`,
- data,
- );
-};
-
-/**
- * 上传B站视频分片
- * @param accountId 账户ID
- * @param uploadToken 上传token
- * @param partNumber 分片序号
- * @param data 分片数据
- * @returns
- */
-export const apiUploadBilibiliVideoPart = (
- accountId: string,
- uploadToken: string,
- partNumber: number,
- data: any,
-) => {
- const formData = new FormData();
- formData.append("file", data);
-
- return request({
- url: `plat/bilibili/video/part/upload/${accountId}`,
- method: "POST",
- body: formData,
- params: {
- uploadToken,
- partNumber,
- },
- });
-};
-
-/**
- * 合并B站视频分片
- * @param accountId 账户ID
- * @param uploadToken 上传token
- * @returns
- */
-export const apiCompleteBilibiliVideo = (
- accountId: string,
- uploadToken: string,
-) => {
- return request({
- url: `plat/bilibili/video/complete/${accountId}`,
- method: "POST",
- data: {
- uploadToken,
- },
- });
-};
-
-/**
- * 获取B站分区列表
- * @param accountId 账户ID
- * @returns
- */
-export const apiGetBilibiliPartitions = (accountId: string) => {
- return http.get<{ code: number; data: any }>(
- `plat/bilibili/archive/type/list/${accountId}`,
- );
-};
diff --git a/src/api/plat/bilibili.ts b/src/api/plat/bilibili.ts
new file mode 100644
index 00000000..1aae5435
--- /dev/null
+++ b/src/api/plat/bilibili.ts
@@ -0,0 +1,46 @@
+// 创建或更新账户
+import http from "@/utils/request";
+import { BiblPartItem } from "@/components/PublishDialog/publishDialog.type";
+
+/**
+ * 获取B站登录地址
+ * @returns
+ */
+export const apiGetBilibiliLoginUrl = (type: "h5" | "pc") => {
+ return http.get<{ code: number; data: { taskId: string; url: string } }>(
+ `plat/bilibili/auth/url/${type}`,
+ );
+};
+
+/**
+ * 检查B站授权状态
+ * @param accointId 账号ID
+ * @returns
+ */
+export const apiCheckAccountAuthStatus = (accointId: string) => {
+ return http.get<{ code: number; data: boolean }>(
+ `plat/bilibili/auth/status/${accointId}`,
+ );
+};
+
+/**
+ * 获取B站授权状态
+ * @param taskId 任务ID
+ * @returns
+ */
+export const apiCheckBilibiliAuth = (taskId: string) => {
+ return http.post<{ code: number; data: any }>(
+ `plat/bilibili/auth/create-account/${taskId}`,
+ );
+};
+
+/**
+ * 获取B站分区列表
+ * @param accountId 账户ID
+ * @returns
+ */
+export const apiGetBilibiliPartitions = (accountId: string) => {
+ return http.get<BiblPartItem[]>(
+ `plat/bilibili/archive/type/list/${accountId}`,
+ );
+};
diff --git a/src/api/plat/types/publish.types.ts b/src/api/plat/types/publish.types.ts
index 59bdbfca..be469e7a 100644
--- a/src/api/plat/types/publish.types.ts
+++ b/src/api/plat/types/publish.types.ts
@@ -1,5 +1,6 @@
import { PubType } from "@/app/config/publishConfig";
import { PlatType } from "@/app/config/platConfig";
+import { IPlatOption } from "@/components/PublishDialog/publishDialog.type";
export enum PublishStatus {
FAIL = -1, // 发布失败
@@ -25,7 +26,7 @@ export interface PublishParams {
// 话题
topics?: string[];
publishTime?: string;
- option?: any;
+ option?: IPlatOption;
}
// 查询发布列表入参
@@ -42,6 +43,7 @@ export interface PublishRecordItem {
dataId: string;
id: string;
flowId: string;
+ workLink: string;
type: string;
title: string;
desc: string;
diff --git a/src/api/tools.ts b/src/api/tools.ts
index eadbda54..279d3740 100644
--- a/src/api/tools.ts
+++ b/src/api/tools.ts
@@ -108,7 +108,6 @@ export const toolsApi = {
"Content-Type": "multipart/form-data",
},
onUploadProgress: (progressEvent) => {
- console.log(progressEvent);
const prog = Math.round(
(progressEvent.loaded * 100) / progressEvent.total!,
);
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
index 5ecbe838..6f98d866 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
@@ -14,7 +14,6 @@ import {
PublishStatus,
} from "@/api/plat/types/publish.types";
import styles from "./recordCore.module.scss";
-import dayjs from "dayjs";
import { AccountPlatInfoMap } from "@/app/config/platConfig";
import {
CheckCircleOutlined,
@@ -30,6 +29,7 @@ import { useAccountStore } from "@/store/account";
import type { MenuProps } from "antd";
import { TooltipRef } from "antd/lib/tooltip";
import { deletePublishRecordApi } from "@/api/plat/publish";
+import { getDays } from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";
export interface IRecordCoreRef {}
@@ -92,6 +92,9 @@ const RecordCore = memo(
{
key: "2",
label: "复制链接",
+ onClick: async () => {
+ await navigator.clipboard.writeText(publishRecord.workLink);
+ },
},
{
key: "3",
@@ -107,7 +110,7 @@ const RecordCore = memo(
];
const days = useMemo(() => {
- return dayjs(publishRecord.publishTime);
+ return getDays(publishRecord.publishTime);
}, [publishRecord]);
const account = useMemo(() => {
@@ -188,7 +191,7 @@ const RecordCore = memo(
>
<div className="recordCore-left">
<img src={platIcon} />
- <div className="recordCore-left-date">{days.format("HH:MM")}</div>
+ <div className="recordCore-left-date">{days.format("HH:mm")}</div>
</div>
<div className="recordCore-right">
<img src={publishRecord.coverUrl} />
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts
index 290c5c82..bb949674 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts
+++ b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts
@@ -1,8 +1,10 @@
import styles from "./calendarTiming.module.scss";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
+import timezone from "dayjs/plugin/timezone";
dayjs.extend(utc);
+dayjs.extend(timezone);
// 日历国际化
export const getFullCalendarLang = (lang: string) => {
diff --git a/src/app/[lng]/accounts/plat/BilibiliLogin.ts b/src/app/[lng]/accounts/plat/BilibiliLogin.ts
index 349a2ebd..25b9070d 100644
--- a/src/app/[lng]/accounts/plat/BilibiliLogin.ts
+++ b/src/app/[lng]/accounts/plat/BilibiliLogin.ts
@@ -1,6 +1,6 @@
import qs from "qs";
import { PlatType } from "@/app/config/platConfig";
-import { apiGetBilibiliLoginUrl, apiCheckBilibiliAuth } from "@/api/bilibili";
+import { apiGetBilibiliLoginUrl, apiCheckBilibiliAuth } from "@/api/plat/bilibili";
import { useAccountStore } from "@/store/account";
diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.ts
index a5e52ec9..966a2b27 100644
--- a/src/app/config/platConfig.ts
+++ b/src/app/config/platConfig.ts
@@ -92,8 +92,8 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
url: "https://cp.kuaishou.com/profile",
pubTypes: new Set([PubType.VIDEO]),
commonPubParamsConfig: {
- topicMax: 4,
- titleMax: 20,
+ topicMax: 10,
+ titleMax: 80,
},
themeColor: "blue",
},
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx
index 002109f5..d7bf170f 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx
@@ -53,5 +53,5 @@ export default function usePlatParamsCommon(pubItem: PubItem) {
return props;
}, [currErrItem, onChange, pubItem]);
- return { pubParmasTextareaCommonParams };
+ return { pubParmasTextareaCommonParams, setOnePubParams };
}
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss b/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
index 6c9845a3..b3a8c51e 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
@@ -38,4 +38,5 @@
.commonTitleInput {
display: flex;
align-items: center;
+ height: 32px;
}
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx
index e5b46f37..11b91a12 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx
@@ -1,4 +1,4 @@
-import { ForwardedRef, forwardRef, memo } from "react";
+import { ForwardedRef, forwardRef, memo, useEffect } from "react";
import {
IPlatsParamsProps,
IPlatsParamsRef,
@@ -6,11 +6,27 @@ import {
import PubParmasTextarea from "@/components/PublishDialog/compoents/PubParmasTextarea";
import usePlatParamsCommon from "@/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon";
import CommonTitleInput from "@/components/PublishDialog/compoents/PlatParamsSetting/common/CommonTitleInput";
+import { usePublishDialogData } from "@/components/PublishDialog/usePublishDialogData";
+import { useShallow } from "zustand/react/shallow";
+import styles from "../platParamsSetting.module.scss";
+import { Input, Radio, Select } from "antd";
const BilibParams = memo(
forwardRef(
({ pubItem }: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {
- const { pubParmasTextareaCommonParams } = usePlatParamsCommon(pubItem);
+ const { pubParmasTextareaCommonParams, setOnePubParams } =
+ usePlatParamsCommon(pubItem);
+ const { getBilibiliPartitions, bilibiliPartitions } =
+ usePublishDialogData(
+ useShallow((state) => ({
+ getBilibiliPartitions: state.getBilibiliPartitions,
+ bilibiliPartitions: state.bilibiliPartitions,
+ })),
+ );
+
+ useEffect(() => {
+ getBilibiliPartitions();
+ }, [getBilibiliPartitions]);
return (
<>
@@ -19,6 +35,71 @@ const BilibParams = memo(
extend={
<>
<CommonTitleInput pubItem={pubItem} />
+ <div
+ className={styles.commonTitleInput}
+ style={{ marginTop: "10px" }}
+ >
+ <div className="platParamsSetting-label">分区</div>
+ <Select
+ style={{ width: "100%" }}
+ options={bilibiliPartitions}
+ value={pubItem.params.option.bilibili?.tid}
+ onChange={(value) => {
+ const option = pubItem.params.option;
+ option.bilibili!.tid = value;
+ setOnePubParams(
+ {
+ option,
+ },
+ pubItem.account.id,
+ );
+ }}
+ showSearch={true}
+ placeholder="请选择分区"
+ fieldNames={{
+ label: "name",
+ value: "id",
+ }}
+ />
+ </div>
+
+ <div
+ className={styles.commonTitleInput}
+ style={{ marginTop: "10px" }}
+ >
+ <div className="platParamsSetting-label">类型</div>
+ <Radio.Group
+ value={pubItem.params.option.bilibili?.copyright}
+ options={[
+ { value: 1, label: "原创" },
+ { value: 2, label: "转载" },
+ ]}
+ onChange={(e) => {
+ const option = pubItem.params.option;
+ const value = e.target.value;
+ option.bilibili!.copyright = value;
+ if (value === 1) {
+ option.bilibili!.source = "";
+ }
+ setOnePubParams(
+ {
+ option,
+ },
+ pubItem.account.id,
+ );
+ }}
+ />
+ </div>
+
+ {pubItem.params.option.bilibili?.copyright === 2 && (
+ <div
+ className={styles.commonTitleInput}
+ style={{ marginTop: "10px" }}
+ >
+ <div className="platParamsSetting-label">转载来源</div>
+ <Input placeholder="转载视频请注明来源、时间、地点(例:转自https://www.xxxx.com/yyyy)" />
+ </div>
+ )}
</>
}
/>
diff --git a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx b/src/components/PublishDialog/compoents/PublishDialogPreview.tsx
index 0033bea0..49dd35e8 100644
--- a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx
+++ b/src/components/PublishDialog/compoents/PublishDialogPreview.tsx
@@ -59,7 +59,9 @@ const PublishDialogPreview = memo(
<div className="publishDialogPreview-preview-video-top" />
<div className="publishDialogPreview-preview-images">
<Swiper
- loop={expandedPubItem!.params.images!.length > 1}
+ loop={
+ (expandedPubItem!.params.images?.length || 0) > 1
+ }
modules={[Navigation, Pagination]}
pagination={{
clickable: true,
diff --git a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx
index bf0da1e8..53864bbd 100644
--- a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx
+++ b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx
@@ -35,7 +35,6 @@ export default function usePubParamsVerify(data: PubItem[]) {
parErrMsg: "请上传图片或视频",
});
}
-
// 强制需要标题
if (v.account.type === PlatType.BILIBILI && !v.params.title) {
return errParamsMapTemp.set(v.account.id, {
@@ -43,6 +42,23 @@ export default function usePubParamsVerify(data: PubItem[]) {
});
}
+ // b站的强制校验
+ if (v.account.type === PlatType.BILIBILI) {
+ if (!v.params.option.bilibili?.tid) {
+ return errParamsMapTemp.set(v.account.id, {
+ parErrMsg: "您必须选择分区!",
+ });
+ }
+ if (
+ v.params.option.bilibili.copyright === 2 &&
+ !v.params.option.bilibili.source
+ ) {
+ return errParamsMapTemp.set(v.account.id, {
+ parErrMsg: "转载时必须填写转载来源",
+ });
+ }
+ }
+
// 快手要求封面必须大于 400x400
if (
v.account?.type === PlatType.KWAI &&
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index 4020f897..f7677e1c 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -161,16 +161,7 @@ const PublishDialog = memo(
item.params.video?.cover.ossUrl || item.params.images![0].ossUrl!,
imgUrlList: item.params.images?.map((v) => v.ossUrl!),
publishTime,
- option: {
- isAutoPublish: true,
- isAutoDelete: true,
- isAutoCover: true,
- isAutoImg: true,
- bilibili: {
- tid: 21,
- copyright: 1,
- },
- },
+ option: item.params.option,
});
if (res?.code !== 0) {
return setCreateLoading(false);
diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.ts
index 3a0fe001..8a2b98c7 100644
--- a/src/components/PublishDialog/publishDialog.type.ts
+++ b/src/components/PublishDialog/publishDialog.type.ts
@@ -35,6 +35,19 @@ export interface IVideoFile {
cover: IImgFile;
}
+// 发布 每个平台的独有参数
+export interface IPlatOption {
+ bilibili?: {
+ // 分区ID,由获取分区信息接口得到
+ tid?: number;
+ // 1-原创,2-转载(转载时source必填)
+ copyright?: number;
+ // 如果copyright为转载,则此字段表示转载来源
+ source?: string;
+ };
+}
+
+// 发布参数
export interface IPubParams {
des: string;
// 视频和图片不能同时存在,存在图片本次发布则为图文,存在视频则本次发布为视频发布 --------------
@@ -46,9 +59,21 @@ export interface IPubParams {
topics?: string[];
// 标题
title?: string;
+ // 发布 每个平台的独有参数
+ option: IPlatOption;
}
+// 发布数据 item
export interface PubItem {
account: SocialAccount;
params: IPubParams;
}
+
+// b站分区 item
+export interface BiblPartItem {
+ description: string;
+ id: number;
+ name: string;
+ parent: number;
+ children: BiblPartItem[];
+}
diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.ts
index 57365fe1..75476eec 100644
--- a/src/components/PublishDialog/usePublishDialog.ts
+++ b/src/components/PublishDialog/usePublishDialog.ts
@@ -35,6 +35,13 @@ const store: IPublishDialogStore = {
des: "",
video: undefined,
images: [],
+ option: {
+ bilibili: {
+ tid: undefined,
+ copyright: 1,
+ source: "",
+ },
+ },
},
expandedPubItem: undefined,
errParamsMap: undefined,
@@ -184,6 +191,7 @@ export const usePublishDialog = create(
});
},
};
+
return methods;
},
),
diff --git a/src/components/PublishDialog/usePublishDialogData.ts b/src/components/PublishDialog/usePublishDialogData.ts
new file mode 100644
index 00000000..fba4c3bf
--- /dev/null
+++ b/src/components/PublishDialog/usePublishDialogData.ts
@@ -0,0 +1,51 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import lodash from "lodash";
+import { BiblPartItem } from "@/components/PublishDialog/publishDialog.type";
+import { apiGetBilibiliPartitions } from "@/api/plat/bilibili";
+import { useAccountStore } from "@/store/account";
+import { PlatType } from "@/app/config/platConfig";
+
+export interface IPublishDialogDataStore {
+ // b站分区列表
+ bilibiliPartitions: BiblPartItem[];
+}
+
+const store: IPublishDialogDataStore = {
+ bilibiliPartitions: [],
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+/**
+ * 存放发布弹框一些平台获取的三方数据
+ * 如:b站的分区列表
+ */
+export const usePublishDialogData = create(
+ combine(
+ {
+ ...getStore(),
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ // 获取b站分区列表
+ async getBilibiliPartitions() {
+ if (get().bilibiliPartitions.length !== 0) return;
+ const res = await apiGetBilibiliPartitions(
+ useAccountStore
+ .getState()
+ .accountList.find((v) => v.type === PlatType.BILIBILI)!.account,
+ );
+ set({
+ bilibiliPartitions: res?.data,
+ });
+ return res?.data;
+ },
+ };
+
+ return methods;
+ },
+ ),
+);