forked from MarSeventh/CloudFlare-ImgBed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
329.5060c3a2.js
2 lines (2 loc) · 15.4 KB
/
329.5060c3a2.js
1
2
"use strict";(self["webpackChunksanyue_imghub"]=self["webpackChunksanyue_imghub"]||[]).push([[329],{9969:function(e,t,l){l.r(t),l.d(t,{default:function(){return K}});var s=l(6768),i=l.p+"img/logo.08a1b5de.png";const a=e=>((0,s.Qi)("data-v-2e0cf1bd"),e=e(),(0,s.jt)(),e),o={class:"upload-home"},n={class:"toolbar"},d=a((()=>(0,s.Lk)("div",{class:"header"},[(0,s.Lk)("a",{href:"https://github.com/MarSeventh/CloudFlare-ImgBed"},[(0,s.Lk)("img",{class:"logo",alt:"Sanyue logo",src:i})]),(0,s.Lk)("h1",null,[(0,s.Lk)("a",{class:"main-title",href:"https://github.com/MarSeventh/CloudFlare-ImgBed",target:"_blank"},"Sanyue"),(0,s.eW)(" ImgHub")])],-1))),u={class:"dialog-action"};function r(e,t,l,i,a,r){const c=(0,s.g2)("Refresh"),p=(0,s.g2)("el-icon"),h=(0,s.g2)("el-button"),g=(0,s.g2)("el-tooltip"),f=(0,s.g2)("Connection"),m=(0,s.g2)("Tools"),b=(0,s.g2)("Close"),k=(0,s.g2)("UploadForm"),F=(0,s.g2)("Footer"),L=(0,s.g2)("el-radio"),U=(0,s.g2)("el-radio-group"),_=(0,s.g2)("el-dialog");return(0,s.uX)(),(0,s.CE)("div",o,[(0,s.Lk)("div",n,[(0,s.bF)(g,{content:"上传方式",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(h,{class:"toolbar-button",size:"large",type:"info",onClick:r.changeUploadMethod,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(p,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(c)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(g,{content:"链接格式",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(h,{class:"toolbar-button",size:"large",type:"success",onClick:r.openUrlDialog,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(p,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(f)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(g,{content:"管理页面",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(h,{class:"toolbar-button",size:"large",type:"primary",onClick:r.handleManage,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(p,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(m)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(g,{content:"退出登录",placement:"left"},{default:(0,s.k6)((()=>[(0,s.bF)(h,{class:"toolbar-button",size:"large",type:"danger",onClick:r.handleLogout,circle:""},{default:(0,s.k6)((()=>[(0,s.bF)(p,{size:"large"},{default:(0,s.k6)((()=>[(0,s.bF)(b)])),_:1})])),_:1},8,["onClick"])])),_:1})]),d,(0,s.bF)(k,{selectedUrlForm:a.selectedUrlForm,uploadMethod:a.uploadMethod,class:"upload"},null,8,["selectedUrlForm","uploadMethod"]),(0,s.bF)(F),(0,s.bF)(_,{title:"选择复制链接格式",modelValue:a.showUrlDialog,"onUpdate:modelValue":t[2]||(t[2]=e=>a.showUrlDialog=e),width:"40%","show-close":!1},{default:(0,s.k6)((()=>[(0,s.bF)(U,{modelValue:a.selectedUrlForm,"onUpdate:modelValue":t[0]||(t[0]=e=>a.selectedUrlForm=e)},{default:(0,s.k6)((()=>[(0,s.bF)(L,{value:"url"},{default:(0,s.k6)((()=>[(0,s.eW)("原始链接")])),_:1}),(0,s.bF)(L,{value:"md"},{default:(0,s.k6)((()=>[(0,s.eW)("MarkDown")])),_:1}),(0,s.bF)(L,{value:"html"},{default:(0,s.k6)((()=>[(0,s.eW)("HTML")])),_:1}),(0,s.bF)(L,{value:"ubb"},{default:(0,s.k6)((()=>[(0,s.eW)("BBCode")])),_:1})])),_:1},8,["modelValue"]),(0,s.Lk)("div",u,[(0,s.bF)(h,{type:"primary",onClick:t[1]||(t[1]=e=>a.showUrlDialog=!1)},{default:(0,s.k6)((()=>[(0,s.eW)("确定")])),_:1})])])),_:1},8,["modelValue"])])}l(4114);var c=l(4232);const p=e=>((0,s.Qi)("data-v-3d98df6c"),e=e(),(0,s.jt)(),e),h={key:0,class:"el-upload__text"},g=p((()=>(0,s.Lk)("em",null,"点击上传",-1))),f={key:1,class:"el-upload__text"},m=p((()=>(0,s.Lk)("em",null,"粘贴",-1))),b=p((()=>(0,s.Lk)("div",{class:"el-upload__tip"},"支持多文件上传,支持图片和视频,文件大小不超过5MB",-1))),k={class:"upload-list-dashboard"},F={class:"upload-list-dashboard-action"},L=["href"],U=["src","onError"],_={class:"upload-list-item-content"},C={key:0,class:"upload-list-item-url"},v={class:"upload-list-item-url-row"},y={class:"upload-list-item-url-row"},w={key:1,class:"upload-list-item-progress"},R={class:"upload-list-item-action"};function x(e,t,l,i,a,o){const n=(0,s.g2)("CameraFilled"),d=(0,s.g2)("CopyDocument"),u=(0,s.g2)("el-icon"),r=(0,s.g2)("el-upload"),p=(0,s.g2)("List"),x=(0,s.g2)("Checked"),M=(0,s.g2)("Failed"),$=(0,s.g2)("el-text"),S=(0,s.g2)("Grid"),V=(0,s.g2)("el-button"),E=(0,s.g2)("el-tooltip"),T=(0,s.g2)("CircleClose"),W=(0,s.g2)("el-button-group"),D=(0,s.g2)("el-input"),z=(0,s.g2)("el-progress"),A=(0,s.g2)("Link"),P=(0,s.g2)("Delete"),X=(0,s.g2)("el-scrollbar"),j=(0,s.g2)("el-card");return(0,s.uX)(),(0,s.CE)("div",{class:"upload-form",onPaste:t[0]||(t[0]=(...e)=>o.handlePaste&&o.handlePaste(...e))},[(0,s.bF)(r,{class:(0,c.C4)(["upload-card",{"is-uploading":a.uploading,"upload-card-busy":a.fileList.length,"paste-mode":"paste"===l.uploadMethod}]),drag:"",multiple:"","http-request":o.uploadFile,onSuccess:o.handleSuccess,"on-error":o.handleError,"before-upload":o.beforeUpload,"on-progress":o.handleProgress,"file-list":a.fileList,"show-file-list":!1,accept:"image/*, video/*"},{tip:(0,s.k6)((()=>[b])),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)(n,{key:0,color:"blanchedalmond"})):((0,s.uX)(),(0,s.Wv)(d,{key:1,color:"blanchedalmond"}))])),_:1}),"drag"===l.uploadMethod?((0,s.uX)(),(0,s.CE)("div",h,[(0,s.eW)("拖拽 或 "),g])):((0,s.uX)(),(0,s.CE)("div",f,[(0,s.eW)("复制 "),m,(0,s.eW)(" 上传")]))])),_:1},8,["class","http-request","onSuccess","on-error","before-upload","on-progress","file-list"]),(0,s.bF)(j,{class:(0,c.C4)(["upload-list-card",{"upload-list-busy":a.fileList.length}])},{default:(0,s.k6)((()=>[(0,s.Lk)("div",{class:(0,c.C4)(["upload-list-container",{"upload-list-busy":a.fileList.length}])},[(0,s.bF)(X,null,{default:(0,s.k6)((()=>[(0,s.Lk)("div",k,[(0,s.bF)($,{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,c.v_)(o.uploadingCount+o.waitingCount)+" ",1),(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(x)])),_:1}),(0,s.eW)((0,c.v_)(o.uploadSuccessCount)+" ",1),(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(M)])),_:1}),(0,s.eW)((0,c.v_)(o.uploadErrorCount),1)])),_:1}),(0,s.Lk)("div",F,[(0,s.bF)(W,null,{default:(0,s.k6)((()=>[(0,s.bF)(E,{content:"整体复制",placement:"top"},{default:(0,s.k6)((()=>[(0,s.bF)(V,{type:"primary",round:"",onClick:o.copyAll,alt:"整体复制"},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(S)])),_:1})])),_:1},8,["onClick"])])),_:1}),(0,s.bF)(E,{content:"清空列表",placement:"top"},{default:(0,s.k6)((()=>[(0,s.bF)(V,{type:"primary",round:"",onClick:o.clearFileList},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(T)])),_:1})])),_:1},8,["onClick"])])),_:1})])),_:1})])]),((0,s.uX)(!0),(0,s.CE)(s.FK,null,(0,s.pI)(a.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,U)],8,L),(0,s.Lk)("div",_,[(0,s.bF)($,{class:"upload-list-item-name",truncated:""},{default:(0,s.k6)((()=>[(0,s.eW)((0,c.v_)(e.name),1)])),_:2},1024),"done"===e.status?((0,s.uX)(),(0,s.CE)("div",C,[(0,s.Lk)("div",v,[(0,s.bF)(D,{modelValue:e.finalURL,"onUpdate:modelValue":t=>e.finalURL=t,size:"small",readonly:"",onFocus:o.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("URL:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"]),(0,s.bF)(D,{modelValue:e.mdURL,"onUpdate:modelValue":t=>e.mdURL=t,size:"small",readonly:"",onFocus:o.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("MarkDown:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"])]),(0,s.Lk)("div",y,[(0,s.bF)(D,{modelValue:e.htmlURL,"onUpdate:modelValue":t=>e.htmlURL=t,size:"small",readonly:"",onFocus:o.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("HTML:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"]),(0,s.bF)(D,{modelValue:e.ubbURL,"onUpdate:modelValue":t=>e.ubbURL=t,size:"small",readonly:"",onFocus:o.selectAllText},{prepend:(0,s.k6)((()=>[(0,s.eW)("BBCode:")])),_:2},1032,["modelValue","onUpdate:modelValue","onFocus"])])])):((0,s.uX)(),(0,s.CE)("div",w,[(0,s.bF)(z,{percentage:e.progreess,status:e.status,"show-text":!1},null,8,["percentage","status"])]))]),(0,s.Lk)("div",R,[(0,s.bF)(V,{type:"primary",circle:"",class:"upload-list-item-action-button",onClick:t=>o.handleCopy(e)},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(A)])),_:1})])),_:2},1032,["onClick"]),(0,s.bF)(V,{type:"danger",circle:"",class:"upload-list-item-action-button",onClick:t=>o.handleRemove(e)},{default:(0,s.k6)((()=>[(0,s.bF)(u,null,{default:(0,s.k6)((()=>[(0,s.bF)(P)])),_:1})])),_:2},1032,["onClick"])])])))),128))])),_:1})],2)])),_:1},8,["class"])],32)}l(4603),l(7566),l(8721);var M=l(4373),$=l(4570),S=l.n($),V={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,M.A)({url:"/upload?authCode="+S().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(),i=new File([t],s,{type:t.type});i.uid=Date.now()+l,i.file=i,this.beforeUpload(i)&&this.uploadFile({file:i,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()}}},E=l(1241);const T=(0,E.A)(V,[["render",x],["__scopeId","data-v-3d98df6c"]]);var W=T;const D=e=>((0,s.Qi)("data-v-7c801e22"),e=e(),(0,s.jt)(),e),z={class:"page-footer"},A=D((()=>(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))),P=[A];function X(e,t){return(0,s.uX)(),(0,s.CE)("div",z,P)}const j={},B=(0,E.A)(j,[["render",X],["__scopeId","data-v-7c801e22"]]);var I=B,q=l(144),H={name:"UploadHome",data(){return{selectedUrlForm:(0,q.KR)("url"),uploadMethod:(0,q.KR)("drag"),showUrlDialog:!1}},components:{UploadForm:W,Footer:I},methods:{handleManage(){window.location.href="/admin"},openUrlDialog(){this.showUrlDialog=!0},changeUploadMethod(){this.uploadMethod="drag"===this.uploadMethod?"paste":"drag"},handleLogout(){S().remove("authCode"),this.$router.push("/login"),this.$message.success("已退出登录~")}}};const Q=(0,E.A)(H,[["render",r],["__scopeId","data-v-2e0cf1bd"]]);var K=Q}}]);
//# sourceMappingURL=329.5060c3a2.js.map