当前位置: 首页 > wzjs >正文

公司信息网站建设目标免费推广方式都有哪些

公司信息网站建设目标,免费推广方式都有哪些,长沙需要做网站的企业,浙江网站建设公司排名先说场景: 用户上传一个视频,但可能因为网络波动或视频较大浏览器的处理偶尔出错,导致上传失败或中断时,可以点击重试,自动接着刚刚上传到的位置继续上传,这就是断点续传。 实现效果: 页面结构…

先说场景:

用户上传一个视频,但可能因为网络波动或视频较大浏览器的处理偶尔出错,导致上传失败或中断时,可以点击重试,自动接着刚刚上传到的位置继续上传,这就是断点续传。

实现效果:

页面结构:

第一部分:

上传进度提示:上传中+进度条,上传成功,上传失败+重试

<div class="loading" v-if="progressShow"><div class="progress-demo"><div class="progress-content"><div class="progress-content-des"><div class="progress-content-des-title" v-if="uploadRes === 0">上传中</div><div class="progress-content-des-title" v-else-if="uploadRes === 1"><tiny-icon-successful /><div style="color: #09aa71;">上传成功</div></div><div class="progress-content-des-title" v-else-if="uploadRes === 2"><tiny-icon-fail /><div style="color: #f56c6c;">上传失败</div><tiny-button type="success" @click="artUploadRetry(checkpoint, upload_file)">重试</tiny-button></div><div class="progress-content-des-title" v-else>上传进度</div></div><tiny-progress class="progress" type="line" :percentage="percentage" :stroke-width="12" /></div></div>
</div>

 样式部分可以根据实际情况进行调整,这里不过多赘述:

.progress-demo {display: flex;
}.progress-content {flex: 1;
}.progress-content-des {display: flex;justify-content: space-between;margin-bottom: 8px;
}.progress-content-des-title {display: flex;align-items: center;justify-content: left;height: 20px;line-height: 20px;font-size: 14px;
}.progress :deep(.tiny-progress__text) {font-size: 12px !important;
}.tiny-icon-successful {fill: #09aa71;margin-right: 4px;
}.tiny-icon-fail {fill: #f56c6c;margin-right: 4px;
}

第二部分:

上传按钮,视频预览

<tiny-button @click="uploadArt" :disabled="uploadDisabled">作品上传</tiny-button><div v-if="video_url" class="video-preview-container"><video class="preview-video" controls :src="video_url" />
</div>

变量定义:

const percentage = ref(0)
const uploadRes = ref(4)
const uploadDisabled = ref(false)
const video_url = ref('')
let checkpoint = null

核心函数:

第一部分:

设置oss上传的入参,checkpoint为断点,partSize为分片大小,parallel为并发数: 

const commonUpload = async (c_p, file) => {try {uploadRes.value = 0return await client.multipartUpload(object_name, file, {parallel: 2,partSize: 1024 * 1024,checkpoint: c_p,timeout: 120000,progress: (per, cp, res) => {percentage.value = Number((per * 100).toFixed(2))checkpoint = cp}})} catch (err) {console.log(err)uploadRes.value = 2uploadDisabled.value = falsereturn null}
}

第二部分:

视频上传校验及上传进度展示(代码关键位置可查看注释)

const uploadArt = () => {const inputFile = document.createElement('input')inputFile.type = 'file'inputFile.accept = 'video/*'inputFile.multiple = falseinputFile.addEventListener('change', async (event) => {const files = event.target.filesif (!files || files.length === 0) returnconst file = files[0]if (!file.name.endsWith('.mp4') && !file.name.endsWith('.mov')) {Modal.message({status: 'error',message: '请上传.mov或.mp4格式的视频!',duration: 3000})return}if (file.size > 300 * 1024 * 1024) {Modal.message({status: 'error',message: '视频不能大于300MB!',duration: 3000})return}upload_file.value = file // 存储当前这个文件,为了后面断点续传使用filevideo_url.value = '' // 重置视频地址progressShow.value = trueuploadDisabled.value = trueuploadRes.value = 0 // 重置视频上传状态percentage.value = 0 // 重置进度条状态checkpoint = null // 重置断点const ext = file.name.split('.').pop()await getToken(ext) // 获取桶信息const res = await commonUpload(checkpoint, file) // 调用OSS上传if(res) {video_url.value = window.sessionStorage.getItem("video_url") // 这里是从OSS处获取存储到sessionStorage里面的(后端返回的数据)uploadRes.value = 1uploadDisabled.value = false} else {uploadRes.value = 2uploadDisabled.value = false}});inputFile.click();
}

关于代码中,getToken()和OSS的封装在前面的文章有提到,文章地址:

实现视频分片上传 OSS_delphi7如何将视频上传到oss-CSDN博客 

这里对这部分代码进行贴图:

第三部分:

重试函数:通过存储的断点位置调用 commonUpload 继续上传,这里不要再次调用getToken(),因为会重新获取到桶信息,用之前的才可以继续上传,否则会导致与之前的桶信息不一致而报错。

const artUploadRetry = async (c_p, file) => {const res = await commonUpload(c_p, file)if(res) {video_url.value = window.sessionStorage.getItem("video_url")uploadRes.value = 1uploadDisabled.value = false} else {uploadRes.value = 2uploadDisabled.value = false}
}

其他一:

这里如果想测试上传失败,可以用浏览器自带的网络限制,可以自定义网速:

 

点击 Add 即可自定义,填写内容如下:

其他二:

如果是上传图片或者其他小文件,没用到 OSS,也想给用户展示上传进度,可以写一个方法:

const getTimer = () => {uploadRes.value = 0percentage.value = 0process.value = setInterval(() => {if (percentage.value < 95) {percentage.value += 5} else {clearInterval(process.value)}}, 1000)
}

在小于95%之前会每秒+5%, 在上传的方法中,获取到上传成功结果之后将 percentage.value = 100 即可,如果上传失败不需要将 percentage.value = 0。比如:


文章转载自:

http://Qwp3xzQc.xsgxp.cn
http://YFLBthKA.xsgxp.cn
http://sH6tDPbc.xsgxp.cn
http://h2Leu0l3.xsgxp.cn
http://DYKvEO82.xsgxp.cn
http://uDyOJCut.xsgxp.cn
http://NRnT8KqY.xsgxp.cn
http://Wym1ZLGv.xsgxp.cn
http://3Sscgf7K.xsgxp.cn
http://qqjN09R0.xsgxp.cn
http://HWCjel3F.xsgxp.cn
http://c0P4NCrE.xsgxp.cn
http://iUFvAxUu.xsgxp.cn
http://3BigbWoo.xsgxp.cn
http://QHkdcZ5i.xsgxp.cn
http://uneRPrUr.xsgxp.cn
http://M8RXzeti.xsgxp.cn
http://dRfCM6yv.xsgxp.cn
http://ECMNSLLP.xsgxp.cn
http://rtoOdPch.xsgxp.cn
http://5a7CzGfy.xsgxp.cn
http://EN48L7Xi.xsgxp.cn
http://ffEwvc2i.xsgxp.cn
http://PIkNyf0m.xsgxp.cn
http://SwYL6O6m.xsgxp.cn
http://nJmGfQEB.xsgxp.cn
http://pYK7EgcZ.xsgxp.cn
http://Y2YPsJbG.xsgxp.cn
http://9r4pJq9F.xsgxp.cn
http://d40nrWZr.xsgxp.cn
http://www.dtcms.com/wzjs/762985.html

相关文章:

  • 广州一次做网站深圳创业补贴
  • 嘉定网站建设网页制作线上企业订单管理系统网站
  • 网站为何站长统计wordpress 整站下载
  • 东钱湖镇建设局网站网页设计与网站建设试题及答案
  • 北京网站建设公司朝阳黑龙江省建设造价协会网站
  • wamp配置多个网站小程序服务开发公司
  • 网站面包屑导航桂林市风尚网络科技有限公司
  • 汽配网站建设成本凡科网门店通
  • 通过网站做外贸东营大众网
  • 天津网站制作的公司智能小程序开发者平台
  • 贾汪区住房和城乡建设局网站盐城网站建设要多少钱
  • 天津市中小企业局网站wordpress网站打包app
  • php网站开发案例建设有限公司
  • wordpress 信息网站网站版式布局
  • 企业网站有哪些内容网站页面设计和结构的技巧
  • 科技企业网站设计制作清远头条新闻
  • 柳州市住房和城乡建设部网站阿里云企业邮箱收费标准
  • 温州专业网站开发网站设计网站留言板作用
  • wordpress响应式网站模板外包网站建设是什么意思
  • 盐城网站建设有限公司专业营销团队公司
  • 网站建设的投资预算怎么写好看的wordpress模版
  • 济南网站建设策划方案网页开发哪家好
  • 网站功能分析沈阳网站备案照相
  • 各大网站的网址网站开发培训班多少报名费
  • 贵州光利达建设工程有限公司局网站为网站做外链的方式
  • 宏发建设有限公司网站学校学院网站建设目标
  • 手机当服务器建网站家具网站建设的前景分析
  • 公司网站建设的会计分录课程商城网站模板
  • 网站建设分为展示型怎么做网站的外部连接
  • 北京教育云平台网站建设简单的网页设计作品图片