Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(日历): 发布记录列表接入
gaoSir4d1613f729cb
diff --git a/.idea/workspace.xml b/.idea/workspace.xmlindex 25c5088b..78c45b68 100644--- a/.idea/workspace.xml+++ b/.idea/workspace.xml@@ -4,22 +4,16 @@<option name="autoReloadType" value="SELECTIVE" /></component><component name="ChangeListManager">- <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat(demo): 添加定时测试demo,修复添加账号switch case语法错误问题">- <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx" afterDir="false" />+ <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat(日历): 日历-日期选择逻辑开发完成">+ <change afterPath="$PROJECT_DIR$/src/api/plat/types/kwai.types.ts" afterDir="false" />+ <change afterPath="$PROJECT_DIR$/src/api/plat/types/publish.types.ts" afterDir="false" /><change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /><change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />- <change beforePath="$PROJECT_DIR$/public/robots.txt" beforeDir="false" afterPath="$PROJECT_DIR$/public/robots.txt" afterDir="false" />- <change beforePath="$PROJECT_DIR$/public/sitemap.xml" beforeDir="false" afterPath="$PROJECT_DIR$/public/sitemap.xml" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/api/plat/types/kwai.type.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api/plat/publish.ts" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/api/publish.ts" beforeDir="false" /><change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts" 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]/demo/demoPublish.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/demo/demoPublish.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubCommonParams.tsx" beforeDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogAi.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogAi.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/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.module.scss" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/app/config/platConfig.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/config/platConfig.ts" afterDir="false" /></list><option name="SHOW_DIALOG" value="false" /><option name="HIGHLIGHT_CONFLICTS" value="true" />@@ -75,7 +69,7 @@"node.js.selected.package.tslint": "(autodetect)","nodejs_package_manager_path": "npm","run.code.analysis.last.selected.profile": "pProject Default",- "settings.editor.selected.configurable": "editor.reader.mode",+ "settings.editor.selected.configurable": "preferences.pluginManager","ts.external.directory.path": "E:\\project-dev\\web\\艺咖\\aitoearn-web\\node_modules\\typescript\\lib","vue.rearranger.settings.migration": "true"}@@ -139,7 +133,8 @@<workItem from="1751766571747" duration="1373000" /><workItem from="1751806982109" duration="7000" /><workItem from="1751853979086" duration="990000" />- <workItem from="1751875610327" duration="12461000" />+ <workItem from="1751875610327" duration="15028000" />+ <workItem from="1751969152766" duration="1525000" /></task><task id="LOCAL-00001" summary="feat: 日历完善"><option name="closed" value="true" />@@ -333,7 +328,15 @@<option name="project" value="LOCAL" /><updated>1751632949416</updated></task>- <option name="localTasksCounter" value="25" />+ <task id="LOCAL-00025" summary="feat(日历): 日历-日期选择逻辑开发完成">+ <option name="closed" value="true" />+ <created>1751962787283</created>+ <option name="number" value="00025" />+ <option name="presentableId" value="LOCAL-00025" />+ <option name="project" value="LOCAL" />+ <updated>1751962787283</updated>+ </task>+ <option name="localTasksCounter" value="26" /><servers /></component><component name="TypeScriptGeneratedFilesManager">@@ -389,6 +392,7 @@<MESSAGE value="refactor(发布): 旧发布和发布记录全部删除" /><MESSAGE value="fix: 修复类型错误,更改next配置" /><MESSAGE value="feat(demo): 添加定时测试demo,修复添加账号switch case语法错误问题" />- <option name="LAST_COMMIT_MESSAGE" value="feat(demo): 添加定时测试demo,修复添加账号switch case语法错误问题" />+ <MESSAGE value="feat(日历): 日历-日期选择逻辑开发完成" />+ <option name="LAST_COMMIT_MESSAGE" value="feat(日历): 日历-日期选择逻辑开发完成" /></component></project>\ No newline at end of filediff --git a/package.json b/package.jsonindex 8283fcaf..3a81a824 100644--- a/package.json+++ b/package.json@@ -5,6 +5,7 @@"scripts": {"postbuild": "next-sitemap","dev": "next dev --experimental-https -p 6060",+ "dev:local": "cross-env NEXT_PUBLIC_API_URL=http://localhost:7000/api/ next dev --experimental-https -p 6060","build": "tsc && next build && npm run copy-static","copy-static": "xcopy public .next\\standalone\\public /E /I /Y && if exist .next\\static xcopy .next\\static .next\\standalone\\.next\\static /E /I /Y","start": "next start",diff --git a/src/api/plat/publish.ts b/src/api/plat/publish.tsnew file mode 100644index 00000000..d6e15ef3--- /dev/null+++ b/src/api/plat/publish.ts@@ -0,0 +1,25 @@+// 创建发布+import { request } from "@/utils/request";+import {+ GetPublishListParams,+ PublishListResponse,+ PublishParams,+} from "@/api/plat/types/publish.types";++// 创建发布+export const apiCreatePublish = (data: PublishParams) => {+ return request({+ url: "/plat/publish/create",+ method: "POST",+ data,+ });+};++// 查询发布列表+export const getPublishList = (data: GetPublishListParams) => {+ return request<PublishListResponse>({+ url: "/plat/publish/getList",+ method: "POST",+ data,+ });+};diff --git a/src/api/plat/types/kwai.type.ts b/src/api/plat/types/kwai.types.tssimilarity index 100%rename from src/api/plat/types/kwai.type.tsrename to src/api/plat/types/kwai.types.tsdiff --git a/src/api/plat/types/publish.types.ts b/src/api/plat/types/publish.types.tsnew file mode 100644index 00000000..e960fc35--- /dev/null+++ b/src/api/plat/types/publish.types.ts@@ -0,0 +1,62 @@+import { PubType } from "@/app/config/publishConfig";+import { PlatType } from "@/app/config/platConfig";++export enum PublishStatus {+ FAIL = -1, // 发布失败+ UNPUBLISH = 0, // 未发布+ RELEASED = 1, // 已发布+ PUB_LOADING = 2, // 发布中+}++// 创建发布入参+export interface PublishParams {+ flowId: string;+ type: PubType;+ title: string;+ desc?: string;+ accountId: string;+ accountType: PlatType;+ videoUrl?: string;+ coverUrl?: string;+ imgList?: string[];+ publishTime?: string;+ option?: any;+}++// 查询发布列表入参+export interface GetPublishListParams {+ filter?: {+ accountId?: string;+ accountType?: PlatType;+ type?: PubType;+ status?: PublishStatus;+ time?: [Date, Date];+ };+ pageNo: number;+ pageSize: number;+}++export interface PublishRecordItem {+ dataId: string;+ id: string;+ flowId: string;+ type: string;+ title: string;+ desc: string;+ accountId: string;+ accountType: PlatType;+ uid: string;+ videoUrl?: string;+ coverUrl?: string;+ imgUrlList: string[];+ publishTime: Date;+ status: PublishStatus;+ errorMsg: string;+ option: any;+}++// 发布记录返回值+export interface PublishListResponse {+ totalCount: number;+ list: PublishRecordItem[];+}diff --git a/src/api/publish.ts b/src/api/publish.tsdeleted file mode 100644index c00cc9d1..00000000--- a/src/api/publish.ts+++ /dev/null@@ -1,87 +0,0 @@-import { request } from "@/utils/request";-import { PubType } from "@/app/config/publishConfig";--export enum AccountType {- Douyin = "douyin", // 抖音- Xhs = "xhs", // 小红书- WxSph = "wxSph", // 微信视频号- KWAI = "KWAI", // 快手- YOUTUBE = "youtube", // youtube- WxGzh = "wxGzh", // 微信公众号- BILIBILI = "bilibili", // B站-}--export enum PubStatus {- UNPUBLISH = 0, // 未发布/草稿- RELEASED = 1, // 已发布- FAIL = 2, // 发布失败- PartSuccess = 3, // 部分成功-}--export interface PublishParams {- flowId: string;- type: PubType;- title: string;- desc?: string;- accountId: string;- accountType: AccountType;- videoUrl?: string;- coverUrl?: string;- imgList?: string[];- publishTime?: string;- option?: any;-}--export interface PublishListResponse {- code: number;- data: {- list: any[];- total: number;- };- msg: string;-}--// 获取发布列表-export const apiGetPublishList = (- pageNo: number,- pageSize: number,- filter: {- readonly accountId?: string;- readonly accountType?: AccountType;- readonly type?: PubType;- readonly status?: PubStatus;- readonly time?: [Date, Date];- },-) => {- return request<PublishListResponse>({- url: `/publish/list/${pageNo}/${pageSize}`,- method: "GET",- params: filter,- });-};--// 创建发布-export const apiCreatePublish = (data: PublishParams) => {- return request({- url: "/plat/publish/create",- method: "POST",- data,- });-};--// 更新发布状态-export const updatePublishStatusApi = (id: number, status: number) => {- return request({- url: `/publish/status/${id}`,- method: "POST",- data: { status },- });-};--// 删除发布-export const deletePublishApi = (id: number) => {- return request({- url: `/publish/${id}`,- method: "DELETE",- });-};diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsxindex 3ea31c8b..0b7ee135 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx@@ -1,7 +1,7 @@import { ForwardedRef, forwardRef, memo } from "react";import styles from "./calendarTimingItem.module.scss";import { DayCellContentArg } from "@fullcalendar/core";-import { Button } from "antd";+import { Button, Skeleton } from "antd";import { useTransClient } from "@/app/i18n/client";import { PlusOutlined } from "@ant-design/icons";import { useDrop } from "react-dnd";@@ -14,12 +14,13 @@ export interface ICalendarTimingItemRef {}export interface ICalendarTimingItemProps {arg: DayCellContentArg;onClickPub: (date: string) => void;+ loading: boolean;}const CalendarTimingItem = memo(forwardRef((- { arg, onClickPub }: ICalendarTimingItemProps,+ { arg, onClickPub, loading }: ICalendarTimingItemProps,ref: ForwardedRef<ICalendarTimingItemRef>,) => {const { t } = useTransClient("account");@@ -87,26 +88,34 @@ const CalendarTimingItem = memo()}</div>- {argDate >= nowDate && (- <div className="calendarTimingItem-con">- <Button- size="small"- type="dashed"- onClick={() => {- const days = dayjs(arg.date)- .set("hour", 16)- .set("minute", 12);- onClickPub(days.format());- }}- >- <div className="calendarTimingItem-con-btn1">04:12 PM</div>- <div className="calendarTimingItem-con-btn2">- {t("addPost")}+ {loading ? (+ <>+ <Skeleton.Button active={true} block={true} size="small" />+ </>+ ) : (+ <>+ {argDate >= nowDate && (+ <div className="calendarTimingItem-con">+ <Button+ size="small"+ type="dashed"+ onClick={() => {+ const days = dayjs(arg.date)+ .set("hour", 16)+ .set("minute", 12);+ onClickPub(days.format());+ }}+ >+ <div className="calendarTimingItem-con-btn1">04:12 PM</div>+ <div className="calendarTimingItem-con-btn2">+ {t("addPost")}+ </div>+ </Button>+ <CustomDragLayer snapToGrid={false} />+ <CalendarRecord /></div>- </Button>- <CustomDragLayer snapToGrid={false} />- <CalendarRecord />- </div>+ )}+ </>)}</div>);diff --git a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx b/src/app/[lng]/accounts/components/CalendarTiming/index.tsxindex 8faa1adc..8adc0761 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx+++ b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx@@ -26,7 +26,7 @@ import { useShallow } from "zustand/react/shallow";import { HTML5Backend } from "react-dnd-html5-backend";import { DndProvider } from "react-dnd";import { useCalendarTiming } from "@/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming";-import dayjs from "dayjs";+import { getPublishList } from "@/api/plat/publish";export interface ICalendarTimingRef {}export interface ICalendarTimingProps {}@@ -63,9 +63,11 @@ const CalendarTiming = memo();const calendarTimingItemCallEl = useRef<HTMLDivElement | null>(null);const publishDialogRef = useRef<IPublishDialogRef>(null);+ const [listLoading, setListLoading] = useState(false);useEffect(() => {window.addEventListener("resize", handleResize);+ getPubRecord();setTimeout(() => {calendarTimingItemCallEl.current = document.querySelector(@@ -78,6 +80,20 @@ const CalendarTiming = memo(return () => window.removeEventListener("resize", handleResize);}, []);+ // 获取发布记录数据+ const getPubRecord = async () => {+ setListLoading(true);+ const res = await getPublishList({+ pageNo: 1,+ pageSize: 500,+ filter: {},+ });+ setListLoading(false);+ console.log(res);+ console.log("发布记录");+ };++ // 处理窗口大小变化const handleResize = () => {setTimeout(() => {const el = calendarTimingItemCallEl.current!;@@ -104,7 +120,6 @@ const CalendarTiming = memo(setAnimating(false);}, 300);};-const handleNext = () => {triggerAnimation("left");setTimeout(() => {@@ -172,6 +187,7 @@ const CalendarTiming = memo(dayCellContent={(arg) => {return (<CalendarTimingItem+ loading={listLoading}arg={arg}onClickPub={(date) => {publishDialogRef.current!.setPubTime(date);diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.tsindex 3edd7b34..1d57216f 100644--- a/src/app/config/platConfig.ts+++ b/src/app/config/platConfig.ts@@ -14,6 +14,7 @@ export enum PlatType {YouTube = "youtube", // YouTubeBILIBILI = "bilibili", // B站Twitter = "twitter", // Twitter+ WxGzh = "wxGzh", // 微信公众号}export interface IAccountPlatInfo {