Files
CloudFlare-ImgBed/js/606.a7e6504b.js
T

2 lines
86 KiB
JavaScript

(self["webpackChunksanyue_imghub"]=self["webpackChunksanyue_imghub"]||[]).push([[606],{200:function(e,t,o){"use strict";o(5331)},213:function(e,t,o){"use strict";o(5331),o(9104)},333:function(e,t,o){"use strict";o(5331),o(6711)},670:function(e,t,o){"use strict";o(5331),o(9648),o(9104),o(5970)},694:function(e,t,o){"use strict";o(5331)},797:function(e,t,o){"use strict";o.d(t,{A:function(){return i}});o(4114),o(4979);var s=o(5507),l=o(1219),a=o(6915);async function i(e,t={}){const o=s.A.getters.credentials||btoa("unset:unset");t.headers={...t.headers,Authorization:`Basic ${o}`},t.credentials="include";const i=await fetch(e,t);return 401===i.status&&(l.nk.error("认证状态错误,请重新登录"),a.A.push("/adminLogin")),i}},1393:function(e,t,o){o(6573),o(8100),o(7936),o(9577),o(1549),o(9797),o(9631),o(5623),o(4979),o(4603),o(7566),o(8721),function(t,o){e.exports=o()}(0,function(){return function(e){var t={};function o(s){if(t[s])return t[s].exports;var l=t[s]={i:s,l:!1,exports:{}};return e[s].call(l.exports,l,l.exports,o),l.l=!0,l.exports}return o.m=e,o.c=t,o.d=function(e,t,s){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(o.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)o.d(s,l,function(t){return e[t]}.bind(null,l));return s},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";var s;function l(e){return["image/png","image/jpeg","image/gif"].some(t=>t===e)}o.r(t),o.d(t,"canvastoDataURL",function(){return i}),o.d(t,"canvastoFile",function(){return n}),o.d(t,"dataURLtoFile",function(){return d}),o.d(t,"dataURLtoImage",function(){return c}),o.d(t,"downloadFile",function(){return u}),o.d(t,"filetoDataURL",function(){return p}),o.d(t,"imagetoCanvas",function(){return m}),o.d(t,"urltoBlob",function(){return f}),o.d(t,"urltoImage",function(){return g}),o.d(t,"compress",function(){return y}),o.d(t,"compressAccurately",function(){return k}),o.d(t,"EImageType",function(){return s}),function(e){e.PNG="image/png",e.JPEG="image/jpeg",e.GIF="image/gif"}(s||(s={}));var a=function(e,t,o,s){return new(o||(o=Promise))(function(l,a){function i(e){try{r(s.next(e))}catch(e){a(e)}}function n(e){try{r(s.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,n)}r((s=s.apply(e,t||[])).next())})};function i(e,t=.92,o=s.JPEG){return a(this,void 0,void 0,function*(){return l(o)||(o=s.JPEG),e.toDataURL(o,t)})}function n(e,t=.92,o=s.JPEG){return new Promise(s=>e.toBlob(e=>s(e),o,t))}var r=function(e,t,o,s){return new(o||(o=Promise))(function(l,a){function i(e){try{r(s.next(e))}catch(e){a(e)}}function n(e){try{r(s.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,n)}r((s=s.apply(e,t||[])).next())})};function d(e,t){return r(this,void 0,void 0,function*(){const o=e.split(",");let s=o[0].match(/:(.*?);/)[1];const a=atob(o[1]);let i=a.length;const n=new Uint8Array(i);for(;i--;)n[i]=a.charCodeAt(i);return l(t)&&(s=t),new Blob([n],{type:s})})}function c(e){return new Promise((t,o)=>{const s=new Image;s.onload=()=>t(s),s.onerror=()=>o(new Error("dataURLtoImage(): dataURL is illegal")),s.src=e})}function u(e,t){const o=document.createElement("a");o.href=window.URL.createObjectURL(e),o.download=t||Date.now().toString(36),document.body.appendChild(o);const s=document.createEvent("MouseEvents");s.initEvent("click",!1,!1),o.dispatchEvent(s),document.body.removeChild(o)}function p(e){return new Promise(t=>{const o=new FileReader;o.onloadend=e=>t(e.target.result),o.readAsDataURL(e)})}var h=function(e,t,o,s){return new(o||(o=Promise))(function(l,a){function i(e){try{r(s.next(e))}catch(e){a(e)}}function n(e){try{r(s.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,n)}r((s=s.apply(e,t||[])).next())})};function m(e,t={}){return h(this,void 0,void 0,function*(){const o=Object.assign({},t),s=document.createElement("canvas"),l=s.getContext("2d");let a,i;for(const e in o)Object.prototype.hasOwnProperty.call(o,e)&&(o[e]=Number(o[e]));if(o.scale){const t=o.scale>0&&o.scale<10?o.scale:1;i=e.width*t,a=e.height*t}else i=o.width||o.height*e.width/e.height||e.width,a=o.height||o.width*e.height/e.width||e.height;switch([5,6,7,8].some(e=>e===o.orientation)?(s.height=i,s.width=a):(s.height=a,s.width=i),o.orientation){case 3:l.rotate(180*Math.PI/180),l.drawImage(e,-s.width,-s.height,s.width,s.height);break;case 6:l.rotate(90*Math.PI/180),l.drawImage(e,0,-s.width,s.height,s.width);break;case 8:l.rotate(270*Math.PI/180),l.drawImage(e,-s.height,0,s.height,s.width);break;case 2:l.translate(s.width,0),l.scale(-1,1),l.drawImage(e,0,0,s.width,s.height);break;case 4:l.translate(s.width,0),l.scale(-1,1),l.rotate(180*Math.PI/180),l.drawImage(e,-s.width,-s.height,s.width,s.height);break;case 5:l.translate(s.width,0),l.scale(-1,1),l.rotate(90*Math.PI/180),l.drawImage(e,0,-s.width,s.height,s.width);break;case 7:l.translate(s.width,0),l.scale(-1,1),l.rotate(270*Math.PI/180),l.drawImage(e,-s.height,0,s.height,s.width);break;default:l.drawImage(e,0,0,s.width,s.height)}return s})}function f(e){return fetch(e).then(e=>e.blob())}function g(e){return new Promise((t,o)=>{const s=new Image;s.onload=()=>t(s),s.onerror=()=>o(new Error("urltoImage(): Image failed to load, please check the image URL")),s.src=e})}var b=function(e,t,o,s){return new(o||(o=Promise))(function(l,a){function i(e){try{r(s.next(e))}catch(e){a(e)}}function n(e){try{r(s.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,n)}r((s=s.apply(e,t||[])).next())})};function y(e,t={}){return b(this,void 0,void 0,function*(){if(!(e instanceof Blob))throw new Error("compress(): First arg must be a Blob object or a File object.");if("object"!=typeof t&&(t=Object.assign({quality:t})),t.quality=Number(t.quality),Number.isNaN(t.quality))return e;const o=yield p(e);let a=o.split(",")[0].match(/:(.*?);/)[1],n=s.JPEG;l(t.type)&&(n=t.type,a=t.type);const r=yield c(o),u=yield m(r,Object.assign({},t)),h=yield i(u,t.quality,n),f=yield d(h,a);return f.size>e.size?e:f})}function k(e,t={}){return b(this,void 0,void 0,function*(){if(!(e instanceof Blob))throw new Error("compressAccurately(): First arg must be a Blob object or a File object.");if("object"!=typeof t&&(t=Object.assign({size:t})),t.size=Number(t.size),Number.isNaN(t.size))return e;if(1024*t.size>e.size)return e;t.accuracy=Number(t.accuracy),(!t.accuracy||t.accuracy<.8||t.accuracy>.99)&&(t.accuracy=.95);const o=t.size*(2-t.accuracy)*1024,a=1024*t.size,n=t.size*t.accuracy*1024,r=yield p(e);let u=r.split(",")[0].match(/:(.*?);/)[1],h=s.JPEG;l(t.type)&&(h=t.type,u=t.type);const f=yield c(r),g=yield m(f,Object.assign({},t));let b,y=.5;const k=[null,null];for(let e=1;e<=7;e++){b=yield i(g,y,h);const t=.75*b.length;if(7===e){(o<t||n>t)&&(b=[b,...k].filter(e=>e).sort((e,t)=>Math.abs(.75*e.length-a)-Math.abs(.75*t.length-a))[0]);break}if(o<t)k[1]=b,y-=Math.pow(.5,e+1);else{if(!(n>t))break;k[0]=b,y+=Math.pow(.5,e+1)}}const C=yield d(b,u);return C.size>e.size?e:C})}}])})},2224:function(e,t,o){"use strict";o.d(t,{A:function(){return T}});var s=o(9114),l=(o(5331),o(694),o(9385)),a=(o(7952),o(650)),i=(o(9104),o(1802)),n=(o(3378),o(47)),r=(o(9648),o(6768)),d=o(5130),c=o(4232);const u={class:"directory-tree-picker"},p={class:"tree-container"},h={key:0,class:"error-state"},m={class:"error-text"},f={class:"node-label"},g={class:"tree-container"},b={key:0,class:"error-state"},y={class:"error-text"},k={class:"node-label"};function C(e,t,o,C,v,w){const F=(0,r.g2)("font-awesome-icon"),L=n.S2,U=i.qk,T=a.Vc,S=l.pw,$=s.A;return(0,r.uX)(),(0,r.CE)("div",u,[w.isDesktop?((0,r.uX)(),(0,r.Wv)(T,{key:0,visible:v.popoverVisible,"onUpdate:visible":t[1]||(t[1]=e=>v.popoverVisible=e),placement:"bottom-start",width:320,trigger:"click","popper-class":"directory-tree-popover","show-arrow":!0,"hide-after":0,"show-after":50,transition:"el-zoom-in-top"},{reference:(0,r.k6)(()=>[(0,r.Lk)("span",{class:"popover-trigger-wrapper",onClick:t[0]||(t[0]=(0,d.D$)(()=>{},["stop"]))},[(0,r.RG)(e.$slots,"trigger",{},void 0,!0)])]),default:(0,r.k6)(()=>[(0,r.bo)(((0,r.uX)(),(0,r.CE)("div",p,[v.error?((0,r.uX)(),(0,r.CE)("div",h,[(0,r.bF)(F,{icon:"exclamation-circle",class:"error-icon"}),(0,r.Lk)("span",m,(0,c.v_)(v.error),1),(0,r.bF)(L,{type:"primary",size:"small",onClick:w.fetchDirectoryTree},{default:(0,r.k6)(()=>[...t[4]||(t[4]=[(0,r.eW)(" 重试 ",-1)])]),_:1},8,["onClick"])])):((0,r.uX)(),(0,r.Wv)(U,{key:1,ref:"treeRef",data:v.treeData,props:v.treeProps,"node-key":"path","default-expand-all":!1,"expand-on-click-node":!1,"highlight-current":!0,"current-node-key":o.currentDirectory,class:"directory-tree",onNodeClick:w.handleNodeClick},{default:(0,r.k6)(({node:e,data:t})=>[(0,r.Lk)("span",{class:(0,c.C4)(["tree-node",{"is-current":t.path===o.currentDirectory}])},[(0,r.bF)(F,{icon:e.expanded?"folder-open":"folder",class:"folder-icon"},null,8,["icon"]),(0,r.Lk)("span",f,(0,c.v_)(t.name),1)],2)]),_:1},8,["data","props","current-node-key","onNodeClick"]))])),[[$,v.loading]])]),_:3},8,["visible"])):((0,r.uX)(),(0,r.CE)(r.FK,{key:1},[(0,r.Lk)("span",{class:"drawer-trigger-wrapper",onClick:t[2]||(t[2]=(...e)=>w.openDrawer&&w.openDrawer(...e))},[(0,r.RG)(e.$slots,"trigger",{},void 0,!0)]),(0,r.bF)(S,{modelValue:v.drawerVisible,"onUpdate:modelValue":t[3]||(t[3]=e=>v.drawerVisible=e),direction:"btt",size:"60%","show-close":!0,"with-header":!0,"z-index":3e3,title:"选择目录",class:"directory-tree-drawer"},{default:(0,r.k6)(()=>[(0,r.bo)(((0,r.uX)(),(0,r.CE)("div",g,[v.error?((0,r.uX)(),(0,r.CE)("div",b,[(0,r.bF)(F,{icon:"exclamation-circle",class:"error-icon"}),(0,r.Lk)("span",y,(0,c.v_)(v.error),1),(0,r.bF)(L,{type:"primary",size:"small",onClick:w.fetchDirectoryTree},{default:(0,r.k6)(()=>[...t[5]||(t[5]=[(0,r.eW)(" 重试 ",-1)])]),_:1},8,["onClick"])])):((0,r.uX)(),(0,r.Wv)(U,{key:1,ref:"treeRefMobile",data:v.treeData,props:v.treeProps,"node-key":"path","default-expand-all":!1,"expand-on-click-node":!1,"highlight-current":!0,"current-node-key":o.currentDirectory,class:"directory-tree mobile-tree",onNodeClick:w.handleNodeClick},{default:(0,r.k6)(({node:e,data:t})=>[(0,r.Lk)("span",{class:(0,c.C4)(["tree-node",{"is-current":t.path===o.currentDirectory}])},[(0,r.bF)(F,{icon:e.expanded?"folder-open":"folder",class:"folder-icon"},null,8,["icon"]),(0,r.Lk)("span",k,(0,c.v_)(t.name),1)],2)]),_:1},8,["data","props","current-node-key","onNodeClick"]))])),[[$,v.loading]])]),_:1},8,["modelValue"])],64))])}var v=o(457),w=o(797),F={name:"DirectoryTreePicker",props:{currentDirectory:{type:String,default:""},source:{type:String,default:"upload",validator:e=>["upload","admin"].includes(e)}},data(){return{popoverVisible:!1,drawerVisible:!1,treeData:[],loading:!1,error:"",treeProps:{children:"children",label:"name"},windowWidth:window.innerWidth}},computed:{isDesktop(){return this.windowWidth>=769}},watch:{popoverVisible(e){e?this.fetchDirectoryTree():setTimeout(()=>{if(!this.popoverVisible&&this.$refs.treeRef){const e=this.$refs.treeRef.store;for(const t in e.nodesMap)e.nodesMap[t].expanded=!1}},200)},drawerVisible(e){e?this.fetchDirectoryTree():setTimeout(()=>{if(!this.drawerVisible&&this.$refs.treeRefMobile){const e=this.$refs.treeRefMobile.store;for(const t in e.nodesMap)e.nodesMap[t].expanded=!1}},300)},currentDirectory(e){this.$nextTick(()=>{this.$refs.treeRef&&e&&this.$refs.treeRef.setCurrentKey(e),this.$refs.treeRefMobile&&e&&this.$refs.treeRefMobile.setCurrentKey(e)})}},mounted(){window.addEventListener("resize",this.handleResize)},beforeUnmount(){window.removeEventListener("resize",this.handleResize)},methods:{handleResize(){this.windowWidth=window.innerWidth},openDrawer(){this.drawerVisible=!0},async fetchDirectoryTree(){this.loading=!0,this.error="";try{let e;if("admin"===this.source){const t=await(0,w.A)("/api/directoryTree",{method:"GET"});if(!t.ok)return void(401===t.status?this.error="认证失败,请重新登录":this.error="服务器错误,请稍后重试");e=await t.json()}else{const t=await v.A.get("/api/directoryTree",{withAuthCode:!0});e=t.data}e.tree?this.treeData=[e.tree]:this.treeData=[]}catch(e){console.error("Failed to fetch directory tree:",e),401===e.response?.status?this.error="认证失败,请重新登录":this.error="加载目录树失败,请检查网络连接"}finally{this.loading=!1}},handleNodeClick(e){let t=e.path;t&&!t.startsWith("/")?t="/"+t:t||(t="/"),this.$emit("select",t),this.popoverVisible=!1,this.drawerVisible=!1}}},L=o(1241);const U=(0,L.A)(F,[["render",C],["__scopeId","data-v-296c1702"]]);var T=U},2388:function(e,t,o){"use strict";function s(e,{strict:t=!0}={}){if(!e||""===e.trim())return{valid:!0};if("/"===e)return{valid:!0};if(!e.startsWith("/"))return{valid:!1,error:'目标目录必须以 "/" 开头'};if(/(?:^|\/)\.\.(\/|$)/.test(e)||e.includes(".."))return{valid:!1,error:'目标目录不能包含路径穿越字符 ".."'};const o=t?/\/\.(\/|$)/:/\/\.\//;if(o.test(e))return{valid:!1,error:'目标目录不能包含单独的 "." 路径段'};if(e.includes("//"))return{valid:!1,error:"目标目录不能包含连续的斜杠"};const s=/[\\:\*\?"'<>\| \(\)\[\]\{\}#%\^`~;@&=\+\$,]/;return s.test(e)?{valid:!1,error:"目标目录包含非法字符,请使用合法的路径格式"}:{valid:!0}}o.d(t,{G:function(){return s}})},2893:function(e,t,o){"use strict";o(5331)},3378:function(e,t,o){"use strict";o(5331),o(8736),o(9899)},3597:function(e,t,o){"use strict";o(5331)},4358:function(e,t,o){"use strict";o.r(t),o.d(t,{default:function(){return oo}});var s=o(8507),l=(o(5331),o(213),o(47)),a=(o(9648),o(6768)),i=o(4232);const n={class:"history-header"},r={class:"header-left"},d={class:"record-count"},c={class:"header-right"},u={class:"timeline-header"},p={class:"date-label"},h={key:0,class:"grid-view"},m={class:"grid-preview"},f=["src"],g=["src"],b={key:2,class:"file-icon-wrapper"},y={class:"grid-overlay"},k={class:"grid-actions"},C={class:"grid-info"},v=["title"],w={class:"upload-time"},F={key:1,class:"list-view"},L={class:"list-preview"},U=["src"],T=["src"],S={key:2,class:"file-icon-wrapper-small"},$={class:"list-info"},M=["title"],x=["title"],_={class:"list-meta"},R={class:"upload-time"},E={class:"list-actions"},A={key:0,class:"load-more-container"},N={key:0,class:"loading-indicator"},I={key:1,class:"load-more-hint"},P={key:1,class:"no-more-hint"},D={key:1,class:"empty-state"};function W(e,t,o,W,z,V){const B=(0,a.g2)("font-awesome-icon"),H=l.S2,X=s.R7;return(0,a.uX)(),(0,a.CE)("div",{class:(0,i.C4)(["history-container",{active:o.show}])},[(0,a.Lk)("div",n,[(0,a.Lk)("div",r,[t[4]||(t[4]=(0,a.Lk)("h2",null,"历史记录",-1)),(0,a.Lk)("span",d,"共 "+(0,i.v_)(z.totalCount)+" 条",1)]),(0,a.Lk)("div",c,[(0,a.bF)(X,{content:"切换视图",placement:"bottom"},{default:(0,a.k6)(()=>[(0,a.bF)(H,{circle:"",onClick:V.toggleViewMode},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"grid"===z.viewMode?"list":"th-large"},null,8,["icon"])]),_:1},8,["onClick"])]),_:1}),(0,a.bF)(X,{content:"清空记录",placement:"bottom"},{default:(0,a.k6)(()=>[(0,a.bF)(H,{circle:"",type:"danger",onClick:V.clearHistory},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"trash-alt"})]),_:1},8,["onClick"])]),_:1}),(0,a.bF)(H,{circle:"",onClick:t[0]||(t[0]=t=>e.$emit("close"))},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"times"})]),_:1})])]),z.historyList.length>0?((0,a.uX)(),(0,a.CE)("div",{key:0,class:"history-content",ref:"historyContent",onScroll:t[3]||(t[3]=(...e)=>V.handleScroll&&V.handleScroll(...e))},[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(V.groupedHistory,e=>((0,a.uX)(),(0,a.CE)("div",{key:e.date,class:"history-group"},[(0,a.Lk)("div",u,[t[5]||(t[5]=(0,a.Lk)("div",{class:"timeline-dot"},null,-1)),(0,a.Lk)("span",p,(0,i.v_)(e.date),1)]),"grid"===z.viewMode?((0,a.uX)(),(0,a.CE)("div",h,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(e.items,e=>((0,a.uX)(),(0,a.CE)("div",{key:e.time,class:"grid-item"},[(0,a.Lk)("div",m,[V.isImage(e.name)?((0,a.uX)(),(0,a.CE)("img",{key:0,src:e.url,loading:"lazy",onError:t[1]||(t[1]=(...e)=>V.handleImageError&&V.handleImageError(...e))},null,40,f)):V.isVideo(e.name)?((0,a.uX)(),(0,a.CE)("video",{key:1,src:e.url,muted:""},null,8,g)):((0,a.uX)(),(0,a.CE)("div",b,[(0,a.bF)(B,{icon:"file",class:"file-icon"})])),(0,a.Lk)("div",y,[(0,a.Lk)("div",k,[(0,a.bF)(H,{circle:"",size:"default",type:"primary",onClick:t=>V.copyLink(e.url)},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"copy"})]),_:1},8,["onClick"]),(0,a.bF)(H,{circle:"",size:"default",class:"action-btn-view",onClick:t=>V.openLink(e.url)},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"external-link-alt"})]),_:1},8,["onClick"]),(0,a.bF)(H,{circle:"",size:"default",type:"danger",onClick:t=>V.deleteItem(e)},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"trash-alt"})]),_:1},8,["onClick"])])])]),(0,a.Lk)("div",C,[(0,a.Lk)("div",{class:"file-name",title:e.name},(0,i.v_)(e.name),9,v),(0,a.Lk)("div",w,(0,i.v_)(V.formatTime(e.time)),1)])]))),128))])):((0,a.uX)(),(0,a.CE)("div",F,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(e.items,e=>((0,a.uX)(),(0,a.CE)("div",{key:e.time,class:"list-item"},[(0,a.Lk)("div",L,[V.isImage(e.name)?((0,a.uX)(),(0,a.CE)("img",{key:0,src:e.url,loading:"lazy",onError:t[2]||(t[2]=(...e)=>V.handleImageError&&V.handleImageError(...e))},null,40,U)):V.isVideo(e.name)?((0,a.uX)(),(0,a.CE)("video",{key:1,src:e.url,muted:""},null,8,T)):((0,a.uX)(),(0,a.CE)("div",S,[(0,a.bF)(B,{icon:"file"})]))]),(0,a.Lk)("div",$,[(0,a.Lk)("div",{class:"file-name",title:e.name},(0,i.v_)(e.name),9,M),(0,a.Lk)("div",{class:"file-url",title:e.url},(0,i.v_)(e.url),9,x)]),(0,a.Lk)("div",_,[(0,a.Lk)("div",R,(0,i.v_)(V.formatTime(e.time)),1)]),(0,a.Lk)("div",E,[(0,a.bF)(H,{circle:"",size:"small",type:"primary",onClick:t=>V.copyLink(e.url)},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"copy"})]),_:1},8,["onClick"]),(0,a.bF)(H,{circle:"",size:"small",class:"action-btn-view",onClick:t=>V.openLink(e.url)},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"external-link-alt"})]),_:1},8,["onClick"]),(0,a.bF)(H,{circle:"",size:"small",type:"danger",onClick:t=>V.deleteItem(e)},{default:(0,a.k6)(()=>[(0,a.bF)(B,{icon:"trash-alt"})]),_:1},8,["onClick"])])]))),128))]))]))),128)),V.hasMore?((0,a.uX)(),(0,a.CE)("div",A,[z.loadingMore?((0,a.uX)(),(0,a.CE)("div",N,[(0,a.bF)(B,{icon:"spinner",spin:""}),t[6]||(t[6]=(0,a.Lk)("span",null,"加载中...",-1))])):((0,a.uX)(),(0,a.CE)("div",I,"下拉加载更多"))])):z.historyList.length>0?((0,a.uX)(),(0,a.CE)("div",P,"没有更多记录了")):(0,a.Q3)("",!0)],544)):((0,a.uX)(),(0,a.CE)("div",D,[(0,a.bF)(B,{icon:"history",class:"empty-icon"}),t[7]||(t[7]=(0,a.Lk)("p",null,"暂无上传记录",-1))]))],2)}o(4114),o(8111),o(2489),o(7588),o(1701),o(3110),o(8335);var z={name:"UploadHistory",props:{show:{type:Boolean,default:!1}},data(){return{historyList:[],allHistory:[],viewMode:"grid",pageSize:30,currentPage:0,loadingMore:!1,totalCount:0}},watch:{show(e){e&&this.resetAndLoad()}},computed:{hasMore(){return this.historyList.length<this.totalCount},groupedHistory(){const e={};return this.historyList.forEach(t=>{const o=new Date(t.time),s=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`;e[s]||(e[s]=[]),e[s].push(t)}),Object.keys(e).sort((e,t)=>new Date(t)-new Date(e)).map(t=>({date:t,items:e[t]}))}},mounted(){const e=localStorage.getItem("historyViewMode");e&&(this.viewMode=e)},methods:{resetAndLoad(){this.historyList=[],this.currentPage=0,this.loadAllHistory(),this.loadMore()},loadAllHistory(){try{const e=JSON.parse(localStorage.getItem("uploadHistory")||"[]");this.allHistory=e.sort((e,t)=>t.time-e.time),this.totalCount=this.allHistory.length}catch(e){console.error("Failed to load history",e),this.allHistory=[],this.totalCount=0}},loadMore(){!this.loadingMore&&this.hasMore&&(this.loadingMore=!0,setTimeout(()=>{const e=this.currentPage*this.pageSize,t=e+this.pageSize,o=this.allHistory.slice(e,t);this.historyList=[...this.historyList,...o],this.currentPage++,this.loadingMore=!1},50))},handleScroll(e){const t=e.target,o=t.scrollTop,s=t.scrollHeight,l=t.clientHeight;s-o-l<100&&this.loadMore()},toggleViewMode(){this.viewMode="grid"===this.viewMode?"list":"grid",localStorage.setItem("historyViewMode",this.viewMode)},clearHistory(){this.$confirm("确定要清空所有上传记录吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{this.historyList=[],this.allHistory=[],this.totalCount=0,this.currentPage=0,localStorage.removeItem("uploadHistory"),this.$message.success("记录已清空")}).catch(()=>{})},deleteItem(e){this.$confirm("确定要删除这条记录吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{this.historyList=this.historyList.filter(t=>t.time!==e.time),this.allHistory=this.allHistory.filter(t=>t.time!==e.time),this.totalCount=this.allHistory.length;try{localStorage.setItem("uploadHistory",JSON.stringify(this.allHistory)),this.$message.success("记录已删除")}catch(t){console.error("Failed to update history",t)}}).catch(()=>{})},isImage(e){const t=["jpg","jpeg","png","gif","bmp","webp","svg","tiff","ico","avif","heic","jfif","pjpeg","pjp"],o=e?e.split(".").pop().toLowerCase():"";return t.includes(o)},isVideo(e){const t=["mp4","webm","ogg","mkv"],o=e?e.split(".").pop().toLowerCase():"";return t.includes(o)},formatTime(e){const t=new Date(e),o=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),n=String(t.getSeconds()).padStart(2,"0");return`${o}-${s}-${l} ${a}:${i}:${n}`},copyLink(e){navigator.clipboard.writeText(e).then(()=>{this.$message.success("链接已复制")}).catch(()=>{this.$message.error("复制失败")})},openLink(e){window.open(e,"_blank")},handleImageError(e){e.target.src=o(6682)}}},V=o(1241);const B=(0,V.A)(z,[["render",W],["__scopeId","data-v-05a2ac54"]]);var H=B,X=o(6975),Q=o(9267),j=(o(5616),o(1418)),O=(o(333),o(4757)),q=o(5558),G=(o(8075),o(9623)),K=(o(6711),o(6018)),J=(o(6808),o(200),o(6810));o(4396),o(4885);const Y={class:"dialog-section"},Z={class:"section-content"},ee={class:"setting-item"},te={key:0,class:"setting-item"},oe={class:"setting-label"},se={class:"setting-item"},le={class:"setting-item"},ae={class:"setting-label"},ie={class:"dialog-section"},ne={class:"section-content"},re={class:"dialog-section"},de={class:"section-header"},ce={class:"section-content"},ue={class:"setting-item"},pe={class:"setting-label"},he={class:"setting-item"},me={key:0,class:"setting-item slider-item"},fe={class:"setting-label"},ge={class:"slider-wrapper"},be={class:"slider-input-wrapper"},ye={key:1,class:"setting-item slider-item"},ke={class:"setting-label"},Ce={class:"slider-wrapper"},ve={class:"slider-input-wrapper"},we={key:0,class:"dialog-section"},Fe={class:"section-header"},Le={class:"section-content"},Ue={class:"setting-item"},Te={class:"dialog-action"};function Se(e,t,o,i,n,r){const d=(0,a.g2)("font-awesome-icon"),c=J.ll,u=J.MQ,p=s.R7,h=K.P9,m=K.AV,f=G.WK,g=q.qi,b=O.B8,y=j.lq,k=l.S2,C=Q.kZ;return(0,a.uX)(),(0,a.Wv)(C,{title:"上传设置",modelValue:r.visible,"onUpdate:modelValue":t[12]||(t[12]=e=>r.visible=e),width:r.dialogWidth,"show-close":!1,class:"settings-dialog"},{default:(0,a.k6)(()=>[(0,a.Lk)("div",Y,[t[22]||(t[22]=(0,a.Lk)("div",{class:"section-header"},[(0,a.Lk)("span",{class:"section-title"},"上传渠道")],-1)),(0,a.Lk)("div",Z,[(0,a.Lk)("div",ee,[t[18]||(t[18]=(0,a.Lk)("span",{class:"setting-label"},"渠道类型",-1)),(0,a.bF)(u,{"model-value":o.uploadChannel,"onUpdate:modelValue":t[0]||(t[0]=t=>e.$emit("update:uploadChannel",t)),class:"radio-card-group compact"},{default:(0,a.k6)(()=>[(0,a.bF)(c,{label:"telegram",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"paper-plane",class:"channel-icon"}),t[13]||(t[13]=(0,a.Lk)("span",null,"TG",-1))]),_:1}),(0,a.bF)(c,{label:"cfr2",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"cloud",class:"channel-icon"}),t[14]||(t[14]=(0,a.Lk)("span",null,"R2",-1))]),_:1}),(0,a.bF)(c,{label:"s3",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"database",class:"channel-icon"}),t[15]||(t[15]=(0,a.Lk)("span",null,"S3",-1))]),_:1}),(0,a.bF)(c,{label:"discord",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"comments",class:"channel-icon"}),t[16]||(t[16]=(0,a.Lk)("span",null,"DC",-1))]),_:1}),(0,a.bF)(c,{label:"huggingface",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"robot",class:"channel-icon"}),t[17]||(t[17]=(0,a.Lk)("span",null,"HF",-1))]),_:1})]),_:1},8,["model-value"])]),o.currentChannelList.length>1?((0,a.uX)(),(0,a.CE)("div",te,[(0,a.Lk)("span",oe,[t[19]||(t[19]=(0,a.eW)(" 渠道名称 ",-1)),(0,a.bF)(p,{content:"选择具体的渠道名称,不选择则使用负载均衡或默认渠道",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"inline-help-icon"})]),_:1})]),(0,a.bF)(m,{"model-value":o.channelName,"onUpdate:modelValue":t[1]||(t[1]=t=>e.$emit("update:channelName",t)),placeholder:"自动选择",clearable:"",class:"setting-input"},{default:(0,a.k6)(()=>[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(o.currentChannelList,e=>((0,a.uX)(),(0,a.Wv)(h,{key:e.name,label:e.name,value:e.name},null,8,["label","value"]))),128))]),_:1},8,["model-value"])])):(0,a.Q3)("",!0),(0,a.Lk)("div",se,[t[20]||(t[20]=(0,a.Lk)("span",{class:"setting-label"},"上传目录",-1)),(0,a.bF)(f,{"model-value":o.uploadFolder,"onUpdate:modelValue":r.handleUploadFolderInput,placeholder:"请输入上传目录路径",class:"setting-input"},null,8,["model-value","onUpdate:modelValue"])]),(0,a.Lk)("div",le,[(0,a.Lk)("span",ae,[t[21]||(t[21]=(0,a.eW)(" 自动切换 ",-1)),(0,a.bF)(p,{content:"对于非分块上传文件,上传失败自动切换到其他渠道上传",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"inline-help-icon"})]),_:1})]),(0,a.bF)(g,{"model-value":o.autoRetry,"onUpdate:modelValue":t[2]||(t[2]=t=>e.$emit("update:autoRetry",t))},null,8,["model-value"])])])]),(0,a.Lk)("div",ie,[t[27]||(t[27]=(0,a.Lk)("div",{class:"section-header"},[(0,a.Lk)("span",{class:"section-title"},"文件命名方式")],-1)),(0,a.Lk)("div",ne,[(0,a.bF)(u,{"model-value":o.uploadNameType,"onUpdate:modelValue":t[3]||(t[3]=t=>e.$emit("update:uploadNameType",t)),class:"radio-card-group grid-2x2"},{default:(0,a.k6)(()=>[(0,a.bF)(c,{label:"default",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"cog",class:"radio-icon"}),t[23]||(t[23]=(0,a.Lk)("span",null,"默认",-1))]),_:1}),(0,a.bF)(c,{label:"index",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"hashtag",class:"radio-icon"}),t[24]||(t[24]=(0,a.Lk)("span",null,"仅前缀",-1))]),_:1}),(0,a.bF)(c,{label:"origin",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"file-signature",class:"radio-icon"}),t[25]||(t[25]=(0,a.Lk)("span",null,"仅原名",-1))]),_:1}),(0,a.bF)(c,{label:"short",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"compress-alt",class:"radio-icon"}),t[26]||(t[26]=(0,a.Lk)("span",null,"短链接",-1))]),_:1})]),_:1},8,["model-value"])])]),(0,a.Lk)("div",re,[(0,a.Lk)("div",de,[t[28]||(t[28]=(0,a.Lk)("span",{class:"section-title"},"文件预处理",-1)),(0,a.bF)(p,{content:"上传前在本地进行格式转换和压缩,仅对图片文件生效",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"section-help-icon"})]),_:1})]),(0,a.Lk)("div",ce,[(0,a.Lk)("div",ue,[(0,a.Lk)("span",pe,[t[29]||(t[29]=(0,a.eW)(" 转换为WebP ",-1)),(0,a.bF)(p,{content:"上传前将图片转换为WebP格式,可有效减小文件体积。转换失败时保持原格式上传",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"inline-help-icon"})]),_:1})]),(0,a.bF)(g,{"model-value":o.convertToWebp,"onUpdate:modelValue":t[4]||(t[4]=t=>e.$emit("update:convertToWebp",t))},null,8,["model-value"])]),(0,a.Lk)("div",he,[t[30]||(t[30]=(0,a.Lk)("span",{class:"setting-label"},"文件压缩",-1)),(0,a.bF)(g,{"model-value":o.customerCompress,"onUpdate:modelValue":t[5]||(t[5]=t=>e.$emit("update:customerCompress",t))},null,8,["model-value"])]),o.customerCompress?((0,a.uX)(),(0,a.CE)("div",me,[(0,a.Lk)("span",fe,[t[31]||(t[31]=(0,a.eW)(" 压缩阈值 ",-1)),(0,a.bF)(p,{content:"设置图片大小阈值,超过此值将自动压缩,单位MB",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"inline-help-icon"})]),_:1})]),(0,a.Lk)("div",ge,[(0,a.bF)(b,{"model-value":o.compressBar,"onUpdate:modelValue":t[6]||(t[6]=t=>e.$emit("update:compressBar",t)),min:1,max:20,"format-tooltip":e=>`${e} MB`},null,8,["model-value","format-tooltip"]),(0,a.Lk)("div",be,[(0,a.bF)(y,{"model-value":o.compressBar,"onUpdate:modelValue":t[7]||(t[7]=t=>e.$emit("update:compressBar",t)),min:1,max:20,step:1,"value-on-clear":1,class:"slider-input","controls-position":"right"},null,8,["model-value"]),t[32]||(t[32]=(0,a.Lk)("span",{class:"slider-unit"},"MB",-1))])])])):(0,a.Q3)("",!0),o.customerCompress?((0,a.uX)(),(0,a.CE)("div",ye,[(0,a.Lk)("span",ke,[t[33]||(t[33]=(0,a.eW)(" 期望大小 ",-1)),(0,a.bF)(p,{content:"设置压缩后图片大小期望值,单位MB",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"inline-help-icon"})]),_:1})]),(0,a.Lk)("div",Ce,[(0,a.bF)(b,{"model-value":o.compressQuality,"onUpdate:modelValue":t[8]||(t[8]=t=>e.$emit("update:compressQuality",t)),min:.5,max:o.compressBar,step:.1,"format-tooltip":e=>`${e} MB`},null,8,["model-value","max","format-tooltip"]),(0,a.Lk)("div",ve,[(0,a.bF)(y,{"model-value":o.compressQuality,"onUpdate:modelValue":t[9]||(t[9]=t=>e.$emit("update:compressQuality",t)),min:.5,max:o.compressBar,step:.1,precision:1,"value-on-clear":.5,class:"slider-input","controls-position":"right"},null,8,["model-value","max"]),t[34]||(t[34]=(0,a.Lk)("span",{class:"slider-unit"},"MB",-1))])])])):(0,a.Q3)("",!0)])]),"telegram"===o.uploadChannel?((0,a.uX)(),(0,a.CE)("div",we,[(0,a.Lk)("div",Fe,[t[35]||(t[35]=(0,a.Lk)("span",{class:"section-title"},"服务端压缩",-1)),(0,a.bF)(p,{content:"1. 在 Telegram 端进行压缩,仅对上传渠道为 Telegram 的图片文件生效 <br> 2. 若图片大小(本地压缩后大小)大于10MB,本设置自动失效 <br> 3. 若上传分辨率过大、透明背景等图片,建议关闭服务端压缩,否则可能出现未知问题",placement:"top","raw-content":""},{default:(0,a.k6)(()=>[(0,a.bF)(d,{icon:"question-circle",class:"section-help-icon"})]),_:1})]),(0,a.Lk)("div",Le,[(0,a.Lk)("div",Ue,[t[36]||(t[36]=(0,a.Lk)("span",{class:"setting-label"},"开启压缩",-1)),(0,a.bF)(g,{"model-value":o.serverCompress,"onUpdate:modelValue":t[10]||(t[10]=t=>e.$emit("update:serverCompress",t))},null,8,["model-value"])])])])):(0,a.Q3)("",!0),(0,a.Lk)("div",Te,[(0,a.bF)(k,{type:"primary",onClick:t[11]||(t[11]=e=>r.visible=!1),class:"confirm-btn"},{default:(0,a.k6)(()=>[...t[37]||(t[37]=[(0,a.eW)("确定",-1)])]),_:1})])]),_:1},8,["modelValue","width"])}var $e={name:"UploadSettingsDialog",methods:{handleUploadFolderInput(e){e&&!e.startsWith("/")&&(e="/"+e),this.$emit("update:uploadFolder",e)}},props:{modelValue:{type:Boolean,default:!1},uploadChannel:{type:String,default:"telegram"},channelName:{type:String,default:""},currentChannelList:{type:Array,default:()=>[]},uploadFolder:{type:String,default:""},autoRetry:{type:Boolean,default:!0},uploadNameType:{type:String,default:"default"},convertToWebp:{type:Boolean,default:!1},customerCompress:{type:Boolean,default:!0},compressBar:{type:Number,default:5},compressQuality:{type:Number,default:4},serverCompress:{type:Boolean,default:!0}},emits:["update:modelValue","update:uploadChannel","update:channelName","update:uploadFolder","update:autoRetry","update:uploadNameType","update:convertToWebp","update:customerCompress","update:compressBar","update:compressQuality","update:serverCompress"],computed:{visible:{get(){return this.modelValue},set(e){this.$emit("update:modelValue",e)}},dialogWidth(){return window.innerWidth>768?"50%":"90%"}}};const Me=(0,V.A)($e,[["render",Se]]);var xe=Me,_e=o(8559),Re=(o(5970),o(813)),Ee=(o(4896),o(9655)),Ae=(o(2893),o(4253));o(9899);const Ne={class:"upload-list-item"},Ie=["href"],Pe={key:0,style:{width:"10vw","border-radius":"12px"},autoplay:"",muted:"",playsinline:"",loop:""},De=["src"],We=["src"],ze={key:2,style:{width:"10vw","border-radius":"12px"}},Ve={class:"upload-list-item-content"},Be={class:"upload-list-item-name-wrapper"},He={key:0,class:"upload-list-item-url"},Xe={class:"upload-list-item-url-row"},Qe={class:"upload-list-item-url-row"},je={key:1,class:"upload-list-item-progress"},Oe={class:"upload-list-item-action"};function qe(e,t,o,s,l,n){const r=(0,a.g2)("font-awesome-icon"),d=Ae.$g,c=G.WK,u=Ee.ve,p=(0,a.g2)("Link"),h=Re.tk,m=(0,a.g2)("Delete");return(0,a.uX)(),(0,a.CE)("div",Ne,[(0,a.Lk)("a",{href:o.file.url,target:"_blank",class:"upload-list-item-preview"},[n.isVideo(o.file.name)?((0,a.uX)(),(0,a.CE)("video",Pe,[(0,a.Lk)("source",{src:o.file.url,type:"video/mp4"},null,8,De),t[7]||(t[7]=(0,a.eW)(" Your browser does not support the video tag. ",-1))])):n.isImage(o.file.name)?((0,a.uX)(),(0,a.CE)("img",{key:1,style:{width:"10vw","border-radius":"12px"},src:o.file.url,onError:t[0]||(t[0]=t=>e.$emit("preview-error",o.file))},null,40,We)):((0,a.uX)(),(0,a.CE)("div",ze,[(0,a.bF)(r,{icon:"file",class:"file-icon"})]))],8,Ie),(0,a.Lk)("div",Ve,[(0,a.Lk)("div",Be,[(0,a.bF)(d,{class:"upload-list-item-name",truncated:""},{default:(0,a.k6)(()=>[(0,a.eW)((0,i.v_)(n.truncateFilename(o.file.name)),1)]),_:1})]),"done"===o.file.status?((0,a.uX)(),(0,a.CE)("div",He,[(0,a.Lk)("div",Xe,[(0,a.bF)(c,{modelValue:o.file.finalURL,"onUpdate:modelValue":t[1]||(t[1]=e=>o.file.finalURL=e),readonly:"",onClick:n.selectAllText,size:n.urlSize},{prepend:(0,a.k6)(()=>[...t[8]||(t[8]=[(0,a.eW)("URL",-1)])]),_:1},8,["modelValue","onClick","size"]),(0,a.bF)(c,{modelValue:o.file.mdURL,"onUpdate:modelValue":t[2]||(t[2]=e=>o.file.mdURL=e),readonly:"",onClick:n.selectAllText,size:n.urlSize},{prepend:(0,a.k6)(()=>[...t[9]||(t[9]=[(0,a.eW)("MarkDown",-1)])]),_:1},8,["modelValue","onClick","size"])]),(0,a.Lk)("div",Qe,[(0,a.bF)(c,{modelValue:o.file.htmlURL,"onUpdate:modelValue":t[3]||(t[3]=e=>o.file.htmlURL=e),readonly:"",onClick:n.selectAllText,size:n.urlSize},{prepend:(0,a.k6)(()=>[...t[10]||(t[10]=[(0,a.eW)("HTML",-1)])]),_:1},8,["modelValue","onClick","size"]),(0,a.bF)(c,{modelValue:o.file.ubbURL,"onUpdate:modelValue":t[4]||(t[4]=e=>o.file.ubbURL=e),readonly:"",onClick:n.selectAllText,size:n.urlSize},{prepend:(0,a.k6)(()=>[...t[11]||(t[11]=[(0,a.eW)("BBCode",-1)])]),_:1},8,["modelValue","onClick","size"])])])):((0,a.uX)(),(0,a.CE)("div",je,[(0,a.bF)(u,{percentage:o.file.progreess,status:o.file.status,"show-text":!1},null,8,["percentage","status"])]))]),(0,a.Lk)("div",Oe,[(0,a.Lk)("button",{class:"modern-file-action-btn modern-file-action-btn-primary",onClick:t[5]||(t[5]=t=>e.$emit("copy",o.file))},[(0,a.bF)(h,null,{default:(0,a.k6)(()=>[(0,a.bF)(p)]),_:1})]),(0,a.Lk)("button",{class:"modern-file-action-btn modern-file-action-btn-danger",onClick:t[6]||(t[6]=t=>e.$emit("remove",o.file))},[(0,a.bF)(h,null,{default:(0,a.k6)(()=>[(0,a.bF)(m)]),_:1})])])])}var Ge=o(7477);const Ke=["jpg","jpeg","png","gif","bmp","webp","svg","tiff","ico","avif","heic","jfif","pjpeg","pjp","raw","cr2","nef","dng","eps","ai","emf","wmf"],Je=["mp4","webm","ogg","mkv"];var Ye={name:"UploadFileItem",components:{Link:Ge.Link,Delete:Ge.Delete},props:{file:{type:Object,required:!0}},emits:["copy","remove","preview-error"],computed:{urlSize(){return window.innerWidth<768?"small":"default"}},methods:{isImage(e){const t=e.split(".").pop().toLowerCase();return Ke.includes(t)},isVideo(e){const t=e.split(".").pop().toLowerCase();return Je.includes(t)},truncateFilename(e,t=20){if(!e||e.length<=t)return e;const o=e.lastIndexOf(".");let s,l;o>0?(s=e.substring(0,o),l=e.substring(o)):(s=e,l="");const a=l.length+4,i=t-a-3;return i<=0?e.substring(0,t-3)+"...":s.substring(0,i)+"..."+s.slice(-4)+l},selectAllText(e){navigator.clipboard.writeText(e.target.value).then(()=>{this.$message({type:"success",message:"复制成功"})}).catch(()=>{this.$message({type:"error",message:"复制失败"})})}}};const Ze=(0,V.A)(Ye,[["render",qe],["__scopeId","data-v-85bdebae"]]);var et=Ze,tt=o(2086),ot=(o(670),o(8830),o(3597),o(683)),st=(o(5385),o(7358));const lt={class:"upload-form"},at={class:"upload-card-glow",ref:"uploadCardGlow"},it={key:0,class:"upload-card"},nt={class:"paste-card-actions"},rt={class:"upload-list-dashboard-action"},dt={class:"modern-action-group"},ct={class:"modern-dropdown-item-content"},ut={class:"modern-action-btn modern-action-btn-danger"};function pt(e,t,n,r,d,c){const u=(0,a.g2)("CameraFilled"),p=Re.tk,h=st.j5,m=G.WK,f=l.S2,g=J.Zh,b=J.MQ,y=ot.Ik,k=(0,a.g2)("List"),C=(0,a.g2)("Checked"),v=(0,a.g2)("Failed"),w=Ae.$g,F=(0,a.g2)("font-awesome-icon"),L=s.R7,U=q.qi,T=tt.c6,S=tt.Iy,$=tt.dW,M=et,x=_e.kA;return(0,a.uX)(),(0,a.CE)("div",lt,[(0,a.Lk)("div",{class:"upload-card-wrapper",onMousemove:t[0]||(t[0]=(...e)=>c.handleUploadCardMouseMove&&c.handleUploadCardMouseMove(...e)),onMouseleave:t[1]||(t[1]=(...e)=>c.handleUploadCardMouseLeave&&c.handleUploadCardMouseLeave(...e))},[(0,a.Lk)("div",at,null,512),"default"===n.uploadMethod?((0,a.uX)(),(0,a.Wv)(h,{key:0,class:(0,i.C4)(["upload-card",{"is-uploading":d.uploading,"upload-card-busy":d.fileList.length}]),drag:"",multiple:"","http-request":c.uploadFile,onSuccess:c.handleSuccess,"on-error":c.handleError,"before-upload":c.beforeUpload,"on-progress":c.handleProgress,"file-list":d.fileList,"show-file-list":!1},{default:(0,a.k6)(()=>[(0,a.bF)(p,{class:(0,i.C4)(["el-icon--upload",{"upload-list-busy":d.fileList.length}])},{default:(0,a.k6)(()=>[(0,a.bF)(u)]),_:1},8,["class"]),(0,a.Lk)("div",{class:(0,i.C4)(["el-upload__text",{"upload-list-busy":d.fileList.length}])},[...t[8]||(t[8]=[(0,a.Lk)("em",null,"拖拽",-1),(0,a.eW)(),(0,a.Lk)("em",null,"点击",-1),(0,a.eW)(" 或 ",-1),(0,a.Lk)("em",null,"Ctrl + V",-1),(0,a.eW)(" 粘贴上传",-1)])],2)]),_:1},8,["class","http-request","onSuccess","on-error","before-upload","on-progress","file-list"])):(0,a.Q3)("",!0)],32),"paste"===n.uploadMethod?((0,a.uX)(),(0,a.CE)("div",it,[(0,a.bF)(y,{class:(0,i.C4)(["paste-card",{"is-uploading":d.uploading,"upload-card-busy":d.fileList.length}])},{default:(0,a.k6)(()=>[(0,a.bF)(m,{modelValue:d.pastedUrls,"onUpdate:modelValue":t[2]||(t[2]=e=>d.pastedUrls=e),class:"upload-card-textarea",placeholder:"粘贴外链上传,多个外链用换行分隔",type:"textarea",rows:d.fileList.length?4:14},null,8,["modelValue","rows"]),(0,a.Lk)("div",nt,[(0,a.bF)(f,{class:"paste-card-upload-button",type:"primary",size:c.pasteCardMethodButtonSize,onClick:c.handleUploadPasteUrls},{default:(0,a.k6)(()=>[...t[9]||(t[9]=[(0,a.eW)(" 上 传 ",-1)])]),_:1},8,["size","onClick"]),(0,a.bF)(b,{modelValue:d.pasteUploadMethod,"onUpdate:modelValue":t[3]||(t[3]=e=>d.pasteUploadMethod=e),class:"paste-card-method-group",size:c.pasteCardMethodButtonSize},{default:(0,a.k6)(()=>[(0,a.bF)(g,{label:"save"},{default:(0,a.k6)(()=>[...t[10]||(t[10]=[(0,a.eW)("转存",-1)])]),_:1}),(0,a.bF)(g,{label:"external"},{default:(0,a.k6)(()=>[...t[11]||(t[11]=[(0,a.eW)("外链",-1)])]),_:1})]),_:1},8,["modelValue","size"])])]),_:1},8,["class"])])):(0,a.Q3)("",!0),(0,a.bF)(y,{class:(0,i.C4)(["upload-list-card",{"upload-list-busy":d.fileList.length,"is-uploading":d.uploading}])},{default:(0,a.k6)(()=>[(0,a.Lk)("div",{class:(0,i.C4)(["upload-list-container",{"upload-list-busy":d.fileList.length}])},[(0,a.bF)(x,{onScroll:c.handleScroll,ref:"scrollContainer"},{default:(0,a.k6)(()=>[(0,a.Lk)("div",{class:(0,i.C4)(["upload-list-dashboard",{"list-scrolled":d.listScrolled}])},[(0,a.bF)(w,{class:"upload-list-dashboard-title"},{default:(0,a.k6)(()=>[(0,a.bF)(p,null,{default:(0,a.k6)(()=>[(0,a.bF)(k)]),_:1}),(0,a.eW)((0,i.v_)(c.uploadingCount+c.waitingCount)+" ",1),(0,a.bF)(p,null,{default:(0,a.k6)(()=>[(0,a.bF)(C)]),_:1}),(0,a.eW)((0,i.v_)(c.uploadSuccessCount)+" ",1),(0,a.bF)(p,null,{default:(0,a.k6)(()=>[(0,a.bF)(v)]),_:1}),(0,a.eW)((0,i.v_)(c.uploadErrorCount),1)]),_:1}),(0,a.Lk)("div",rt,[(0,a.Lk)("div",dt,[(0,a.bF)(L,{disabled:c.disableTooltip,content:"整体复制",placement:"top"},{default:(0,a.k6)(()=>[(0,a.Lk)("button",{class:"modern-action-btn",onClick:t[4]||(t[4]=(...e)=>c.copyAll&&c.copyAll(...e))},[(0,a.bF)(F,{icon:"copy"})])]),_:1},8,["disabled"]),(0,a.bF)(L,{disabled:c.disableTooltip,content:"失败重试",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)($,null,{dropdown:(0,a.k6)(()=>[(0,a.bF)(S,{class:"modern-dropdown-menu"},{default:(0,a.k6)(()=>[(0,a.bF)(T,null,{default:(0,a.k6)(()=>[(0,a.Lk)("div",ct,[t[12]||(t[12]=(0,a.Lk)("span",null,"自动重试",-1)),(0,a.bF)(U,{modelValue:d.autoReUpload,"onUpdate:modelValue":t[6]||(t[6]=e=>d.autoReUpload=e),onChange:c.handleAutoRetryChange,size:"small"},null,8,["modelValue","onChange"])])]),_:1})]),_:1})]),default:(0,a.k6)(()=>[(0,a.Lk)("button",{class:"modern-action-btn",onClick:t[5]||(t[5]=(...e)=>c.retryError&&c.retryError(...e))},[(0,a.bF)(F,{icon:"redo"})])]),_:1})]),_:1},8,["disabled"]),(0,a.bF)(L,{disabled:c.disableTooltip,content:"清空列表",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)($,null,{dropdown:(0,a.k6)(()=>[(0,a.bF)(S,{class:"modern-dropdown-menu"},{default:(0,a.k6)(()=>[(0,a.bF)(T,{onClick:c.clearFileList},{default:(0,a.k6)(()=>[...t[13]||(t[13]=[(0,a.eW)("清空全部",-1)])]),_:1},8,["onClick"]),(0,a.bF)(T,{onClick:c.clearSuccessList},{default:(0,a.k6)(()=>[...t[14]||(t[14]=[(0,a.eW)("清空已上传",-1)])]),_:1},8,["onClick"])]),_:1})]),default:(0,a.k6)(()=>[(0,a.Lk)("button",ut,[(0,a.bF)(F,{icon:"trash-alt"})])]),_:1})]),_:1},8,["disabled"])])])],2),((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(d.fileList.slice().reverse(),e=>((0,a.uX)(),(0,a.Wv)(M,{key:e.name,file:e,onCopy:c.handleCopy,onRemove:c.handleRemove,onPreviewError:t[7]||(t[7]=e=>e.url=o(6682))},null,8,["file","onCopy","onRemove"]))),128))]),_:1},8,["onScroll"])],2)]),_:1},8,["class"])])}o(6573),o(8100),o(7936),o(116),o(8237),o(9577),o(1549),o(9797),o(9631),o(5623),o(4979),o(4603),o(7566),o(8721);var ht=o(457),mt=o(6334),ft=o(8401);function gt(e,t,o){const s=o+e;return{finalURL:s,mdURL:`![${t}](${s})`,htmlURL:`<img src="${s}" alt="${t}" width=100% />`,ubbURL:`[img]${s}[/img]`}}function bt(e,t){const o={url:e.finalURL,md:e.mdURL,html:e.htmlURL,ubb:e.ubbURL};return o[t]||e.finalURL}function yt(e,t){e.forEach(e=>{if("external"===e.uploadChannel)return;const o=gt(e.srcID,e.name,t);Object.assign(e,o)})}const kt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ct=(e,t)=>e>>>t|e<<32-t;function vt(e,t){const o=new Uint32Array(64);for(let u=0;u<16;u++)o[u]=e[4*u]<<24|e[4*u+1]<<16|e[4*u+2]<<8|e[4*u+3];for(let u=16;u<64;u++){const e=Ct(o[u-15],7)^Ct(o[u-15],18)^o[u-15]>>>3,t=Ct(o[u-2],17)^Ct(o[u-2],19)^o[u-2]>>>10;o[u]=o[u-16]+e+o[u-7]+t>>>0}let[s,l,a,i,n,r,d,c]=t;for(let u=0;u<64;u++){const e=Ct(n,6)^Ct(n,11)^Ct(n,25),t=n&r^~n&d,p=c+e+t+kt[u]+o[u]>>>0,h=Ct(s,2)^Ct(s,13)^Ct(s,22),m=s&l^s&a^l&a,f=h+m>>>0;c=d,d=r,r=n,n=i+p>>>0,i=a,a=l,l=s,s=p+f>>>0}t[0]=t[0]+s>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+a>>>0,t[3]=t[3]+i>>>0,t[4]=t[4]+n>>>0,t[5]=t[5]+r>>>0,t[6]=t[6]+d>>>0,t[7]=t[7]+c>>>0}function wt(){let e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t=new Uint8Array(64),o=0,s=0;return{update(l){s+=l.length;let a=0;if(o>0){const s=64-o,i=Math.min(s,l.length);t.set(l.subarray(0,i),o),o+=i,a=i,64===o&&(vt(t,e),o=0)}while(a+64<=l.length)vt(l.subarray(a,a+64),e),a+=64;a<l.length&&(t.set(l.subarray(a),0),o=l.length-a)},digest(){const l=8*s;t[o++]=128,o>56&&(t.fill(0,o,64),vt(t,e),o=0),t.fill(0,o,56);const a=new DataView(t.buffer);a.setUint32(56,Math.floor(l/4294967296),!1),a.setUint32(60,l>>>0,!1),vt(t,e);let i="";for(let t=0;t<8;t++)i+=e[t].toString(16).padStart(8,"0");return i}}}async function Ft(e){const t=wt(),o=4194304;let s=0;while(s<e.size){const l=e.slice(s,Math.min(s+o,e.size)),a=await l.arrayBuffer();t.update(new Uint8Array(a)),s+=o,s%20971520<o&&console.log(`SHA256 progress: ${Math.min(100,Math.round(s/e.size*100))}%`)}return t.digest()}var Lt={name:"UploadForm",components:{UploadFileItem:et},props:{selectedUrlForm:{type:String,default:"url",required:!1},customerCompress:{type:Boolean,default:!0,required:!1},compressQuality:{type:Number,default:4,required:!1},compressBar:{type:Number,default:5,required:!1},serverCompress:{type:Boolean,default:!0,required:!1},uploadChannel:{type:String,default:"telegram",required:!1},channelName:{type:String,default:"",required:!1},uploadNameType:{type:String,default:"default",required:!1},useCustomUrl:{type:String,default:"false",required:!1},customUrlPrefix:{type:String,default:"",required:!1},autoRetry:{type:Boolean,default:!0,required:!1},urlPrefix:{type:String,default:"",required:!1},uploadMethod:{type:String,default:"default",required:!1},uploadFolder:{type:String,default:"",required:!1},convertToWebp:{type:Boolean,default:!1,required:!1}},data(){return{fileList:[],uploading:!1,maxUploading:6,exceptionList:[],listScrolled:!1,fileListLength:0,uploadCount:0,pastedUrls:"",pasteUploadMethod:"save",autoReUpload:!0,maxRetryCount:10,retryTimer:null,retryDelay:12e3,uploadQueue:[],activeUploads:0,maxConcurrentUploads:6,abortControllers:new Map}},watch:{fileList:{handler(){this.fileList.length>this.fileListLength&&this.$nextTick(()=>{setTimeout(()=>{this.$refs.scrollContainer&&this.$refs.scrollContainer.setScrollTop(0)},100)}),this.fileListLength=this.fileList.length},deep:!0},useCustomUrl:{handler(){yt(this.fileList,this.rootUrl)},immediate:!0},customUrlPrefix:{handler(){"true"===this.useCustomUrl&&yt(this.fileList,this.rootUrl)},immediate:!0},autoReUpload(e){this.$store.commit("setStoreAutoReUpload",e)}},computed:{...(0,ft.L8)(["storeAutoReUpload"]),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.uploadQueue.length},urlSize(){return window.innerWidth<768?"small":"default"},disableTooltip(){return window.innerWidth<768},rootUrl(){return"true"===this.useCustomUrl?this.customUrlPrefix:this.urlPrefix||`${window.location.protocol}//${window.location.host}/file/`},pasteCardMethodButtonSize(){return this.fileList.length||window.innerWidth<768?"small":"medium"}},mounted(){document.addEventListener("paste",this.handlePaste),this.autoReUpload=this.storeAutoReUpload},beforeUnmount(){document.removeEventListener("paste",this.handlePaste),this.uploadQueue=[],this.fileList=[],this.activeUploads=0},methods:{truncateFilename(e,t=20){if(!e||e.length<=t)return e;const o=e.lastIndexOf(".");let s,l;o>0?(s=e.substring(0,o),l=e.substring(o)):(s=e,l="");const a=l.length+4,i=t-a-3;return i<=0?e.substring(0,t-3)+"...":s.substring(0,i)+"..."+s.slice(-4)+l},uploadFile(e){if(!this.fileList.find(t=>t.uid===e.file.uid))return;if(this.activeUploads>=this.maxConcurrentUploads){this.uploadQueue.push(e);const t=this.fileList.find(t=>t.uid===e.file.uid);return void(t&&(t.status="waiting"))}this.activeUploads++;const t=this.fileList.find(t=>t.uid===e.file.uid);t&&(t.status="uploading");const o=this.fileList.find(t=>t.uid===e.file.uid),s=o?.uploadChannel||this.uploadChannel;if("external"===s)return void this.uploadSingleFile(e);if("huggingface"===s){const t=20971520;return void(e.file.size>=t?this.uploadToHuggingFaceDirect(e):this.uploadSingleFile(e))}if("discord"===s){const t=9437184;return void(e.file.size>t?this.uploadFileInChunks(e):this.uploadSingleFile(e))}const l=20971520;e.file.size>l?this.uploadFileInChunks(e):this.uploadSingleFile(e)},processUploadQueue(){if(0===this.uploadQueue.length||this.activeUploads>=this.maxConcurrentUploads)return;const e=this.uploadQueue.shift();e&&this.fileList.find(t=>t.uid===e.file.uid)?this.uploadFile(e):this.processUploadQueue()},onUploadComplete(){this.activeUploads=Math.max(0,this.activeUploads-1),this.processUploadQueue(),0===this.activeUploads&&0===this.uploadQueue.length&&(this.uploading=!1)},async uploadSingleFile(e){const t=this.fileList.find(t=>t.uid===e.file.uid);if(!t)return;const o=t.serverCompress,s=t.uploadChannel||this.uploadChannel,l=this.autoRetry&&"external"!==s,a="external"===s?"default":this.uploadNameType,i=new AbortController;this.abortControllers.set(e.file.uid,i);const n=new FormData;if(n.append("file",e.file),"external"===s&&n.append("url",e.file.url),"huggingface"===s)try{console.log("Computing SHA256 for HuggingFace upload...");const t=await Ft(e.file);n.append("sha256",t),console.log("SHA256 computed:",t)}catch(r){console.error("Failed to compute SHA256:",r)}(0,ht.A)({url:"/upload?serverCompress="+o+"&uploadChannel="+s+(this.channelName?"&channelName="+encodeURIComponent(this.channelName):"")+"&uploadNameType="+a+"&autoRetry="+l+"&uploadFolder="+encodeURIComponent(this.uploadFolder),method:"post",data:n,withAuthCode:!0,signal:i.signal,onUploadProgress:t=>{const o=Math.round(t.loaded/t.total*100);e.onProgress({percent:o,file:e.file})}}).then(t=>{e.onSuccess(t,e.file)}).catch(t=>{"CanceledError"!==t.name&&"ERR_CANCELED"!==t.code?t.response&&401!==t.response.status?(this.exceptionList.push(e),e.onError(t,e.file)):t.response||(this.exceptionList.push(e),e.onError(t,e.file)):console.log("上传已取消:",e.file.name)}).finally(()=>{this.abortControllers.delete(e.file.uid),this.onUploadComplete()})},async uploadFileInChunks(e){const t=this.fileList.find(t=>t.uid===e.file.uid);if(!t)return;const o=t.uploadChannel||this.uploadChannel,s=new AbortController;this.abortControllers.set(e.file.uid,s);const l="discord"===o?9437184:16777216,a=e.file.size,i=Math.ceil(a/l),n=t.serverCompress,r=this.autoRetry&&"external"!==o,d="external"===o?"default":this.uploadNameType;let c=null;if("huggingface"===o)try{console.log("Computing SHA256 for HuggingFace chunked upload..."),c=await Ft(e.file),console.log("SHA256 computed:",c)}catch(u){console.error("Failed to compute SHA256:",u)}try{const t=new FormData;t.append("originalFileName",e.file.name),t.append("originalFileType",e.file.type),t.append("totalChunks",i.toString());const p=await(0,ht.A)({url:"/upload?serverCompress="+n+"&uploadChannel="+o+(this.channelName?"&channelName="+encodeURIComponent(this.channelName):"")+"&uploadNameType="+d+"&autoRetry="+r+"&uploadFolder="+encodeURIComponent(this.uploadFolder)+"&initChunked=true",method:"post",data:t,withAuthCode:!0});if(!p.data.success)throw new Error("初始化分块上传失败: "+p.data.message);const h=p.data.uploadId;console.log("分块上传初始化成功,uploadId:",h);const m=this.fileList.find(t=>t.uid===e.file.uid);m&&(m.totalChunks=i,m.uploadId=h);const f=3,g=new Array(i).fill(0);let b=0,y=!1,k="",C=!1;const v=async t=>{if(y||C)return;const c=t*l,p=Math.min(c+l,a),m=e.file.slice(c,p),f=new FormData;f.append("file",m,`${e.file.name}.part${t.toString().padStart(3,"0")}`),f.append("chunkIndex",t.toString()),f.append("totalChunks",i.toString()),f.append("uploadId",h),f.append("originalFileName",e.file.name),f.append("originalFileType",e.file.type);let b=0;const v=3;while(b<v){if(y||C)return;try{return void await(0,ht.A)({url:"/upload?serverCompress="+n+"&uploadChannel="+o+(this.channelName?"&channelName="+encodeURIComponent(this.channelName):"")+"&uploadNameType="+d+"&autoRetry="+r+"&uploadFolder="+encodeURIComponent(this.uploadFolder)+"&chunked=true",method:"post",data:f,withAuthCode:!0,signal:s.signal,onUploadProgress:o=>{if(y||C)return;const s=Math.round(o.loaded/o.total*100);g[t]=s;const l=Math.round(g.reduce((e,t)=>e+t,0)/i);e.onProgress({percent:l,file:e.file})}})}catch(u){if("CanceledError"===u.name||"ERR_CANCELED"===u.code)return C=!0,void console.log("分块上传已取消:",e.file.name);if(b++,console.warn(`分块 ${t+1}/${i} 上传失败 (重试 ${b}/${v}):`,u),b>=v)throw y=!0,k=`分块 ${t+1}/${i} 上传失败: ${u.message}`,new Error(k);await new Promise(e=>setTimeout(e,2e3*b))}}},w=[];for(let e=0;e<f;e++)w.push((async()=>{while(b<i&&!y&&!C){const t=b++;try{await v(t)}catch(e){C||(y=!0,k=e.message);break}}})());if(await Promise.all(w),C)return void console.log("分块上传已取消,跳过合并步骤");if(y)throw new Error(k||"上传过程中发生错误");this.$message({type:"info",message:"分块上传完成,正在合并文件,请耐心等待...",duration:0});const F=new FormData;F.append("uploadId",h),F.append("totalChunks",i.toString()),F.append("originalFileName",e.file.name),F.append("originalFileType",e.file.type),c&&F.append("sha256",c);const L=await(0,ht.A)({url:"/upload?serverCompress="+n+"&uploadChannel="+o+(this.channelName?"&channelName="+encodeURIComponent(this.channelName):"")+"&uploadNameType="+d+"&autoRetry="+r+"&uploadFolder="+encodeURIComponent(this.uploadFolder)+"&chunked=true&merge=true",method:"post",data:F,withAuthCode:!0});this.$message.closeAll(),e.onSuccess(L,e.file)}catch(u){if("CanceledError"===u.name||"ERR_CANCELED"===u.code)return void console.log("分块上传已取消:",e.file.name);console.error("分块上传失败:",u);const t=this.fileList.find(t=>t.uid===e.file.uid);t&&t.uploadId&&this.cleanupUploadResources(t.uploadId,t.totalChunks).then(()=>{console.log(`已清理分块上传失败的资源: ${t.uploadId}`)}).catch(e=>{console.warn("清理分块上传失败资源时出错:",e)}),u.response&&401!==u.response.status?(this.exceptionList.push(e),e.onError(u,e.file)):u.response||(this.exceptionList.push(e),e.onError(u,e.file))}finally{this.abortControllers.delete(e.file.uid),this.onUploadComplete()}},handleRemove(e){this.abortControllers.has(e.uid)&&(this.abortControllers.get(e.uid).abort(),this.abortControllers.delete(e.uid)),this.uploadQueue=this.uploadQueue.filter(t=>t.file.uid!==e.uid),this.fileList=this.fileList.filter(t=>t.uid!==e.uid),this.$message({type:"info",message:this.truncateFilename(e.name)+"已删除"})},async cleanupUploadResources(e,t=0){try{await(0,ht.A)({url:`/upload?cleanup=true&uploadId=${e}&totalChunks=${t}`,method:"get",withAuthCode:!0,timeout:5e3}),console.log(`清理上传资源成功: ${e}`)}catch(o){console.warn("清理上传资源失败:",o)}},handleSuccess(e,t){const o=this.fileList.find(e=>e.uid===t.uid);if(o)try{const s=o.uploadChannel||this.uploadChannel;if("external"!==s){const s=e.data[0].src.replace("/file/","");o.url=`${window.location.protocol}//${window.location.host}/file/`+s;const l=gt(s,t.name,this.rootUrl);Object.assign(o,l),o.srcID=s}o.progreess=100,o.status="success",this.saveToHistory(o),this.$message({type:"success",message:this.truncateFilename(t.name)+"上传成功"}),setTimeout(()=>{const e=this.fileList.find(e=>e.uid===t.uid);e&&(e.status="done")},1e3)}catch(s){this.$message.error(this.truncateFilename(t.name)+"上传失败"),o.status="exception"}},saveToHistory(e){try{const t=JSON.parse(localStorage.getItem("uploadHistory")||"[]"),o={name:e.name,url:e.finalURL,time:Date.now(),type:e.name.split(".").pop().toLowerCase()};t.push(o),localStorage.setItem("uploadHistory",JSON.stringify(t))}catch(t){console.error("Failed to save history",t)}},handleError(e,t){const o=this.fileList.find(e=>e.uid===t.uid);o&&(this.$message.error(this.truncateFilename(t.name)+"上传失败"),o.status="exception",this.autoReUpload&&this.scheduleAutoRetry())},handleCopy(e){const t=this.fileList.find(t=>t.uid===e.uid).status;"done"===t||"success"===t?(navigator.clipboard.writeText(bt(e,this.selectedUrlForm)),this.$message({type:"success",message:"复制成功"})):this.$message({type:"warning",message:"文件未上传成功,无法复制链接"})},beforeUpload(e){return new Promise(async(t,o)=>{let s=e;const l=this.convertToWebp&&e.type.includes("image")&&!e.type.includes("webp")&&!e.type.includes("gif")&&!e.type.includes("svg");if(l)try{const t=await this.convertImageToWebp(e);t&&(s=t,console.log(`WebP转换成功: ${e.name} -> ${t.name}, 大小: ${(e.size/1024).toFixed(1)}KB -> ${(t.size/1024).toFixed(1)}KB`))}catch(r){console.warn("WebP转换失败,使用原文件:",r)}const a=s.type.includes("image")&&this.customerCompress&&s.size/1024/1024>this.compressBar,i=s.size/1024/1024<=1024||"telegram"!==this.uploadChannel,n=(e,o)=>{const s=URL.createObjectURL(e);this.fileList.push({uid:e.uid,name:e.name,url:s,finalURL:"",mdURL:"",htmlURL:"",ubbURL:"",srcID:"",status:"uploading",progreess:0,serverCompress:o,retryCount:0}),t(e)};if(a)mt.compressAccurately(s,1024*this.compressQuality).then(t=>{t.size/1024/1024>1024&&"telegram"===this.uploadChannel&&(this.$message.error(s.name+"压缩后文件过大,无法上传!"),o("文件过大")),this.uploading=!0;const l=new File([t],s.name,{type:t.type});l.uid=e.uid;const a=this.uploadCount++,i=this.serverCompress&&l.size/1024/1024<10&&"telegram"===this.uploadChannel;0===a?n(l,i):setTimeout(()=>{n(l,i),this.uploadCount--},300*a)}).catch(e=>{this.$message.error(s.name+"压缩失败,无法上传!"),o(e)});else if(i){this.uploading=!0;const e=this.uploadCount++,t="telegram"===this.uploadChannel&&this.serverCompress&&(!s.type.includes("image")||s.size/1024/1024<10);0===e?n(s,t):setTimeout(()=>{n(s,t),this.uploadCount--},300*e)}else this.$message.error(s.name+"文件过大,无法上传!"),o("文件过大")})},handleProgress(e){const t=this.fileList.find(t=>t.uid===e.file.uid);t&&(t.progreess=e.percent)},copyAll(){const e=this.fileList.filter(e=>"done"===e.status||"success"===e.status).map(e=>bt(e,this.selectedUrlForm)).join("\n");navigator.clipboard.writeText(e),this.$message({type:"success",message:"整体复制成功"})},clearFileList(){this.fileList.length>0?(this.abortControllers.forEach((e,t)=>{e.abort()}),this.abortControllers.clear(),this.uploadQueue=[],this.fileList=[],this.$message({type:"success",message:"文件列表已清空"})):this.$message({type:"info",message:"文件列表为空"})},clearSuccessList(){this.uploadSuccessCount>0?(this.fileList=this.fileList.filter(e=>"done"!==e.status&&"success"!==e.status),this.$message({type:"success",message:"成功上传文件已清空"})):this.$message({type:"info",message:"成功上传文件为空"})},handlePaste(e){if("INPUT"===e.target.tagName||"TEXTAREA"===e.target.tagName)return;const t=e.clipboardData.items;t.length>0&&this.uploadFromUrl(t)},handleUploadPasteUrls(){const e=this.pastedUrls.split("\n"),t=e.map(e=>e.trim()).filter(e=>""!==e).filter(e=>/^(https?:\/\/[^\s$.?#].[^\s]*)$/.test(e));if("save"===this.pasteUploadMethod)this.uploadFromUrl(t.map(e=>({kind:"string",getAsString:t=>{t(e)}})));else if("external"===this.pasteUploadMethod)for(let o=0;o<t.length;o++){const e=t[o],s=e.split("/").pop(),l=`![${s}](${e})`,a=`<img src="${e}" alt="${s}" width=100% />`,i=`[img]${e}[/img]`,n=new File([],e.split("/").pop(),{type:"text/plain"});n.uid=Date.now()+o,n.url=e,this.fileList.push({uid:n.uid,name:n.name,url:e,finalURL:e,mdURL:l,htmlURL:a,ubbURL:i,srcID:e,status:"uploading",progreess:0,serverCompress:!1,uploadChannel:"external",retryCount:0}),this.uploadFile({file:n,onProgress:e=>this.handleProgress(e),onSuccess:(e,t)=>this.handleSuccess(e,t),onError:(e,t)=>this.handleError(e,t)})}},uploadFromUrl(e){for(let t=0;t<e.length;t++)if("file"===e[t].kind){const o=e[t].getAsFile();o.uid=Date.now()+t;const s=this.beforeUpload(o);s instanceof Promise&&s.then(e=>{e instanceof File&&this.uploadFile({file:e,onProgress:e=>this.handleProgress(e),onSuccess:(e,t)=>this.handleSuccess(e,t),onError:(e,t)=>this.handleError(e,t)})}).catch(e=>{console.log(e)})}else"string"===e[t].kind&&e[t].getAsString(e=>{const o=/^(https?:\/\/[^\s$.?#].[^\s]*)$/;let s="";o.test(e)&&ht.A.post("/api/fetchRes",{url:e},{responseType:"blob",withAuthCode:!0}).then(o=>{o.headers["content-type"];if(200!=o.status)throw new Error("URL地址请求失败");{const a=o.headers["content-disposition"];if(a){const e=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/,t=/filename\*\s*=\s*UTF-8''([^;\n]*)/;let o=e.exec(a);if(null!=o&&o[1]){s=o[1].replace(/['"]/g,"");try{s=decodeURIComponent(s)}catch(l){s=""}}""===s&&(o=t.exec(a),null!=o&&o[1]&&(s=decodeURIComponent(o[1])))}if(""===s){const t=new URL(e);s=t.pathname.split("/").pop()}if(""===s){const o=new URL(e);let l=o.pathname.split(".").pop();(!l||""===l||l.length>10)&&(l="bin"),s="PastedFile"+Date.now()+t+"."+l}const i=o.data,n=new File([i],s,{type:i.type});n.uid=Date.now()+t;const r=this.beforeUpload(n);r instanceof Promise&&r.then(e=>{e instanceof File&&this.uploadFile({file:e,onProgress:e=>this.handleProgress(e),onSuccess:(e,t)=>this.handleSuccess(e,t),onError:(e,t)=>this.handleError(e,t)})}).catch(e=>{console.log(e)})}}).catch(e=>{this.$message({type:"warning",message:"粘贴板中的URL地址请求失败"})})})},handleScroll(e){this.listScrolled=e.scrollTop>0&&this.fileList.length>0},retryError(){this.exceptionList.length>0?(this.retryFailedFiles(this.exceptionList),this.exceptionList=[]):this.$message({type:"info",message:"无上传失败文件"})},handleAutoRetryChange(e){this.$message({type:e?"success":"info",message:e?"自动重试已开启":"自动重试已关闭"}),e&&this.exceptionList.length>0&&this.scheduleAutoRetry()},retryFailedFiles(e){e.forEach(e=>{const t=e.retryCount||0;t<this.maxRetryCount?(e.retryCount=t+1,this.uploadFile({file:e.file,onProgress:e=>this.handleProgress(e),onSuccess:(e,t)=>this.handleSuccess(e,t),onError:(e,t)=>this.handleError(e,t)})):this.$message({type:"warning",message:`${e.name} 已达到最大重试次数(${this.maxRetryCount}),停止重试`})})},scheduleAutoRetry(){this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{if(this.autoReUpload&&this.exceptionList.length>0){const e=[...this.exceptionList];this.exceptionList=[],this.retryFailedFiles(e)}},this.retryDelay)},async uploadToHuggingFaceDirect(e){const t=this.fileList.find(t=>t.uid===e.file.uid);if(!t)return;const o=new AbortController;this.abortControllers.set(e.file.uid,o);try{console.log("=== HuggingFace Direct Upload ==="),console.log("File:",e.file.name,"Size:",e.file.size),e.onProgress({percent:5,file:e.file}),console.log("Computing SHA256...");const t=await Ft(e.file);if(console.log("SHA256:",t),o.signal.aborted)return void console.log("HuggingFace 上传已取消:",e.file.name);const s=new Uint8Array(await e.file.slice(0,512).arrayBuffer()),l=btoa(String.fromCharCode(...s));e.onProgress({percent:10,file:e.file}),console.log("Getting LFS upload URL...");const a=await(0,ht.A)({url:"/upload/huggingface/getUploadUrl",method:"post",data:{fileSize:e.file.size,fileName:e.file.name,fileType:e.file.type,sha256:t,fileSample:l,channelName:this.channelName,uploadNameType:this.uploadNameType,uploadFolder:this.uploadFolder},withAuthCode:!0,signal:o.signal});if(!a.data.success)throw new Error(a.data.error||"Failed to get upload URL");const i=a.data;if(console.log("Upload info:",i),i.alreadyExists)console.log("File already exists in LFS, skipping upload"),e.onProgress({percent:90,file:e.file});else if(i.needsLfs&&i.uploadAction){const{href:t,header:s}=i.uploadAction;if(s?.chunk_size)await this.uploadToHuggingFaceMultipart(e,i,o);else{console.log("Uploading to S3 (basic)...");const l=await fetch(t,{method:"PUT",headers:s||{},body:e.file,signal:o.signal});if(!l.ok){const e=await l.text();throw new Error(`S3 upload failed: ${l.status} - ${e}`)}console.log("S3 upload complete")}}if(o.signal.aborted)return void console.log("HuggingFace 上传已取消:",e.file.name);e.onProgress({percent:95,file:e.file}),console.log("Committing file...");const n=await(0,ht.A)({url:"/upload/huggingface/commitUpload",method:"post",data:{fullId:i.fullId,filePath:i.filePath,sha256:t,fileSize:e.file.size,fileName:e.file.name,fileType:e.file.type,channelName:i.channelName},withAuthCode:!0,signal:o.signal});if(!n.data.success)throw new Error(n.data.error||"Failed to commit file");console.log("Upload complete:",n.data);const r={data:[{src:n.data.src}]};e.onSuccess(r,e.file)}catch(s){if("CanceledError"===s.name||"ERR_CANCELED"===s.code||"AbortError"===s.name)return void console.log("HuggingFace 上传已取消:",e.file.name);console.error("HuggingFace direct upload error:",s),this.exceptionList.push(e),e.onError(s,e.file)}finally{this.abortControllers.delete(e.file.uid),this.onUploadComplete()}},async uploadToHuggingFaceMultipart(e,t,o){const{uploadAction:s}=t,{href:l,header:a}=s,i=parseInt(a.chunk_size),n=Object.keys(a).filter(e=>/^[0-9]+$/.test(e));console.log(`Multipart upload: ${n.length} parts, chunk size: ${i}`);const r=[],d=n.length;for(const u of n){if(o&&o.signal.aborted)throw console.log("HuggingFace 分片上传已取消"),new DOMException("Upload cancelled","AbortError");const t=parseInt(u)-1,s=t*i,l=Math.min(s+i,e.file.size),n=e.file.slice(s,l);console.log(`Uploading part ${u}/${d}`);const c=await fetch(a[u],{method:"PUT",body:n,signal:o?o.signal:void 0});if(!c.ok)throw new Error(`Failed to upload part ${u}: ${c.status}`);const p=c.headers.get("ETag");if(!p)throw new Error(`No ETag for part ${u}`);r.push({partNumber:parseInt(u),etag:p});const h=10+Math.round(parseInt(u)/d*80);e.onProgress({percent:h,file:e.file})}if(o&&o.signal.aborted)throw console.log("HuggingFace 分片上传已取消"),new DOMException("Upload cancelled","AbortError");console.log("Completing multipart upload...");const c=await fetch(l,{method:"POST",headers:{Accept:"application/vnd.git-lfs+json","Content-Type":"application/vnd.git-lfs+json"},body:JSON.stringify({oid:t.oid,parts:r}),signal:o?o.signal:void 0});if(!c.ok){const e=await c.text();throw new Error(`Multipart complete failed: ${c.status} - ${e}`)}console.log("Multipart upload complete")},async convertImageToWebp(e){return new Promise((t,o)=>{if(e.type.includes("gif")||e.type.includes("svg")||e.type.includes("webp"))return void t(null);const s=new Image,l=document.createElement("canvas"),a=l.getContext("2d");s.onload=()=>{l.width=s.width,l.height=s.height,a.drawImage(s,0,0),l.toBlob(l=>{if(l){const o=e.name,s=o.lastIndexOf("."),a=s>0?o.substring(0,s)+".webp":o+".webp",i=new File([l],a,{type:"image/webp"});i.uid=e.uid,t(i)}else o(new Error("WebP 转换失败"));URL.revokeObjectURL(s.src)},"image/webp",.92)},s.onerror=()=>{URL.revokeObjectURL(s.src),o(new Error("图片加载失败"))},s.src=URL.createObjectURL(e)})},handleUploadCardMouseMove(e){const t=this.$refs.uploadCardGlow;if(!t)return;const o=e.currentTarget.getBoundingClientRect(),s=e.clientX-o.left,l=e.clientY-o.top;t.style.opacity="1",t.style.left=s+"px",t.style.top=l+"px"},handleUploadCardMouseLeave(){const e=this.$refs.uploadCardGlow;e&&(e.style.opacity="0")}},beforeDestroy(){this.retryTimer&&clearTimeout(this.retryTimer)}};const Ut=(0,V.A)(Lt,[["render",pt],["__scopeId","data-v-a12d47f4"]]);var Tt=Ut,St=o(732),$t=o(2224),Mt=o(4453);const xt={class:"container"},_t={class:"upload-home"},Rt={href:"https://cfbed.sanyue.de/qa/",target:"_blank",class:"info-container"},Et={class:"toolbar-manage"},At={class:"toolbar"},Nt={class:"header"},It={class:"title"},Pt={class:"main-title",href:"https://github.com/MarSeventh/CloudFlare-ImgBed",target:"_blank"},Dt={class:"dialog-section"},Wt={class:"section-content"},zt={class:"dialog-section"},Vt={class:"section-header"},Bt={class:"section-content"},Ht={class:"setting-item"},Xt={key:0,class:"setting-item"},Qt={class:"dialog-action"},jt=["innerHTML"],Ot={class:"dialog-footer"};function qt(e,t,o,n,r,d){const c=Mt.A,u=(0,a.g2)("font-awesome-icon"),p=s.R7,h=G.WK,m=l.S2,f=$t.A,g=tt.c6,b=tt.Iy,y=tt.dW,k=St.A,C=Tt,v=J.ll,w=J.MQ,F=q.qi,L=Q.kZ,U=xe,T=X.A,S=H;return(0,a.uX)(),(0,a.CE)("div",xt,[(0,a.Lk)("div",_t,[(0,a.bF)(c,{class:"toggle-dark-button desktop-only"}),(0,a.bF)(p,{content:"查看文档",placement:"bottom",disabled:d.disableTooltip},{default:(0,a.k6)(()=>[(0,a.Lk)("a",Rt,[(0,a.bF)(u,{icon:"book",class:"info-icon",size:"lg"})])]),_:1},8,["disabled"]),(0,a.Lk)("div",{class:(0,i.C4)(["upload-folder-container",{"no-announcement":!d.announcementAvailable}])},[(0,a.bF)(h,{class:(0,i.C4)(["upload-folder",{active:r.isFolderInputActive}]),modelValue:r.uploadFolder,"onUpdate:modelValue":t[0]||(t[0]=e=>r.uploadFolder=e),placeholder:"上传目录",onFocus:t[1]||(t[1]=e=>r.isFolderInputActive=!0),onBlur:d.handleFolderInputBlur},null,8,["class","modelValue","onBlur"]),d.showDirectorySuggestions?((0,a.uX)(),(0,a.Wv)(f,{key:0,"current-directory":r.uploadFolder,source:"upload",onSelect:d.handleDirectorySelect},{trigger:(0,a.k6)(()=>[(0,a.bF)(p,{content:"选择目录",placement:"bottom",disabled:d.disableTooltip},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:"directory-picker-trigger"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"folder-tree",size:"lg"})]),_:1})]),_:1},8,["disabled"])]),_:1},8,["current-directory","onSelect"])):(0,a.Q3)("",!0)],2),(0,a.bF)(p,{content:"切换上传方式",placement:"bottom",disabled:d.disableTooltip},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:"upload-method-button desktop-only",onClick:d.handleChangeUploadMethod},{default:(0,a.k6)(()=>["default"===r.uploadMethod?((0,a.uX)(),(0,a.Wv)(u,{key:0,icon:"folder-open",class:"upload-method-icon",size:"lg"})):"paste"===r.uploadMethod?((0,a.uX)(),(0,a.Wv)(u,{key:1,icon:"paste",class:"upload-method-icon",size:"lg"})):(0,a.Q3)("",!0)]),_:1},8,["onClick"])]),_:1},8,["disabled"]),(0,a.bF)(p,{content:"上传记录",placement:"bottom",disabled:d.disableTooltip},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:"history-button desktop-only",onClick:t[2]||(t[2]=e=>r.showHistory=!0)},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"history",class:"history-icon",size:"lg"})]),_:1})]),_:1},8,["disabled"]),d.announcementAvailable?((0,a.uX)(),(0,a.Wv)(p,{key:0,content:"查看公告",placement:"bottom",disabled:d.disableTooltip},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:"announcement-button desktop-only",onClick:d.handleShowAnnouncement},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"bullhorn",class:"announcement-icon",size:"lg"})]),_:1},8,["onClick"])]),_:1},8,["disabled"])):(0,a.Q3)("",!0),(0,a.bF)(y,{class:"mobile-more-dropdown mobile-only",trigger:"click",onCommand:d.handleMobileMenuCommand},{dropdown:(0,a.k6)(()=>[(0,a.bF)(b,null,{default:(0,a.k6)(()=>[(0,a.bF)(g,{command:"toggleTheme"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:d.getThemeIcon(),style:{"margin-right":"8px"}},null,8,["icon"]),(0,a.eW)(" "+(0,i.v_)(d.getThemeText()),1)]),_:1}),(0,a.bF)(g,{command:"toggleUploadMethod"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"default"===r.uploadMethod?"paste":"folder-open",style:{"margin-right":"8px"}},null,8,["icon"]),(0,a.eW)(" "+(0,i.v_)("default"===r.uploadMethod?"粘贴上传":"文件上传"),1)]),_:1}),(0,a.bF)(g,{command:"showHistory"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"history",style:{"margin-right":"8px"}}),t[22]||(t[22]=(0,a.eW)(" 上传记录 ",-1))]),_:1}),(0,a.bF)(g,{command:"showAnnouncement",disabled:!d.announcementAvailable},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"bullhorn",style:{"margin-right":"8px"}}),t[23]||(t[23]=(0,a.eW)(" 查看公告 ",-1))]),_:1},8,["disabled"])]),_:1})]),default:(0,a.k6)(()=>[(0,a.bF)(m,{class:"mobile-more-button"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"ellipsis-v",size:"lg"})]),_:1})]),_:1},8,["onCommand"]),(0,a.Lk)("div",Et,[(0,a.bF)(m,{class:(0,i.C4)(["toolbar-manage-button",{active:r.isToolBarOpen}]),size:"large",onClick:d.handleOpenToolbar,circle:""},{default:(0,a.k6)(()=>[r.isToolBarOpen?((0,a.uX)(),(0,a.Wv)(u,{key:1,icon:"times",class:"manage-icon",size:"lg"})):((0,a.uX)(),(0,a.Wv)(u,{key:0,icon:"bars",class:"manage-icon",size:"lg"}))]),_:1},8,["class","onClick"])]),(0,a.Lk)("div",At,[(0,a.bF)(p,{disabled:d.disableTooltip,content:"上传设置",placement:"top"},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:(0,i.C4)(["toolbar-button compress-button",{active:r.isToolBarOpen}]),size:"large",onClick:d.openCompressDialog,circle:""},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"cloud-upload",class:"compress-icon",size:"lg"})]),_:1},8,["class","onClick"])]),_:1},8,["disabled"]),(0,a.bF)(p,{disabled:d.disableTooltip,content:"链接格式",placement:"left"},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:(0,i.C4)(["toolbar-button link-button",{active:r.isToolBarOpen}]),size:"large",onClick:d.openUrlDialog,circle:""},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"link",class:"link-icon",size:"lg"})]),_:1},8,["class","onClick"])]),_:1},8,["disabled"]),(0,a.bF)(p,{disabled:d.disableTooltip,content:"系统管理",placement:"left"},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:(0,i.C4)(["toolbar-button config-button",{active:r.isToolBarOpen}]),size:"large",onClick:d.handleManage,circle:""},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"cog",class:"config-icon",size:"lg"})]),_:1},8,["class","onClick"])]),_:1},8,["disabled"]),(0,a.bF)(p,{disabled:d.disableTooltip,content:"退出登录",placement:"left"},{default:(0,a.k6)(()=>[(0,a.bF)(m,{class:(0,i.C4)(["toolbar-button sign-out-button",{active:r.isToolBarOpen}]),size:"large",onClick:d.handleLogout,circle:""},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"sign-out-alt",class:"sign-out-icon",size:"lg"})]),_:1},8,["class","onClick"])]),_:1},8,["disabled"])]),(0,a.bF)(k,{useConfigLink:!0}),(0,a.Lk)("div",Nt,[(0,a.Lk)("h1",It,[(0,a.Lk)("a",Pt,(0,i.v_)(d.ownerName),1),t[24]||(t[24]=(0,a.eW)(" ImgHub",-1))])]),(0,a.bF)(C,{selectedUrlForm:r.selectedUrlForm,customerCompress:r.customerCompress,compressQuality:r.compressQuality,compressBar:r.compressBar,serverCompress:r.serverCompress,uploadChannel:r.uploadChannel,channelName:r.channelName,uploadNameType:r.uploadNameType,useCustomUrl:r.useCustomUrl,customUrlPrefix:r.customUrlPrefix,autoRetry:r.autoRetry,urlPrefix:d.urlPrefix,uploadMethod:r.uploadMethod,uploadFolder:r.uploadFolder,convertToWebp:r.convertToWebp,class:"upload"},null,8,["selectedUrlForm","customerCompress","compressQuality","compressBar","serverCompress","uploadChannel","channelName","uploadNameType","useCustomUrl","customUrlPrefix","autoRetry","urlPrefix","uploadMethod","uploadFolder","convertToWebp"]),(0,a.bF)(L,{title:"链接格式设置",modelValue:r.showUrlDialog,"onUpdate:modelValue":t[7]||(t[7]=e=>r.showUrlDialog=e),width:d.dialogWidth,"show-close":!1,class:"settings-dialog"},{default:(0,a.k6)(()=>[(0,a.Lk)("div",Dt,[t[29]||(t[29]=(0,a.Lk)("div",{class:"section-header"},[(0,a.Lk)("span",{class:"section-title"},"默认复制链接")],-1)),(0,a.Lk)("div",Wt,[(0,a.bF)(w,{modelValue:r.selectedUrlForm,"onUpdate:modelValue":t[3]||(t[3]=e=>r.selectedUrlForm=e),onChange:d.changeUrlForm,class:"radio-card-group grid-2x2"},{default:(0,a.k6)(()=>[(0,a.bF)(v,{value:"url",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"link",class:"radio-icon"}),t[25]||(t[25]=(0,a.Lk)("span",null,"原始链接",-1))]),_:1}),(0,a.bF)(v,{value:"md",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"code",class:"radio-icon"}),t[26]||(t[26]=(0,a.Lk)("span",null,"MarkDown",-1))]),_:1}),(0,a.bF)(v,{value:"html",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"code-branch",class:"radio-icon"}),t[27]||(t[27]=(0,a.Lk)("span",null,"HTML",-1))]),_:1}),(0,a.bF)(v,{value:"ubb",class:"radio-card"},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"quote-right",class:"radio-icon"}),t[28]||(t[28]=(0,a.Lk)("span",null,"BBCode",-1))]),_:1})]),_:1},8,["modelValue","onChange"])])]),(0,a.Lk)("div",zt,[(0,a.Lk)("div",Vt,[t[30]||(t[30]=(0,a.Lk)("span",{class:"section-title"},"自定义链接",-1)),(0,a.bF)(p,{content:"默认链接为https://your.domain/file/xxx.jpg <br> 如果启用自定义链接格式,只保留xxx.jpg部分,其他部分请自行输入",placement:"top","raw-content":""},{default:(0,a.k6)(()=>[(0,a.bF)(u,{icon:"question-circle",class:"section-help-icon"})]),_:1})]),(0,a.Lk)("div",Bt,[(0,a.Lk)("div",Ht,[t[31]||(t[31]=(0,a.Lk)("span",{class:"setting-label"},"启用自定义",-1)),(0,a.bF)(F,{modelValue:r.useCustomUrl,"onUpdate:modelValue":t[4]||(t[4]=e=>r.useCustomUrl=e),"active-value":"true","inactive-value":"false"},null,8,["modelValue"])]),"true"===r.useCustomUrl?((0,a.uX)(),(0,a.CE)("div",Xt,[t[32]||(t[32]=(0,a.Lk)("span",{class:"setting-label"},"自定义前缀",-1)),(0,a.bF)(h,{modelValue:r.customUrlPrefix,"onUpdate:modelValue":t[5]||(t[5]=e=>r.customUrlPrefix=e),placeholder:"请输入自定义链接前缀",class:"setting-input"},null,8,["modelValue"])])):(0,a.Q3)("",!0)])]),(0,a.Lk)("div",Qt,[(0,a.bF)(m,{type:"primary",onClick:t[6]||(t[6]=e=>r.showUrlDialog=!1),class:"confirm-btn"},{default:(0,a.k6)(()=>[...t[33]||(t[33]=[(0,a.eW)("确定",-1)])]),_:1})])]),_:1},8,["modelValue","width"]),(0,a.bF)(U,{modelValue:r.showCompressDialog,"onUpdate:modelValue":t[8]||(t[8]=e=>r.showCompressDialog=e),uploadChannel:r.uploadChannel,"onUpdate:uploadChannel":t[9]||(t[9]=e=>r.uploadChannel=e),channelName:r.channelName,"onUpdate:channelName":t[10]||(t[10]=e=>r.channelName=e),currentChannelList:d.currentChannelList,uploadFolder:r.uploadFolder,"onUpdate:uploadFolder":t[11]||(t[11]=e=>r.uploadFolder=e),autoRetry:r.autoRetry,"onUpdate:autoRetry":t[12]||(t[12]=e=>r.autoRetry=e),uploadNameType:r.uploadNameType,"onUpdate:uploadNameType":t[13]||(t[13]=e=>r.uploadNameType=e),convertToWebp:r.convertToWebp,"onUpdate:convertToWebp":t[14]||(t[14]=e=>r.convertToWebp=e),customerCompress:r.customerCompress,"onUpdate:customerCompress":t[15]||(t[15]=e=>r.customerCompress=e),compressBar:r.compressBar,"onUpdate:compressBar":t[16]||(t[16]=e=>r.compressBar=e),compressQuality:r.compressQuality,"onUpdate:compressQuality":t[17]||(t[17]=e=>r.compressQuality=e),serverCompress:r.serverCompress,"onUpdate:serverCompress":t[18]||(t[18]=e=>r.serverCompress=e)},null,8,["modelValue","uploadChannel","channelName","currentChannelList","uploadFolder","autoRetry","uploadNameType","convertToWebp","customerCompress","compressBar","compressQuality","serverCompress"])]),(0,a.bF)(T,{class:"footer"}),(0,a.bF)(L,{title:"公告",modelValue:r.showAnnouncementDialog,"onUpdate:modelValue":t[20]||(t[20]=e=>r.showAnnouncementDialog=e),width:d.dialogWidth,"show-close":!1,"close-on-click-modal":!1,"close-on-press-escape":!1,center:""},{footer:(0,a.k6)(()=>[(0,a.Lk)("span",Ot,[(0,a.bF)(m,{type:"primary",onClick:t[19]||(t[19]=e=>r.showAnnouncementDialog=!1)},{default:(0,a.k6)(()=>[...t[34]||(t[34]=[(0,a.eW)("我已知晓!",-1)])]),_:1})])]),default:(0,a.k6)(()=>[(0,a.Lk)("div",{innerHTML:r.announcementContent},null,8,jt)]),_:1},8,["modelValue","width"]),(0,a.bF)(S,{show:r.showHistory,onClose:t[21]||(t[21]=e=>r.showHistory=!1)},null,8,["show"])])}o(3579);var Gt=o(8903),Kt=o(144),Jt=o(4570),Yt=o.n(Jt),Zt=o(2388),eo={name:"UploadHome",mixins:[Gt.A],data(){return{selectedUrlForm:(0,Kt.KR)(""),showUrlDialog:!1,showCompressDialog:!1,customerCompress:!0,compressQuality:4,compressBar:5,convertToWebp:!1,serverCompress:!0,uploadChannel:"",channelName:"",availableChannels:{},uploadNameType:"",customUrlPrefix:"",useCustomUrl:"false",autoRetry:!0,useDefaultWallPaper:!1,isToolBarOpen:!1,uploadMethod:"default",uploadFolder:"",isFolderInputActive:!1,showAnnouncementDialog:!1,announcementContent:"",showHistory:!1,themeMode:"auto"}},watch:{customerCompress(e){this.updateCompressConfig("customerCompress",e)},compressQuality(e){this.updateCompressConfig("compressQuality",e)},compressBar(e){null===e||void 0===e||e<1?this.compressBar=1:(this.compressQuality>e&&(this.compressQuality=e),this.updateCompressConfig("compressBar",e))},serverCompress(e){this.updateCompressConfig("serverCompress",e)},convertToWebp(e){this.updateCompressConfig("convertToWebp",e)},uploadChannel(e){this.updateStoreUploadChannel(e);const t=this.availableChannels[e]||[],o=this.storeChannelName;o&&t.some(e=>e.name===o)?this.channelName=o:this.channelName=""},channelName(e){this.$store.commit("setStoreChannelName",e||"")},uploadNameType(e){this.updateStoreUploadNameType(e)},customUrlPrefix(e){this.$store.commit("setCustomUrlSettings",{key:"customUrlPrefix",value:e})},useCustomUrl(e){this.$store.commit("setCustomUrlSettings",{key:"useCustomUrl",value:e})},autoRetry(e){this.$store.commit("setStoreAutoRetry",e)},uploadFolder(e){if(this.validateUploadFolder(e,!1)){const t=(0,Zt.G)(e,{strict:!0});t.valid&&this.$store.commit("setStoreUploadFolder",e)}else this.$nextTick(()=>{this.uploadFolder=this.storeUploadFolder})}},computed:{...(0,ft.L8)(["userConfig","uploadCopyUrlForm","compressConfig","storeUploadChannel","storeChannelName","storeUploadNameType","customUrlSettings","storeAutoRetry","storeUploadMethod","storeUploadFolder"]),ownerName(){return this.userConfig?.ownerName||"Sanyue"},dialogWidth(){return window.innerWidth>768?"50%":"90%"},disableTooltip(){return window.innerWidth<768},urlPrefix(){return this.userConfig?.urlPrefix||`${window.location.protocol}//${window.location.host}/file/`},announcementAvailable(){return!!this.userConfig?.announcement},showDirectorySuggestions(){return this.userConfig?.showDirectorySuggestions??!1},currentChannelList(){return this.availableChannels[this.uploadChannel]||[]}},mounted(){this.initializeBackground("uploadBkImg",".container",!1,!0),this.selectedUrlForm=this.uploadCopyUrlForm||"url",this.customerCompress=this.compressConfig.customerCompress??this.parseBoolean(this.userConfig?.defaultCustomerCompress,!0),this.compressQuality=this.compressConfig.compressQuality??this.parseNumber(this.userConfig?.defaultCompressQuality,4),this.compressBar=this.compressConfig.compressBar??this.parseNumber(this.userConfig?.defaultCompressBar,5),this.serverCompress=this.compressConfig.serverCompress??!0,this.convertToWebp=this.compressConfig.convertToWebp??this.parseBoolean(this.userConfig?.defaultConvertToWebp,!1),this.uploadChannel=this.storeUploadChannel||this.userConfig?.defaultUploadChannel||"telegram",this.autoRetry=this.storeAutoRetry,this.uploadNameType=this.storeUploadNameType||this.userConfig?.defaultUploadNameType||"default",this.customUrlPrefix=this.customUrlSettings.customUrlPrefix,this.useCustomUrl=this.customUrlSettings.useCustomUrl,this.uploadMethod=this.storeUploadMethod,this.fetchAvailableChannels(),this.uploadFolder=this.storeUploadFolder||this.userConfig?.defaultUploadFolder||"";const e=this.$store.getters.cusDarkMode,t=this.$store.getters.useDarkMode;this.themeMode=e?t?"dark":"light":"auto";const o=localStorage.getItem("visitedUploadHome"),s=this.userConfig?.announcement;!o&&s&&(this.announcementContent=s,this.showAnnouncementDialog=!0,localStorage.setItem("visitedUploadHome","true")),this.$nextTick(()=>{this.$refs.directoryPickerTriggerRef&&(this.directoryPickerTriggerRef=this.$refs.directoryPickerTriggerRef.$el||this.$refs.directoryPickerTriggerRef)})},components:{UploadForm:Tt,Footer:X.A,ToggleDark:Mt.A,Logo:St.A,UploadHistory:H,UploadSettingsDialog:xe,DirectoryTreePicker:$t.A},methods:{async fetchAvailableChannels(){try{const e=await ht.A.get("/api/channels",{withAuthCode:!0});if(e.data){this.availableChannels=e.data;const t=this.storeChannelName,o=this.userConfig?.defaultChannelName,s=this.availableChannels[this.uploadChannel]||[];t&&s.some(e=>e.name===t)?this.channelName=t:""!==t&&null!==t&&void 0!==t||""!==t&&o&&s.some(e=>e.name===o)&&(this.channelName=o)}}catch(e){console.error("Failed to fetch available channels:",e)}},validateUploadFolder(e,t=!0){e&&!e.startsWith("/")&&(e="/"+e,this.uploadFolder=e);const o=(0,Zt.G)(e,{strict:t});if(!o.valid){const e=o.error.replace("目标目录","上传目录");return this.$message.error(e),!1}return!0},handleFolderInputBlur(){this.isFolderInputActive=!1,this.uploadFolder&&!this.uploadFolder.startsWith("/")&&(this.uploadFolder="/"+this.uploadFolder),this.validateUploadFolder(this.uploadFolder,!0)||this.$nextTick(()=>{this.uploadFolder=this.storeUploadFolder})},handleManage(){this.$router.push("/dashboard")},parseBoolean(e,t){return void 0===e||null===e?t:"boolean"===typeof e?e:"string"===typeof e?"true"===e:t},parseNumber(e,t){if(void 0===e||null===e)return t;const o=parseFloat(e);return isNaN(o)?t:o},openUrlDialog(){this.showUrlDialog=!0},handleLogout(){Yt().remove("authCode"),this.$router.push("/login"),this.$message.success("已退出登录")},changeUrlForm(){this.$store.commit("setUploadCopyUrlForm",this.selectedUrlForm)},openCompressDialog(){this.showCompressDialog=!0},updateCompressConfig(e,t){this.$store.commit("setCompressConfig",{key:e,value:t})},updateStoreUploadChannel(e){this.$store.commit("setStoreUploadChannel",e)},updateStoreUploadNameType(e){this.$store.commit("setStoreUploadNameType",e)},handleOpenToolbar(){this.isToolBarOpen=!this.isToolBarOpen,setTimeout(()=>{const e=document.querySelectorAll(".toolbar-button");e.forEach(e=>{e.style.pointerEvents=this.isToolBarOpen?"auto":"none"})},300)},handleChangeUploadMethod(){this.uploadMethod="default"===this.uploadMethod?"paste":"default",this.$store.commit("setUploadMethod",this.uploadMethod)},handleMobileMenuCommand(e){"toggleTheme"===e?"auto"===this.themeMode?(this.themeMode="light",this.$store.commit("setCusDarkMode",!0),this.$store.commit("setUseDarkMode",!1)):"light"===this.themeMode?(this.themeMode="dark",this.$store.commit("setCusDarkMode",!0),this.$store.commit("setUseDarkMode",!0)):(this.themeMode="auto",this.$store.commit("setCusDarkMode",!1)):"toggleUploadMethod"===e?this.handleChangeUploadMethod():"showHistory"===e?this.showHistory=!0:"showAnnouncement"===e&&this.handleShowAnnouncement()},getThemeIcon(){return"auto"===this.themeMode?"sun":"light"===this.themeMode?"moon":"adjust"},getThemeText(){return"auto"===this.themeMode?"浅色模式":"light"===this.themeMode?"深色模式":"自动模式"},handleShowAnnouncement(){const e=this.userConfig?.announcement;e?(this.announcementContent=e,this.showAnnouncementDialog=!0):this.$message.info("暂无公告")},handleDirectorySelect(e){this.uploadFolder=e,this.validateUploadFolder(e,!0)&&this.$store.commit("setStoreUploadFolder",e)}}};const to=(0,V.A)(eo,[["render",qt],["__scopeId","data-v-4547efc4"]]);var oo=to},4396:function(e,t,o){"use strict";o(5331),o(4885)},4885:function(e,t,o){"use strict";o(5331)},5385:function(e,t,o){"use strict";o(5331)},5616:function(e,t,o){"use strict";o(5331),o(7197)},5970:function(e,t,o){"use strict";o(5331)},6334:function(e,t,o){e.exports=o(1393)},6682:function(e,t,o){"use strict";e.exports=o.p+"img/404.8ed11fb3.png"},6808:function(e,t,o){"use strict";o(5331),o(8785),o(200),o(5970),o(9104)},7952:function(e,t,o){"use strict";o(5331),o(7197)},8075:function(e,t,o){"use strict";o(5331)},8736:function(e,t,o){"use strict";o(5331)},8785:function(e,t,o){"use strict";o(5331)},8830:function(e,t,o){"use strict";o(5331)},9104:function(e,t,o){"use strict";o(5331)},9899:function(e,t,o){"use strict";o(5331)}}]);
//# sourceMappingURL=606.a7e6504b.js.map