Browse Source

限制视频格式

dev
陈鹏飞 3 years ago
parent
commit
34cd0a08a6
  1. 4
      src/app/pages/plan/plan.component.html
  2. 6
      src/app/pages/plan/plan.component.ts

4
src/app/pages/plan/plan.component.html

@ -170,10 +170,10 @@
<div class="planHeaderVideo">
<video [src]="beforePlanNode.video" [hidden]="!beforePlanNode.video" (click)="openVideo(beforePlanNode.video)"></video>
<div class="positionHandleImgVideo" style="width: 120px;" *ngIf="editMode && beforePlanNode.video">
<a href="javascript:;" class="imgAndVideoUpload"><input type="file" accept="video/*" (change)='uploadImgVideo($event, true)'><i nz-icon nzType="upload" nzTheme="outline"></i></a>
<a href="javascript:;" class="imgAndVideoUpload"><input type="file" accept=".mp4,.ogg,.webm" (change)='uploadImgVideo($event, true)'><i nz-icon nzType="upload" nzTheme="outline"></i></a>
<i nz-icon nzType="delete" nzTheme="outline" (click)="deleteImgVideo(3)"></i>
</div>
<a href="javascript:;" class="bottomPlanUpload" style="width: 100px;" *ngIf="editMode && !beforePlanNode.video"><input type="file" accept="video/*" (change)='uploadImgVideo($event, true)'><img src="../../../assets/images/uploadVideo.png"></a>
<a href="javascript:;" class="bottomPlanUpload" style="width: 100px;" *ngIf="editMode && !beforePlanNode.video"><input type="file" accept=".mp4,.ogg,.webm" (change)='uploadImgVideo($event, true)'><img src="../../../assets/images/uploadVideo.png"></a>
</div>
</div>
<div style="height: 5px;"></div>

6
src/app/pages/plan/plan.component.ts

@ -732,6 +732,10 @@ export class PlanComponent implements OnInit {
if (e.target.files.length) {
let maxSize = 30 * 1024 * 1024 //限制30MB
let file = e.target.files[0]
if (isVideo && !file.name.toLowerCase().includes(".mp4") && !file.name.toLowerCase().includes(".ogg") && !file.name.toLowerCase().includes(".webm")) { //视频格式限制
this.message.info("上传视频限制为mp4/ogg/webm格式");
return
}
if (file.size > maxSize) { //超出限制
this.message.info("上传资源需小于30MB");
return
@ -739,7 +743,7 @@ export class PlanComponent implements OnInit {
this.isShowLoading = true //打开遮罩
let institutionKey = `${this.companyData.id}` || "ceshi"; //单位id
let resType = isVideo ? ResType.Video : ResType.Texture
let key = `${(new Date()).getMonth() + 1}-${(new Date()).getDate()}-${(new Date()).getHours()}`
let key = `${(new Date()).getFullYear()}-${(new Date()).getMonth() + 1}-${(new Date()).getDate()}-${(new Date()).getHours()}`
let url = DataManager.getResPath_mark(institutionKey, resType, key) //url
ServeManager.instance.openFileSelect(file, url, (name: string, path: string) => { //上传
if (!isVideo) { //img

Loading…
Cancel
Save