99AI/public/assets/index-e889edd8.js
2024-07-07 13:09:08 +08:00

2 lines
7.0 KiB
JavaScript

import{a as ce,o as de,t as j,z as ue}from"./index-d64a7cc4.js";import{d as H,S as v,U as x,a3 as s,g as pe,r as a,e as R,w as q,f as G,G as he,H as P,F as ve,a6 as fe,n as me,X as _,W as m,z as _e,a4 as D,V as z,ab as N,M as i,a5 as W}from"./vue-10b4afc0.js";import{_ as S}from"./index.vue_vue_type_script_setup_true_lang-f425914e.js";import{c as ge}from"./index-c94da121.js";import{e as we,I as B,J as xe,K as ye,r as ke}from"./naive-ui-fedd20b1.js";import"./vueuse-motion-d4cdaf7b.js";const be={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 512 512"},$e=s("path",{d:"M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 0 0 2.33 2.77h0a2.36 2.36 0 0 0 1.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 0 0-2.44-2.75h0a2.42 2.42 0 0 0-1.95 1z",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"},null,-1),Le=[$e],Ce=H({name:"FlashOutline",render:function(l,c){return v(),x("svg",be,Le)}});function Ie(y,l){let c,n;return function(...g){n=g,c||(c=setTimeout(()=>{y.apply(this,n),c=null},l))}}const Me={class:"min-h-full overflow-hidden flex flex-col"},Pe={class:"flex-1 min-h-full p-4 relative"},We=["id"],Re=["id","src","onLoad","onError","onClick"],je={class:"menu p-2 text-[#cbd5e1]"},ze={class:"prompt"},Ne={class:"flex justify-end items-end space-x-2"},Se=["onClick"],Be={class:"text-sm dark:text-slate-400"},De=s("span",null,"画同款",-1),He=["onClick"],Ee={class:"text-sm dark:text-slate-400"},Ue=s("span",null,"使用当前画同款",-1),Ae=["onClick"],Te={class:"text-sm dark:text-slate-400"},Fe=s("span",null,"复制提示词",-1),Oe=s("div",{id:"footer",class:"w-full absolute bottom-[350px]"},null,-1),Ve=H({__name:"index",props:{dataList:{},scaleWidth:{},isDrawLike:{type:Boolean},usePropmpt:{type:Boolean},copyPropmpt:{type:Boolean},gap:{default:5}},emits:["loadMore","usePropmptDraw"],setup(y,{emit:l}){var A;const c=ce(),n=y,f=l,g=(A=pe())==null?void 0:A.appContext.config.globalProperties.$viewerApi,L=we(),k=a({}),C=a(0),d=a(160),u=a(0),b=a([]),p=a(null),h=a(0),$=R(()=>c.isLogin),E=R(()=>n.scaleWidth?Number(n.scaleWidth)*2+n.gap+150:150),J=de();function K(){Q(),Y();const e=u.value,o=d.value,t=[];n.dataList.forEach((w,r)=>{const T=w.drawRatio.split("x"),ae=parseInt(T[0],10),re=parseInt(T[1],10),ie=o/ae,F=re*ie+n.gap+C.value,M=k.value[w.id];if(t.length<e)M.style.top="0px",M.style.left=`${(o+n.gap)*r}px`,t.push(F);else{const O=Math.min.apply(null,t),V=t.findIndex(le=>le===O);M.style.top=`${O+0}px`,M.style.left=`${V*(d.value+n.gap)}px`,t[V]+=F}}),h.value=Math.max(...t)+100}function X(e,o){e&&o&&(k.value[o.id]=e)}function Q(){const{showName:e=0,showOther:o=0}={};C.value=[e,o].filter(t=>t).length*15}q(()=>n.scaleWidth,e=>{I()}),q(()=>n.dataList,e=>{e&&me(()=>{I()})},{immediate:!0});function Y(){if(!p.value)return;const e=p.value.clientWidth;u.value=Math.floor(e/E.value);const o=e-u.value*E.value,t=(u.value-1)*n.gap;o-t<0&&(u.value-=1),d.value=Math.floor((e-t)/u.value)}function Z(e,o){b.value.push(o.id)}function ee(e,o){b.value.push(o.id)}function te(e){if(!$.value)return c.setLoginDialog(!0);const{prompt:o}=e;ge({text:o}),L.success("复制prompt成功")}function se(e){J.push(`/midjourney?mjId=${e.id}`)}function oe(e){const{fullPrompt:o}=e;f("usePropmptDraw",o)}function ne(e){const{drawUrl:o}=e;g({options:{},images:[o]})}const U=R(()=>e=>{const o=e.drawRatio.split("x"),t=Number(o[0]);return Number(o[1])/(t/d.value)}),I=Ie(function(){K()},200);return G(async()=>{window.addEventListener("resize",I);const e=document.getElementById("footer");new IntersectionObserver((t,w)=>{t.forEach(r=>{r.isIntersecting&&f("loadMore")})}).observe(e)}),he(()=>{window.removeEventListener("resize",I)}),(e,o)=>(v(),x("div",Me,[s("div",Pe,[s("div",{id:"wapper",ref_key:"wapperRef",ref:p,class:"wapper",style:P({height:`${h.value}px`})},[(v(!0),x(ve,null,fe(e.dataList,(t,w)=>(v(),x("div",{id:t.id.toString(),key:w,ref_for:!0,ref:r=>X(r,t),class:"wapper-item",style:P({width:`${d.value}px`})},[_(_e,{name:"img",css:!0},{default:m(()=>[s("img",{id:t.id.toString(),class:"item-file rounded-sm",style:P({width:`${d.value}px`,height:`${U.value(t)}px`}),src:t.drawUrl,loading:"lazy",onLoad:r=>Z(r,t),onError:r=>ee(r,t),onClick:r=>ne(t)},null,44,Re)]),_:2},1024),s("div",je,[s("div",ze,D(t.fullPrompt),1),s("div",Ne,[e.isDrawLike?(v(),z(i(B),{key:0,trigger:"hover"},{trigger:m(()=>[s("button",{class:"flex h-5 w-8 items-center justify-center rounded border transition hover:bg-[#666161] dark:border-neutral-700 dark:hover:bg-[#33373c]",onClick:N(r=>se(t),["stop"])},[s("span",Be,[_(i(S),{icon:"fluent:draw-image-24-regular",class:"text-sm"})])],8,Se)]),default:m(()=>[De]),_:2},1024)):W("",!0),e.usePropmpt?(v(),z(i(B),{key:1,trigger:"hover"},{trigger:m(()=>[s("button",{class:"flex h-5 w-8 items-center justify-center rounded border transition hover:bg-[#666161] dark:border-neutral-700 dark:hover:bg-[#33373c]",onClick:N(r=>oe(t),["stop"])},[s("span",Ee,[_(i(S),{icon:"fluent:draw-image-24-regular",class:"text-sm"})])],8,He)]),default:m(()=>[Ue]),_:2},1024)):W("",!0),e.copyPropmpt?(v(),z(i(B),{key:2,trigger:"hover"},{trigger:m(()=>[s("button",{class:"flex h-5 w-8 items-center justify-center rounded border transition hover:bg-[#666161] dark:border-neutral-700 dark:hover:bg-[#33373c]",onClick:N(r=>te(t),["stop"])},[s("span",Te,[_(i(S),{icon:"tabler:copy",class:"text-sm"})])],8,Ae)]),default:m(()=>[Fe]),_:2},1024)):W("",!0)])]),b.value.includes(t.id)?W("",!0):(v(),x("div",{key:0,class:"item-loading",style:P({width:`${d.value}px`,height:`${U.value(t)}px`})},null,4))],12,We))),128)),Oe],4)])]))}});const qe={class:"bg-white h-[100vh] overflow-hidden p-4 pr-0 dark:bg-gray-900 flex flex-col"},Ge={class:"p-4 flex pr-6 justify-between items-center"},Je={class:"font-bold text-xl"},Ke={class:"w-[200px] sm:w-[300px] flex justify-between"},Xe={class:"hidden sm:block"},Qe={class:"flex-1 ml-5"},Ye={class:"px-4 mb-1 pr-5"},Ze={class:"market overflow-y-scroll flex-1 min-h-screen p-4 relative"},it=H({__name:"index",setup(y){const l=a([]),c=a(null),n=a(50),f=a(""),g=a(1),L=a(20),k=a(!1),C=a(!0),d=R(()=>f.value?l.value.filter(p=>{const{prompt:h}=p;return h.includes(f.value)}):l.value);async function u(){k.value=!0;const p=await ue({page:g.value,size:L.value,rec:1});k.value=!1,C.value=L.value===p.data.rows.length,l.value=[...l.value,...p.data.rows]}G(async()=>{await u()});function b(){g.value=g.value+1,u()}return(p,h)=>(v(),x("div",qe,[s("div",Ge,[s("div",Je,D(i(j)("draw.aiDrawingSquare")),1),s("div",Ke,[s("span",Xe,D(i(j)("draw.sizeAdjustment")),1),s("div",Qe,[_(i(xe),{value:n.value,"onUpdate:value":h[0]||(h[0]=$=>n.value=$),step:10},null,8,["value"])])])]),s("div",Ye,[_(i(ye),{value:f.value,"onUpdate:value":h[1]||(h[1]=$=>f.value=$),placeholder:i(j)("draw.keywordSearchPlaceholder")},{prefix:m(()=>[_(i(ke),{component:i(Ce)},null,8,["component"])]),_:1},8,["value","placeholder"])]),s("div",Ze,[s("div",{id:"wapper",ref_key:"wapperRef",ref:c,class:"wapper"},[_(Ve,{onLoadMore:b,copyPropmpt:"",isDrawLike:"",dataList:d.value,scaleWidth:n.value},null,8,["dataList","scaleWidth"])],512)])]))}});export{it as default};