Files
CoreInject/frontend/dist/assets/lyDeIg7R.js
2025-11-16 05:39:11 +08:00

13 lines
865 B
JavaScript

import{A as e}from"./BaSQ3xJt.js"
import{c as a,h as t}from"./BqTCaadz.js"
import{r as s}from"./CdD4XvnD.js"
function o(){const o=s(!1),c=s([]),n=s(0),r=s(new Map)
return{previewVisible:o,previewImagesInfo:c,previewIndex:n,imageCache:r,preloadPostImages:async s=>{const o=a(s)
for(const a of o){const s=t(a)
if(!r.value.has(s))try{const a=await e.getAttachmentImage(s)
a&&r.value.set(s,a)}catch(c){}}},handleImageClick:async(s,l)=>{const i=a(s),u=[]
for(const a of i){const s=t(a)
let o=r.value.get(s)
if(!o)try{const a=await e.getAttachmentImage(s)
a&&(o=a,r.value.set(s,a))}catch(v){continue}o&&u.push({url:o,size:a.size})}u.length>0&&(c.value=u,n.value=Math.min(l,u.length-1),o.value=!0)},closePreview:()=>{o.value=!1,c.value=[],n.value=0},clearImageCache:()=>{r.value.forEach(e=>{e.startsWith("blob:")&&URL.revokeObjectURL(e)}),r.value.clear()}}}export{o as u}