Commit e96f7fe7 by 黄南光

修复前端预览滑轮滚动问题

1 parent cc153b69
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"dev": "next dev -H 0.0.0.0 --webpack", "dev": "next dev -H 0.0.0.0 --webpack",
"build": "next build", "build": "next build",
"start": "next start -H 0.0.0.0", "start": "next start -H 0.0.0.0",
"test:scroll-lock": "node scripts/check-preview-modal-scroll-lock.mjs",
"lint": "eslint" "lint": "eslint"
}, },
"dependencies": { "dependencies": {
......
...@@ -399,6 +399,21 @@ export default function EnterpriseWiki() { ...@@ -399,6 +399,21 @@ export default function EnterpriseWiki() {
useEffect(() => { useEffect(() => {
lintEndRef.current?.scrollIntoView({ behavior: "smooth" }); lintEndRef.current?.scrollIntoView({ behavior: "smooth" });
}, [lintHistory]); }, [lintHistory]);
useEffect(() => {
if (!isModalOpen) return undefined;
const previousBodyOverflow = document.body.style.overflow;
const previousBodyOverscrollBehavior = document.body.style.overscrollBehavior;
document.body.style.overflow = "hidden";
document.body.style.overscrollBehavior = "contain";
return () => {
document.body.style.overflow = previousBodyOverflow;
document.body.style.overscrollBehavior = previousBodyOverscrollBehavior;
};
}, [isModalOpen]);
const [searchQuery, setSearchQuery] = useState(""); const [searchQuery, setSearchQuery] = useState("");
const [searchInput, setSearchInput] = useState(""); const [searchInput, setSearchInput] = useState("");
const [sortBy, setSortBy] = useState<"name" | "time" | "size" | "status" | "format" | "id">("time"); const [sortBy, setSortBy] = useState<"name" | "time" | "size" | "status" | "format" | "id">("time");
...@@ -1613,6 +1628,7 @@ export default function EnterpriseWiki() { ...@@ -1613,6 +1628,7 @@ export default function EnterpriseWiki() {
"group hover:bg-slate-50/80 transition-colors cursor-pointer", "group hover:bg-slate-50/80 transition-colors cursor-pointer",
selectedFileId === file.id && "bg-blue-50/30" selectedFileId === file.id && "bg-blue-50/30"
)} )}
// eslint-disable-next-line react-hooks/refs -- ref access happens after the row click starts preview loading.
onClick={() => onSelectFile(file.id)} onClick={() => onSelectFile(file.id)}
> >
<td className="px-6 py-4 whitespace-nowrap" onClick={(e) => e.stopPropagation()}> <td className="px-6 py-4 whitespace-nowrap" onClick={(e) => e.stopPropagation()}>
...@@ -1829,7 +1845,10 @@ export default function EnterpriseWiki() { ...@@ -1829,7 +1845,10 @@ export default function EnterpriseWiki() {
{/* 3. Preview Modal */} {/* 3. Preview Modal */}
{isModalOpen && ( {isModalOpen && (
<div className="fixed inset-0 z-[60] flex items-center justify-center p-6 bg-slate-900/60 backdrop-blur-sm animate-in fade-in duration-300"> <div
className="fixed inset-0 z-[60] flex items-center justify-center p-6 bg-slate-900/60 backdrop-blur-sm animate-in fade-in duration-300 overflow-hidden overscroll-contain"
onWheel={(e) => e.stopPropagation()}
>
<div className="bg-white w-full max-w-[75vw] h-[94vh] rounded-[2rem] shadow-2xl flex flex-col overflow-hidden animate-in zoom-in-95 duration-300"> <div className="bg-white w-full max-w-[75vw] h-[94vh] rounded-[2rem] shadow-2xl flex flex-col overflow-hidden animate-in zoom-in-95 duration-300">
<header className="px-8 py-6 border-b border-slate-100 flex items-center justify-between shrink-0"> <header className="px-8 py-6 border-b border-slate-100 flex items-center justify-between shrink-0">
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!