Skip to content

Let's use AI to Earn!

feat: 【发布弹框】展开和隐藏、光标自动聚焦和自动到最后一位

gaoSir490b5ffe0ef9
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8c7a325b..d4d1183c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,15 +4,12 @@
<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/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts" afterDir="false" />
+ <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" 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/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss" 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/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" />
@@ -108,7 +105,8 @@
<workItem from="1750763285511" duration="48000" />
<workItem from="1750763342070" duration="32000" />
<workItem from="1750763376065" duration="41000" />
- <workItem from="1750763426455" duration="35733000" />
+ <workItem from="1750763426455" duration="38708000" />
+ <workItem from="1750932869295" duration="6465000" />
</task>
<task id="LOCAL-00001" summary="feat: 日历完善">
<option name="closed" value="true" />
@@ -198,7 +196,15 @@
<option name="project" value="LOCAL" />
<updated>1750859702156</updated>
</task>
- <option name="localTasksCounter" value="12" />
+ <task id="LOCAL-00012" summary="feat: 【发布弹框】精细化参数处理">
+ <option name="closed" value="true" />
+ <created>1750907902596</created>
+ <option name="number" value="00012" />
+ <option name="presentableId" value="LOCAL-00012" />
+ <option name="project" value="LOCAL" />
+ <updated>1750907902596</updated>
+ </task>
+ <option name="localTasksCounter" value="13" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -229,6 +235,7 @@
<MESSAGE value="feat: 发布逻辑初步实现" />
<MESSAGE value="feat: 发布弹框:上传图片/视频完成、裁剪图片,描述写入,完成。" />
<MESSAGE value="feat: 发布弹框整体设计" />
- <option name="LAST_COMMIT_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/components/PublishDialog/compoents/PlatParamsSetting/index.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
index e918900d..44198885 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
@@ -1,26 +1,35 @@
-import { ForwardedRef, forwardRef, memo, useMemo } from "react";
+import { CSSProperties, ForwardedRef, forwardRef, memo, useMemo } from "react";
import styles from "./platParamsSetting.module.scss";
import {
PubItem,
usePublishDialog,
} from "@/components/PublishDialog/usePublishDialog";
-import { useShallow } from "zustand/react/shallow";
import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
import BilibParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams";
import KwaiParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams";
+import { useShallow } from "zustand/react/shallow";
export interface IPlatParamsSettingRef {}
export interface IPlatParamsSettingProps {
pubItem: PubItem;
+ style?: CSSProperties;
}
const PlatParamsSetting = memo(
forwardRef(
(
- { pubItem }: IPlatParamsSettingProps,
+ { pubItem, style }: IPlatParamsSettingProps,
ref: ForwardedRef<IPlatParamsSettingRef>,
) => {
+ const { expandedPubItem, step, setExpandedPubItem } = usePublishDialog(
+ useShallow((state) => ({
+ expandedPubItem: state.expandedPubItem,
+ step: state.step,
+ setExpandedPubItem: state.setExpandedPubItem,
+ })),
+ );
+
const platConfig = useMemo(() => {
return AccountPlatInfoMap.get(pubItem.account.type)!;
}, [pubItem]);
@@ -34,12 +43,35 @@ const PlatParamsSetting = memo(
}
}, [pubItem]);
+ // true=展开当前账号的参数设置 false=不展开
+ const isExpand = useMemo(() => {
+ if (step === 0) return true;
+ return expandedPubItem?.account.id === pubItem.account.id;
+ }, [expandedPubItem, pubItem]);
+
return (
- <div className={styles.platParamsSetting}>
+ <div
+ className={[
+ styles.platParamsSetting,
+ !isExpand ? styles.platParamsSetting_expand : "",
+ ].join(" ")}
+ style={style}
+ >
<div className="platParamsSetting-icon">
<img src={platConfig.icon} style={{ borderRadius: "50%" }} />
</div>
- {PlatItemComp}
+ {isExpand ? (
+ PlatItemComp
+ ) : (
+ <div
+ className="platParamsSetting-des"
+ onClick={() => {
+ setExpandedPubItem(pubItem);
+ }}
+ >
+ {pubItem.params.des}
+ </div>
+ )}
</div>
);
},
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss b/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
index f49c4f53..1f427809 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
@@ -3,6 +3,26 @@
:global {
.platParamsSetting-icon {
margin-right: 10px;
+ img {
+ width: 25px;
+ height: 25px;
+ }
+ }
+ .platParamsSetting-des {
+ border: 1px solid var(--grayColor3);
+ width: 100%;
+ border-radius: 4px;
+ height: 40px;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ padding-left: 15px;
+ color: var(--grayColor11);
}
}
+}
+
+.platParamsSetting_expand {
+ display: flex;
+ align-items: center;
}
\ No newline at end of file
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
index b9a1bd52..b6ae4711 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
@@ -6,6 +6,7 @@ import React, {
useCallback,
useEffect,
useMemo,
+ useRef,
useState,
} from "react";
import { Button, Image, Input, message, Modal, Tooltip, Upload } from "antd";
@@ -23,6 +24,7 @@ import { formatVideo } from "@/app/[lng]/publish/components/Choose/videoChoose.u
import { formatImg } from "@/app/[lng]/publish/components/Choose/ImgChoose.util";
import VideoCoverSeting from "@/app/[lng]/publish/videoPage/components/VideoCoverSeting";
import isEqual from "lodash/isEqual";
+import { TextAreaRef } from "antd/es/input/TextArea";
const { TextArea } = Input;
const { Dragger } = Upload;
@@ -79,6 +81,7 @@ const PubParmasTextarea = memo(
);
// 裁剪弹框
const [videoCoverSetingModal, setVideoCoverSetingModal] = useState(false);
+ const textareaRef = useRef<TextAreaRef>(null);
useEffect(() => {
const values = {
@@ -243,10 +246,22 @@ const PubParmasTextarea = memo(
<div className={styles.pubParmasTextarea} style={style}>
<div className="pubParmasTextarea-input">
<TextArea
+ ref={textareaRef}
placeholder="开始写"
value={value}
onChange={(e) => setValue(e.target.value)}
rows={rows}
+ autoFocus={true}
+ onFocus={() => {
+ setTimeout(() => {
+ if (textareaRef.current) {
+ const val =
+ textareaRef.current.resizableTextArea!.textArea;
+ const len = value.length;
+ val.setSelectionRange(len, len);
+ }
+ }, 10);
+ }}
/>
<ReactSortable
className="pubParmasTextarea-uploads"
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index d048446b..f6e27664 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -67,6 +67,7 @@ const PublishDialog = memo(
if (open) {
init(accounts);
} else {
+ setPubListChoosed([]);
clear();
}
}, [accounts, open]);
@@ -214,9 +215,12 @@ const PublishDialog = memo(
) : (
<>
{pubListChoosed.map((v) => {
- console.log(v);
return (
- <PlatParamsSetting pubItem={v} key={v.account.id} />
+ <PlatParamsSetting
+ pubItem={v}
+ key={v.account.id}
+ style={{ marginBottom: "12px" }}
+ />
);
})}
</>
diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.ts
index 0658c6f2..3baf8d86 100644
--- a/src/components/PublishDialog/usePublishDialog.ts
+++ b/src/components/PublishDialog/usePublishDialog.ts
@@ -127,6 +127,11 @@ export const usePublishDialog = create(
pubListChoosed,
});
},
+ setExpandedPubItem(expandedPubItem: PubItem | undefined) {
+ set({
+ expandedPubItem,
+ });
+ },
};
return methods;
},