更新pptx 1.0

This commit is contained in:
liyulin 2025-01-04 10:49:21 +08:00
parent 67e4f885b6
commit be20e5201d
16 changed files with 431 additions and 1 deletions

View File

@ -0,0 +1 @@
import{d as r}from"./docx-00263541.js";import{d as p}from"./url-065d6777.js";import{d as x,_ as l,r as _,o as h,w as v,a as m,c as g,b as D,e as w,f as y,g as O,u as B}from"./index-d9ffc391.js";import{P as R,u}from"./PreviewWrapper-7c2e5c79.js";import"./jszip.min-00309054.js";import"./_commonjs-dynamic-modules-302442b1.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=_(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()}),v(()=>e.src,()=>{e.src?a():r.render("",n.value,e.options).then(()=>{o("rendered")})});function s(t){p(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 m(),g("div",b,[D("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=_(),s={headers:{"component-name":"VueOfficeDocx"}};return(t,i)=>(m(),w(R,{accept:".docx",placeholder:"请输入docx文件地址","default-src":c},{default:y(f=>[O(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};

View File

@ -0,0 +1 @@
import{S as I,r as S,g as E,a as B,t as $,c as R}from"./media-e013723d.js";import{l as q}from"./lodash-700e46b8.js";import{d as F}from"./url-065d6777.js";import{d as L,_ as V,r as b,o as W,n as j,h as N,w as A,a as O,c as H,b as M,i as P,e as U,f as z,j as G,g as J,u as K}from"./index-d9ffc391.js";import{P as Q,u as y}from"./PreviewWrapper-7c2e5c79.js";import"./_commonjs-dynamic-modules-302442b1.js";const C={xls:!1,minColLength:20},X=L({name:"VueOfficeExcel",props:{src:[String,ArrayBuffer,Blob],requestOptions:{type:Object,default:()=>({})},options:{type:Object,default:()=>({...C})}},emits:["rendered","error","switchSheet","cellSelected","cellsSelected"],setup(t,{emit:a}){const d=b(null),x=b(null);let c={_worksheets:[]},r=[],h=0,_=null,e=null,u=null,o=null;function i(n){o=n,B(n,t.options.xls).then(l=>{if(!l._worksheets||l._worksheets.length===0)throw new Error("未获取到数据,可能文件格式不正确或文件已损坏");t.options.beforeTransformData&&typeof t.options.beforeTransformData=="function"&&(l=t.options.beforeTransformData(l));let{workbookData:m,medias:g,workbookSource:v}=$(l,{...C,...t.options});t.options.transformData&&typeof t.options.transformData=="function"&&(m=t.options.transformData(m)),r=g,c=v,u=null,h=0,R(),e.loadData(m),S(_,r,c._worksheets[h],u,t.options),a("rendered"),a("switchSheet",0)}).catch(l=>{console.warn(l),r=[],c={_worksheets:[]},R(),e&&e.loadData({}),a("error",l),a("switchSheet",0)})}W(()=>{j(()=>{e=new I(x.value,{mode:"read",showToolbar:!1,showContextmenu:t.options.showContextmenu||!1,view:{height:()=>d.value&&d.value.clientHeight||300,width:()=>d.value&&d.value.clientWidth||1200},row:{height:24,len:100},col:{len:26,width:80,indexWidth:60,minWidth:60},autoFocus:!1}).loadData({}),e.on("cell-selected",(s,D,p)=>{a("cellSelected",{cell:s,rowIndex:D,columnIndex:p})}),e.on("cells-selected",(s,{sri:D,sci:p,eri:T,eci:k})=>{a("cellsSelected",{cell:s,startRowIndex:D,startColumnIndex:p,endRowIndex:T,endColumnIndex:k})});let n=e.bottombar.swapFunc;e.bottombar.swapFunc=function(s){n.call(e.bottombar,s),h=s,u=e.sheet.data.getSelectedRect(),setTimeout(()=>{e.reRender(),S(_,r,c._worksheets[h],u,t.options),a("switchSheet",s)})};let l=q.debounce(S,200,{leading:!0}),m=e.sheet.table.render;e.sheet.table.render=function(...s){e&&e.sheet&&m.apply(e.sheet.table,s),l(_,r,c._worksheets[h],u,t.options)};let g=e.sheet.editor.setOffset;e.sheet.editor.setOffset=function(...s){g.apply(e.sheet.editor,s),u=s[0]},_=x.value.querySelector("canvas").getContext("2d"),t.src&&E(t.src,t.requestOptions).then(i).catch(s=>{r=[],c={_worksheets:[]},e.loadData({}),a("error",s)})})}),N(()=>{e=null}),A(()=>t.src,()=>{t.src?E(t.src,t.requestOptions).then(i).catch(n=>{r=[],c={_worksheets:[]},e.loadData({}),a("error",n)}):(r=[],c={_worksheets:[]},e.loadData({}),a("error",new Error("src属性不能为空")))});function f(n){F(n||`vue-office-excel-${new Date().getTime()}.xlsx`,o)}return{wrapperRef:d,rootRef:x,save:f}}}),Y={class:"vue-office-excel",ref:"wrapperRef"},Z={class:"vue-office-excel-main",ref:"rootRef"};function ee(t,a,d,x,c,r){return O(),H("div",Y,[M("div",Z,null,512)],512)}const w=V(X,[["render",ee]]);w.install=function(t){t.component(w.name,w)};const re={__name:"ExcelDemo",setup(t){function a(){y.hideLoading()}function d(o){console.log("出差",o),y.hideLoading()}function x(o){return console.log("transformData",o),o}const c=location.origin+(location.pathname+"/").replace("//","/")+"static/test-files/test.xlsx",r=b();function h(o){return console.log("beforeTransformData",o,r),o._worksheets.forEach(i=>{let f=0;if(i._rows[f]&&i._rows[f]._cells)for(let n=0;n<i._rows[f]._cells.length;n++){let l=i._rows[f]._cells[n];l?l.style={bgcolor:"#00ff00"}:i._rows[f]._cells[n]={text:"",value:"",style:{bgcolor:"#00ff00"}}}}),o}function _(o){console.log("当前sheet",o)}function e(o){console.log("点击了单元格",o)}function u(o){console.log("选择了单元格",o)}return(o,i)=>{const f=P("loading");return O(),U(Q,{accept:".xlsx,.xls",placeholder:"请输入xlsx文件地址","default-src":c},{default:z(n=>[G(J(K(w),{ref_key:"docxRef",ref:r,src:n.src,options:{beforeTransformData:h,transformData:x,xls:n.xls},style:{flex:"1",height:"0"},onRendered:a,onError:d,onSwitchSheet:_,onCellSelected:e,onCellsSelected:u},null,8,["src","options"]),[[f,!0]])]),_:1})}}};export{re as default};

View File

@ -0,0 +1 @@
var p=Object.defineProperty;var c=(i,e,t)=>e in i?p(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(c(i,typeof e!="symbol"?e+"":e,t),t);import{d as r}from"./docx-00263541.js";import{d as l}from"./url-065d6777.js";import{r as h,o as d,a as u,c as m}from"./index-d9ffc391.js";import"./jszip.min-00309054.js";import"./_commonjs-dynamic-modules-302442b1.js";typeof window.setImmediate>"u"&&(window.setImmediate=function(i,...e){setTimeout(()=>i(e))});class w{constructor(e,t={},s={}){n(this,"container",null);n(this,"wrapper",null);n(this,"wrapperMain",null);n(this,"options",{});n(this,"requestOptions",{});n(this,"fileData",null);this.container=e,this.options=t,this.requestOptions=s,this.createWrapper()}createWrapper(){this.wrapper=document.createElement("div"),this.wrapper.className="vue-office-docx",this.wrapperMain=document.createElement("div"),this.wrapperMain.className="vue-office-docx-main",this.wrapper.appendChild(this.wrapperMain),this.container.appendChild(this.wrapper)}setOptions(e){this.options=e}setRequestOptions(e){this.requestOptions=e}preview(e){return new Promise((t,s)=>{r.getData(e,this.requestOptions).then(async o=>{this.fileData=await r.getBlob(o),r.render(this.fileData,this.wrapperMain,this.options).then(()=>{t()}).catch(a=>{r.render("",this.wrapperMain,this.options),s(a)})}).catch(o=>{r.render("",this.wrapperMain,this.options),s(o)})})}save(e){l(e||`js-preview-docx-${new Date().getTime()}.docx`,this.fileData)}destroy(){this.container.removeChild(this.wrapper),this.container=null,this.wrapper=null,this.wrapperMain=null,this.options=null,this.requestOptions=null}}function f(i,e,t){return new w(i,e,t)}const v={init:f};const g={__name:"JsDocxDemo",setup(i){const e=h(null);return d(()=>{let t=v.init(e.value);t.preview("/vue-office/examples/dist/static/test-files/test.docx").then(s=>{console.log("docx preview done"),setTimeout(()=>{t.preview("/vue-office/examples/dist/static/test-files/test2.docx")},3e3)}).catch(s=>{console.log("err",s)})}),(t,s)=>(u(),m("div",{ref_key:"dom",ref:e},null,512))}};export{g as default};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
import{r as u,m as C,_ as I,w as N,p as n,a as d,c as k,u as t,g as i,f as r,q as g,s as S,e as x,t as y,l as V,v as A,x as R,b as T}from"./index-d9ffc391.js";function $(e){const p=u("url"),a=u(e),o=u(e),l=u(typeof e=="string"?e.endsWith(".xls"):!1),c=u([]);function h(_){l.value=_.name.endsWith("xls");let f=new FileReader;return f.onload=s=>{let v=s.target.result;o.value=v},f.readAsArrayBuffer(_),!1}return{type:p,inputSrc:a,src:o,xls:l,fileList:c,beforeUpload:h}}let w=u(!1),B;function q(e){B=C.loading(e,0),w.value=!0}function E(){w.value===!0&&(B(),w.value=!1)}const F={loading:w,showLoading:q,hideLoading:E};function j(){return location.href.includes("test")}const z=e=>(A("data-v-0bd825a5"),e=e(),R(),e),D={class:"preview-wrapper"},G={key:0,class:"operate-area"},H=z(()=>T("div",{class:"preview-wrapper-main"},null,-1)),J={__name:"PreviewWrapper",props:{accept:String,placeholder:String,defaultSrc:String},setup(e){const p=e,{type:a,inputSrc:o,src:l,xls:c,fileList:h,beforeUpload:_}=$(p.defaultSrc);return N(l,()=>{F.showLoading()},{immediate:!0}),(f,s)=>{const v=n("a-radio-button"),L=n("a-radio-group"),U=n("a-input"),b=n("a-button"),W=n("upload-outlined"),P=n("a-upload");return d(),k("div",D,[t(j)()?y("",!0):(d(),k("div",G,[i(L,{value:t(a),"onUpdate:value":s[0]||(s[0]=m=>S(a)?a.value=m:null),"button-style":"solid"},{default:r(()=>[i(v,{value:"url"},{default:r(()=>[g("远程文件地址")]),_:1}),i(v,{value:"upload"},{default:r(()=>[g("上传本地文件")]),_:1})]),_:1},8,["value"]),t(a)==="url"?(d(),x(U,{key:0,value:t(o),"onUpdate:value":s[1]||(s[1]=m=>S(o)?o.value=m:null),placeholder:p.placeholder,style:{width:"600px","margin-left":"10px"}},null,8,["value","placeholder"])):y("",!0),t(a)==="url"?(d(),x(b,{key:1,type:"primary",style:{"margin-left":"10px"},onClick:s[2]||(s[2]=m=>{l.value=t(o),c.value=t(o).endsWith("xls")})},{default:r(()=>[g(" 预览 ")]),_:1})):y("",!0),t(a)!=="url"?(d(),x(P,{key:2,accept:p.accept,action:"",beforeUpload:t(_),"file-list":[]},{default:r(()=>[i(b,{style:{"margin-left":"10px"}},{default:r(()=>[i(W),g(" 选择文件 ")]),_:1})]),_:1},8,["accept","beforeUpload"])):y("",!0)])),V(f.$slots,"default",{src:t(l),xls:t(c)},void 0,!0),H])}}},M=I(J,[["__scopeId","data-v-0bd825a5"]]);export{M as P,F as u};

22
examples/dist/assets/docx-00263541.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

121
examples/dist/assets/index-d9ffc391.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

27
examples/dist/assets/lodash-700e46b8.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

174
examples/dist/assets/media-e013723d.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<title>@vue-office演示demo</title>
<script type="module" crossorigin src="/vue-office/examples/dist/assets/index-0ea1e283.js"></script>
<script type="module" crossorigin src="/vue-office/examples/dist/assets/index-d9ffc391.js"></script>
<link rel="stylesheet" href="/vue-office/examples/dist/assets/index-9a3c0236.css">
</head>
<body>