update 使用element-plus组件

This commit is contained in:
AprilWind 2024-12-02 18:25:09 +08:00
parent 7d2e98cb05
commit bb90b0e68b

View File

@ -1,15 +1,16 @@
<template>
<div>
<a href='https://gitee.com/dromara/RuoYi-Vue-Plus/pulls/522'>分支地址</a>
<Progress :status='uploadStatus' :percent='percent' />
<input type='file' @change='handleFileChange' />
<a href="https://gitee.com/dromara/RuoYi-Vue-Plus/pulls/522">分支地址</a>
<!-- 使用 element-plus Progress 组件 -->
<el-progress :status="uploadStatus" :percentage="percent" />
<input type="file" @change="handleFileChange" />
</div>
</template>
<script setup lang='ts'>
<script setup lang="ts">
import { md5 } from 'hash-wasm';
import { httpInstance, multipartUpload, type PartUploadList } from '@/utils/partUpload';
import { message, Progress } from 'ant-design-vue';
import { ElMessage, ElProgress } from 'element-plus'; // element-plus
import { computed, ref } from 'vue';
/**
@ -31,7 +32,7 @@ async function handleFileChange(e: any) {
const fileSize = file.size;
if (fileSize <= CHUNK_SIZE) {
message.error('文件大小不能小于5MB');
ElMessage.error('文件大小不能小于5MB'); // 使 element-plus ElMessage
return;
}
@ -59,14 +60,8 @@ async function handleFileChange(e: any) {
const partUploadList: PartUploadList[] = [];
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];
// const uint8array = new Uint8Array(await chunk.arrayBuffer());
// const md5Digest = await md5(uint8array);
const uploadResp = await multipartUpload({
ossStatus: 'upload',
/***
* 大坑 这里不能传md5 否则上传失败
*/
// md5Digest,
uploadId,
partNumber: i + 1
});
@ -76,7 +71,6 @@ async function handleFileChange(e: any) {
const minioResp = await httpInstance.put(privateUrl, chunk, {
headers: {
'Content-Type': 'application/octet-stream'
// 'Content-MD5': md5Digest,
}
});
@ -99,6 +93,10 @@ async function handleFileChange(e: any) {
partUploadList
});
message.success('上传成功');
ElMessage.success('上传成功'); // 使 element-plus ElMessage
}
</script>
<style scoped>
/* 你可以在这里添加一些样式 */
</style>