Files
qhmes/deploy-qhmes/frontend/js/NativeTemplateListPreviewModal-BNRs16cy.js

2 lines
11 KiB
Java
Raw Normal View History

2026-05-15 11:34:12 +08:00
var Oe=Object.defineProperty,Te=Object.defineProperties;var je=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var De=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable;var re=(f,c,n)=>c in f?Oe(f,c,{enumerable:!0,configurable:!0,writable:!0,value:n}):f[c]=n,ue=(f,c)=>{for(var n in c||(c={}))De.call(c,n)&&re(f,n,c[n]);if(ie)for(var n of ie(c))Je.call(c,n)&&re(f,n,c[n]);return f},ce=(f,c)=>Te(f,je(c));var U=(f,c,n)=>new Promise((E,w)=>{var H=v=>{try{N(n.next(v))}catch(l){w(l)}},J=v=>{try{N(n.throw(v))}catch(l){w(l)}},N=v=>v.done?E(v.value):Promise.resolve(v.value).then(H,J);N((n=n.apply(f,c)).next())});import{d as Ie,w as $,f as p,e as C,ah as g,aC as L,as as k,aF as i,k as o,ar as X,ag as W,av as ve,au as d,q as pe,at as me,B as de,G as q,A as Be,u as Q,aB as Y,n as ee}from"./vue-vendor-C7Zq48Yl.js";import{bM as $e,J as Le,M as te,u as He,d as Re}from"./index-BI6CMai0.js";import{q as Fe}from"./printTemplate.api-CHChWHTu.js";import{n as Ue,s as We,g as fe,r as qe,a as Ee,p as Ve}from"./printNativeViaPrintDot-CW0hqAEQ.js";import"./antd-vue-vendor-BPnV8VqP.js";import"./vxe-table-vendor-B88kchpX.js";import"./browser-INOPQ3v-.js";import"./tableMerge-CpKVscEF.js";import"./tableBuilder-lOY0L2dW.js";import"./freeTableGrid-BXWKfNhh.js";import"./freeTableBorders-DHo40MDb.js";import"./freeTableTracks-CfeiVurn.js";const Ae={key:0,class:"native-preview-error"},Ke={class:"json-template-pane"},Ze={class:"params-json-pane"},Ge={class:"params-json-head"},Xe={class:"json-sub-tabs json-sub-tabs--segmented",role:"tablist","aria-label":"参数数据来源"},Qe={class:"preview-header-row"},Ye={class:"preview-zoom-label"},et={key:0,class:"preview-scroll-flex"},tt={class:"preview-zoom-slot"},at=["srcdoc"],he=1.15,nt=.25,ot=4,we=96/25.4,lt=Ie({__name:"NativeTemplateListPreviewModal",props:{open:{type:Boolean},templateId:{}},emits:["update:open"],setup(f,{emit:c}){const n=f,E=c,{createMessage:w}=He(),H=C({get:()=>n.open,set:e=>E("update:open",e)}),J=p(!1),N=p(!1),v=p(""),l=p(null),I=p("{}"),V=p("template"),y=p("mock"),R=p("{}"),z=p("{}"),b=p(""),F=p(null),A=p(null),O=p(1),M=p(1),K=C(()=>{const e=O.value*M.value;return!Number.isFinite(e)||e<=0?1:Math.min(4,Math.max(.08,e))}),xe=C(()=>`${Math.round(M.value*100)}%`),ae=C(()=>y.value==="mock"?z.value:R.value),Z=C(()=>{try{return JSON.parse(ae.value||"{}")}catch(e){return{}}}),ne=C(()=>{var u,m;if(!l.value)return null;const e=Math.max(1,qe(l.value,Z.value)),t=Number(((u=l.value.page)==null?void 0:u.width)||210),r=Number(((m=l.value.page)==null?void 0:m.height)||297),a=t*we,s=r*e*we;return{wPx:a,hPx:s,pageCount:e}}),T=p({w:0,h:0}),P=C(()=>{const e=ne.value;if(!e)return null;const t=T.value;return ce(ue({},e),{wPx:Math.max(e.wPx,t.w||0),hPx:Math.max(e.hPx,t.h||0)})});function _e(e){const t=e.body;let r=1/0,a=0,s=1/0,u=0;const m=D=>{if(D instanceof HTMLElement){const h=D.getBoundingClientRect();h.height>.5&&h.width>.5&&(r=Math.min(r,h.top),a=Math.max(a,h.bottom),s=Math.min(s,h.left),u=Math.max(u,h.right))}for(let h=0;h<D.children.length;h++)m(D.children[h])};m(t);const x=Number.isFinite(r)&&a>0?{w:Math.ceil(u-s+6),h:Math.ceil(a-r+12)}:{w:0,h:0},j=Math.max(e.documentElement.scrollHeight,t.scrollHeight,x.h),B=Math.max(e.documentElement.scrollWidth,t.scrollWidth,x.w);return{w:Math.ceil(B),h:Math.ceil(j)}}function oe(){ee(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{var t;const e=(t=A.value)==null?void 0:t.contentDocument;if(!(e!=null&&e.body)){T.value={w:0,h:0},S();return}T.value=_e(e),S()})})})}function le(){return U(this,null,function*(){if(!l.value){b.value="";return}try{b.value=yield Ee(l.value,Z.value)}catch(e){b.value="",w.error(`预览渲染失败:${(e==null?void 0:e.message)||"未知错误"}`)}})}const ge=Le(()=>void le(),320);function ye(){const e=F.value,t=P.value;if(!e||!t){O.value=1;return}const r=20,a=Math.max(0,e.clientWidth-r),s=Math.max(0,e.clientHeight-r);if(a<=0||s<=0||t.wPx<=0||t.hPx<=0){O.value=1;return}const u=Math.min(a/t.wPx,s/t.hPx,1)*.96;O.value=Number.isFinite(u)&&u>0?u:1}function be(){M.value=Math.min(ot,M.value*he),G()}f