2026-04-16-19-06-18 - 修复路由切换后报告全部丢失及自动帧插入实时刷新问题
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { flushSync } from 'react-dom';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import Sidebar from '../components/Sidebar';
|
||||
import {
|
||||
@@ -120,18 +121,18 @@ export default function ReportEditor() {
|
||||
setCapturedFrames(draft.capturedFrames.sort((a: CapturedFrame, b: CapturedFrame) => a.time - b.time));
|
||||
}
|
||||
if (draft.activeTab) setActiveTab(draft.activeTab);
|
||||
stateRef.current = {
|
||||
...stateRef.current,
|
||||
reportData: draft.reportData,
|
||||
videos: draft.videos,
|
||||
capturedFrames: draft.capturedFrames,
|
||||
loadedTemplateId: draft.loadedTemplateId || ''
|
||||
};
|
||||
if (editorRef.current && typeof draft.content === 'string' && draft.content.trim().length > 0) {
|
||||
editorRef.current.innerHTML = draft.content;
|
||||
contentRef.current = draft.content;
|
||||
contentLoadedRef.current = true;
|
||||
setLoadedTemplateId(draft.loadedTemplateId || '');
|
||||
stateRef.current = {
|
||||
...stateRef.current,
|
||||
reportData: draft.reportData,
|
||||
videos: draft.videos,
|
||||
capturedFrames: draft.capturedFrames,
|
||||
loadedTemplateId: draft.loadedTemplateId || ''
|
||||
};
|
||||
setTimeout(() => updatePageHeight(), 0);
|
||||
}
|
||||
} else {
|
||||
@@ -139,6 +140,12 @@ export default function ReportEditor() {
|
||||
const found = reports.find(r => r.id === reportId);
|
||||
if (found) {
|
||||
setReportData(found);
|
||||
stateRef.current = {
|
||||
...stateRef.current,
|
||||
reportData: found,
|
||||
videos: found.videos || [],
|
||||
capturedFrames: found.capturedFrames || []
|
||||
};
|
||||
if (editorRef.current) {
|
||||
const restoreContent = storage.getSession<string | null>(`restore_${reportId}`, null);
|
||||
if (restoreFlag && restoreContent) {
|
||||
@@ -146,16 +153,9 @@ export default function ReportEditor() {
|
||||
storage.removeSession(`restore_${reportId}`);
|
||||
} else {
|
||||
editorRef.current.innerHTML = found.content;
|
||||
contentRef.current = found.content;
|
||||
contentRef.current = found.content;
|
||||
contentRef.current = found.content;
|
||||
}
|
||||
contentLoadedRef.current = true;
|
||||
stateRef.current = {
|
||||
...stateRef.current,
|
||||
reportData: found,
|
||||
videos: found.videos || [],
|
||||
capturedFrames: found.capturedFrames || []
|
||||
};
|
||||
setTimeout(() => updatePageHeight(), 0);
|
||||
}
|
||||
if (found.capturedFrames) {
|
||||
@@ -181,18 +181,18 @@ export default function ReportEditor() {
|
||||
setCapturedFrames(draft.capturedFrames.sort((a: CapturedFrame, b: CapturedFrame) => a.time - b.time));
|
||||
}
|
||||
if (draft.activeTab) setActiveTab(draft.activeTab);
|
||||
stateRef.current = {
|
||||
...stateRef.current,
|
||||
reportData: draft.reportData,
|
||||
videos: draft.videos,
|
||||
capturedFrames: draft.capturedFrames,
|
||||
loadedTemplateId: draft.loadedTemplateId || ''
|
||||
};
|
||||
if (editorRef.current && typeof draft.content === 'string' && draft.content.trim().length > 0) {
|
||||
editorRef.current.innerHTML = draft.content;
|
||||
contentRef.current = draft.content;
|
||||
contentLoadedRef.current = true;
|
||||
setLoadedTemplateId(draft.loadedTemplateId || '');
|
||||
stateRef.current = {
|
||||
...stateRef.current,
|
||||
reportData: draft.reportData,
|
||||
videos: draft.videos,
|
||||
capturedFrames: draft.capturedFrames,
|
||||
loadedTemplateId: draft.loadedTemplateId || ''
|
||||
};
|
||||
setTimeout(() => updatePageHeight(), 0);
|
||||
}
|
||||
}
|
||||
@@ -517,7 +517,9 @@ export default function ReportEditor() {
|
||||
isManual: false
|
||||
};
|
||||
accumulatedFrames = [...accumulatedFrames, newFrame].sort((a, b) => a.time - b.time);
|
||||
setCapturedFrames(accumulatedFrames);
|
||||
flushSync(() => {
|
||||
setCapturedFrames(accumulatedFrames);
|
||||
});
|
||||
stateRef.current = { ...stateRef.current, capturedFrames: accumulatedFrames };
|
||||
if (settings.autoInsertFrames && settings.autoInsertFrameIndices?.includes(i) && editorRef.current) {
|
||||
if ((settings.autoInsertDelay || 0) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user