Files
CloudFlare-ImgBed/js/445.ad8cef74.js
2024-08-26 19:29:36 +08:00

2 lines
17 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";(self["webpackChunksanyue_imghub"]=self["webpackChunksanyue_imghub"]||[]).push([[445],{4445:function(e,t,l){l.r(t),l.d(t,{default:function(){return Y}});var s=l(6768),a=l(4232);const i=e=>((0,s.Qi)("data-v-7d691d23"),e=e(),(0,s.jt)(),e),o={class:"upload-home"},n=i((()=>(0,s.Lk)("img",{id:"bg1",class:"background-image1",alt:"Background Image"},null,-1))),d=i((()=>(0,s.Lk)("img",{id:"bg2",class:"background-image2",alt:"Background Image"},null,-1))),r={class:"toolbar"},u={class:"header"},c={href:"https://github.com/MarSeventh/CloudFlare-ImgBed"},p=["src"],g={class:"main-title",href:"https://github.com/MarSeventh/CloudFlare-ImgBed",target:"_blank"},h={class:"dialog-action"};function m(e,t,l,i,m,f){const b=(0,s.g2)("Refresh"),k=(0,s.g2)("el-icon"),L=(0,s.g2)("el-button"),F=(0,s.g2)("el-tooltip"),y=(0,s.g2)("Connection"),U=(0,s.g2)("Tools"),C=(0,s.g2)("Close"),_=(0,s.g2)("UploadForm"),v=(0,s.g2)("Footer"),w=(0,s.g2)("el-radio"),R=(0,s.g2)("el-radio-group"),x=(0,s.g2)("el-dialog");return(0,s.uX)(),(0,s.CE)("div",o,[n,d,(0,s.Lk)("div",r,[(0,s.bF)(F,{content:"上传方式",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(L,{class:"toolbar-button",size:"large",type:"info",onClick:f.changeUploadMethod,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(k,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(b)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(F,{content:"链接格式",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(L,{class:"toolbar-button",size:"large",type:"success",onClick:f.openUrlDialog,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(k,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(y)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(F,{content:"管理页面",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(L,{class:"toolbar-button",size:"large",type:"primary",onClick:f.handleManage,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(k,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(U)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(F,{content:"退出登录",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(L,{class:"toolbar-button",size:"large",type:"danger",onClick:f.handleLogout,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(k,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(C)])),_:1})])),_:1},8,["onClick"])])),_:1})]),(0,s.Lk)("div",u,[(0,s.Lk)("a",c,[(0,s.Lk)("img",{class:"logo",alt:"Sanyue logo",src:f.logoUrl},null,8,p)]),(0,s.Lk)("h1",null,[(0,s.Lk)("a",g,(0,a.v_)(f.ownerName),1),(0,s.eW)(" ImgHub")])]),(0,s.bF)(_,{selectedUrlForm:m.selectedUrlForm,uploadMethod:m.uploadMethod,class:"upload"},null,8,["selectedUrlForm","uploadMethod"]),(0,s.bF)(v),(0,s.bF)(x,{title:"选择复制链接格式",modelValue:m.showUrlDialog,"onUpdate:modelValue":t[2]||(t[2]=e=>m.showUrlDialog=e),width:"40%","show-close":!1},{default:(0,s.k6)((()=>[(0,s.bF)(R,{modelValue:m.selectedUrlForm,"onUpdate:modelValue":t[0]||(t[0]=e=>m.selectedUrlForm=e)},{default:(0,s.k6)((()=>[(0,s.bF)(w,{value:"url"},{default:(0,s.k6)((()=>[(0,s.eW)("原始链接")])),_:1}),(0,s.bF)(w,{value:"md"},{default:(0,s.k6)((()=>[(0,s.eW)("MarkDown")])),_:1}),(0,s.bF)(w,{value:"html"},{default:(0,s.k6)((()=>[(0,s.eW)("HTML")])),_:1}),(0,s.bF)(w,{value:"ubb"},{default:(0,s.k6)((()=>[(0,s.eW)("BBCode")])),_:1})])),_:1},8,["modelValue"]),(0,s.Lk)("div",h,[(0,s.bF)(L,{type:"primary",onClick:t[1]||(t[1]=e=>m.showUrlDialog=!1)},{default:(0,s.k6)((()=>[(0,s.eW)("确定")])),_:1})])])),_:1},8,["modelValue"])])}l(4114);const f=e=>((0,s.Qi)("data-v-0100786c"),e=e(),(0,s.jt)(),e),b={key:0,class:"el-upload__text"},k=f((()=>(0,s.Lk)("em",null,"点击上传",-1))),L={key:1,class:"el-upload__text"},F=f((()=>(0,s.Lk)("em",null,"粘贴",-1))),y=f((()=>(0,s.Lk)("div",{class:"el-upload__tip"},"支持多文件上传支持图片和视频文件大小不超过5MB",-1))),U={class:"upload-list-dashboard"},C={class:"upload-list-dashboard-action"},_=["href"],v=["src","onError"],w={class:"upload-list-item-content"},R={key:0,class:"upload-list-item-url"},x={class:"upload-list-item-url-row"},W={class:"upload-list-item-url-row"},I={key:1,class:"upload-list-item-progress"},P={class:"upload-list-item-action"};function M(e,t,l,i,o,n){const d=(0,s.g2)("CameraFilled"),r=(0,s.g2)("CopyDocument"),u=(0,s.g2)("el-icon"),c=(0,s.g2)("el-upload"),p=(0,s.g2)("List"),g=(0,s.g2)("Checked"),h=(0,s.g2)("Failed"),m=(0,s.g2)("el-text"),f=(0,s.g2)("Grid"),M=(0,s.g2)("el-button"),$=(0,s.g2)("el-tooltip"),E=(0,s.g2)("CircleClose"),B=(0,s.g2)("el-button-group"),S=(0,s.g2)("el-input"),V=(0,s.g2)("el-progress"),T=(0,s.g2)("Link"),D=(0,s.g2)("Delete"),A=(0,s.g2)("el-scrollbar"),z=(0,s.g2)("el-card");return(0,s.uX)(),(0,s.CE)("div",{class:"upload-form",onPaste:t[0]||(t[0]=(...e)=>n.handlePaste&&n.handlePaste(...e))},[(0,s.bF)(c,{class:(0,a.C4)(["upload-card",{"is-uploading":o.uploading,"upload-card-busy":o.fileList.length,"paste-mode":"paste"===l.uploadMethod}]),drag:"",multiple:"","http-request":n.uploadFile,onSuccess:n.handleSuccess,"on-error":n.handleError,"before-upload":n.beforeUpload,"on-progress":n.handleProgress,"file-list":o.fileList,"show-file-list":!1,accept:"image/*, video/*"},{tip:(0,s.k6)((()=>[y])),default:(0,s.k6)((()=>[(0,s.bF)(u,{class:"el-icon--upload"},{default:(0,s.k6)((()=>["drag"===l.uploadMethod?((0,s.uX)(),(0,s.Wv)(d,{key:0,color:"blanchedalmond"})):((0,s.uX)(),(0,s.Wv)(r,{key:1,color:"blanchedalmond"}))])),_:1}),"drag"===l.uploadMethod?((0,s.uX)(),(0,s.CE)("div",b,[(0,s.eW)("拖拽 或 "),k])):((0,s.uX)(),(0,s.CE)("div",L,[(0,s.eW)("复制 "),F,(0,s.eW)(" 上传")]))])),_:1},8,["class","http-request","onSuccess","on-error","before-upload","on-progress","file-list"]),(0,s.bF)(z,{class:(0,a.C4)(["upload-list-card",{"upload-list-busy":o.fileList.length}])},{default:(0,s.k6)((()=>[(0,s.Lk)("div",{class:(0,a.C4)(["upload-list-container",{"upload-list-busy":o.fileList.length}])},[(0,s.bF)(A,null,{default:(0,s.k6)((()=>[(0,s.Lk)("div",U,[(0,s.bF)(m,{class:"upload-list-dashboard-title"},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(p)])),_:1}),(0,s.eW)((0,a.v_)(n.uploadingCount+n.waitingCount)+" ",1),(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(g)])),_:1}),(0,s.eW)((0,a.v_)(n.uploadSuccessCount)+" ",1),(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(h)])),_:1}),(0,s.eW)((0,a.v_)(n.uploadErrorCount),1)])),_:1}),(0,s.Lk)("div",C,[(0,s.bF)(B,null,{default:(0,s.k6)((()=>[(0,s.bF)($,{content:"整体复制",placement:"top"},{default:(0,s.k6)((()=>[(0,s.bF)(M,{type:"primary",round:"",onClick:n.copyAll,alt:"整体复制"},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(f)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)($,{content:"清空列表",placement:"top"},{default:(0,s.k6)((()=>[(0,s.bF)(M,{type:"primary",round:"",onClick:n.clearFileList},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(E)])),_:1})])),_:1},8,["onClick"])])),_:1})])),_:1})])]),((0,s.uX)(!0),(0,s.CE)(s.FK,null,(0,s.pI)(o.fileList,(e=>((0,s.uX)(),(0,s.CE)("div",{class:"upload-list-item",key:e.name,span:8},[(0,s.Lk)("a",{href:e.url,target:"_blank"},[(0,s.Lk)("img",{style:{width:"10vw","border-radius":"12px"},src:e.url,onError:t=>e.url="https://imgbed.sanyue.site/file/b6a4a65b4edba4377492e.png"},null,40,v)],8,_),(0,s.Lk)("div",w,[(0,s.bF)(m,{class:"upload-list-item-name",truncated:""},{default:(0,s.k6)((()=>[(0,s.eW)((0,a.v_)(e.name),1)])),_:2},1024),"done"===e.status?((0,s.uX)(),(0,s.CE)("div",R,[(0,s.Lk)("div",x,[(0,s.bF)(S,{modelValue:e.finalURL,"onUpdate:modelValue":t=>e.finalURL=t,size:"small",readonly:"",onFocus:n.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("URL:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"]),(0,s.bF)(S,{modelValue:e.mdURL,"onUpdate:modelValue":t=>e.mdURL=t,size:"small",readonly:"",onFocus:n.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("MarkDown:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"])]),(0,s.Lk)("div",W,[(0,s.bF)(S,{modelValue:e.htmlURL,"onUpdate:modelValue":t=>e.htmlURL=t,size:"small",readonly:"",onFocus:n.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("HTML:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"]),(0,s.bF)(S,{modelValue:e.ubbURL,"onUpdate:modelValue":t=>e.ubbURL=t,size:"small",readonly:"",onFocus:n.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("BBCode:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"])])])):((0,s.uX)(),(0,s.CE)("div",I,[(0,s.bF)(V,{percentage:e.progreess,status:e.status,"show-text":!1},null,8,["percentage","status"])]))]),(0,s.Lk)("div",P,[(0,s.bF)(M,{type:"primary",circle:"",class:"upload-list-item-action-button",onClick:t=>n.handleCopy(e)},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(T)])),_:1})])),_:2},1032,["onClick"]),(0,s.bF)(M,{type:"danger",circle:"",class:"upload-list-item-action-button",onClick:t=>n.handleRemove(e)},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(D)])),_:1})])),_:2},1032,["onClick"])])])))),128))])),_:1})],2)])),_:1},8,["class"])],32)}l(4603),l(7566),l(8721);var $=l(4373),E=l(4570),B=l.n(E),S={name:"UploadForm",props:{selectedUrlForm:{type:String,default:"url",required:!1},uploadMethod:{type:String,default:"drag",required:!1}},data(){return{fileList:[],uploading:!1,maxUploading:10,waitingList:[]}},computed:{uploadSuccessCount(){return this.fileList.filter((e=>"done"===e.status||"success"===e.status)).length},uploadErrorCount(){return this.fileList.filter((e=>"exception"===e.status)).length},uploadingCount(){return this.fileList.filter((e=>"uploading"===e.status)).length},waitingCount(){return this.waitingList.length}},methods:{uploadFile(e){if(this.uploadingCount>this.maxUploading)return this.waitingList.push(e),void(this.fileList.find((t=>t.uid===e.file.uid)).status="waiting");this.fileList.find((t=>t.uid===e.file.uid)).status="uploading";const t=new FormData;t.append("file",e.file),(0,$.A)({url:"/upload?authCode="+B().get("authCode"),method:"post",data:t,onUploadProgress:t=>{const l=Math.round(t.loaded/t.total*100);e.onProgress({percent:l,file:e.file})}}).then((t=>{e.onSuccess(t,e.file)})).catch((t=>{t.response&&401===t.response.status?(this.waitingList=[],this.fileList=[],this.$message.error("认证状态错误!"),this.$router.push("/login")):e.onError(t,e.file)})).finally((()=>{this.uploadingCount+this.waitingCount===0&&(this.uploading=!1)}))},handleRemove(e){this.fileList=this.fileList.filter((t=>t.uid!==e.uid)),this.$message({type:"info",message:e.name+"已删除"})},handleSuccess(e,t){try{const l=`${window.location.protocol}//${window.location.host}`;this.fileList.find((e=>e.uid===t.uid)).url=l+e.data[0].src,this.fileList.find((e=>e.uid===t.uid)).finalURL=l+e.data[0].src,this.fileList.find((e=>e.uid===t.uid)).mdURL=`![${t.name}](${l+e.data[0].src})`,this.fileList.find((e=>e.uid===t.uid)).htmlURL=`<img src="${l+e.data[0].src}" alt="${t.name}" width=100% />`,this.fileList.find((e=>e.uid===t.uid)).ubbURL=`[img]${l+e.data[0].src}[/img]`,this.fileList.find((e=>e.uid===t.uid)).progreess=100,this.fileList.find((e=>e.uid===t.uid)).status="success",this.$message({type:"success",message:t.name+"上传成功"}),setTimeout((()=>{this.fileList.find((e=>e.uid===t.uid)).status="done"}),1e3)}catch(l){this.$message.error(t.name+"上传失败"),this.fileList.find((e=>e.uid===t.uid)).status="exception"}finally{if(this.uploadingCount+this.waitingCount===0&&(this.uploading=!1),this.waitingList.length){const e=this.waitingList.shift();this.uploadFile(e)}}},handleError(e,t){if(this.$message.error(t.name+"上传失败"),this.fileList.find((e=>e.uid===t.uid)).status="exception",this.waitingList.length){const e=this.waitingList.shift();this.uploadFile(e)}this.uploadingCount+this.waitingCount===0&&(this.uploading=!1)},handleCopy(e){const t=this.fileList.find((t=>t.uid===e.uid)).status;"done"===t||"success"===t?("url"===this.selectedUrlForm?navigator.clipboard.writeText(e.finalURL):"md"===this.selectedUrlForm?navigator.clipboard.writeText(e.mdURL):"html"===this.selectedUrlForm?navigator.clipboard.writeText(e.htmlURL):"ubb"===this.selectedUrlForm?navigator.clipboard.writeText(e.ubbURL):navigator.clipboard.writeText(e.finalURL),this.$message({type:"success",message:"复制成功"})):this.$message({type:"warning",message:"文件未上传成功,无法复制链接"})},beforeUpload(e){const t=e.size/1024/1024<5;if(t){this.uploading=!0;const t=URL.createObjectURL(e);return this.fileList.push({uid:e.uid,name:e.name,url:t,finalURL:"",mdURL:"",htmlURL:"",ubbURL:"",status:"uploading",progreess:0}),!0}return this.$message.error("上传文件大小不能超过 5MB!"),!1},handleProgress(e){this.fileList.find((t=>t.uid===e.file.uid)).progreess=e.percent},copyAll(){if("url"===this.selectedUrlForm){const e=this.fileList.map((e=>{if("done"===e.status||"success"===e.status)return e.finalURL})).join("\n");navigator.clipboard.writeText(e)}else if("md"===this.selectedUrlForm){const e=this.fileList.map((e=>{if("done"===e.status||"success"===e.status)return e.mdURL})).join("\n");navigator.clipboard.writeText(e)}else if("html"===this.selectedUrlForm){const e=this.fileList.map((e=>{if("done"===e.status||"success"===e.status)return e.htmlURL})).join("\n");navigator.clipboard.writeText(e)}else if("ubb"===this.selectedUrlForm){const e=this.fileList.map((e=>{if("done"===e.status||"success"===e.status)return e.ubbURL})).join("\n");navigator.clipboard.writeText(e)}else{const e=this.fileList.map((e=>{if("done"===e.status||"success"===e.status)return e.finalURL})).join("\n");navigator.clipboard.writeText(e)}this.$message({type:"success",message:"整体复制成功"})},clearFileList(){this.fileList=[],this.$message({type:"info",message:"列表已清空"})},handlePaste(e){if("paste"!==this.uploadMethod)return;const t=e.clipboardData.items;for(let l=0;l<t.length;l++)if("file"===t[l].kind){const e=t[l].getAsFile();e.type.includes("image")||e.type.includes("video")?(e.uid=Date.now()+l,e.file=e,this.beforeUpload(e)&&this.uploadFile({file:e,onProgress:e=>this.handleProgress(e),onSuccess:(e,t)=>this.handleSuccess(e,t),onError:(e,t)=>this.handleError(e,t)})):this.$message({type:"warning",message:"粘贴板中的文件不是图片或视频"})}else"string"===t[l].kind&&t[l].getAsString((e=>{const t=/^(https?:\/\/[^\s$.?#].[^\s]*)$/;t.test(e)&&fetch("/api/fetchRes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})}).then((e=>{const t=e.headers.get("content-type");if(200==e.status&&(t.includes("image")||t.includes("video")))return e.blob();throw new Error("URL地址的内容不是图片或视频")})).then((t=>{const s=e.split("/").pop(),a=new File([t],s,{type:t.type});a.uid=Date.now()+l,a.file=a,this.beforeUpload(a)&&this.uploadFile({file:a,onProgress:e=>this.handleProgress(e),onSuccess:(e,t)=>this.handleSuccess(e,t),onError:(e,t)=>this.handleError(e,t)})})).catch((e=>{this.$message({type:"warning",message:"粘贴板中的URL地址的内容不是图片或视频"})}))}))},selectAllText(e){e.target.select()}}},V=l(1241);const T=(0,V.A)(S,[["render",M],["__scopeId","data-v-0100786c"]]);var D=T;const A=e=>((0,s.Qi)("data-v-7c801e22"),e=e(),(0,s.jt)(),e),z={class:"page-footer"},j=A((()=>(0,s.Lk)("p",null,[(0,s.eW)("© 2024 Designed by "),(0,s.Lk)("a",{class:"footer-name",href:"https://github.com/MarSeventh",target:"_blank"},"SanyueQi"),(0,s.eW)(" for You!")],-1))),X=[j];function q(e,t){return(0,s.uX)(),(0,s.CE)("div",z,X)}const H={},N=(0,V.A)(H,[["render",q],["__scopeId","data-v-7c801e22"]]);var Q=N,K=l(144),O=l(782),G={name:"UploadHome",data(){return{selectedUrlForm:(0,K.KR)("url"),uploadMethod:(0,K.KR)("drag"),showUrlDialog:!1,bingWallPaperIndex:0,customWallPaperIndex:0}},computed:{...(0,O.L8)(["userConfig","bingWallPapers"]),ownerName(){return this.userConfig?.ownerName||"Sanyue"},logoUrl(){return this.userConfig?.logoUrl||l(3153)}},mounted(){const e=document.getElementById("bg1"),t=document.getElementById("bg2");"bing"===this.userConfig?.uploadBkImg?this.$store.dispatch("fetchBingWallPapers").then((()=>{e.src=this.bingWallPapers[this.bingWallPaperIndex]?.url,e.onload=()=>{e.style.opacity=1},setInterval((()=>{let l=0!=e.style.opacity?e:t,s=0!=e.style.opacity?t:e;l.style.opacity=0,this.bingWallPaperIndex=(this.bingWallPaperIndex+1)%this.bingWallPapers.length,s.src=this.bingWallPapers[this.bingWallPaperIndex]?.url,s.onload=()=>{s.style.opacity=1}}),3e3)})):this.userConfig?.uploadBkImg instanceof Array&&this.userConfig?.uploadBkImg?.length>1?(e.src=this.userConfig.uploadBkImg[this.customWallPaperIndex],e.onload=()=>{e.style.opacity=1},setInterval((()=>{let l=0!=e.style.opacity?e:t,s=0!=e.style.opacity?t:e;l.style.opacity=0,this.customWallPaperIndex=(this.customWallPaperIndex+1)%this.userConfig.uploadBkImg.length,s.src=this.userConfig.uploadBkImg[this.customWallPaperIndex],s.onload=()=>{s.style.opacity=1}}),3e3)):this.userConfig?.uploadBkImg instanceof Array&&1==this.userConfig?.uploadBkImg.length?(e.src=this.userConfig.uploadBkImg[0],e.onload=()=>{e.style.opacity=1}):(e.src="https://imgbed.sanyue.site/file/0dbd5add3605a0b2e8994.jpg",e.onload=()=>{e.style.opacity=1})},components:{UploadForm:D,Footer:Q},methods:{handleManage(){window.location.href="/admin"},openUrlDialog(){this.showUrlDialog=!0},changeUploadMethod(){this.uploadMethod="drag"===this.uploadMethod?"paste":"drag"},handleLogout(){B().remove("authCode"),this.$router.push("/login"),this.$message.success("已退出登录~")}}};const J=(0,V.A)(G,[["render",m],["__scopeId","data-v-7d691d23"]]);var Y=J},3153:function(e,t,l){e.exports=l.p+"img/logo.08a1b5de.png"}}]);
//# sourceMappingURL=445.ad8cef74.js.map