1
0

feat(web): 增加文件上传接口

This commit is contained in:
2024-11-21 12:25:19 +08:00
parent 6d63c20b7f
commit d68f8a27ee
10 changed files with 338 additions and 6 deletions

View File

@@ -83,6 +83,14 @@ export function paginationTemplate(perPage = 20, maxButtons = 5) {
}
}
export function inputFileFormItemCommonOptions(accept = '*', maxSize = 5242880) {
return {
accept: accept,
maxSize: maxSize,
autoUpload: false,
}
}
export function copyField(field, tips = '复制', ignoreLength = 0, extra = undefined) {
let tpl = ignoreLength === 0 ? `\${${field}}` : `\${TRUNCATE(${field}, ${ignoreLength})}`
let content = extra

View File

@@ -1,5 +1,5 @@
import './dialog-resource.css'
import {apiPost, horizontalFormOptions} from "../constants.js";
import {apiPost, horizontalFormOptions, inputFileFormItemCommonOptions} from "../constants.js";
const clearable = {
clearable: true,
@@ -99,8 +99,8 @@ export function resourceAddDialog() {
{
type: 'input-file',
name: 'filePath',
accept: '.zip',
description: '只适合小于2M的资源文件使用大文件请使用其他资源类型',
...inputFileFormItemCommonOptions('.zip', 2097152),
},
]
},
@@ -148,13 +148,13 @@ export function resourceAddDialog() {
type: 'input-file',
description: 'core-site.xml',
name: 'coreSiteFile',
accept: '.xml',
...inputFileFormItemCommonOptions('.xml', 1048576),
},
{
type: 'input-file',
description: 'hdfs-site.xml',
name: 'hdfsSiteFile',
accept: '.xml',
...inputFileFormItemCommonOptions('.xml', 1048576),
},
]
},
@@ -257,7 +257,7 @@ export function resourceAddDialog() {
label: '资源示例',
description: '可以上传用于作为格式示范的样例数据',
name: 'example',
accept: '*',
...inputFileFormItemCommonOptions(),
},
]
}

View File

@@ -1,4 +1,5 @@
import {resourceAddDialog} from "../../components/resource/dialog-resource.js";
import {apiPost, inputFileFormItemCommonOptions} from "../../components/constants.js";
export function tabData() {
return {
@@ -10,6 +11,21 @@ export function tabData() {
label: '',
icon: 'fa fa-plus',
...resourceAddDialog()
},
{
type: 'form',
body: [
{
type: 'input-file',
name: 'file',
label: '测试文件上传',
...inputFileFormItemCommonOptions(undefined, 1073741824),
useChunk: true,
startChunkApi: apiPost('${base}/upload/start'),
chunkApi: apiPost('${base}/upload/slice'),
finishChunkApi: apiPost('${base}/upload/finish')
}
]
}
]
}