Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/layouts/PaperNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
<pane :size="pdfPaneSize" min-size="20">
<!-- PDF 查看区域 -->
<div class="pdf-container">
<PdfViewer
<PdfViewer ref="PdfViewerRef"
v-if="pdfUrl"
:fileUrl="pdfUrl"
:fileName="documentTitle"
:articleId="articleId"
:write="true"
:ref="PdfViewerRef"

/>
<div v-else class="pdf-loading">
<el-icon class="loading-icon is-loading"><Loading /></el-icon>
Expand Down Expand Up @@ -120,11 +120,12 @@ import PdfViewer from '@/components/Pdfview/PdfViewer.vue';
import 'splitpanes/dist/splitpanes.css';
import { ElMessage } from 'element-plus';
import debounce from 'lodash/debounce';
import {ref} from 'vue'
export default {
name: "PaperNote",
components: {
Back,
Loading,
Expand All @@ -147,7 +148,7 @@ export default {
editorPropsReady: false,
notesListLoading: true, // 新增:标记笔记列表是否正在加载
updateRoute: null, // 将在 created 中初始化
PdfViewerRef: ref(null), // 新增:PdfViewer组件实例
}
},
created() {
Expand Down Expand Up @@ -262,7 +263,7 @@ export default {
if (pdfResponse?.data?.article_url) {
const nowTime = new Date().getTime();
this.pdfUrl = pdfResponse.data.article_url + `&t=${nowTime}`;
this.pdfUrl = pdfResponse.data.article_url + `?t=${nowTime}`;
} else {
console.error("获取PDF链接失败:", pdfResponse);
ElMessage.error("获取 PDF 链接失败!");
Expand Down Expand Up @@ -302,20 +303,21 @@ export default {
}
},
async handleSaveNote() {
if (this.isSaving) return;
handleSaveNote() {
try {
this.isSaving = true;
if (this.PdfViewerRef) {
this.PdfViewerRef.value.handleSave();
if (this.$refs.PdfViewerRef) {
this.$refs.PdfViewerRef.handleSave();
} else {
console.log('is null,waiting...')
}
} catch (error) {
} catch (error) {
console.error("[Note] 保存笔记失败:", error);
} finally {
this.isSaving = false;
}
}
},
async fetchDocumentTitle(articleId) {
Expand Down
38 changes: 38 additions & 0 deletions src/views/PdfViewerPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
<template>
<div class="app">
<div class="save-button-container">
<el-button
type="success"
class="header-save-btn"
@click="handleSaveNote"
:loading="isSaving"
size="small"
round
>
<template #icon>
<el-icon><EditPen /></el-icon>
</template>
<template v-if="!isSaving">
<span class="save-text">保存批注</span>
</template>
<template v-else>
<el-icon class="loading-icon"><Loading /></el-icon>
<span class="save-text">保存中…</span>
</template>
</el-button>
</div>
<h1 class="title">PDF reader example Page</h1>

<PdfViewer ref="pdfViewerRef"
Expand All @@ -20,7 +41,24 @@ import PdfViewer from '@/components/Pdfview/PdfViewer.vue'


const pdfViewerRef = ref(null)
let isSaving = ref(false)

function handleSaveNote() {
console.log('handleSaveNote');
if (isSaving.value) return;

try {
isSaving.value = true;
if (pdfViewerRef.value) {
pdfViewerRef.value.handleSave();
}

} catch (error) {
console.error("[Note] 保存笔记失败:", error);
} finally {
isSaving.value = false;
}
}

</script>

Expand Down