Skip to content

Let's use AI to Earn!

feat: 拖动调整完成(目前等待接接口)

gaoSir7ea9c1f060ab
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 623ef820..372d7ba1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,16 +4,17 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 【发布弹框】预览样式调整">
- <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview.tsx" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer.tsx" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarRecord.module.scss" afterDir="false" />
+ <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 拖动调整完成(目前等待接接口)">
+ <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.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-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview.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/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/CalendarTimingItem/CustomDragLayer.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss" 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/layout/styles/lyaoutHeader.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/layout/styles/lyaoutHeader.module.scss" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -24,8 +25,8 @@
<option name="RECENT_TEMPLATES">
<list>
<option value="TypeScript JSX File" />
- <option value="TypeScript File" />
<option value="tsx组件模板" />
+ <option value="TypeScript File" />
</list>
</option>
</component>
@@ -115,7 +116,8 @@
<workItem from="1750989966702" duration="688000" />
<workItem from="1751010085244" duration="6172000" />
<workItem from="1751023561603" duration="4162000" />
- <workItem from="1751027862143" duration="4419000" />
+ <workItem from="1751027862143" duration="5251000" />
+ <workItem from="1751248094372" duration="6605000" />
</task>
<task id="LOCAL-00001" summary="feat: 日历完善">
<option name="closed" value="true" />
@@ -261,7 +263,15 @@
<option name="project" value="LOCAL" />
<updated>1751027720106</updated>
</task>
- <option name="localTasksCounter" value="19" />
+ <task id="LOCAL-00019" summary="feat: 日历拖拽初步开发">
+ <option name="closed" value="true" />
+ <created>1751032440817</created>
+ <option name="number" value="00019" />
+ <option name="presentableId" value="LOCAL-00019" />
+ <option name="project" value="LOCAL" />
+ <updated>1751032440817</updated>
+ </task>
+ <option name="localTasksCounter" value="20" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -299,6 +309,8 @@
<MESSAGE value="feat: 1. 【发布作品弹框】填写发布参数时未选中的账户参数自动填写。&#10;2. 【发布作品弹框】切换步骤0-&gt;1保持展开状态" />
<MESSAGE value="feat: 【发布作品】图片和视频预览完成" />
<MESSAGE value="feat: 【发布弹框】预览样式调整" />
- <option name="LAST_COMMIT_MESSAGE" value="feat: 【发布弹框】预览样式调整" />
+ <MESSAGE value="feat: 日历拖拽初步开发" />
+ <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/BoxDragPreview.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview.tsx
index a7364a89..6e584d6b 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview.tsx
@@ -1,23 +1,18 @@
import type { CSSProperties, FC } from "react";
import { memo, useEffect, useState } from "react";
-import { Button } from "antd";
+import RecordCore from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore";
const styles: CSSProperties = {
display: "inline-block",
transform: "rotate(-7deg)",
WebkitTransform: "rotate(-7deg)",
+ transition: "0.3s",
};
-export interface BoxDragPreviewProps {
- title: string;
-}
-
-export interface BoxDragPreviewState {
- tickTock: any;
-}
+export interface BoxDragPreviewProps {}
export const BoxDragPreview: FC<BoxDragPreviewProps> = memo(
- function BoxDragPreview({ title }) {
+ function BoxDragPreview({}) {
const [tickTock, setTickTock] = useState(false);
useEffect(
@@ -30,7 +25,7 @@ export const BoxDragPreview: FC<BoxDragPreviewProps> = memo(
return (
<div style={styles}>
- <Button style={{ width: "152px" }}>123456</Button>
+ <RecordCore />
</div>
);
},
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx
index 2798ea34..4203a69b 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarRecord.tsx
@@ -1,8 +1,8 @@
import { ForwardedRef, forwardRef, memo, useEffect } from "react";
import styles from "./calendarRecord.module.scss";
import { DragSourceMonitor, useDrag } from "react-dnd";
-import { Button } from "antd";
import { getEmptyImage } from "react-dnd-html5-backend";
+import RecordCore from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore";
export interface ICalendarRecordRef {}
@@ -39,7 +39,7 @@ const CalendarRecord = memo(
className={styles.calendarRecord}
role="DraggableBox"
>
- <Button>123456</Button>
+ <RecordCore />
</div>
);
},
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx
index 7c5f3cbb..3738717c 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx
@@ -39,10 +39,9 @@ const CalendarTimingItem = memo(
() => ({
accept: "box",
drop: () => ({
- name: `move Dustbin`,
- allowedDropEffect: "move",
+ time: arg,
}),
- collect: (monitor: any) => ({
+ collect: (monitor) => ({
isOver: monitor.isOver(),
canDrop: monitor.canDrop(),
}),
@@ -53,11 +52,15 @@ const CalendarTimingItem = memo(
return (
<div
ref={(node) => {
- drop(node);
+ if (argDate >= nowDate) {
+ drop(node);
+ }
}}
className={[
+ "calendarTimingItem--js",
styles.calendarTimingItem,
argDate < nowDate ? styles.calendarTimingItemPast : "",
+ isOver ? styles.calendarTimingItem_over : "",
].join(" ")}
>
<div className="calendarTimingItem-top">
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer.tsx
index 6b3cd8bf..b7f7d939 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CustomDragLayer.tsx
@@ -1,7 +1,6 @@
import type { CSSProperties, FC } from "react";
import type { XYCoord } from "react-dnd";
import { useDragLayer } from "react-dnd";
-import { Button } from "antd";
import { BoxDragPreview } from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/BoxDragPreview";
function snapToGrid(x: number, y: number): [number, number] {
@@ -70,9 +69,7 @@ export const CustomDragLayer: FC<CustomDragLayerProps> = (props) => {
<div
style={getItemStyles(initialOffset, currentOffset, props.snapToGrid)}
>
- <div>
- <BoxDragPreview title="123" />
- </div>
+ <BoxDragPreview />
</div>
</div>
);
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
new file mode 100644
index 00000000..314703ca
--- /dev/null
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
@@ -0,0 +1,22 @@
+import { ForwardedRef, forwardRef, memo } from "react";
+import { Button } from "antd";
+import { useCalendarTiming } from "@/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming";
+import { useShallow } from "zustand/react/shallow";
+
+export interface IRecordCoreRef {}
+
+export interface IRecordCoreProps {}
+
+const RecordCore = memo(
+ forwardRef(({}: IRecordCoreProps, ref: ForwardedRef<IRecordCoreRef>) => {
+ const { calendarCallWidth } = useCalendarTiming(
+ useShallow((state) => ({
+ calendarCallWidth: state.calendarCallWidth,
+ })),
+ );
+
+ return <Button style={{ width: calendarCallWidth + "px" }}>123456</Button>;
+ }),
+);
+
+export default RecordCore;
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss
index 9b4b15f8..dfc446b6 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss
@@ -58,4 +58,8 @@
.calendarTimingItemPast {
background: var(--grayColor1);
+}
+
+.calendarTimingItem_over {
+ background: var(--colorPrimary3);
}
\ 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.tsx
index 7db77520..4de8f69c 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
@@ -1,4 +1,11 @@
-import { ForwardedRef, forwardRef, memo, useRef, useState } from "react";
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useEffect,
+ useRef,
+ useState,
+} from "react";
import styles from "./calendarTiming.module.scss";
import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
@@ -18,6 +25,7 @@ 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";
export interface ICalendarTimingRef {}
export interface ICalendarTimingProps {}
@@ -47,6 +55,36 @@ const CalendarTiming = memo(
accountList: state.accountList,
})),
);
+ const { setCalendarCallWidth } = useCalendarTiming(
+ useShallow((state) => ({
+ setCalendarCallWidth: state.setCalendarCallWidth,
+ })),
+ );
+ const calendarTimingItemCallEl = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => {
+ window.addEventListener("resize", handleResize);
+
+ setTimeout(() => {
+ calendarTimingItemCallEl.current = document.querySelector(
+ ".calendarTimingItem--js",
+ )!;
+ handleResize();
+ }, 1);
+
+ // 清理事件监听
+ return () => window.removeEventListener("resize", handleResize);
+ }, []);
+
+ const handleResize = () => {
+ setTimeout(() => {
+ const el = calendarTimingItemCallEl.current!;
+ const style = window.getComputedStyle(el);
+ const paddingLeft = parseFloat(style.paddingLeft);
+ const paddingRight = parseFloat(style.paddingRight);
+ setCalendarCallWidth(el.clientWidth - (paddingLeft + paddingRight));
+ }, 1);
+ };
// 动画触发函数
const triggerAnimation = (dir: "left" | "right" | "fade") => {
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts b/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts
new file mode 100644
index 00000000..8cb05a6e
--- /dev/null
+++ b/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts
@@ -0,0 +1,38 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import lodash from "lodash";
+
+export interface ICalendarTimingStore {
+ // 日历单元格宽度
+ calendarCallWidth: number;
+}
+
+const store: ICalendarTimingStore = {
+ calendarCallWidth: 0,
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+export const useCalendarTiming = create(
+ combine(
+ {
+ ...getStore(),
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ setCalendarCallWidth(calendarCallWidth: number) {
+ set({ calendarCallWidth });
+ },
+
+ clear() {
+ set({
+ ...getStore(),
+ });
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/app/layout/styles/lyaoutHeader.module.scss b/src/app/layout/styles/lyaoutHeader.module.scss
index 5f6f8306..3c26f134 100644
--- a/src/app/layout/styles/lyaoutHeader.module.scss
+++ b/src/app/layout/styles/lyaoutHeader.module.scss
@@ -28,7 +28,9 @@
display: flex;
justify-content: space-between;
align-items: center;
- @include wrapper;
+ //@include wrapper;
+ width: calc(100% - 60px);
+ margin: 0 auto;
.layoutHeader_wrapper-left {
display: flex;