上传文件
This commit is contained in:
parent
84d3e45292
commit
4b83d61df7
@ -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){
|
||||
|
@ -9,6 +9,7 @@
|
||||
class="avatar-uploader"
|
||||
:show-upload-list="false"
|
||||
:customRequest="uploadspic"
|
||||
:beforeUpload="imgs"
|
||||
@change="handleChange"
|
||||
>
|
||||
<a-avatar :size="85" shape="circle" :src="userinfo.img">
|
||||
@ -177,7 +178,7 @@
|
||||
<a-upload
|
||||
list-type="picture"
|
||||
:customRequest="uploads"
|
||||
:beforeUpload="beforeVideoUpload"
|
||||
:beforeUpload="video"
|
||||
>
|
||||
<div class="upload-image">
|
||||
<PlaySquareOutlined
|
||||
@ -531,7 +532,7 @@ import {
|
||||
} from "@/api/index";
|
||||
import { message } from "ant-design-vue";
|
||||
import { useI18n } from "@/utils/i18n";
|
||||
import { provenvideo } from '@/utils/common';
|
||||
import { provenimg, provenvideo } from '@/utils/common';
|
||||
|
||||
export default defineComponent({
|
||||
name: "Archives",
|
||||
@ -977,15 +978,20 @@ export default defineComponent({
|
||||
setheadimg(res.video.url);
|
||||
}
|
||||
|
||||
function beforeVideoUpload(file: any){
|
||||
console.log(file)
|
||||
const type = provenvideo(file.name);
|
||||
if(!type){
|
||||
message.error("文件类型错误,请重新选择")
|
||||
}
|
||||
return false;
|
||||
// function beforeVideoUpload(file: any){
|
||||
// console.log(file)
|
||||
// const type = provenvideo(file.name);
|
||||
// // if(!type){
|
||||
// // message.error("文件类型错误,请重新选择")
|
||||
// // }
|
||||
// return type;
|
||||
// }
|
||||
function video(file: any){
|
||||
return provenvideo(file)
|
||||
}
|
||||
function imgs(file: any){
|
||||
return provenimg(file)
|
||||
}
|
||||
|
||||
function setname(){
|
||||
setusername(formData.value.name).then(()=>{
|
||||
showname.value = true;
|
||||
@ -1040,8 +1046,9 @@ export default defineComponent({
|
||||
lan,
|
||||
interestslist,
|
||||
isdisabled,
|
||||
beforeVideoUpload,
|
||||
setname
|
||||
setname,
|
||||
video,
|
||||
imgs
|
||||
};
|
||||
},
|
||||
});
|
||||
|
@ -14,7 +14,7 @@
|
||||
<a-upload
|
||||
list-type="picture"
|
||||
:customRequest="uploadspic"
|
||||
:before-upload="beforeUploadpic"
|
||||
:beforeUpload="imgs"
|
||||
>
|
||||
<div
|
||||
class="upload-image"
|
||||
@ -59,7 +59,7 @@
|
||||
<a-upload
|
||||
list-type="picture"
|
||||
:customRequest="uploads"
|
||||
:before-upload="beforeUpload"
|
||||
:beforeUpload="video"
|
||||
>
|
||||
<div class="upload-image" v-if="form.fileurl.length == 0">
|
||||
<PlaySquareOutlined
|
||||
@ -131,7 +131,7 @@
|
||||
import { defineComponent, onMounted, reactive, Ref, ref, toRaw } from "vue";
|
||||
import { PlaySquareOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
||||
import NavBottom from "@/components/NavBottom.vue";
|
||||
import { previewCover, provenimg } from "@/utils/common";
|
||||
import { previewCover, provenimg, provenvideo } from "@/utils/common";
|
||||
import { FromSend, ImgInfo, VideoInfo } from "@/types";
|
||||
import { uploadflie } from "@/utils/vod";
|
||||
import { setvideo, videoadd, videodetail } from "@/api";
|
||||
@ -227,16 +227,14 @@ export default defineComponent({
|
||||
file: File;
|
||||
}
|
||||
async function uploadspic(file: AntUpload) {
|
||||
if (ifalowupload.value) {
|
||||
|
||||
const res = await uploadflie(file.file, (info: any) => {
|
||||
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<number> = ref(0);
|
||||
const ifallowvideo = ref<boolean>(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
|
||||
};
|
||||
},
|
||||
});
|
||||
|
@ -14,7 +14,7 @@
|
||||
<a-upload
|
||||
list-type="picture"
|
||||
:customRequest="uploadspic"
|
||||
:before-upload="beforeUploadpic"
|
||||
:before-upload="imgs"
|
||||
>
|
||||
<div
|
||||
class="upload-image"
|
||||
@ -61,7 +61,7 @@
|
||||
<a-upload
|
||||
list-type="picture"
|
||||
:customRequest="uploads"
|
||||
:before-upload="beforeUpload"
|
||||
:before-upload="video"
|
||||
>
|
||||
<div class="upload-image" v-if="form.fileurl.length == 0">
|
||||
<PlaySquareOutlined
|
||||
@ -233,7 +233,7 @@ import { PlaySquareOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
||||
import { useForm } from "@ant-design-vue/use";
|
||||
import NavBottom from "@/components/NavBottom.vue";
|
||||
import RankList from "./RankList.vue";
|
||||
import { previewCover } from "@/utils/common";
|
||||
import { previewCover, provenimg, provenvideo } from "@/utils/common";
|
||||
import { FromSend, ImgInfo } from "@/types/index";
|
||||
import { uploadflie } from "@/utils/vod";
|
||||
import { cancellive, getlivest, liveadd, liveinfo, setlive } from "@/api";
|
||||
@ -475,7 +475,6 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
async function uploads(file: AntUpload) {
|
||||
if (ifallowupload.value) {
|
||||
console.log(file);
|
||||
videofile.value = file.file;
|
||||
videos.value[0].addEventListener("durationchange", () => {
|
||||
@ -490,11 +489,9 @@ export default defineComponent({
|
||||
|
||||
form.value.fileid = res.fileId;
|
||||
form.value.fileurl = res.video.url;
|
||||
}
|
||||
}
|
||||
const ifallowpic = ref<boolean>(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
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user