diff --git a/src/utils/common.ts b/src/utils/common.ts index 474eea0..7276adb 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -59,16 +59,19 @@ export function getValue(key: string): any{ * @param name 图片名字 */ -export function provenimg(name: string): boolean{ +export function provenimg(file: any): boolean | void{ const type = ['png', 'jpg']; - const ntypearr = name.split('.'); + const ntypearr = file.name.split('.'); const ntype = ntypearr[ntypearr.length - 1]; + console.log(ntype) + let istype = false for(const i in type){ if(type[i] == ntype){ - return true; + istype = true } } - return false; + console.log(istype) + return istype; } /** @@ -76,9 +79,9 @@ export function provenimg(name: string): boolean{ * @param name 图片名字 */ -export function provenvideo(name: string): boolean{ +export function provenvideo(file: any): boolean{ const type = ['flv', 'mp4', 'wmv', 'mov', 'avi']; - const ntypearr = name.split('.'); + const ntypearr = file.name.split('.'); const ntype = ntypearr[ntypearr.length - 1]; for(const i in type){ if(type[i] == ntype){ diff --git a/src/views/mine/Archives.vue b/src/views/mine/Archives.vue index a1cdc73..49f432a 100644 --- a/src/views/mine/Archives.vue +++ b/src/views/mine/Archives.vue @@ -9,6 +9,7 @@ class="avatar-uploader" :show-upload-list="false" :customRequest="uploadspic" + :beforeUpload="imgs" @change="handleChange" > @@ -177,7 +178,7 @@
{ showname.value = true; @@ -1040,8 +1046,9 @@ export default defineComponent({ lan, interestslist, isdisabled, - beforeVideoUpload, - setname + setname, + video, + imgs }; }, }); diff --git a/src/views/mine/ReleaseVideo.vue b/src/views/mine/ReleaseVideo.vue index ae09075..4d44cc4 100644 --- a/src/views/mine/ReleaseVideo.vue +++ b/src/views/mine/ReleaseVideo.vue @@ -14,7 +14,7 @@
{ console.log(info); uploadpicprogress.value = info.percent.toFixed(2) * 100; }); console.log(res); form.value.img = res.video.url; - } else { - return; - } + } function beforeUploadpic(info?: any) { @@ -256,7 +254,6 @@ export default defineComponent({ const uploadprogress: Ref = ref(0); const ifallowvideo = ref(false); async function uploads(file: AntUpload) { - if (ifallowvideo.value) { console.log(file); videofile.value = file.file; videos.value[0].addEventListener("durationchange", () => { @@ -271,7 +268,6 @@ export default defineComponent({ form.value.fileid = res.fileId; form.value.fileurl = res.video.url; - } } function beforeVideoUpload(info?: any) { @@ -326,6 +322,13 @@ export default defineComponent({ ifallowvideo.value = true; } } + function video(file: any){ + return provenvideo(file) + } + function imgs(file: any){ + return provenimg(file) + } + return { labelCol: { span: 4 }, @@ -349,7 +352,9 @@ export default defineComponent({ ifalowupload, beforeVideoUpload, lan, - beforeUploadpic + beforeUploadpic, + video, + imgs }; }, }); diff --git a/src/views/mine/ReleaseWebcast.vue b/src/views/mine/ReleaseWebcast.vue index 8eef676..d59d7a7 100644 --- a/src/views/mine/ReleaseWebcast.vue +++ b/src/views/mine/ReleaseWebcast.vue @@ -14,7 +14,7 @@
{ @@ -490,11 +489,9 @@ export default defineComponent({ form.value.fileid = res.fileId; form.value.fileurl = res.video.url; - } } const ifallowpic = ref(false); async function uploadspic(file: AntUpload) { - if (ifallowpic.value) { const res = await uploadflie(file.file, (info: any) => { console.log(info); uploadpicprogress.value = info.percent.toFixed(2) * 100; @@ -504,7 +501,6 @@ export default defineComponent({ // picinfo.fileId=res.fileId // picinfo.url=res.video.url form.value.img = res.video.url; - } } getlivest().then((res) => { @@ -540,6 +536,12 @@ export default defineComponent({ }) } } + function video(file: any){ + return provenvideo(file) + } + function imgs(file: any){ + return provenimg(file) + } return { labelCol: { span: 4 }, @@ -574,7 +576,9 @@ export default defineComponent({ disabledDate, isbianji, onquxiao, - isquxiao + isquxiao, + video, + imgs }; }, });