fix(frontend): 移除易被误认为加载条的顶部阅读进度条

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-16 06:04:12 +08:00
parent 9d3ea4d95c
commit d282a0f9b8
3 changed files with 0 additions and 52 deletions

View File

@@ -1,37 +0,0 @@
"use client";
import { useEffect, useState } from "react";
export default function ReadingProgress() {
const [progress, setProgress] = useState(0);
useEffect(() => {
let raf = 0;
const update = () => {
raf = 0;
const doc = document.documentElement;
const max = doc.scrollHeight - doc.clientHeight;
setProgress(max > 0 ? Math.min(1, doc.scrollTop / max) : 0);
};
const onScroll = () => {
if (!raf) raf = requestAnimationFrame(update);
};
update();
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onScroll);
return () => {
window.removeEventListener("scroll", onScroll);
window.removeEventListener("resize", onScroll);
if (raf) cancelAnimationFrame(raf);
};
}, []);
if (progress <= 0) return null;
return (
<div
className="reading-progress"
style={{ transform: `scaleX(${progress})`, opacity: progress >= 1 ? 0 : 1 }}
aria-hidden="true"
/>
);
}