Skip to content

Commit

Permalink
init example pdf without onMounted
Browse files Browse the repository at this point in the history
  • Loading branch information
rwv committed Dec 1, 2023
1 parent a51d058 commit 990f1dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/views/CanvasScanView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import MainContainer from '@/components/MainContainer.vue'
import { type ScanConfig, defaultConfig, CanvasScanner } from '@/utils/scan-renderer/canvas-scan'
import ScanSettingsCard from '@/components/scan-settings/ScanSettingsCard.vue'
import PDFUpload from '@/components/pdf-upload/PDFUpload.vue'
import { ref, computed, onMounted, watch } from 'vue'
import { ref, computed, watch } from 'vue'
import PDFURL from '@/assets/examples/pdfs/test.pdf'
import BackToIndex from '@/components/buttons/BackToIndex.vue'
import { useHead } from '@unhead/vue'
Expand All @@ -59,11 +59,16 @@ useHead({
const pdf = ref<File | undefined>(undefined)
onMounted(async () => {
const initExamplePDF = async () => {
const response = await fetch(PDFURL)
const blob = await response.blob()
pdf.value = new File([blob], 'example.pdf')
})
const file = new File([blob], 'example.pdf')
if (!pdf.value) {
pdf.value = file
}
}
initExamplePDF()
const config = ref<ScanConfig>(defaultConfig)
const pdfRenderer = computed(() => {
Expand Down
13 changes: 9 additions & 4 deletions src/views/MagicaScanView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import MainContainer from '@/components/MainContainer.vue'
import { type ScanConfig, defaultConfig, MagicaScanner } from '@/utils/scan-renderer/magica-scan'
import ScanSettingsCard from '@/components/scan-settings/ScanSettingsCard.vue'
import PDFUpload from '@/components/pdf-upload/PDFUpload.vue'
import { ref, computed, onMounted, watch } from 'vue'
import { ref, computed, watch } from 'vue'
import PDFURL from '@/assets/examples/pdfs/test.pdf'
import BackToIndex from '@/components/buttons/BackToIndex.vue'
import { useHead } from '@unhead/vue'
Expand All @@ -59,11 +59,16 @@ useHead({
const pdf = ref<File | undefined>(undefined)
onMounted(async () => {
const initExamplePDF = async () => {
const response = await fetch(PDFURL)
const blob = await response.blob()
pdf.value = new File([blob], 'example.pdf')
})
const file = new File([blob], 'example.pdf')
if (!pdf.value) {
pdf.value = file
}
}
initExamplePDF()
const config = ref<ScanConfig>(defaultConfig)
const pdfRenderer = computed(() => {
Expand Down

0 comments on commit 990f1dd

Please sign in to comment.