From 6fbf7cc84dc82f5a60df2290a06ad84b217593c1 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 18 Jan 2026 14:51:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(label-studio):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A2=84=E5=8A=A0=E8=BD=BD=E7=BB=84=E4=BB=B6=E4=BB=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=8A=A0=E8=BD=BD=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现 LabelStudioPreloader 组件用于预加载资源 - 使用 iframe 在后台加载 /lsf/lsf.html 页面 - 设置 2 秒延迟避免与初始页面加载竞争资源 - 配置隐藏样式确保预加载过程不可见 - 添加清理函数防止内存泄漏 - 实现条件渲染控制预加载时机 --- .../business/LabelStudioPreloader.tsx | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 frontend/src/components/business/LabelStudioPreloader.tsx diff --git a/frontend/src/components/business/LabelStudioPreloader.tsx b/frontend/src/components/business/LabelStudioPreloader.tsx new file mode 100644 index 0000000..0bc8db6 --- /dev/null +++ b/frontend/src/components/business/LabelStudioPreloader.tsx @@ -0,0 +1,35 @@ +import { useEffect, useState } from "react"; + +const PRELOAD_URL = "/lsf/lsf.html"; + +export default function LabelStudioPreloader() { + const [shouldLoad, setShouldLoad] = useState(false); + + useEffect(() => { + // Delay preloading slightly to avoid contending with initial page load resources + // Using 2000ms (2 seconds) as a reasonable idle time approximation + const timer = setTimeout(() => { + setShouldLoad(true); + }, 2000); + + return () => clearTimeout(timer); + }, []); + + if (!shouldLoad) return null; + + return ( +