feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
normalizeResumableCompletePayload,
|
||||
normalizeResumableCompleteResult,
|
||||
@@ -15,11 +14,6 @@ import {
|
||||
requestStrict
|
||||
} from './request-client.js'
|
||||
|
||||
const requireRemoteUpload = () => {
|
||||
if (hasRemoteConfig()) return
|
||||
throw createRequestError('文件上传需要真实服务,当前本地预览不伪造回执', 'REMOTE_WRITE_REQUIRED')
|
||||
}
|
||||
|
||||
const normalizeChunkIndex = (value) => {
|
||||
if (!Number.isInteger(value) || value < 0 || value > 2147483647) {
|
||||
throw new TypeError('chunkIndex必须是非负 int32')
|
||||
@@ -30,7 +24,6 @@ const normalizeChunkIndex = (value) => {
|
||||
export const fileUploadApi = {
|
||||
async initializeResumableUpload(payload, requestOptions = {}) {
|
||||
const uploadRequest = normalizeResumableInitPayload(payload)
|
||||
requireRemoteUpload()
|
||||
const uploadSession = await requestStrict({
|
||||
url: '/genealogy/app/files/resumable/init',
|
||||
method: 'POST',
|
||||
@@ -50,7 +43,6 @@ export const fileUploadApi = {
|
||||
if (typeof payload.filePath !== 'string' || !payload.filePath.trim()) {
|
||||
throw new TypeError('filePath必须是非空字符串')
|
||||
}
|
||||
requireRemoteUpload()
|
||||
return requestNativeFileChunk({
|
||||
uploadId: normalizeUploadId(payload.uploadId, 'uploadId'),
|
||||
chunkIndex: normalizeChunkIndex(payload.chunkIndex),
|
||||
@@ -68,7 +60,6 @@ export const fileUploadApi = {
|
||||
if (!file || typeof file !== 'object') {
|
||||
throw new TypeError('浏览器文件分片必须提供文件对象')
|
||||
}
|
||||
requireRemoteUpload()
|
||||
return requestBrowserFileChunk({
|
||||
uploadId: normalizeUploadId(payload.uploadId, 'uploadId'),
|
||||
chunkIndex: normalizeChunkIndex(payload.chunkIndex),
|
||||
@@ -79,7 +70,6 @@ export const fileUploadApi = {
|
||||
|
||||
async completeResumableUpload(payload, requestOptions = {}) {
|
||||
const completionRequest = normalizeResumableCompletePayload(payload)
|
||||
requireRemoteUpload()
|
||||
const uploadedFile = await requestStrict({
|
||||
url: '/genealogy/app/files/resumable/complete',
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user