feat: improve map and upload experience

This commit is contained in:
2026-05-21 16:54:38 +08:00
parent cb2581afb2
commit 2b7f393d7c
6 changed files with 386 additions and 85 deletions
+17 -1
View File
@@ -119,6 +119,13 @@ export function useUpload() {
}
}
function clearAll() {
for (const item of items.value) {
URL.revokeObjectURL(item.preview)
}
items.value = []
}
function validateItem(item: UploadItem): boolean {
const errors: Record<string, string> = {}
if (!item.cloudCategoryId) {
@@ -130,6 +137,14 @@ export function useUpload() {
if (!item.capturedAt) {
errors.capturedAt = '请选择拍摄时间'
}
const hasLat = typeof item.latitude === 'number' && !isNaN(item.latitude)
const hasLng = typeof item.longitude === 'number' && !isNaN(item.longitude)
if (hasLat && !hasLng) {
errors.longitude = '经纬度必须同时填写'
}
if (hasLng && !hasLat) {
errors.latitude = '经纬度必须同时填写'
}
item.errors = errors
return Object.keys(errors).length === 0
}
@@ -198,6 +213,7 @@ export function useUpload() {
location_name: item.locationName || null,
description: item.description.trim() || null,
captured_at: item.capturedAt,
status: 'approved',
is_hidden: item.isHidden,
})
if (dbError) throw dbError
@@ -217,5 +233,5 @@ export function useUpload() {
}
}
return { items, uploading, overallProgress, currentItemIndex, totalItems, addFiles, removeItem, validateItem, validateAll, uploadAll }
return { items, uploading, overallProgress, currentItemIndex, totalItems, addFiles, removeItem, clearAll, validateItem, validateAll, uploadAll }
}