feat: 问题修复

This commit is contained in:
2025-10-13 13:06:22 +08:00
parent 97deeba4cb
commit c7ce9c2086
6 changed files with 119 additions and 84 deletions

View File

@@ -220,7 +220,7 @@
& > .input {
width: 100%;
height: 36px;
height: 24px;
}
}

View File

@@ -22,6 +22,7 @@ import addComment from "@/static/detail/icon-write.svg";
import emptyComment from "@/static/emptyStatus/comment-empty.png";
import CommonPopup from "../CommonPopup";
import styles from "./index.module.scss";
import { useKeyboardHeight } from "@/store/keyboardStore";
// const PAGESIZE = 4;
const PAGESIZE = 1000;
@@ -58,9 +59,30 @@ const CommentInput = forwardRef<CommentInputRef, CommentInputProps>(function (
CommentInputReplyParamsType | undefined
>();
const inputDomRef = useRef(null);
const {
keyboardHeight,
isKeyboardVisible,
addListener,
initializeKeyboardListener,
} = useKeyboardHeight();
const [adjust, setAdjust] = useState(false);
// 使用全局键盘状态监听
useEffect(() => {
// 初始化全局键盘监听器
initializeKeyboardListener();
// 添加本地监听器
const removeListener = addListener((height, visible) => {
console.log("PublishBall 收到键盘变化:", height, visible);
// 这里只记录或用于其他逻辑,布局是否响应交由 shouldReactToKeyboard 决定
});
return () => {
removeListener();
};
}, [initializeKeyboardListener, addListener]);
const inputDomRef = useRef(null);
useImperativeHandle(ref, () => ({
show: (_params: CommentInputReplyParamsType | undefined) => {
@@ -84,9 +106,9 @@ const CommentInput = forwardRef<CommentInputRef, CommentInputProps>(function (
function onClose() {
setVisible(false);
setValue("");
setAdjust(false);
inputDomRef.current && inputDomRef.current?.blur();
}
console.log(keyboardHeight, "keyboardHeight");
return (
<CommonPopup
visible={visible}
@@ -97,27 +119,23 @@ const CommentInput = forwardRef<CommentInputRef, CommentInputProps>(function (
style={{
height: "60px!important",
minHeight: "unset",
bottom:
isKeyboardVisible && keyboardHeight > 0 ? `${keyboardHeight}px` : "0",
}}
enableDragToClose={false}
>
<View className={styles.inputContainer}>
<View className={styles.inputWrapper}>
<Input
adjustPosition={adjust}
adjustPosition={false}
ref={inputDomRef}
className={styles.input}
value={value}
onInput={(e) => setValue(e.detail.value)}
cursorSpacing={20}
placeholder={
params?.reply_to_user_id ? `回复 @${params.nickname}` : "写评论"
}
focus
onFocus={() => {
setTimeout(() => {
setAdjust(true);
}, 10);
}}
maxlength={100}
/>
</View>