Commit ebd71360 authored by salitedfish's avatar salitedfish

bug修复

parent af372209
......@@ -151,9 +151,9 @@ export default Vue.extend({
case '音频':
return {acceptTitle:'请上传音频附件',acceptType:"audio/*",acceptText:'上传音频仅支持MP3格式文件,大小限制为100M以内',acceptSize:1024*1024*100,acceptArray:['.mp3','.MP3']}
case '图片':
return {acceptTitle:'请上传图片附件',acceptType:'image/*',acceptText:'仅支持png、jpg图片',acceptArray:['.png','.jpg','.PNG','.JPG']}
return {acceptTitle:'请上传图片附件',acceptType:'image/*',acceptText:'仅支持png、jpg图片',acceptArray:['.png','.jpg','.jpeg','.PNG','.JPG','.JPEG']}
case '封面图片':
return {acceptTitle:'请上传封面图片',acceptType:'image/*',acceptText:'仅支持png、jpg图片',acceptArray:['.png','.jpg','.PNG','.JPG']}
return {acceptTitle:'请上传封面图片',acceptType:'image/*',acceptText:'仅支持png、jpg图片',acceptArray:['.png','.jpg','.jpeg','.PNG','.JPG','.JPEG']}
default:
return {acceptTitle:'',acceptType:'',acceptText:''}
}
......@@ -227,6 +227,8 @@ export default Vue.extend({
//限制类型
const type_name = files[0].name.substring(files[0].name.lastIndexOf('.'),files[0].name.length)
console.log('图片后缀',type_name)
if(this.uploadAccept.acceptArray && this.uploadAccept.acceptArray.indexOf(type_name) == -1) {
this.$toast('请上传指定类型文件~')
ele.value = ''
......@@ -243,12 +245,21 @@ export default Vue.extend({
}),
async afterRead(file: File) {
try {
//分块计算hash
const ab = await file.arrayBuffer();
// const fileMd5_old = md5(Buffer.from(ab));
// const fileMd5 = md5(Buffer.from(ab));
let chunkSize = 104857600;
let chunks = Math.ceil(file.size / chunkSize);
let currentChunk = 0;
let spark = new SparkMD5.ArrayBuffer();
spark.append(Buffer.from(ab))
while(currentChunk<chunks){
const start = currentChunk * chunkSize,
end = start + chunkSize >= file.size ? file.size : start + chunkSize;
spark.append(Buffer.from(ab).slice(start,end))
currentChunk ++
}
// spark.append(Buffer.from(ab))
const fileMd5 = spark.end()
// const fileMd5 = await this.computedHash(file)
if(this.uploadType == '封面图片') {
this.setState({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment