feat: 添加Slot和Slots类型支持并优化PDF预览功能
在.eslintrc-auto-import.json中添加Slot和Slots类型支持,优化PdfPreview.vue组件,使其支持动态文件名,并在StudyDetailPage.vue中调整PDF预览逻辑以显示文件标题
Showing
5 changed files
with
15 additions
and
8 deletions
| ... | @@ -74,6 +74,8 @@ | ... | @@ -74,6 +74,8 @@ |
| 74 | "watch": true, | 74 | "watch": true, |
| 75 | "watchEffect": true, | 75 | "watchEffect": true, |
| 76 | "watchPostEffect": true, | 76 | "watchPostEffect": true, |
| 77 | - "watchSyncEffect": true | 77 | + "watchSyncEffect": true, |
| 78 | + "Slot": true, | ||
| 79 | + "Slots": true | ||
| 78 | } | 80 | } |
| 79 | } | 81 | } | ... | ... |
| ... | @@ -71,6 +71,6 @@ declare global { | ... | @@ -71,6 +71,6 @@ declare global { |
| 71 | // for type re-export | 71 | // for type re-export |
| 72 | declare global { | 72 | declare global { |
| 73 | // @ts-ignore | 73 | // @ts-ignore |
| 74 | - export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' | 74 | + export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' |
| 75 | import('vue') | 75 | import('vue') |
| 76 | } | 76 | } | ... | ... |
| ... | @@ -21,7 +21,6 @@ declare module 'vue' { | ... | @@ -21,7 +21,6 @@ declare module 'vue' { |
| 21 | LiveStreamCard: typeof import('./components/ui/LiveStreamCard.vue')['default'] | 21 | LiveStreamCard: typeof import('./components/ui/LiveStreamCard.vue')['default'] |
| 22 | MenuItem: typeof import('./components/ui/MenuItem.vue')['default'] | 22 | MenuItem: typeof import('./components/ui/MenuItem.vue')['default'] |
| 23 | PdfPreview: typeof import('./components/ui/PdfPreview.vue')['default'] | 23 | PdfPreview: typeof import('./components/ui/PdfPreview.vue')['default'] |
| 24 | - PdfViewer: typeof import('./components/ui/PdfViewer.vue')['default'] | ||
| 25 | ReviewPopup: typeof import('./components/courses/ReviewPopup.vue')['default'] | 24 | ReviewPopup: typeof import('./components/courses/ReviewPopup.vue')['default'] |
| 26 | RouterLink: typeof import('vue-router')['RouterLink'] | 25 | RouterLink: typeof import('vue-router')['RouterLink'] |
| 27 | RouterView: typeof import('vue-router')['RouterView'] | 26 | RouterView: typeof import('vue-router')['RouterView'] | ... | ... |
| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | </template> | 10 | </template> |
| 11 | 11 | ||
| 12 | <script setup> | 12 | <script setup> |
| 13 | -import { ref, nextTick, onMounted } from 'vue'; | 13 | +import { ref, nextTick, onMounted, computed } from 'vue'; |
| 14 | import { initPdfView, configPdfApiOptions } from "@sunsetglow/vue-pdf-viewer"; | 14 | import { initPdfView, configPdfApiOptions } from "@sunsetglow/vue-pdf-viewer"; |
| 15 | import "@sunsetglow/vue-pdf-viewer/dist/style.css"; | 15 | import "@sunsetglow/vue-pdf-viewer/dist/style.css"; |
| 16 | 16 | ||
| ... | @@ -22,6 +22,10 @@ const props = defineProps({ | ... | @@ -22,6 +22,10 @@ const props = defineProps({ |
| 22 | url: { | 22 | url: { |
| 23 | type: String, | 23 | type: String, |
| 24 | default: '' | 24 | default: '' |
| 25 | + }, | ||
| 26 | + title: { | ||
| 27 | + type: String, | ||
| 28 | + default: '' | ||
| 25 | } | 29 | } |
| 26 | }); | 30 | }); |
| 27 | 31 | ||
| ... | @@ -60,7 +64,7 @@ const initPdfViewer = () => { | ... | @@ -60,7 +64,7 @@ const initPdfViewer = () => { |
| 60 | toolShow: true, | 64 | toolShow: true, |
| 61 | download: true, | 65 | download: true, |
| 62 | clearScale: 1.5, | 66 | clearScale: 1.5, |
| 63 | - fileName: "preview.pdf", | 67 | + fileName: props.title, |
| 64 | lang: "en", | 68 | lang: "en", |
| 65 | print: false, | 69 | print: false, |
| 66 | watermarkOptions: undefined | 70 | watermarkOptions: undefined | ... | ... |
| ... | @@ -54,7 +54,7 @@ | ... | @@ -54,7 +54,7 @@ |
| 54 | <font-awesome-icon icon="file-alt" class="text-gray-400 text-lg flex-shrink-0" /> | 54 | <font-awesome-icon icon="file-alt" class="text-gray-400 text-lg flex-shrink-0" /> |
| 55 | <h3 class="text-x font-medium text-gray-900 truncate">{{ item.title }}</h3> | 55 | <h3 class="text-x font-medium text-gray-900 truncate">{{ item.title }}</h3> |
| 56 | </div> | 56 | </div> |
| 57 | - <div class="text-x text-blue-600 hover:text-blue-800 hover:underline whitespace-nowrap" @click="showPdf(item.url)">查看文件</div> | 57 | + <div class="text-x text-blue-600 hover:text-blue-800 hover:underline whitespace-nowrap" @click="showPdf(item)">查看文件</div> |
| 58 | </div> | 58 | </div> |
| 59 | </div> | 59 | </div> |
| 60 | </div> | 60 | </div> |
| ... | @@ -225,7 +225,7 @@ | ... | @@ -225,7 +225,7 @@ |
| 225 | </van-popup> | 225 | </van-popup> |
| 226 | 226 | ||
| 227 | <!-- PDF预览 --> | 227 | <!-- PDF预览 --> |
| 228 | - <PdfPreview v-model:show="pdfShow" :url="pdfUrl" /> | 228 | + <PdfPreview v-model:show="pdfShow" :url="pdfUrl" :title="pdfTitle" /> |
| 229 | </div> | 229 | </div> |
| 230 | </template> | 230 | </template> |
| 231 | 231 | ||
| ... | @@ -356,9 +356,11 @@ const handleLessonClick = async (lesson) => { | ... | @@ -356,9 +356,11 @@ const handleLessonClick = async (lesson) => { |
| 356 | }; | 356 | }; |
| 357 | 357 | ||
| 358 | const pdfShow = ref(false); | 358 | const pdfShow = ref(false); |
| 359 | +const pdfTitle = ref(''); | ||
| 359 | const pdfUrl = ref(''); | 360 | const pdfUrl = ref(''); |
| 360 | 361 | ||
| 361 | -const showPdf = (url) => { | 362 | +const showPdf = ({title, url}) => { |
| 363 | + pdfTitle.value = title; | ||
| 362 | pdfUrl.value = url; | 364 | pdfUrl.value = url; |
| 363 | pdfShow.value = true; | 365 | pdfShow.value = true; |
| 364 | }; | 366 | }; | ... | ... |
-
Please register or login to post a comment