fix: drag flicker guard, error body parsing, wizard session restore answer
This commit is contained in:
parent
07f6cadfaf
commit
939b3c4ea6
2 changed files with 16 additions and 3 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<div class="rounded border-2 border-dashed border-surface-border p-6 text-center"
|
||||
:class="{ 'border-accent bg-accent/5': isDragging }"
|
||||
@dragover.prevent="isDragging = true"
|
||||
@dragleave="isDragging = false"
|
||||
@dragleave="onDragLeave"
|
||||
@drop.prevent="onDrop">
|
||||
<p class="text-sm font-medium text-text-primary mb-1">Upload documents</p>
|
||||
<p class="text-xs text-text-dim mb-3">
|
||||
|
|
@ -56,8 +56,13 @@ async function uploadFile(file: File) {
|
|||
fileStatuses.value[idx] = { name: file.name, status: 'done' }
|
||||
emit('uploaded')
|
||||
} else {
|
||||
const msg = await r.text()
|
||||
fileStatuses.value[idx] = { name: file.name, status: 'error', error: msg || `Error ${r.status}` }
|
||||
let errorMsg = `Error ${r.status}`
|
||||
try {
|
||||
const body = await r.text()
|
||||
const parsed = JSON.parse(body)
|
||||
errorMsg = parsed.detail ?? parsed.message ?? errorMsg
|
||||
} catch { /* leave default */ }
|
||||
fileStatuses.value[idx] = { name: file.name, status: 'error', error: errorMsg }
|
||||
}
|
||||
} catch {
|
||||
fileStatuses.value[idx] = { name: file.name, status: 'error', error: 'Upload failed' }
|
||||
|
|
@ -71,6 +76,12 @@ function onFileInput(e: Event) {
|
|||
input.value = ''
|
||||
}
|
||||
|
||||
function onDragLeave(e: DragEvent) {
|
||||
if (e.currentTarget instanceof Node && e.relatedTarget instanceof Node &&
|
||||
(e.currentTarget as Node).contains(e.relatedTarget as Node)) return
|
||||
isDragging.value = false
|
||||
}
|
||||
|
||||
function onDrop(e: DragEvent) {
|
||||
isDragging.value = false
|
||||
if (!e.dataTransfer?.files) return
|
||||
|
|
|
|||
|
|
@ -151,6 +151,8 @@ async function loadSchema() {
|
|||
if (saved) {
|
||||
try { session.value = JSON.parse(saved) } catch {}
|
||||
}
|
||||
// Pre-populate answer for the current step (handles sessionStorage restore)
|
||||
answer.value = session.value.answers[currentStep.value?.id ?? ''] ?? ''
|
||||
}
|
||||
|
||||
async function goNext(skip = false) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue