2026-05-08-01-53-07 修正DICOM范围和切割Mask预览

This commit is contained in:
2026-05-08 01:59:36 +08:00
parent 4ba85eba6e
commit 22b0a93654
7 changed files with 348 additions and 29 deletions

View File

@@ -657,12 +657,29 @@ export default function ProjectLibrary({
const [actionMessage, setActionMessage] = useState('');
const sliceRepeatRef = useRef<number | null>(null);
const dicomRequestRef = useRef(0);
const preloadedProjectIdsRef = useRef(new Set<string>());
const preloadProjectAssets = (project: Project) => {
if (preloadedProjectIdsRef.current.has(project.id)) {
return;
}
preloadedProjectIdsRef.current.add(project.id);
const maxSlice = Math.max((project.dicomCount || 1) - 1, 0);
if (project.dicomCount > 0) {
void api.getDicomPreview(project.id, maxSlice, 'axial', 'default').catch(() => undefined);
void api.getDicomFusionVolume(project.id, maxSlice, maxSlice, 'soft').catch(() => undefined);
}
(project.stlFiles ?? []).slice(0, 3).forEach((fileName) => {
void fetch(`/api/projects/${project.id}/models/${encodeURIComponent(fileName)}/preview?limit=3500`).catch(() => undefined);
});
};
const refreshProjects = () => {
setLoading(true);
return api.getProjects()
.then((items) => {
setProjects(items);
items.slice(0, 2).forEach(preloadProjectAssets);
setSelectedProject((current) => {
if (!current) {
return items[0] ?? null;
@@ -677,6 +694,12 @@ export default function ProjectLibrary({
refreshProjects();
}, []);
useEffect(() => {
if (selectedProject) {
preloadProjectAssets(selectedProject);
}
}, [selectedProject?.id]);
const filteredProjects = useMemo(() => {
const keyword = search.trim().toLowerCase();
if (!keyword) {