This commit is contained in:
Zyronon
2025-10-19 23:46:33 +08:00
parent 03e38d1ce6
commit eccf3880be
2 changed files with 18 additions and 3 deletions

View File

@@ -48,7 +48,7 @@ export function addDict(params?, data?) {
return http<Dict>('dict/addDict', remove(data), remove(params), 'post')
}
export function uploadImportData(data) {
export function uploadImportData(data,onUploadProgress) {
return axiosInstance({
url: 'dict/uploadImportData',
method: 'post',
@@ -56,5 +56,6 @@ export function uploadImportData(data) {
contentType: 'formdata',
},
data,
onUploadProgress
})
}

View File

@@ -8,13 +8,27 @@ function sync() {
}
function handleAudioChange(e) {
async function handleAudioChange(e) {
let uploadFile = e.target?.files?.[0]
if (!uploadFile) return
let data = new FormData();
data.append("file", uploadFile);
uploadImportData(data)
let res = await uploadImportData(data, e => {
console.log('e', e)
})
console.log('res', res)
console.log(uploadFile)
e.target.value = ''
}
async function s() {
const taskId = await fetch('/startImport').then(r => r.json()).then(d => d.taskId);
const timer = setInterval(async () => {
const res = await fetch(`/getProgress/${taskId}`).then(r => r.json());
console.log(`当前进度: ${res.progress}%`);
if (res.progress >= 100) clearInterval(timer);
}, 1000);
}
</script>