diff --git a/chat_web_front/src/components/PdfViewer.vue b/chat_web_front/src/components/PdfViewer.vue index 072f977..5d170eb 100644 --- a/chat_web_front/src/components/PdfViewer.vue +++ b/chat_web_front/src/components/PdfViewer.vue @@ -74,9 +74,17 @@ const loadPdf = async () => { loading.value = true; error.value = ''; try { + // 每次加载都复制一份,避免 pdfjs worker transfer 后 detach 原始数据 const rawSrc = toRaw(props.src); - const data = rawSrc instanceof ArrayBuffer ? new Uint8Array(rawSrc) : rawSrc; - const loadingTask = pdfjsLib.getDocument({ data }); + let bytes: Uint8Array; + if (rawSrc instanceof Uint8Array) { + bytes = new Uint8Array(rawSrc); // 复制 + } else if (rawSrc instanceof ArrayBuffer) { + bytes = new Uint8Array(new Uint8Array(rawSrc)); // 复制 + } else { + bytes = rawSrc as any; + } + const loadingTask = pdfjsLib.getDocument({ data: bytes }); pdfDoc = await loadingTask.promise; const numPages = pdfDoc.numPages; pages.value = Array.from({ length: numPages }, (_, i) => i + 1); diff --git a/chat_web_front/src/components/ReadingCreate.vue b/chat_web_front/src/components/ReadingCreate.vue index 9af880a..5be0c74 100644 --- a/chat_web_front/src/components/ReadingCreate.vue +++ b/chat_web_front/src/components/ReadingCreate.vue @@ -434,7 +434,7 @@ const handleStop = async () => {