完善接单平台上传与物品规则

This commit is contained in:
yml2213
2026-07-25 15:56:18 +08:00
parent f6d3f00f21
commit a2587eda01
40 changed files with 4978 additions and 1008 deletions
+22
View File
@@ -0,0 +1,22 @@
import { apiPostForm } from '@/lib/http'
import type { UploadedFile } from '@/types/worker-platform'
import { optimizeImageForUpload } from '@/utils/image-upload'
type UploadScope = 'admin' | 'worker'
export async function uploadFile(
file: File,
scene: string,
scope: UploadScope,
) {
const uploadTarget = await optimizeImageForUpload(file, scene)
const form = new FormData()
form.append('file', uploadTarget)
form.append('scene', scene)
const endpoint =
scope === 'admin'
? '/api/v1/admin/files/upload'
: '/api/v1/worker/files/upload'
const response = await apiPostForm<{ file: UploadedFile }>(endpoint, form)
return response.data.file
}