Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(发布弹框): 立即发布接入API
gaoSir6b18941f1990
diff --git a/.idea/workspace.xml b/.idea/workspace.xmlindex 03216206..4135b41a 100644--- a/.idea/workspace.xml+++ b/.idea/workspace.xml@@ -4,9 +4,13 @@<option name="autoReloadType" value="SELECTIVE" /></component><component name="ChangeListManager">- <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="fix(日历):修复了单元格没有预期时间但是发布记录还是不会填满单元格的问题。">+ <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="fix(发布弹框): 修复右侧预览不正常隐藏的问题"><change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/api/plat/publish.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api/plat/publish.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/components/CalendarTiming/CalendarTimingItem/recordCore.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/recordCore.module.scss" 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/store/account.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/store/account.ts" afterDir="false" /></list><option name="SHOW_DIALOG" value="false" /><option name="HIGHLIGHT_CONFLICTS" value="true" />@@ -106,7 +110,7 @@<workItem from="1752459064500" duration="10175000" /><workItem from="1752498765091" duration="2121000" /><workItem from="1752543943603" duration="2208000" />- <workItem from="1752546939831" duration="2147000" />+ <workItem from="1752546939831" duration="6622000" /></task><task id="LOCAL-00001" summary="feat(CalendarTiming): 优化发布记录列表展示 - 调整日历记录项的样式和布局 - 优化 RecordCore组件,添加平台图标和时间显示 - 修改 CalendarTimingItem 组件,移除不必要的 Fragment -调整 index.tsx 中的日期格式化逻辑"><option name="closed" value="true" />@@ -292,7 +296,15 @@<option name="project" value="LOCAL" /><updated>1752546046166</updated></task>- <option name="localTasksCounter" value="24" />+ <task id="LOCAL-00024" summary="fix(发布弹框): 修复右侧预览不正常隐藏的问题">+ <option name="closed" value="true" />+ <created>1752551524945</created>+ <option name="number" value="00024" />+ <option name="presentableId" value="LOCAL-00024" />+ <option name="project" value="LOCAL" />+ <updated>1752551524945</updated>+ </task>+ <option name="localTasksCounter" value="25" /><servers /></component><component name="TypeScriptGeneratedFilesManager">@@ -335,6 +347,7 @@<MESSAGE value="feat(发布):发布记录添加账户筛选API" /><MESSAGE value="feat(发布):1. b站添加是否转载、选择分区参数。 2. 发布记录展示时间修复,将后端返回的时间转为当前时区给用户展示。 3. b站添加强制拦截,分区、转载不选择会强制拦截用户。" /><MESSAGE value="fix(日历):修复了单元格没有预期时间但是发布记录还是不会填满单元格的问题。" />- <option name="LAST_COMMIT_MESSAGE" value="fix(日历):修复了单元格没有预期时间但是发布记录还是不会填满单元格的问题。" />+ <MESSAGE value="fix(发布弹框): 修复右侧预览不正常隐藏的问题" />+ <option name="LAST_COMMIT_MESSAGE" value="fix(发布弹框): 修复右侧预览不正常隐藏的问题" /></component></project>\ No newline at end of filediff --git a/src/api/plat/publish.ts b/src/api/plat/publish.tsindex e8db2619..15aa960a 100644--- a/src/api/plat/publish.ts+++ b/src/api/plat/publish.ts@@ -48,3 +48,11 @@ export const deletePublishRecordApi = (id: string) => {method: "DELETE",});};++// 立即发布任务+export const nowPubTaskApi = (id: string) => {+ return request({+ url: `/plat/publish/nowPubTask/${id}`,+ method: "POST",+ });+};diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsxindex 6f98d866..87b3ee92 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx@@ -23,12 +23,13 @@ import {FullscreenOutlined,LoadingOutlined,MoreOutlined,+ SendOutlined,} from "@ant-design/icons";import AvatarPlat from "@/components/AvatarPlat";import { useAccountStore } from "@/store/account";import type { MenuProps } from "antd";import { TooltipRef } from "antd/lib/tooltip";-import { deletePublishRecordApi } from "@/api/plat/publish";+import { deletePublishRecordApi, nowPubTaskApi } from "@/api/plat/publish";import { getDays } from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";export interface IRecordCoreRef {}@@ -81,9 +82,9 @@ const RecordCore = memo(getPubRecord: state.getPubRecord,})),);- const { accountUidMap } = useAccountStore(+ const { accountAccountMap } = useAccountStore(useShallow((state) => ({- accountUidMap: state.accountUidMap,+ accountAccountMap: state.accountAccountMap,})),);const [popoverOpen, setPopoverOpen] = useState(false);@@ -114,8 +115,8 @@ const RecordCore = memo(}, [publishRecord]);const account = useMemo(() => {- return accountUidMap.get(publishRecord.flowId)!;- }, [accountUidMap, publishRecord.flowId]);+ return accountAccountMap.get(publishRecord.accountId)!;+ }, [accountAccountMap, publishRecord.accountId]);const platIcon = useMemo(() => {return AccountPlatInfoMap.get(publishRecord.accountType)?.icon;@@ -177,6 +178,15 @@ const RecordCore = memo(</div></div><div className="recordDetails-bottom">+ <Button+ icon={<SendOutlined />}+ onClick={async () => {+ await nowPubTaskApi(publishRecord.id);+ getPubRecord();+ }}+ >+ 立即发布+ </Button><Dropdown menu={{ items: dropdownItems }} placement="top"><Button icon={<MoreOutlined />} /></Dropdown>diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/recordCore.module.scss b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/recordCore.module.scssindex 97ebb2f7..daa15d4f 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/recordCore.module.scss+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/recordCore.module.scss@@ -84,6 +84,9 @@display: flex;justify-content: right;:global {+ button {+ margin-left: 10px;+ }.anticon {font-size: 18px !important;font-weight: 900 !important;diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsxindex 404d79a7..b2e0500a 100644--- a/src/components/PublishDialog/index.tsx+++ b/src/components/PublishDialog/index.tsx@@ -29,6 +29,7 @@ import {getDays,getUtcDays,} from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";+import { generateUUID } from "@/utils";export interface IPublishDialogRef {// 设置发布时间@@ -145,10 +146,11 @@ const PublishDialog = memo(pubTime ? pubTime : getDays().add(6, "minute"),).format();+ const flowId = generateUUID();for (const item of pubListChoosed) {const res = await apiCreatePublish({topics: [],- flowId: item.account.uid,+ flowId: flowId,type: item.params.video?.cover.ossUrl? PubType.VIDEO: PubType.ImageText,@@ -244,6 +246,7 @@ const PublishDialog = memo(} else {newPubListChoosed.push(pubItem);}+ // 是否自动回到第一步if (newPubListChoosed.length === 0 && step === 1) {const isBack = newPubListChoosed.every((v) =>@@ -255,6 +258,7 @@ const PublishDialog = memo(setStep(0);}}+ // 是否自动前往第二步if (step === 0 && newPubListChoosed.length !== 0) {const isFront = newPubListChoosed.every((v) =>diff --git a/src/store/account.ts b/src/store/account.tsindex 7d8550bd..8e79ea0d 100644--- a/src/store/account.ts+++ b/src/store/account.ts@@ -11,8 +11,8 @@ export interface AccountGroup extends AccountGroupItem {export interface IAccountStore {accountList: SocialAccount[];accountMap: Map<string, SocialAccount>;- // key=uid,value=账户- accountUidMap: Map<string, SocialAccount>;+ // key=account,value=账户+ accountAccountMap: Map<string, SocialAccount>;accountGroupList: AccountGroup[];accountGroupMap: Map<string, AccountGroup>;accountLoading: boolean;@@ -27,7 +27,7 @@ const store: IAccountStore = {accountGroupList: [],accountGroupMap: new Map([]),accountMap: new Map([]),- accountUidMap: new Map([]),+ accountAccountMap: new Map([]),accountLoading: false,accountActive: undefined,};@@ -65,20 +65,20 @@ export const useAccountStore = create(set({ accountLoading: true });const accountMap = new Map<string, SocialAccount>([]);- const accountUidMap = new Map<string, SocialAccount>([]);+ const accountAccountMap = new Map<string, SocialAccount>([]);const result = await getAccountListApi();if (result?.code !== 0) return;for (const item of result.data) {accountMap.set(item.id, item);- accountUidMap.set(item.uid, item);+ accountAccountMap.set(item.account, item);}set({accountList: result.data,accountMap,- accountUidMap,+ accountAccountMap,});await methods.getAccountGroup();