上传文件
This commit is contained in:
parent
84d3e45292
commit
4b83d61df7
@ -59,16 +59,19 @@ export function getValue(key: string): any{
|
|||||||
* @param name 图片名字
|
* @param name 图片名字
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function provenimg(name: string): boolean{
|
export function provenimg(file: any): boolean | void{
|
||||||
const type = ['png', 'jpg'];
|
const type = ['png', 'jpg'];
|
||||||
const ntypearr = name.split('.');
|
const ntypearr = file.name.split('.');
|
||||||
const ntype = ntypearr[ntypearr.length - 1];
|
const ntype = ntypearr[ntypearr.length - 1];
|
||||||
|
console.log(ntype)
|
||||||
|
let istype = false
|
||||||
for(const i in type){
|
for(const i in type){
|
||||||
if(type[i] == ntype){
|
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 图片名字
|
* @param name 图片名字
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function provenvideo(name: string): boolean{
|
export function provenvideo(file: any): boolean{
|
||||||
const type = ['flv', 'mp4', 'wmv', 'mov', 'avi'];
|
const type = ['flv', 'mp4', 'wmv', 'mov', 'avi'];
|
||||||
const ntypearr = name.split('.');
|
const ntypearr = file.name.split('.');
|
||||||
const ntype = ntypearr[ntypearr.length - 1];
|
const ntype = ntypearr[ntypearr.length - 1];
|
||||||
for(const i in type){
|
for(const i in type){
|
||||||
if(type[i] == ntype){
|
if(type[i] == ntype){
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
class="avatar-uploader"
|
class="avatar-uploader"
|
||||||
:show-upload-list="false"
|
:show-upload-list="false"
|
||||||
:customRequest="uploadspic"
|
:customRequest="uploadspic"
|
||||||
|
:beforeUpload="imgs"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
>
|
>
|
||||||
<a-avatar :size="85" shape="circle" :src="userinfo.img">
|
<a-avatar :size="85" shape="circle" :src="userinfo.img">
|
||||||
@ -177,7 +178,7 @@
|
|||||||
<a-upload
|
<a-upload
|
||||||
list-type="picture"
|
list-type="picture"
|
||||||
:customRequest="uploads"
|
:customRequest="uploads"
|
||||||
:beforeUpload="beforeVideoUpload"
|
:beforeUpload="video"
|
||||||
>
|
>
|
||||||
<div class="upload-image">
|
<div class="upload-image">
|
||||||
<PlaySquareOutlined
|
<PlaySquareOutlined
|
||||||
@ -531,7 +532,7 @@ import {
|
|||||||
} from "@/api/index";
|
} from "@/api/index";
|
||||||
import { message } from "ant-design-vue";
|
import { message } from "ant-design-vue";
|
||||||
import { useI18n } from "@/utils/i18n";
|
import { useI18n } from "@/utils/i18n";
|
||||||
import { provenvideo } from '@/utils/common';
|
import { provenimg, provenvideo } from '@/utils/common';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Archives",
|
name: "Archives",
|
||||||
@ -977,15 +978,20 @@ export default defineComponent({
|
|||||||
setheadimg(res.video.url);
|
setheadimg(res.video.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeVideoUpload(file: any){
|
// function beforeVideoUpload(file: any){
|
||||||
console.log(file)
|
// console.log(file)
|
||||||
const type = provenvideo(file.name);
|
// const type = provenvideo(file.name);
|
||||||
if(!type){
|
// // if(!type){
|
||||||
message.error("文件类型错误,请重新选择")
|
// // message.error("文件类型错误,请重新选择")
|
||||||
|
// // }
|
||||||
|
// return type;
|
||||||
|
// }
|
||||||
|
function video(file: any){
|
||||||
|
return provenvideo(file)
|
||||||
}
|
}
|
||||||
return false;
|
function imgs(file: any){
|
||||||
|
return provenimg(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setname(){
|
function setname(){
|
||||||
setusername(formData.value.name).then(()=>{
|
setusername(formData.value.name).then(()=>{
|
||||||
showname.value = true;
|
showname.value = true;
|
||||||
@ -1040,8 +1046,9 @@ export default defineComponent({
|
|||||||
lan,
|
lan,
|
||||||
interestslist,
|
interestslist,
|
||||||
isdisabled,
|
isdisabled,
|
||||||
beforeVideoUpload,
|
setname,
|
||||||
setname
|
video,
|
||||||
|
imgs
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<a-upload
|
<a-upload
|
||||||
list-type="picture"
|
list-type="picture"
|
||||||
:customRequest="uploadspic"
|
:customRequest="uploadspic"
|
||||||
:before-upload="beforeUploadpic"
|
:beforeUpload="imgs"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="upload-image"
|
class="upload-image"
|
||||||
@ -59,7 +59,7 @@
|
|||||||
<a-upload
|
<a-upload
|
||||||
list-type="picture"
|
list-type="picture"
|
||||||
:customRequest="uploads"
|
:customRequest="uploads"
|
||||||
:before-upload="beforeUpload"
|
:beforeUpload="video"
|
||||||
>
|
>
|
||||||
<div class="upload-image" v-if="form.fileurl.length == 0">
|
<div class="upload-image" v-if="form.fileurl.length == 0">
|
||||||
<PlaySquareOutlined
|
<PlaySquareOutlined
|
||||||
@ -131,7 +131,7 @@
|
|||||||
import { defineComponent, onMounted, reactive, Ref, ref, toRaw } from "vue";
|
import { defineComponent, onMounted, reactive, Ref, ref, toRaw } from "vue";
|
||||||
import { PlaySquareOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
import { PlaySquareOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
||||||
import NavBottom from "@/components/NavBottom.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 { FromSend, ImgInfo, VideoInfo } from "@/types";
|
||||||
import { uploadflie } from "@/utils/vod";
|
import { uploadflie } from "@/utils/vod";
|
||||||
import { setvideo, videoadd, videodetail } from "@/api";
|
import { setvideo, videoadd, videodetail } from "@/api";
|
||||||
@ -227,16 +227,14 @@ export default defineComponent({
|
|||||||
file: File;
|
file: File;
|
||||||
}
|
}
|
||||||
async function uploadspic(file: AntUpload) {
|
async function uploadspic(file: AntUpload) {
|
||||||
if (ifalowupload.value) {
|
|
||||||
const res = await uploadflie(file.file, (info: any) => {
|
const res = await uploadflie(file.file, (info: any) => {
|
||||||
console.log(info);
|
console.log(info);
|
||||||
uploadpicprogress.value = info.percent.toFixed(2) * 100;
|
uploadpicprogress.value = info.percent.toFixed(2) * 100;
|
||||||
});
|
});
|
||||||
console.log(res);
|
console.log(res);
|
||||||
form.value.img = res.video.url;
|
form.value.img = res.video.url;
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeUploadpic(info?: any) {
|
function beforeUploadpic(info?: any) {
|
||||||
@ -256,7 +254,6 @@ export default defineComponent({
|
|||||||
const uploadprogress: Ref<number> = ref(0);
|
const uploadprogress: Ref<number> = ref(0);
|
||||||
const ifallowvideo = ref<boolean>(false);
|
const ifallowvideo = ref<boolean>(false);
|
||||||
async function uploads(file: AntUpload) {
|
async function uploads(file: AntUpload) {
|
||||||
if (ifallowvideo.value) {
|
|
||||||
console.log(file);
|
console.log(file);
|
||||||
videofile.value = file.file;
|
videofile.value = file.file;
|
||||||
videos.value[0].addEventListener("durationchange", () => {
|
videos.value[0].addEventListener("durationchange", () => {
|
||||||
@ -272,7 +269,6 @@ export default defineComponent({
|
|||||||
form.value.fileid = res.fileId;
|
form.value.fileid = res.fileId;
|
||||||
form.value.fileurl = res.video.url;
|
form.value.fileurl = res.video.url;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function beforeVideoUpload(info?: any) {
|
function beforeVideoUpload(info?: any) {
|
||||||
console.log(info);
|
console.log(info);
|
||||||
@ -326,6 +322,13 @@ export default defineComponent({
|
|||||||
ifallowvideo.value = true;
|
ifallowvideo.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function video(file: any){
|
||||||
|
return provenvideo(file)
|
||||||
|
}
|
||||||
|
function imgs(file: any){
|
||||||
|
return provenimg(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
labelCol: { span: 4 },
|
labelCol: { span: 4 },
|
||||||
@ -349,7 +352,9 @@ export default defineComponent({
|
|||||||
ifalowupload,
|
ifalowupload,
|
||||||
beforeVideoUpload,
|
beforeVideoUpload,
|
||||||
lan,
|
lan,
|
||||||
beforeUploadpic
|
beforeUploadpic,
|
||||||
|
video,
|
||||||
|
imgs
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<a-upload
|
<a-upload
|
||||||
list-type="picture"
|
list-type="picture"
|
||||||
:customRequest="uploadspic"
|
:customRequest="uploadspic"
|
||||||
:before-upload="beforeUploadpic"
|
:before-upload="imgs"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="upload-image"
|
class="upload-image"
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<a-upload
|
<a-upload
|
||||||
list-type="picture"
|
list-type="picture"
|
||||||
:customRequest="uploads"
|
:customRequest="uploads"
|
||||||
:before-upload="beforeUpload"
|
:before-upload="video"
|
||||||
>
|
>
|
||||||
<div class="upload-image" v-if="form.fileurl.length == 0">
|
<div class="upload-image" v-if="form.fileurl.length == 0">
|
||||||
<PlaySquareOutlined
|
<PlaySquareOutlined
|
||||||
@ -233,7 +233,7 @@ import { PlaySquareOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
|||||||
import { useForm } from "@ant-design-vue/use";
|
import { useForm } from "@ant-design-vue/use";
|
||||||
import NavBottom from "@/components/NavBottom.vue";
|
import NavBottom from "@/components/NavBottom.vue";
|
||||||
import RankList from "./RankList.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 { FromSend, ImgInfo } from "@/types/index";
|
||||||
import { uploadflie } from "@/utils/vod";
|
import { uploadflie } from "@/utils/vod";
|
||||||
import { cancellive, getlivest, liveadd, liveinfo, setlive } from "@/api";
|
import { cancellive, getlivest, liveadd, liveinfo, setlive } from "@/api";
|
||||||
@ -475,7 +475,6 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function uploads(file: AntUpload) {
|
async function uploads(file: AntUpload) {
|
||||||
if (ifallowupload.value) {
|
|
||||||
console.log(file);
|
console.log(file);
|
||||||
videofile.value = file.file;
|
videofile.value = file.file;
|
||||||
videos.value[0].addEventListener("durationchange", () => {
|
videos.value[0].addEventListener("durationchange", () => {
|
||||||
@ -491,10 +490,8 @@ export default defineComponent({
|
|||||||
form.value.fileid = res.fileId;
|
form.value.fileid = res.fileId;
|
||||||
form.value.fileurl = res.video.url;
|
form.value.fileurl = res.video.url;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const ifallowpic = ref<boolean>(false);
|
const ifallowpic = ref<boolean>(false);
|
||||||
async function uploadspic(file: AntUpload) {
|
async function uploadspic(file: AntUpload) {
|
||||||
if (ifallowpic.value) {
|
|
||||||
const res = await uploadflie(file.file, (info: any) => {
|
const res = await uploadflie(file.file, (info: any) => {
|
||||||
console.log(info);
|
console.log(info);
|
||||||
uploadpicprogress.value = info.percent.toFixed(2) * 100;
|
uploadpicprogress.value = info.percent.toFixed(2) * 100;
|
||||||
@ -505,7 +502,6 @@ export default defineComponent({
|
|||||||
// picinfo.url=res.video.url
|
// picinfo.url=res.video.url
|
||||||
form.value.img = res.video.url;
|
form.value.img = res.video.url;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getlivest().then((res) => {
|
getlivest().then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -540,6 +536,12 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function video(file: any){
|
||||||
|
return provenvideo(file)
|
||||||
|
}
|
||||||
|
function imgs(file: any){
|
||||||
|
return provenimg(file)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
labelCol: { span: 4 },
|
labelCol: { span: 4 },
|
||||||
@ -574,7 +576,9 @@ export default defineComponent({
|
|||||||
disabledDate,
|
disabledDate,
|
||||||
isbianji,
|
isbianji,
|
||||||
onquxiao,
|
onquxiao,
|
||||||
isquxiao
|
isquxiao,
|
||||||
|
video,
|
||||||
|
imgs
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user