Commit 527d5a41 by xinla

上传进度优化

1 parent 1d4aa3f4
...@@ -282,7 +282,7 @@ export default { ...@@ -282,7 +282,7 @@ export default {
try { try {
const data = await this.ossObj.multipartUpload(name, file, { const data = await this.ossObj.multipartUpload(name, file, {
progress: (progressData) => { progress: (progressData) => {
this.percentage = progressData * 100 progressData > 0 && (this.percentage = progressData.toFixed(2) * 100)
// this.speed = (progressData.speed / 1024 / 1024).toFixed(2) // this.speed = (progressData.speed / 1024 / 1024).toFixed(2)
}, },
}) })
...@@ -349,8 +349,8 @@ export default { ...@@ -349,8 +349,8 @@ export default {
...params, ...params,
Body: file /* 必须,上传文件对象,可以是input[type="file"]的file对象 */, Body: file /* 必须,上传文件对象,可以是input[type="file"]的file对象 */,
onProgress: (progressData) => { onProgress: (progressData) => {
this.percentage = progressData.percent * 100 progressData.percent > 0 && (this.percentage = progressData.percent.toFixed(2) * 100)
this.speed = (progressData.speed / 1024 / 1024).toFixed(2) progressData.speed > 0 && (this.speed = (progressData.speed / 1024 / 1024).toFixed(2))
// this.onProgress && this.onProgress(this.percentage, this.speed) // this.onProgress && this.onProgress(this.percentage, this.speed)
}, },
}, },
...@@ -381,11 +381,11 @@ export default { ...@@ -381,11 +381,11 @@ export default {
this.$emit('update:fileName', (this.fileNameWatch = name)) this.$emit('update:fileName', (this.fileNameWatch = name))
this.$emit('update:imgSize', memorySize) this.$emit('update:imgSize', memorySize)
} else { } else {
this.fileListWatch = this.fileListWatch.concat({ name, url, memorySize }) this.fileListWatch = this.fileListWatch.concat({ name, url, memorySize })
this.$emit('update:fileList', this.fileList.concat({ name, url: location, memorySize })) this.$emit('update:fileList', this.fileList.concat({ name, url: location, memorySize }))
} }
} }
} },
) )
}, },
remove(i) { remove(i) {
...@@ -579,8 +579,7 @@ export default { ...@@ -579,8 +579,7 @@ export default {
:src="item.url" :src="item.url"
fit="contain" fit="contain"
:preview-src-list="fileListWatch.map((e) => e.url)" :preview-src-list="fileListWatch.map((e) => e.url)"
alt="" alt="" />
/>
<div class="action-mask"> <div class="action-mask">
<el-icon-search class="el-icon-search mr5" @click="showView(index)"></el-icon-search> <el-icon-search class="el-icon-search mr5" @click="showView(index)"></el-icon-search>
<!-- <span v-if="action.includes('download')" @click="download(item)"> <!-- <span v-if="action.includes('download')" @click="download(item)">
...@@ -608,8 +607,7 @@ export default { ...@@ -608,8 +607,7 @@ export default {
:limit="limit" :limit="limit"
:on-error="onError" :on-error="onError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:before-upload="handleBeforeUpload" :before-upload="handleBeforeUpload">
>
<!-- <!--
element-loading-text="正在上传..." element-loading-text="正在上传..."
:on-success="onSuccess" :on-success="onSuccess"
...@@ -623,7 +621,7 @@ export default { ...@@ -623,7 +621,7 @@ export default {
<TransitionGroup> <TransitionGroup>
<!-- 上传进度条 --> <!-- 上传进度条 -->
<div class="upload-action uploader-size" v-if="loading" :key="1"> <div class="upload-action uploader-size" v-if="loading" :key="1">
<el-progress class="progress cc" type="circle" :percentage="percentage"></el-progress> <el-progress v-if="percentage" class="progress cc" type="circle" :percentage="percentage"></el-progress>
<div class="el-loading-spinner"> <div class="el-loading-spinner">
<svg viewBox="25 25 50 50" class="circular"> <svg viewBox="25 25 50 50" class="circular">
<circle cx="50" cy="50" r="20" fill="none" class="path"></circle> <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
...@@ -645,8 +643,7 @@ export default { ...@@ -645,8 +643,7 @@ export default {
:preview-src-list="[fileUrlWatch]" :preview-src-list="[fileUrlWatch]"
preview-teleported preview-teleported
fit="contain" fit="contain"
@click.stop @click.stop />
/>
<div class="action-mask" @click.self.stop> <div class="action-mask" @click.self.stop>
<el-icon-search class="el-icon-search" @click.stop="showView()"></el-icon-search> <el-icon-search class="el-icon-search" @click.stop="showView()"></el-icon-search>
...@@ -670,8 +667,7 @@ export default { ...@@ -670,8 +667,7 @@ export default {
playsinline="true" playsinline="true"
:autoplay="false" :autoplay="false"
:key="fileUrlWatch" :key="fileUrlWatch"
preload="auto" preload="auto">
>
<source :src="fileUrlWatch" type="video/mp4" /> <source :src="fileUrlWatch" type="video/mp4" />
</video> </video>
<div class="action-mask" style="height: 30%" @click.self.stop> <div class="action-mask" style="height: 30%" @click.self.stop>
...@@ -682,15 +678,8 @@ export default { ...@@ -682,15 +678,8 @@ export default {
{{ fileNameWatch || fileUrlWatch }} {{ fileNameWatch || fileUrlWatch }}
<el-icon-EditPen class="el-icon-EditPen ml10"></el-icon-EditPen> <el-icon-EditPen class="el-icon-EditPen ml10"></el-icon-EditPen>
<!-- a链接用本地视频打不开,视频地址使用远程地址 --> <!-- a链接用本地视频打不开,视频地址使用远程地址 -->
<a <a @click.stop :href="/\.mp4$/.test(fileNameWatch) ? fileUrl : fileUrlWatch" target="_blank">
@click.stop <el-icon-view class="el-icon-view ml10" style="vertical-align: middle"></el-icon-view>
:href="/\.mp4$/.test(fileNameWatch) ? fileUrl : fileUrlWatch"
target="_blank"
>
<el-icon-view
class="el-icon-view ml10"
style="vertical-align: middle"
></el-icon-view>
</a> </a>
</template> </template>
</div> </div>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!