Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(日历): 日历-日期选择逻辑开发完成
gaoSirf18a8d05cc5f
diff --git a/.idea/workspace.xml b/.idea/workspace.xmlindex e24a3f92..25c5088b 100644--- a/.idea/workspace.xml+++ b/.idea/workspace.xml@@ -4,13 +4,22 @@<option name="autoReloadType" value="SELECTIVE" /></component><component name="ChangeListManager">- <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat(demo): 添加定时任务测试">- <change afterPath="$PROJECT_DIR$/src/app/[lng]/demo/pubDemo/page.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/.env.development" beforeDir="false" afterPath="$PROJECT_DIR$/.env.development" afterDir="false" />+ <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" /><change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/api/publish.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api/publish.ts" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/AddAccountModal/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/AddAccountModal/index.tsx" 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/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" /></list><option name="SHOW_DIALOG" value="false" /><option name="HIGHLIGHT_CONFLICTS" value="true" />@@ -21,8 +30,8 @@<option name="RECENT_TEMPLATES"><list><option value="TypeScript File" />- <option value="tsx组件模板" /><option value="TypeScript JSX File" />+ <option value="tsx组件模板" /></list></option></component>@@ -126,7 +135,11 @@<workItem from="1751278214456" duration="955000" /><workItem from="1751334170049" duration="2844000" /><workItem from="1751351785412" duration="26981000" />- <workItem from="1751624107936" duration="2913000" />+ <workItem from="1751624107936" duration="4186000" />+ <workItem from="1751766571747" duration="1373000" />+ <workItem from="1751806982109" duration="7000" />+ <workItem from="1751853979086" duration="990000" />+ <workItem from="1751875610327" duration="12461000" /></task><task id="LOCAL-00001" summary="feat: 日历完善"><option name="closed" value="true" />@@ -312,7 +325,15 @@<option name="project" value="LOCAL" /><updated>1751445479615</updated></task>- <option name="localTasksCounter" value="24" />+ <task id="LOCAL-00024" summary="feat(demo): 添加定时测试demo,修复添加账号switch case语法错误问题">+ <option name="closed" value="true" />+ <created>1751632949416</created>+ <option name="number" value="00024" />+ <option name="presentableId" value="LOCAL-00024" />+ <option name="project" value="LOCAL" />+ <updated>1751632949416</updated>+ </task>+ <option name="localTasksCounter" value="25" /><servers /></component><component name="TypeScriptGeneratedFilesManager">@@ -367,6 +388,7 @@<MESSAGE value="feat: 授权改到后端" /><MESSAGE value="refactor(发布): 旧发布和发布记录全部删除" /><MESSAGE value="fix: 修复类型错误,更改next配置" />- <option name="LAST_COMMIT_MESSAGE" value="fix: 修复类型错误,更改next配置" />+ <MESSAGE value="feat(demo): 添加定时测试demo,修复添加账号switch case语法错误问题" />+ <option name="LAST_COMMIT_MESSAGE" value="feat(demo): 添加定时测试demo,修复添加账号switch case语法错误问题" /></component></project>\ No newline at end of filediff --git a/package.json b/package.jsonindex 6a6ac314..8283fcaf 100644--- a/package.json+++ b/package.json@@ -4,7 +4,7 @@"private": true,"scripts": {"postbuild": "next-sitemap",- "dev": "next dev --experimental-https",+ "dev": "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/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsxindex 3738717c..3ea31c8b 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx@@ -7,12 +7,13 @@ import { PlusOutlined } from "@ant-design/icons";import { useDrop } from "react-dnd";import CalendarRecord from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord";import { CustomDragLayer } from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer";+import dayjs from "dayjs";export interface ICalendarTimingItemRef {}export interface ICalendarTimingItemProps {arg: DayCellContentArg;- onClickPub: () => void;+ onClickPub: (date: string) => void;}const CalendarTimingItem = memo(@@ -73,7 +74,14 @@ const CalendarTimingItem = memo(size="small"icon={<PlusOutlined />}onClick={() => {- onClickPub();+ const days = dayjs(arg.date);+ const today = dayjs();++ if (today.date() === days.date()) {+ onClickPub(today.add(10, "minute").format());+ } else {+ onClickPub(days.format());+ }}}/>)}@@ -85,7 +93,10 @@ const CalendarTimingItem = memo(size="small"type="dashed"onClick={() => {- onClickPub();+ const days = dayjs(arg.date)+ .set("hour", 16)+ .set("minute", 12);+ onClickPub(days.format());}}><div className="calendarTimingItem-con-btn1">04:12 PM</div>diff --git a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.tsindex 2b302bce..4b4ba5d1 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts+++ b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts@@ -36,4 +36,6 @@ export function getTransitionClassNames(direction: "left" | "right" | "fade") {exitActive: styles.fadeExitActive,};}-}\ No newline at end of file+}++diff --git a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx b/src/app/[lng]/accounts/components/CalendarTiming/index.tsxindex 0d037b70..8faa1adc 100644--- a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx+++ b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx@@ -20,12 +20,13 @@ import { Button } from "antd";import { LeftOutlined, RightOutlined } from "@ant-design/icons";import { useTransClient } from "@/app/i18n/client";import CalendarTimingItem from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem";-import PublishDialog from "@/components/PublishDialog";+import PublishDialog, { IPublishDialogRef } from "@/components/PublishDialog";import { useAccountStore } from "@/store/account";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";export interface ICalendarTimingRef {}export interface ICalendarTimingProps {}@@ -61,6 +62,7 @@ const CalendarTiming = memo(})),);const calendarTimingItemCallEl = useRef<HTMLDivElement | null>(null);+ const publishDialogRef = useRef<IPublishDialogRef>(null);useEffect(() => {window.addEventListener("resize", handleResize);@@ -123,6 +125,7 @@ const CalendarTiming = memo(return (<div className={styles.calendarTiming}><PublishDialog+ ref={publishDialogRef}open={publishDialogOpen}onClose={() => setPublishDialogOpen(false)}accounts={accountList}@@ -170,7 +173,8 @@ const CalendarTiming = memo(return (<CalendarTimingItemarg={arg}- onClickPub={() => {+ onClickPub={(date) => {+ publishDialogRef.current!.setPubTime(date);setPublishDialogOpen(true);}}/>diff --git a/src/app/[lng]/demo/demoPublish.tsx b/src/app/[lng]/demo/demoPublish.tsxindex 36184590..b9bb312b 100644--- a/src/app/[lng]/demo/demoPublish.tsx+++ b/src/app/[lng]/demo/demoPublish.tsx@@ -22,10 +22,10 @@ export const DemoPublish = () => {type: PubType.VIDEO,title: "测试视频标题",desc: "测试视频描述",- accountId: "685a8d466d33f16378b7bdfe",+ accountId: "686ba36565c9020dc1f3a043",accountType: AccountType.BILIBILI,videoUrl:- "https://v2.kwaicdn.com/ksc2/d2q1A45M3Dq7tzU1oxY-1trkIMKvM7_7SzRHFhPWMyv8MatfnrAhssXlVmWRVcok-zzQmyooCLGO_K-UXLRx547rxh4VnQ1uMCK4ljl6h8IANtgbCDdDnMvk7amRiyvfADYxi0GedqjHF8kF4iUDMjSl3kJTWbtbbjn8F-AK8UWG66m0W4rFjuSig1px-gxC.mp4?pkey=AAU8pxO15eRlb-oUBHkLPbqgb41b-i13g7MJXM_rILMMpOH-W8mR0-_V5teAff_N6MmFZN6abZXieAoDuAVUaWMDd1YGZCfB3B7qIv2MBHqsEPQC3-SRIQ5T8PTEKWP2a8c&tag=1-1751611371-unknown-0-csnzcnrvrd-0ae9c87425d902fe&clientCacheKey=3xnhic5vb7mq3n9_b.mp4&di=dfa08251&bp=14944&kwai-not-alloc=28&tt=b&ss=vpm",+ "https://v2-zj-bjcm.kwaicdn.com/upic/2025/06/24/09/BMjAyNTA2MjQwOTI3MjlfNDQwMjk3NjY1Nl8xNjc1OTkwOTUzNzBfMl8z_b_Bea472124f75ea09e1483d87c112ede39.mp4?tag=1-1751887066-unknown-0-uqpbdciha7-0f5473b4478e400b&provider=self&clientCacheKey=3xcwhdmk5jcyv8y_b.mp4&di=dfa08272&bp=14944&x-ks-ptid=167599095370&Aecs=172.17.4.195&ocid=100001260&tt=b&ss=vpm",coverUrl: "https://education.yikart.cn/images/swiper/swiper1.png",// imgList: ["imgList1", "imgList2"],publishTime,diff --git a/src/components/PublishDialog/compoents/PubCommonParams.tsx b/src/components/PublishDialog/compoents/PubCommonParams.tsxdeleted file mode 100644index bb61f965..00000000--- a/src/components/PublishDialog/compoents/PubCommonParams.tsx+++ /dev/null@@ -1,15 +0,0 @@-import { ForwardedRef, forwardRef, memo } from "react";--export interface IPubCommonParamsRef {}--export interface IPubCommonParamsProps {}--const PubCommonParams = memo(- forwardRef(- ({}: IPubCommonParamsProps, ref: ForwardedRef<IPubCommonParamsRef>) => {- return <div>发布通用参数</div>;- },- ),-);--export default PubCommonParams;diff --git a/src/components/PublishDialog/compoents/PublishDialogAi.tsx b/src/components/PublishDialog/compoents/PublishDialogAi.tsxindex 9fb7f137..31058e33 100644--- a/src/components/PublishDialog/compoents/PublishDialogAi.tsx+++ b/src/components/PublishDialog/compoents/PublishDialogAi.tsx@@ -5,6 +5,7 @@ export interface IPublishDialogAiRef {}export interface IPublishDialogAiProps {}+// AI写作const PublishDialogAi = memo(forwardRef(({}: IPublishDialogAiProps, ref: ForwardedRef<IPublishDialogAiRef>) => {diff --git a/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx b/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsxnew file mode 100644index 00000000..7b5d2075--- /dev/null+++ b/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx@@ -0,0 +1,110 @@+import { ForwardedRef, forwardRef, memo, useMemo } from "react";+import { DatePicker } from "antd";+import type { DatePickerProps, GetProps } from "antd";+import dayjs from "dayjs";+import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";+import { useShallow } from "zustand/react/shallow";++type RangePickerProps = GetProps<typeof DatePicker.RangePicker>;++export interface IPublishDialogDataPickerRef {}++export interface IPublishDialogDataPickerProps {}++// 日期选择器+const PublishDialogDataPicker = memo(+ forwardRef(+ (+ {}: IPublishDialogDataPickerProps,+ ref: ForwardedRef<IPublishDialogDataPickerRef>,+ ) => {+ const { pubTime } = usePublishDialog(+ useShallow((state) => ({+ pubTime: state.pubTime,+ })),+ );++ const onOk = (+ value: DatePickerProps["value"] | RangePickerProps["value"],+ ) => {+ console.log("onOk: ", value);+ };++ // 禁用今天之前的日期+ const disabledDate = (current: dayjs.Dayjs) => {+ return current && current < dayjs().startOf("day");+ };++ // 禁用当前时间之前和当前时间半小时内的时间(只精确到分钟,不考虑秒)+ const disabledDateTime = (current: dayjs.Dayjs | null) => {+ if (!current) return {};++ const now = dayjs();+ const minTime = now.add(20, "minute");++ // 只对今天限制+ if (current.isSame(now, "day")) {+ const minHour = minTime.hour();+ const minMinute = minTime.minute();++ // 禁用小时+ const disabledHours = () => {+ const hours: number[] = [];+ for (let i = 0; i < 24; i++) {+ if (i < minHour) hours.push(i);+ }+ return hours;+ };++ // 禁用分钟+ const disabledMinutes = (selectedHour: number) => {+ const minutes: number[] = [];+ if (selectedHour === minHour) {+ for (let i = 0; i < minMinute; i++) {+ minutes.push(i);+ }+ } else if (selectedHour < minHour) {+ // 小时都禁用了,分钟全部禁用+ for (let i = 0; i < 60; i++) {+ minutes.push(i);+ }+ }+ return minutes;+ };++ return {+ disabledHours,+ disabledMinutes,+ };+ }+ // 非今天不限制+ return {};+ };++ const pubTimeValue = useMemo(() => {+ if (pubTime) {+ return dayjs(pubTime);+ }+ }, [pubTime]);++ return pubTime ? (+ <DatePicker+ value={pubTimeValue}+ showTime={{ format: "HH:mm" }}+ allowClear={false}+ disabledDate={disabledDate}+ disabledTime={disabledDateTime}+ onChange={(value, dateString) => {+ console.log("Selected Time: ", value);+ console.log("Formatted Selected Time: ", dateString);+ }}+ onOk={onOk}+ />+ ) : (+ <div />+ );+ },+ ),+);++export default PublishDialogDataPicker;diff --git a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx b/src/components/PublishDialog/compoents/PublishDialogPreview.tsxindex d0b9491c..79a993a3 100644--- a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx+++ b/src/components/PublishDialog/compoents/PublishDialogPreview.tsx@@ -12,6 +12,7 @@ export interface IPublishDialogPreviewRef {}export interface IPublishDialogPreviewProps {}+// 预览const PublishDialogPreview = memo(forwardRef((diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsxindex 544949c9..4326c12e 100644--- a/src/components/PublishDialog/index.tsx+++ b/src/components/PublishDialog/index.tsx@@ -4,6 +4,7 @@ import {memo,useCallback,useEffect,+ useImperativeHandle,useMemo,useState,} from "react";@@ -21,8 +22,12 @@ import { useShallow } from "zustand/react/shallow";import PlatParamsSetting from "@/components/PublishDialog/compoents/PlatParamsSetting";import PubParmasTextarea from "@/components/PublishDialog/compoents/PubParmasTextarea";import usePubParamsVerify from "@/components/PublishDialog/hooks/usePubParamsVerify";+import PublishDialogDataPicker from "@/components/PublishDialog/compoents/PublishDialogDataPicker";-export interface IPublishDialogRef {}+export interface IPublishDialogRef {+ // 设置发布时间+ setPubTime: (pubTime?: string) => void;+}export interface IPublishDialogProps {open: boolean;@@ -53,6 +58,7 @@ const PublishDialog = memo(setExpandedPubItem,expandedPubItem,setErrParamsMap,+ setPubTime,} = usePublishDialog(useShallow((state) => ({pubListChoosed: state.pubListChoosed,@@ -67,6 +73,7 @@ const PublishDialog = memo(setExpandedPubItem: state.setExpandedPubItem,expandedPubItem: state.expandedPubItem,setErrParamsMap: state.setErrParamsMap,+ setPubTime: state.setPubTime,})),);const { errParamsMap } = usePubParamsVerify(pubListChoosed);@@ -117,6 +124,11 @@ const PublishDialog = memo(console.log("发布:", pubListChoosed);}, [pubListChoosed]);+ const imperativeHandle: IPublishDialogRef = {+ setPubTime,+ };+ useImperativeHandle(ref, () => imperativeHandle);+return (<><Modal@@ -268,7 +280,8 @@ const PublishDialog = memo(className="publishDialog-footer"onClick={(e) => e.stopPropagation()}>- time+ <PublishDialogDataPicker />+<div className="publishDialog-footer-btns">{step === 0 && pubListChoosed.length >= 2 ? (<Buttondiff --git a/src/components/PublishDialog/publishDialog.module.scss b/src/components/PublishDialog/publishDialog.module.scssindex 5740e84c..c8b9a617 100644--- a/src/components/PublishDialog/publishDialog.module.scss+++ b/src/components/PublishDialog/publishDialog.module.scss@@ -85,6 +85,9 @@ $assistantWidth: 330px;margin-right: 10px;}}+ &-time {++ }}.ant-modal-body {display: flex;diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.tsindex 69aa1bf9..64a5f9e5 100644--- a/src/components/PublishDialog/usePublishDialog.ts+++ b/src/components/PublishDialog/usePublishDialog.ts@@ -21,10 +21,13 @@ export interface IPublishDialogStore {expandedPubItem?: PubItem;// 错误提示errParamsMap?: ErrPubParamsMapType;+ // 发布时间+ pubTime?: string;}const store: IPublishDialogStore = {pubListChoosed: [],+ pubTime: undefined,pubList: [],step: 0,commonPubParams: {@@ -65,6 +68,9 @@ export const usePublishDialog = create(setStep(step: number) {set({ step });},+ setPubTime(pubTime: string | undefined) {+ set({ pubTime });+ },// 清空所有数据clear() {