Skip to content

Let's use AI to Earn!

chore(发布弹框): daysjs 时区统一管理

gaoSira4e4bdf269ae
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 56364b7c..7c5ceaf9 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。">
+ <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(发布弹框): 发布弹框对不支持上传 图片/视频 的平台做了限制">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/PubParmasTextarea/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.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]/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/components/PublishDialog/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -93,7 +96,7 @@
<workItem from="1752118620733" duration="566000" />
<workItem from="1752130881346" duration="11774000" />
<workItem from="1752200550278" duration="253000" />
- <workItem from="1752200816463" duration="16253000" />
+ <workItem from="1752200816463" duration="17099000" />
</task>
<task id="LOCAL-00001" summary="feat(CalendarTiming): 优化发布记录列表展示&#10;- 调整日历记录项的样式和布局&#10;- 优化 RecordCore组件,添加平台图标和时间显示&#10;- 修改 CalendarTimingItem 组件,移除不必要的 Fragment&#10;-调整 index.tsx 中的日期格式化逻辑">
<option name="closed" value="true" />
@@ -215,7 +218,15 @@
<option name="project" value="LOCAL" />
<updated>1752239323126</updated>
</task>
- <option name="localTasksCounter" value="16" />
+ <task id="LOCAL-00016" summary="feat(发布弹框): 发布弹框对不支持上传 图片/视频 的平台做了限制">
+ <option name="closed" value="true" />
+ <created>1752240016715</created>
+ <option name="number" value="00016" />
+ <option name="presentableId" value="LOCAL-00016" />
+ <option name="project" value="LOCAL" />
+ <updated>1752240016715</updated>
+ </task>
+ <option name="localTasksCounter" value="17" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -250,6 +261,7 @@
<MESSAGE value="feat(日历):细节调整,1. 发布记录查看,添加图片、视频分别处理。 2. 发布API添加图片处理" />
<MESSAGE value="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多" />
<MESSAGE value="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。" />
- <option name="LAST_COMMIT_MESSAGE" value="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。" />
+ <MESSAGE value="feat(发布弹框): 发布弹框对不支持上传 图片/视频 的平台做了限制" />
+ <option name="LAST_COMMIT_MESSAGE" value="feat(发布弹框): 发布弹框对不支持上传 图片/视频 的平台做了限制" />
</component>
</project>
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx
index 2f31712a..2e7b94eb 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx
@@ -7,6 +7,8 @@ import {
PublishRecordItem,
PublishStatus,
} from "@/api/plat/types/publish.types";
+import { useCalendarTiming } from "@/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming";
+import { useShallow } from "zustand/react/shallow";
export interface ICalendarRecordRef {}
@@ -20,12 +22,22 @@ const CalendarRecord = memo(
{ publishRecord }: ICalendarRecordProps,
ref: ForwardedRef<ICalendarRecordRef>,
) => {
+ const { setRecordMap, recordMap, } = useCalendarTiming(
+ useShallow((state) => ({
+ setRecordMap: state.setRecordMap,
+ recordMap: state.recordMap,
+ })),
+ );
const [{ opacity }, drag, preview] = useDrag(
() => ({
type: "box",
- item: { name: "1" },
+ item: { publishRecord },
end(item, monitor) {
const dropResult = monitor.getDropResult();
+ const { publishRecord } = item;
+ const newRecordMap = new Map(recordMap);
+ newRecordMap.delete(publishRecord.id);
+
console.log(item, dropResult);
},
collect: (monitor: DragSourceMonitor) => ({
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts
index d52b9301..290c5c82 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts
+++ b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils.ts
@@ -1,4 +1,8 @@
import styles from "./calendarTiming.module.scss";
+import dayjs from "dayjs";
+import utc from "dayjs/plugin/utc";
+
+dayjs.extend(utc);
// 日历国际化
export const getFullCalendarLang = (lang: string) => {
@@ -37,3 +41,13 @@ export function getTransitionClassNames(direction: "left" | "right" | "fade") {
};
}
}
+
+// 获取UTC days
+export function getUtcDays(date: dayjs.ConfigType) {
+ return dayjs(date).utc();
+}
+
+// 获取当前时区的days
+export function getDays(date?: dayjs.ConfigType) {
+ return dayjs(date);
+}
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
index 105b0ba0..7bda9057 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
@@ -11,6 +11,7 @@ import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
import { useGetClientLng } from "@/hooks/useSystem";
import {
+ getDays,
getFullCalendarLang,
getTransitionClassNames,
} from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";
@@ -26,13 +27,9 @@ 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 utc from "dayjs/plugin/utc";
import AvatarPlat from "@/components/AvatarPlat";
import AllPlatIcon from "@/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon";
-dayjs.extend(utc);
-
export interface ICalendarTimingRef {}
export interface ICalendarTimingProps {}
@@ -232,7 +229,7 @@ const CalendarTiming = memo(
headerToolbar={false}
stickyFooterScrollbar={true}
dayCellContent={(arg) => {
- const dateStr = dayjs(arg.date).format("YYYY-MM-DD");
+ const dateStr = getDays(arg.date).format("YYYY-MM-DD");
return (
<CalendarTimingItem
key={dateStr}
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts b/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts
index 0cbd529f..b63ec783 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts
+++ b/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts
@@ -2,9 +2,9 @@ import { create } from "zustand";
import { combine } from "zustand/middleware";
import lodash from "lodash";
import { PublishRecordItem } from "@/api/plat/types/publish.types";
-import dayjs from "dayjs";
import { getPublishList } from "@/api/plat/publish";
import FullCalendar from "@fullcalendar/react";
+import { getDays } from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";
export interface ICalendarTimingStore {
// 日历单元格宽度
@@ -51,7 +51,7 @@ export const useCalendarTiming = create(
// 获取发布记录数据
async getPubRecord() {
methods.setListLoading(true);
- const date = dayjs(get().calendarRef?.getApi().getDate());
+ const date = getDays(get().calendarRef?.getApi().getDate());
const startOfMonth = date.startOf("month");
const endOfMonth = date.endOf("month");
@@ -63,7 +63,7 @@ export const useCalendarTiming = create(
const recordMap = new Map<string, PublishRecordItem[]>();
// 将数据分拣到对应天中
res?.data.map((v) => {
- const days = dayjs(v.publishTime);
+ const days = getDays(v.publishTime);
const timeStr = days.format("YYYY-MM-DD");
let list = recordMap.get(timeStr);
if (!list) {
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index 29bb3cf5..6300c506 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -15,7 +15,7 @@ import PublishDialogAi from "@/components/PublishDialog/compoents/PublishDialogA
import PublishDialogPreview from "@/components/PublishDialog/compoents/PublishDialogPreview";
import { CSSTransition } from "react-transition-group";
import { SocialAccount } from "@/api/types/account.type";
-import { AccountPlatInfoMap } from "@/app/config/platConfig";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
import AvatarPlat from "@/components/AvatarPlat";
import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";
import { useShallow } from "zustand/react/shallow";
@@ -25,10 +25,10 @@ import usePubParamsVerify from "@/components/PublishDialog/hooks/usePubParamsVer
import PublishDialogDataPicker from "@/components/PublishDialog/compoents/PublishDialogDataPicker";
import { apiCreatePublish } from "@/api/plat/publish";
import { PubType } from "@/app/config/publishConfig";
-import dayjs from "dayjs";
-import utc from "dayjs/plugin/utc";
-
-dayjs.extend(utc);
+import {
+ getDays,
+ getUtcDays,
+} from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";
export interface IPublishDialogRef {
// 设置发布时间
@@ -141,9 +141,9 @@ const PublishDialog = memo(
const pubClick = useCallback(async () => {
setCreateLoading(true);
- const publishTime = dayjs(pubTime ? pubTime : dayjs().add(6, "minute"))
- .utc()
- .format();
+ const publishTime = getUtcDays(
+ pubTime ? pubTime : getDays().add(6, "minute"),
+ ).format();
for (const item of pubListChoosed) {
const res = await apiCreatePublish({
@@ -299,6 +299,7 @@ const PublishDialog = memo(
)}
{pubListChoosed.length >= 2 && (
<PubParmasTextarea
+ platType={PlatType.KWAI}
rows={16}
desValue={commonPubParams.des}
videoFileValue={commonPubParams.video}