diff --git a/supernote/server/static/js/components/FileViewer.js b/supernote/server/static/js/components/FileViewer.js index 6c64c104..f3f7678d 100644 --- a/supernote/server/static/js/components/FileViewer.js +++ b/supernote/server/static/js/components/FileViewer.js @@ -1,4 +1,4 @@ -import { ref, onMounted } from 'vue'; +import { ref, computed, onMounted, watch } from 'vue'; import { convertNoteToPng, fetchTranscript, fetchSummaries } from '../api/client.js'; export default { @@ -38,14 +38,16 @@ export default { fetchSummaries(props.file.id).catch(() => []) ]); - if (transcriptData && transcriptData.transcript) { - realTranscript.value = transcriptData.transcript; - } else if (transcriptData && transcriptData.text) { - realTranscript.value = transcriptData.text; + if (typeof transcriptData === 'string') { + realTranscript.value = transcriptData; + } else if (transcriptData && (transcriptData.transcript || transcriptData.text)) { + realTranscript.value = transcriptData.transcript || transcriptData.text; + } else { + realTranscript.value = ''; } if (summariesData && Array.isArray(summariesData)) { - realSummaries.value = summariesData; + realSummaries.value = summariesData.filter(s => (s.dataSource || '').toUpperCase() !== 'OCR'); } } catch (e) { console.error("Failed to load notebook content:", e); @@ -57,6 +59,14 @@ export default { }; onMounted(loadNoteContent); + watch(() => props.file?.id, (newId) => { + if (newId) loadNoteContent(); + }); + + const formatContent = (str) => { + if (!str) return ''; + return str.replaceAll('\\n', '\n'); + }; return { pages, @@ -66,65 +76,49 @@ export default { activeRightTab, isMobileSidePanelOpen, realTranscript, - realSummaries + realSummaries, + formatContent }; }, template: `
{{ pages.length }} Pages Total
-{{ error }}
-Converting notebook vector pages to HD PNG...
+Converting notebook pages...
-{{ s.title || 'Summary' }}
- {{ s.content || s.summary }} + class="p-3.5 bg-indigo-50/60 dark:bg-indigo-950/40 rounded-xl border border-indigo-100 dark:border-indigo-900/60 text-xs text-slate-800 dark:text-slate-200 leading-relaxed whitespace-pre-wrap"> +{{ s.title }}
+ {{ formatContent(s.content || s.summary) }}