vue-office/examples/dist/assets/DocxDemo-Dp-UENXA.js

2 lines
1.9 KiB
JavaScript

import{d as r}from"./docx-6qMHUQoF.js";import{d as _}from"./url-Br1dDInx.js";import{d as x,_ as l,r as m,o as h,w as g,a as p,c as w,b as v,e as D,f as O,g as y,u as B}from"./index-DW896H28.js";import{P as R,u}from"./PreviewWrapper-BacM9rN8.js";import"./jszip.min-DZRpzOVe.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";typeof window.setImmediate>"u"&&(window.setImmediate=function(e,...o){setTimeout(()=>e(o))});const $=x({name:"VueOfficeDocx",props:{src:[String,ArrayBuffer,Blob],requestOptions:{type:Object,default:()=>({})},options:{type:Object,default:()=>({})}},emits:["rendered","error"],setup(e,{emit:o}){const n=m(null);let c=null;function a(){let t=n.value;r.getData(e.src,e.requestOptions).then(async i=>{c=await r.getBlob(i),r.render(c,t,e.options).then(()=>{o("rendered")}).catch(f=>{r.render("",t,e.options),o("error",f)})}).catch(i=>{r.render("",t,e.options),o("error",i)})}h(()=>{e.src&&a()}),g(()=>e.src,()=>{e.src?a():r.render("",n.value,e.options).then(()=>{o("rendered")})});function s(t){_(t||`vue-office-docx-${new Date().getTime()}.docx`,c)}return{rootRef:n,save:s}}}),b={class:"vue-office-docx"},V={class:"vue-office-docx-main",ref:"rootRef"};function k(e,o,n,c,a,s){return p(),w("div",b,[v("div",V,null,512)])}const d=l($,[["render",k]]);d.install=function(e){e.component(d.name,d)};const q={__name:"DocxDemo",setup(e){function o(){u.hideLoading()}function n(t){console.log("出差",t),u.hideLoading()}const c=location.origin+(location.pathname+"/").replace("//","/")+"static/test-files/test.docx",a=m(),s={headers:{"component-name":"VueOfficeDocx"}};return(t,i)=>(p(),D(R,{accept:".docx",placeholder:"请输入docx文件地址","default-src":c},{default:O(f=>[y(B(d),{ref_key:"docxRef",ref:a,src:f.src,"request-options":s,style:{flex:"1",height:"0"},onRendered:o,onError:n},null,8,["src"])]),_:1}))}},P=l(q,[["__scopeId","data-v-844ea5ef"]]);export{P as default};