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: `
-
-
- 📄 -
-
-

- {{ file.name }} -

-

{{ pages.length }} Pages Total

-
-
- -
- - - - +
+

{{ file?.name || 'Notebook Viewer' }}

+

ID: {{ file?.id }}

+
+
- +
- -
-
- -
-

{{ error }}

-
+ +
+
+
+

Converting notebook vector pages to HD PNG...

+
- -
-
-

Converting notebook pages...

-
+
+ {{ error }} +
- -
-
-
- Page {{ page.pageNo }} of {{ pages.length }} - Dot Grid Canvas -
- Handwriting Page +
+
+
+ Page {{ idx + 1 }} of {{ pages.length }} + Dot Grid Canvas
+ Handwriting Page
@@ -133,7 +127,6 @@ export default {
-
@@ -165,7 +158,7 @@ export default {
- {{ realTranscript }} + {{ formatContent(realTranscript) }}
@@ -182,9 +175,9 @@ export default {
-

{{ 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) }}
@@ -196,4 +189,4 @@ export default {
` -} +};