astrion-website/demo/static/dist/assets/ImagePicker.js

2 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{d as C,k as _,w as S,o as B,b as o,e as I,s as x,c as n,A as z,g as e,t as p,F as A,r as D,n as F,f as L,T as P,l as T}from"./runtime-dom.esm-bundler.js";import{_ as U}from"./_plugin-vue_export-helper.js";const V={class:"image-picker-panel"},M={class:"header"},N={class:"header-left"},$=["disabled"],j={class:"body"},E={key:0,class:"loading"},R={key:1,class:"empty"},W={key:2,class:"grid"},q=["onClick","title"],G=["src","alt"],H={class:"name"},J={class:"footer"},K={class:"count"},O={class:"actions"},Q=["disabled"],X=C({__name:"ImagePicker",props:{open:{type:Boolean},entries:{},initialSelected:{},loading:{type:Boolean},uploading:{type:Boolean,default:!1}},emits:["close","confirm","local-files"],setup(i,{emit:h}){const c=i,d=h,l=_(new Set(c.initialSelected||[])),f=_(null);let m=0;S(()=>c.initialSelected,t=>{l.value=new Set(t||[])});const g=T(()=>c.entries||[]),v=t=>{if(!t)return;const s=new Set(l.value);if(s.has(t))s.delete(t);else{if(s.size>=9)return;s.add(t)}l.value=s},u=()=>{Date.now()<m||d("close")},k=()=>d("confirm",Array.from(l.value)),b=()=>{var t;c.uploading||(m=Date.now()+1500,(t=f.value)==null||t.click())},y=t=>{const s=t.target,a=s==null?void 0:s.files,r=a&&a.length?Array.from(a):null;!r||r.length===0?(console.warn("[ImagePicker] change fired but files empty — likely WebView compat issue"),d("local-files",null)):d("local-files",r),setTimeout(()=>{s&&(s.value="")},200)},w=t=>`/api/gui/files/download?path=${encodeURIComponent(t)}`;return B(()=>{l.value=new Set(c.initialSelected||[])}),(t,s)=>(o(),I(P,{name:"overlay-fade"},{default:x(()=>[i.open?(o(),n("div",{key:0,class:"image-picker-backdrop",onClick:z(u,["self"])},[e("div",V,[e("div",M,[e("div",N,[s[0]||(s[0]=e("div",{class:"title"},"选择图片最多9张",-1)),e("button",{type:"button",class:"local-btn",disabled:i.uploading,onClick:b},p(i.uploading?"上传中...":"从本地发送"),9,$),e("input",{ref_key:"localInput",ref:f,type:"file",class:"file-input-hidden",accept:"image/png,image/jpeg,image/webp,image/gif,image/bmp",multiple:"",onChange:y},null,544)]),e("button",{class:"close-btn",onClick:u},"×")]),e("div",j,[i.loading?(o(),n("div",E,"加载中...")):g.value.length?(o(),n("div",W,[(o(!0),n(A,null,D(g.value,a=>(o(),n("div",{key:a.path,class:F(["card",{selected:l.value.has(a.path)}]),onClick:r=>v(a.path),title:a.path},[e("img",{src:w(a.path),alt:a.name},null,8,G),e("div",H,p(a.name),1)],10,q))),128))])):(o(),n("div",R,"未找到图片文件"))]),e("div",J,[e("div",K,"已选 "+p(l.value.size)+" / 9",1),e("div",O,[e("button",{type:"button",class:"btn secondary",onClick:u},"取消"),e("button",{type:"button",class:"btn primary",disabled:!l.value.size,onClick:k}," 确认 ",8,Q)])])])])):L("",!0)]),_:1}))}}),ee=U(X,[["__scopeId","data-v-eb7976c1"]]);export{ee as default};