Files
RE-Amachiromaker/static/js/main.72370a41.chunk.js
2025-11-04 10:54:59 +08:00

23 lines
8.4 KiB
JavaScript

(this["webpackJsonpamachiromaker-clone"]=this["webpackJsonpamachiromaker-clone"]||[]).push([[0],{32:function(t,e,n){},54:function(t,e,n){},57:function(t,e,n){"use strict";n.r(e);var c=n(0),i=n.n(c),a=n(23),r=n.n(a),o=(n(32),n(6)),u=n.n(o),l=n(14),s=n(8),d=n(26),m=n(3),v=n(7),f=n(24),b=n(12);function j(){var t=window;return{width:t.innerWidth,height:t.innerHeight}}var h=n(25),O=n.n(h).a.create({baseURL:"",timeout:1e4,headers:{}});var g={get:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,c){O.get(t,{params:e}).then((function(t){n(t.data)})).catch((function(t){c(t)}))}))},post:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,c){O.post(t,e).then((function(t){n(t.data)})).catch((function(t){c(t)}))}))},put:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,c){O.put(t,e).then((function(t){n(t.data)})).catch((function(t){c(t)}))}))},del:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,c){O.delete(t,{params:e}).then((function(t){n(t.data)})).catch((function(t){c(t)}))}))}},p=function(){return g.get("defaultCombination.json")},x=function(){return g.get("orderedLayers.json")},w={CDN_PREFIX:"cdn.picrew.me"},I=(n(54),n(55),n(1));var N=function(){var t=Object(c.useState)(),e=Object(m.a)(t,2),i=e[0],a=e[1],r=Object(c.useState)(),o=Object(m.a)(r,2),h=o[0],O=o[1],g=Object(c.useState)(),N=Object(m.a)(g,2),y=N[0],C=N[1],S=Object(c.useState)(),k=Object(m.a)(S,2),P=k[0],E=k[1],D=Object(c.useState)(),F=Object(m.a)(D,2),R=F[0],J=F[1],L=Object(c.useState)(),M=Object(m.a)(L,2),A=M[0],B=M[1],X=Object(c.useState)(),_=Object(m.a)(X,2),T=_[0],U=_[1],z=function(){var t=Object(c.useState)(j()),e=Object(m.a)(t,2),n=e[0],i=e[1];return Object(c.useEffect)((function(){function t(){i(j())}return window.addEventListener("resize",t),function(){return window.removeEventListener("resize",t)}}),[]),n}(),W=z.width,G=z.height;Object(c.useEffect)((function(){var t=JSON.parse(localStorage.getItem("layerComb")||"null");t?a(t):p().then((function(t){a(t)})),x().then((function(t){O(t)}))}),[]),Object(c.useEffect)((function(){var t=function(){var t=W>G?.05*W:.083*W;return Math.min(60,t)};E(function(){var t=W>G?.3*W:.5*W,e=Math.min(600,t);return e<300?300:e}()),J(function(){var t=W>G?.1*W:.167*W;return Math.min(160,t)}()),B(t()),U(t())}),[W,G]);var H=function(t,e,n,c){var r=Object(d.a)(i||[]);r[t]=Object(s.a)(Object(s.a)({},r[t]),{},{itmId:e,cId:n,url:c}),localStorage.setItem("layerComb",JSON.stringify(r)),a(r)};Object(c.useEffect)((function(){var t,e=(null===i||void 0===i||null===(t=i.filter((function(t){return t.url})))||void 0===t?void 0:t.map((function(t){return{src:"".concat(w.CDN_PREFIX).concat(t.url),x:t.x,y:t.y}})))||[];Object(f.a)(e).then((function(t){C(t)}))}),[i]);var q=function(){var t=Object(l.a)(u.a.mark((function t(){var e,c,a,r,o;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.e(3).then(n.t.bind(null,75,7));case 2:return e=t.sent,t.next=5,Promise.all((i||[]).map((function(t,e){return Object(s.a)(Object(s.a)({},t),{},{name:null===h||void 0===h?void 0:h[e].pNm})})).filter((function(t){return t.url})).map(function(){var t=Object(l.a)(u.a.mark((function t(e,n){var c,i;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c=function(t,e){return new Promise((function(n){var c=new Image;c.onload=function(){t.drawImage(c,0,0),n("resolved")},c.src="".concat(w.CDN_PREFIX).concat(e)}))},i=new OffscreenCanvas(600,600),t.next=4,c(i.getContext("2d"),e.url);case 4:return t.abrupt("return",{top:e.y,left:e.x,blendMode:"normal",opacity:1,name:e.name,canvas:i});case 5:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 5:c=t.sent,a={width:600,height:600,colorMode:3,channels:3,bitsPerChannel:8,children:c},r=e.writePsd(a),o=new Blob([r]),Object(b.saveAs)(o,"amachiromaker-output-".concat(Date.now(),".psd"));case 10:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return Object(I.jsxs)("div",{className:"App",style:{flexDirection:W>G?"row":"column"},children:[Object(I.jsx)("div",{className:"left-area",children:(null===y||void 0===y?void 0:y.startsWith("data:image/png;base64,"))?Object(I.jsxs)(I.Fragment,{children:[Object(I.jsx)("img",{className:"layer-image",width:P,src:y,title:"Output Image",alt:"Output"}),Object(I.jsxs)("div",{className:"button-group",children:[Object(I.jsx)("button",{className:"button-1",onClick:function(){p().then((function(t){a(t),localStorage.setItem("layerComb",JSON.stringify(t))}))},children:"重置"}),Object(I.jsx)("button",{className:"button-2",onClick:function(){Object(b.saveAs)(y||"","amachiromaker-output-".concat(Date.now(),".png"))},children:"保存PNG"}),Object(I.jsx)("button",{className:"button-2",onClick:q,children:"保存PSD"})]}),Object(I.jsxs)("div",{className:"button-group",children:[Object(I.jsx)("input",{id:"presetInput",type:"file",style:{display:"none"},onChange:function(t){var e=t.target.files[0],n=new FileReader;n.onload=function(){var e=JSON.parse(n.result);localStorage.setItem("layerComb",n.result),a(e),t.target.value=""},n.readAsText(e)}}),Object(I.jsx)("button",{className:"button-3",onClick:function(){var t;null===(t=document.getElementById("presetInput"))||void 0===t||t.click()},children:"加载预设"}),Object(I.jsx)("button",{className:"button-2",onClick:function(){var t=JSON.stringify(i),e=new Blob([t],{type:"text/plain"});Object(b.saveAs)(e,"amachiromaker-preset-".concat(Date.now(),".json"))},children:"下载预设"})]})]}):Object(I.jsx)("div",{className:"loading-text-container",style:{width:P,height:P},children:"loading..."})}),Object(I.jsx)("div",{className:"config-area",children:Object(I.jsxs)(v.d,{children:[Object(I.jsx)(v.b,{children:null===h||void 0===h?void 0:h.map((function(t){return Object(I.jsx)(v.a,{children:Object(I.jsx)("img",{className:"tab-image",width:T,src:"".concat(w.CDN_PREFIX).concat(t.thumbUrl),alt:""})})}))}),null===h||void 0===h?void 0:h.map((function(t,e){var n,c,a;return Object(I.jsx)(v.c,{children:Object(I.jsxs)("div",{className:"tab-content",children:[Object(I.jsxs)("div",{className:"item-container",children:[!!t.isRmv&&Object(I.jsx)("img",{className:0===(null===i||void 0===i||null===(n=i[e])||void 0===n?void 0:n.itmId)?"item-image-selected":"item-image",onClick:function(){H(e,0,0,"")},width:R,height:R,src:"emptyset.svg",alt:""}),t.items.map((function(t){var n;return Object(I.jsx)("img",{className:(null===i||void 0===i||null===(n=i[e])||void 0===n?void 0:n.itmId)===t.itmId?"item-image-selected":"item-image",src:"".concat(w.CDN_PREFIX).concat(t.thumbUrl),width:R,height:R,onClick:function(){var n=t.originals.find((function(t){var n;return t.cId===(null===i||void 0===i||null===(n=i[e])||void 0===n?void 0:n.cId)}));H(e,t.itmId,(null===n||void 0===n?void 0:n.cId)||t.originals[0].cId,(null===n||void 0===n?void 0:n.url)||t.originals[0].url)},alt:""})}))]}),!!(Object.keys(t.colors).length>1&&(null===i||void 0===i||null===(c=i[e])||void 0===c?void 0:c.itmId))&&Object(I.jsx)("div",{className:"color-container",children:null===(a=t.items.find((function(t){var n;return t.itmId===(null===i||void 0===i||null===(n=i[e])||void 0===n?void 0:n.itmId)})))||void 0===a?void 0:a.originals.map((function(n){var c;return Object(I.jsx)("div",{className:(null===i||void 0===i||null===(c=i[e])||void 0===c?void 0:c.cId)===n.cId?"color-image-selected":"color-image",style:{background:t.colors[n.cId],width:A,height:A},onClick:function(){var t;H(e,null===i||void 0===i||null===(t=i[e])||void 0===t?void 0:t.itmId,n.cId,n.url)}})}))})]})})}))]})})]})},y=function(t){t&&t instanceof Function&&n.e(4).then(n.bind(null,76)).then((function(e){var n=e.getCLS,c=e.getFID,i=e.getFCP,a=e.getLCP,r=e.getTTFB;n(t),c(t),i(t),a(t),r(t)}))};r.a.render(Object(I.jsx)(i.a.StrictMode,{children:Object(I.jsx)(N,{})}),document.getElementById("root")),y()}},[[57,1,2]]]);
// 阻止图片右键菜单
document.addEventListener('contextmenu', (event) => {
if (event.target.tagName === 'IMG') {
event.preventDefault();
}
});
// 禁止图片拖拽
document.addEventListener('dragstart', (event) => {
if (event.target.tagName === 'IMG') {
event.preventDefault();
event.dataTransfer.setData('text/plain', '');
event.target.draggable = false;
}
});
// 统一设置图片draggable属性
const images = document.getElementsByTagName('img');
for (let img of images) {
img.setAttribute('draggable', 'false');
}
//# sourceMappingURL=main.72370a41.chunk.js.map