Fix evetn listening redirection on doc upload
This commit is contained in:
parent
d22f2e973e
commit
079595b57d
2 changed files with 13 additions and 3 deletions
|
|
@ -27,6 +27,8 @@ import { ref } from 'vue'
|
||||||
import { useDocumentStore } from '../store'
|
import { useDocumentStore } from '../store'
|
||||||
import { useI18n } from '../../../shared/i18n'
|
import { useI18n } from '../../../shared/i18n'
|
||||||
|
|
||||||
|
const emit = defineEmits<{ uploaded: [docId: number] }>()
|
||||||
|
|
||||||
const store = useDocumentStore()
|
const store = useDocumentStore()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const fileInput = ref<HTMLInputElement | null>(null)
|
const fileInput = ref<HTMLInputElement | null>(null)
|
||||||
|
|
@ -39,7 +41,10 @@ function openFilePicker() {
|
||||||
async function onFileSelect(e: Event) {
|
async function onFileSelect(e: Event) {
|
||||||
const target = e.target as HTMLInputElement
|
const target = e.target as HTMLInputElement
|
||||||
const file = target.files?.[0]
|
const file = target.files?.[0]
|
||||||
if (file) await store.upload(file)
|
if (file) {
|
||||||
|
const doc = await store.upload(file)
|
||||||
|
if (doc) emit('uploaded', doc.id)
|
||||||
|
}
|
||||||
target.value = ''
|
target.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +52,8 @@ async function onDrop(e: DragEvent) {
|
||||||
dragging.value = false
|
dragging.value = false
|
||||||
const file = e.dataTransfer?.files?.[0]
|
const file = e.dataTransfer?.files?.[0]
|
||||||
if (file && file.type === 'application/pdf') {
|
if (file && file.type === 'application/pdf') {
|
||||||
await store.upload(file)
|
const doc = await store.upload(file)
|
||||||
|
if (doc) emit('uploaded', doc.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<!-- Quick upload -->
|
<!-- Quick upload -->
|
||||||
<div class="home-upload">
|
<div class="home-upload">
|
||||||
<DocumentUpload />
|
<DocumentUpload @uploaded="onUploaded" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Stats -->
|
<!-- Stats -->
|
||||||
|
|
@ -71,6 +71,10 @@ const docCount = computed(() => documentStore.documents.length)
|
||||||
const analysisCount = computed(() => historyStore.analyses.length)
|
const analysisCount = computed(() => historyStore.analyses.length)
|
||||||
const recentDocs = computed(() => documentStore.documents.slice(0, 5))
|
const recentDocs = computed(() => documentStore.documents.slice(0, 5))
|
||||||
|
|
||||||
|
function onUploaded() {
|
||||||
|
router.push('/studio')
|
||||||
|
}
|
||||||
|
|
||||||
function openInStudio(doc: Document) {
|
function openInStudio(doc: Document) {
|
||||||
documentStore.select(doc.id)
|
documentStore.select(doc.id)
|
||||||
router.push('/studio')
|
router.push('/studio')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue