Revert "feat: fix the problem in the Operator Market frontend pages"

This commit is contained in:
Kecheng Sha
2025-12-29 12:00:37 +08:00
committed by GitHub
parent 8f30f71a68
commit 0df7a872e4
213 changed files with 45537 additions and 45547 deletions

View File

@@ -1,69 +1,69 @@
import { useEffect, useRef, useState } from "react";
const TopLoadingBar = () => {
const [isVisible, setIsVisible] = useState(false);
const [progress, setProgress] = useState(0);
const intervalRef = useRef(null);
useEffect(() => {
// 监听全局事件
const handleShow = () => {
setIsVisible(true);
setProgress(0);
// 清除可能存在的旧interval
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
// 模拟进度
let currentProgress = 0;
intervalRef.current = setInterval(() => {
currentProgress += Math.random() * 10;
if (currentProgress >= 90) {
clearInterval(intervalRef.current);
}
setProgress(currentProgress);
}, 200);
};
const handleHide = () => {
// 清除进度interval
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
setProgress(100);
setTimeout(() => {
setIsVisible(false);
setProgress(0);
}, 300);
};
// 添加全局事件监听器
window.addEventListener("loading:show", handleShow);
window.addEventListener("loading:hide", handleHide);
return () => {
// 组件卸载时清理
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
window.removeEventListener("loading:show", handleShow);
window.removeEventListener("loading:hide", handleHide);
};
}, []);
if (!isVisible) return null;
return (
<div className="top-loading-bar">
<div
className="loading-bar-progress"
style={{ width: `${progress}%` }}
></div>
</div>
);
};
export default TopLoadingBar;
import { useEffect, useRef, useState } from "react";
const TopLoadingBar = () => {
const [isVisible, setIsVisible] = useState(false);
const [progress, setProgress] = useState(0);
const intervalRef = useRef(null);
useEffect(() => {
// 监听全局事件
const handleShow = () => {
setIsVisible(true);
setProgress(0);
// 清除可能存在的旧interval
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
// 模拟进度
let currentProgress = 0;
intervalRef.current = setInterval(() => {
currentProgress += Math.random() * 10;
if (currentProgress >= 90) {
clearInterval(intervalRef.current);
}
setProgress(currentProgress);
}, 200);
};
const handleHide = () => {
// 清除进度interval
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
setProgress(100);
setTimeout(() => {
setIsVisible(false);
setProgress(0);
}, 300);
};
// 添加全局事件监听器
window.addEventListener("loading:show", handleShow);
window.addEventListener("loading:hide", handleHide);
return () => {
// 组件卸载时清理
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
window.removeEventListener("loading:show", handleShow);
window.removeEventListener("loading:hide", handleHide);
};
}, []);
if (!isVisible) return null;
return (
<div className="top-loading-bar">
<div
className="loading-bar-progress"
style={{ width: `${progress}%` }}
></div>
</div>
);
};
export default TopLoadingBar;