1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return l(4115)}])},4115:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return C}});var n=l(5893),a=l(7294),r=l(9008),s=l.n(r),i=l(4677);function o(){let[e,t]=(0,a.useState)(!1);return(0,n.jsxs)("div",{className:"w-full h-full flex justify-between items-center",children:[(0,n.jsx)("div",{className:"font-bold font-mono text-3xl",children:"Strapi OSS"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(i.Z,{onClick:()=>{t(!0)},className:"text-2xl transform hover:rotate-180 cursor-pointer transition-all ease duration-500"}),(0,n.jsx)(k,{visible:e,onDrawerOk:()=>{t(!1)},onDrawerCancel:()=>{t(!1)}})]})]})}var c=l(507),d=l(8211),u=l(8335),h=l(5776),f={setting:"Setting",language:"Language / è¯è¨",apiPrefix:"API Prefix",warning:"Please fill in the API prefix and TOKEN in the settings for the first time",copied:"Copied to clipboard",error:"Network error, more information please check the F12 console",deleteTitle:"Delete",deleteContent:"Are you sure to delete this content?",okText:"OK",cancelText:"Cancel",success:"Success",failed:"Failed",unknownError:"Unknown error",upload:"Click or drag file to this area to upload"},x={setting:"设置",language:"è¯è¨ / Language",apiPrefix:"API åç¼",warning:"馿¬¡ä½¿ç¨è¯·å¨è®¾ç½®ä¸å¡«å API åç¼ä»¥å TOKEN",copied:"å·²å¤å¶å°åªè´´æ¿",error:"ç½ç»éè¯¯ï¼æ´å¤ä¿¡æ¯è¯·æ¥ç F12 æ§å¶å°",deleteTitle:"æ¯å¦å é¤",deleteContent:"æ¯å¦å é¤è¯¥æ¡å
容ï¼",okText:"ç¡®å®",cancelText:"åæ¶",success:"æå",failed:"失败",unknownError:"æªç¥é误",upload:"ç¹å»æææ½æä»¶å°æ¤åºåä¸ä¼ "};function g(){let e="zh";null===localStorage||null===localStorage.getItem("strapilanguage")?(localStorage.setItem("strapilanguage","zh"),e="zh"):e=localStorage.getItem("strapilanguage");let t=e=>{localStorage.setItem("strapilanguage",e),window.location.reload()},l="zh"===e?x:f;return{language:e,i18n:l,changeLanguage:t}}function p(){let e,t;null===localStorage||null===localStorage.getItem("strapiPrefix")?(e="",t=!1):(e=localStorage.getItem("strapiPrefix"),t=!0);let l=e=>{localStorage.setItem("strapiPrefix",e),window.location.reload()};return{apiPrefix:e,setApiPrefix:l,hasApiPrefix:t}}function m(){let e,t;null===localStorage||null===localStorage.getItem("strapiToken")?(e="",t=!1):(e=localStorage.getItem("strapiToken"),t=!0);let l=e=>{localStorage.setItem("strapiToken",e),window.location.reload()};return{token:e,setToken:l,hasToken:t}}function j(e){let{onUpload:t}
1=e,l=m(),r=p(),s=g(),[i,o]=a.useState(0),[f,x]=a.useState("normal"),j=(0,a.useRef)(0);a.useEffect(()=>{let e=e=>{var t;let l=null===(t=e.clipboardData)||void 0===t?void 0:t.items;if(null!=l)for(let e=0;e<l.length;e++){let t=l[e];if("file"===t.kind){let e=t.getAsFile();null!=e&&w(e)}}};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[]);let w=e=>{o(Math.floor(100*Math.random()));let n=new FormData;n.append("files",e),fetch(r.apiPrefix+"/api/upload/",{method:"POST",headers:{Authorization:"Bearer "+l.token},body:n}).then(async e=>await e.json()).then(e=>{console.log(e),o(100),x("success"),navigator.clipboard.writeText(String(r.apiPrefix)+String(e[0].url)).then(()=>{c.Z.success({content:s.i18n.success,duration:1e3,closable:!0}),c.Z.success({content:s.i18n.copied,duration:1e3,closable:!0}),j.current=j.current+1,t(j.current)})}).catch(e=>{c.Z.error({content:s.i18n.failed,duration:1e3,closable:!0}),j.current=j.current+1,t(j.current),x("error"),console.log(e)})};return(0,n.jsxs)("div",{className:"h-full lg:absolute w-full xl:w-96 mb-3",children:[(0,n.jsx)(d.Z,{className:"h-max w-full xl:w-96",drag:!0,autoUpload:!1,directory:!1,multiple:!1,beforeUpload:e=>(w(e),!1),tip:s.i18n.upload,children:(0,n.jsx)("div",{className:"w-full mr-2 h-96 xl:w-96 bg-gray-50 rounded-md hover:bg-gray-100 transition-all ease-in-out duration-500 flex flex-col justify-center items-center",children:(0,n.jsx)("div",{className:"text-xl",children:s.i18n.upload})})}),(0,n.jsx)(u.Z,{percent:i,status:f,style:{marginBottom:20}}),(0,n.jsx)(h.Z,{showIcon:!1,type:"success",className:"!w-96",content:"TIP: 使ç¨å请设置æ¨ç API åç¼å Token. Please set your API prefix and Token before use."})]})}var w=l(9489),v=l(5212),b=l(8406),N=l(3256),S=l(9784);function k(e){let{visible:t,onDrawerOk:l,onDrawerCancel:r}=e,s=p(),i=m(),o=g(),[c]=v.Z.useForm(),[d,u]=(0,a.useState)(),[h,f]=(0,a.useState)(),[x,j]=(0,a.useState)(),w=()=>{null!=d&&(window.localStorage.setItem("strapilanguage",d),o.changeLanguage(d)),null!=h&&s.setApiPrefix(h),null!=x&&window.localStorage.setItem("strapiToken",x),l()};return(0,n.jsx)("div",{className:"h-full w-full",children:(0,n.jsx)(b.Z,{width:332,title:(0,n.jsx)("span",{children:o.i18n.setting}),visible:t,onOk:()=>{w()},onCancel:()=>{r()},children:(0,n.jsxs)(v.Z,{form:c,layout:"vertical",children:[(0,n.jsx)(v.Z.Item,{label:o.i18n.language,field:"language",children:(0,n.jsx)(N.Z,{placeholder:"zh"===String(o.language)?"䏿":"English",options:["English","䏿"],onChange:e=>{"English"===e?u("en"):u("zh")}})}),(0,n.jsx)(v.Z.Item,{label:o.i18n.apiPrefix,field:"api",children:(0,n.jsx)(S.Z,{placeholder:s.hasApiPrefix?s.apiPrefix:"example: https://oss.yourdomain.com",onChange:e=>{f(e)}})}),(0,n.jsx)(v.Z.Item,{label:"TOKEN",field:"token",children:(0,n.jsx)(S.Z.Password,{placeholder:i.hasToken?i.token:"example: 1234567890",type:"password",onChange:e=>{j(e)}})}),(0,n.jsx)("div",{className:"w-full h-max bg-gray-100 px-2 py-3 rounded-md",children:(0,n.jsxs)("div",{className:"flex gap-1 text-lg font-mono items-center justify-center",children:["Made with ",(0,n.jsx)("div",{className:"text-red-500",children:"â¤"})," by ",(0,n.jsx)("a",{className:"text-blue-500",href:"https://jet-lab.site",target:"_blank",rel:"noreferrer",children:"JetLab"})]})}),(0,n.jsx)("div",{className:"w-full h-max bg-gray-100 px-2 py-3 rounded-md my-1",children:(0,n.jsxs)("div",{className:"flex gap-1 text-base items-center justify-center",children:["Powered by",(0,n.jsx)("a",{href:"https://netlify.com/",target:"_blank",rel:"noreferrer",children:(0,n.jsx)("img",{alt:"netlify",src:"/Netlify.svg",className:"h-8"})})]})}),(0,n.jsx)("div",{className:"w-full h-max bg-gray-100 px-2 py-3 rounded-md",children:(0,n.jsxs)("div",{className:"flex gap-1 text-base items-center justify-center",children:["Star me on ",(0,n.jsx)("a",{href:"https://github.com/inannan423/oss-strapi",target:"_blank",rel:"noreferrer",children:"GitHub"})]})})]})})})}w.Z.addFromIconFontCn({src:"//at.alicdn.com/t/font_180975_26f1p759rvn.js"});var y=l(5695),T=l(2687),P=l(8460),Z=l(1873);function I(e){let{update:t}=e,[l,r]=a.useState(!1),s=m(),i=p(),o=g(),[d,u]=a.useState();(0,a.useEffect)(()=>{fetch(i.apiPrefix+"/api/upload/files",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+s.token}}).then(async e=>await e.json()).then(e=>{u(e.reverse()),r(!0)}).catch(e=>{console.log(e),c.Z.error(o.i18n.error)})},[l,t]);let h=e=>{fetch(i.apiPrefix+"/api/upload/files/"+e,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+s.token}}).then(async e=>await e.json()).then(e=>{console.log(e),null!=e.id?(c.Z.success(o.i18n.success),r(!1)):null!=e.error.message?c.Z.error(e.error.message):c.Z.error(o.i18n.unknownError)}).catch(e=>{console.log(e),c.Z.error(o.i18n.failed)})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-2",children:[null==d?void 0:d.length," Files"]}),(0,n.jsx)("div",{className:"grid grid-cols-3 h-full gap-3 w-full px-2 py-3",children:null==d?void 0:d.map((e,t)=>(0,n.jsxs)("div",{className:"h-full",children:[(0,n.jsx)(y.Z,{content:String(e.size)+"B | "+String(e.updatedAt),children:(0,n.jsxs)("div",{className:"w-full h-32 bg-gray-200 rounded-lg overflow-hidden",children:[e.mime.includes("image")&&null!==e.formats&&(0,n.jsx)("img",{src:i.apiPrefix+e.formats.thumbnail.url,alt:e.alternativeText,className:"h-32 w-full object-cover object-center"}),e.mime.includes("video")&&(0,n.jsx)("video",{src:i.apiPrefix+e.url,className:"h-32 w-full object-cover object-center"})]},t)}),(0,n.jsxs)("div",{className:"flex w-full items-center justify-between mt-1",children:[(0,n.jsx)("div",{className:"w-1/2 truncate",children:e.name}),(0,n.jsxs)("div",{className:"w-1/2 flex gap-2 justify-end",children:[(0,n.jsx)(P.Z,{className:"cursor-pointer",onClick:()=>{navigator.clipboard.writeText(i.apiPrefix+e.url).then(()=>{c.Z.success(o.i18n.copied)})}}),(0,n.jsx)(T.Z,{focusLock:!0,title:o.i18n.deleteTitle,content:o.i18n.deleteContent,okText:o.i18n.okText,cancelText:o.i18n.cancelText,onOk:()=>{h(String(e.id))},children:(0,n.jsx)(Z.Z,{className:"cursor-pointer"})})]})]})]},t))})]})}let E=["bg-red-500","bg-yellow-500","bg-green-500","bg-blue-500","bg-indigo-500","bg-purple-500","bg-pink-500"];function C(){let[e,t]=(0,a.useState)(!1),[l]=(0,a.useState)(E[Math.floor(Math.random()*E.length)]),[r,i]=(0,a.useState)(0);return a.useEffect(()=>{t(!0)},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(s(),{children:[(0,n.jsx)("title",{children:"Strapi OSS"}),(0,n.jsx)("meta",{name:"description",content:"Upload Files to Strapi"}),(0,n.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),(0,n.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"".concat(l," h-96 w-96 fixed -bottom-20 -left-10 -z-10 opacity-10 blur-3xl")}),(0,n.jsxs)("div",{className:"min-h-screen h-screen w-full grid grid-cols-2 grid-rows-6 px-12 lg:px-24 z-20",children:[(0,n.jsx)("div",{className:"col-span-2 w-full h-full row-span-1",children:(0,n.jsx)(o,{})}),(0,n.jsxs)("div",{className:"col-span-2 flex flex-col xl:grid xl:grid-cols-3 gap-10 h-full w-full row-span-5 overflow-auto px-3",children:[(0,n.jsx)("div",{className:"col-span-1 h-full",children:(0,n.jsx)(j,{onUpload:e=>{i(e)}})}),(0,n.jsx)("div",{className:"col-span-2 h-full w-full",children:(0,n.jsx)(I,{update:r})})]})]})]})]})}}},function(e){e.O(0,[222,774,888,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.