sakura-preview-file 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +6 -1
- package/dist/index.umd.js +1 -1
- package/dist/style.css +1 -1
- package/index.d.ts +185 -42
- package/package.json +3 -4
package/dist/index.es.js
CHANGED
|
@@ -497,7 +497,12 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
497
497
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _pageNum.value = $event),
|
|
498
498
|
onBlur: _cache[2] || (_cache[2] = ($event) => emits(unref(EVENT_NAME).改变))
|
|
499
499
|
}, null, 544), [
|
|
500
|
-
[
|
|
500
|
+
[
|
|
501
|
+
vModelText,
|
|
502
|
+
_pageNum.value,
|
|
503
|
+
void 0,
|
|
504
|
+
{ number: true }
|
|
505
|
+
]
|
|
501
506
|
]),
|
|
502
507
|
createElementVNode("span", _hoisted_3$1, " / " + toDisplayString(__props.total), 1)
|
|
503
508
|
]),
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("vue"),require("sakura-utils"),require("vue-pdf-embed"),require("pdfjs-dist"),require("@vueuse/core"),require("docx-preview")):"function"==typeof define&&define.amd?define(["exports","vue","sakura-utils","vue-pdf-embed","pdfjs-dist","@vueuse/core","docx-preview"],a):a((e="undefined"!=typeof globalThis?globalThis:e||self).SakuraPreviewFile={},e.Vue,e.sakuraUtils,e.VuePdfEmbed,null,e.core,e.docxPreview)}(this,(function(e,a,l,o,t,n,r){"use strict";const s=["stroke"],i=(e,a)=>{const l=e.__vccOpts||e;for(const[o,t]of a)l[o]=t;return l},u={Circle:i(a.defineComponent({__name:"Circle",props:{size:{default:50},color:{default:"#409eff"},duration:{default:2}},setup(e){const o=e,t=a.computed(()=>{const{size:e,duration:a}=o;return{"--circle-size":l.addUnit(e),"--circle-duration":a+"s"}});return(l,o)=>(a.openBlock(),a.createElementBlock("svg",{class:"circular",viewBox:"0 0 50 50",style:a.normalizeStyle([t.value])},[a.createElementVNode("circle",{class:"circular__path-inner",cx:"25",cy:"25",r:"20",fill:"none",stroke:e.color,"stroke-width":"4","stroke-miterlimit":"10"},null,8,s)],4))}}),[["__scopeId","data-v-51d1fa15"]]),Dot:i(a.defineComponent({__name:"Dot",props:{gap:{default:6},color:{default:"var(--preview-file-primary-color)"},size:{default:10},duration:{default:1.4}},setup(e){const o=e,t=a.computed(()=>{const{size:e,gap:a,duration:t,color:n}=o;return{"--dot-size":l.addUnit(e),"--dot-duration":t+"s","--dot-gap":l.addUnit(a),"--dot-color":n}});return(e,l)=>(a.openBlock(),a.createElementBlock("div",{class:"dot",style:a.normalizeStyle([t.value])},[...l[0]||(l[0]=[a.createElementVNode("div",{class:"dot__item"},null,-1),a.createElementVNode("div",{class:"dot__item"},null,-1),a.createElementVNode("div",{class:"dot__item"},null,-1)])],4))}}),[["__scopeId","data-v-2acd99b5"]]),Progress:i(a.defineComponent({__name:"Progress",props:{width:{default:200},height:{default:4},background:{default:"#ebeef5"},radius:{},color:{default:"var(--preview-file-primary-color)"},duration:{default:2}},setup(e){const o=e,t=a.computed(()=>{const{width:e,height:a,color:t,duration:n,radius:r,background:s}=o;return{"--progress-width":l.addUnit(e),"--progress-height":l.addUnit(a),"--progress-border-radius":l.addUnit(r||Number(a)/2),"--progress-background":s,"--progress-duration":n+"s","--progress-color":t}});return(e,l)=>(a.openBlock(),a.createElementBlock("div",{class:"progress",style:a.normalizeStyle([t.value])},[...l[0]||(l[0]=[a.createElementVNode("div",{class:"progress__bar"},null,-1)])],4))}}),[["__scopeId","data-v-3a710001"]]),Cube:i(a.defineComponent({__name:"Cube",props:{size:{default:40},color:{default:"var(--preview-file-primary-color)"},duration:{default:1.3}},setup(e){const o=e,t=a.computed(()=>{const{size:e,duration:a,color:t}=o;return{"--cube-size":l.addUnit(e),"--cube-color":t,"--cube-duration":a+"s"}});return(e,l)=>(a.openBlock(),a.createElementBlock("div",{class:"cube",style:a.normalizeStyle([t.value])},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(9,e=>a.createElementVNode("div",{key:e,class:"cube__item"})),64))],4))}}),[["__scopeId","data-v-0e6bb9d0"]])},c=(e,a,l,o,t)=>{let n=e+"-"+a;return l&&(n+="-"+l),o&&(n+="__"+o),t&&(n+="--"+t),n},d=e=>{const o=a.ref(""),t=a.computed(()=>l.isEmpty(o.value)?l.FILE_TYPE.IMAGE:l.getFileType(e.convertToLocalFileUrl?e.src:o.value));return a.watchEffect(async()=>{const{src:a}=e;o.value="",a instanceof Blob?o.value=l.base64ToFileUrl(await l.blobToBase64(a)):l.isBase64File(a)?o.value=l.base64ToFileUrl(a):o.value=e.convertToLocalFileUrl?await l.networkFileUrlToLocalFileUrl(a):a}),{fileType:t,fileUrl:o}},m=(e={})=>{const{maxScale:o=3,minScale:t=.4,stepNum:r=.2,wheelNum:s=.3}=e,i=a.ref(1),u=a.computed(()=>l.numberToFixed(100*i.value,0)+"%"),c=(e=r)=>{i.value=Math.max(t,i.value-=e)},d=(e=r)=>{i.value=(i.value+=e)>o?o:i.value},m=n.useThrottleFn(()=>c(),300),p=n.useThrottleFn(()=>d(),300);return{clickMinusScale:m,clickPlusScale:p,scale:i,scaleText:u,onWheel:e=>{e.ctrlKey&&(e.preventDefault(),e.deltaY>0?c(Math.random()*s):d(Math.random()*s))},resetWheelState:()=>{i.value=1}}},p=(e,l)=>{const{onWheel:o,clickMinusScale:t,clickPlusScale:n,resetWheelState:r,scale:s,scaleText:i}=m(),{isMouseDown:u,onMouseStart:c,resetMouseState:d,translateX:p,translateY:f}=(()=>{const e=a.ref(!1),l=a.ref(0),o=a.ref(0),t=a.ref(0),n=a.ref(0),r=a=>{if(!e.value)return;a.preventDefault();const r=a.clientX,s=a.clientY;t.value=r-l.value,n.value=s-o.value},s=()=>{e.value=!1,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s)};return{resetMouseState:()=>{l.value=0,o.value=0,t.value=0,n.value=0,e.value=!1},onMouseStart:a=>{e.value=!0,l.value=a.clientX-t.value,o.value=a.clientY-n.value,window.addEventListener("mousemove",r),window.addEventListener("mouseup",s)},translateX:t,translateY:n,isMouseDown:e}})(),v=a.computed(()=>({transform:`translate(${p.value}px, ${f.value}px) scale(${s.value})`,transformOrigin:"center center"})),k=()=>{d(),r()};a.watch(()=>null==l?void 0:l.value,k);const g=a.ref(null);return a.watch(()=>e.value,()=>{g.value&&(g.value.scrollTop=0,k())}),{wrapperRef:g,onWheel:o,clickMinusScale:t,clickPlusScale:n,resetWheelState:r,scale:s,scaleText:i,isMouseDown:u,onMouseStart:c,resetMouseState:d,translateX:p,translateY:f,wrapperStyle:v}};var f=(e=>(e["完成"]="loaded",e["改变"]="change",e["下一页"]="next",e["上一页"]="prev",e["放大"]="zoomIn",e["缩小"]="zoomOut",e))(f||{});const v={class:"sakura-file-data__tools"},k={class:"sakura-file-data__page"},g={class:"sakura-file-data__text"},b={key:1,class:"sakura-file-data__scale"},w={class:"sakura-file-data__scale-text"},h=a.defineComponent({__name:"Tools",props:a.mergeModels({showTools:{type:Boolean},total:{},scaleText:{},nextPageDisabled:{type:Boolean},prevPageDisabled:{type:Boolean},enablePagination:{type:Boolean},enableMove:{type:Boolean},enableScale:{type:Boolean}},{modelValue:{type:Number,default:1},modelModifiers:{}}),emits:a.mergeModels([f.改变,f.下一页,f.上一页,f.放大,f.缩小],["update:modelValue"]),setup(e,{emit:l}){const o=l,t=a.useModel(e,"modelValue");return(l,n)=>(a.openBlock(),a.createElementBlock("div",v,[a.renderSlot(l.$slots,"default"),e.showTools?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[e.enablePagination?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createElementVNode("div",{class:a.normalizeClass(["sakura-file-data__arrow sakura-file-data__arrow-prev",[e.prevPageDisabled?"is-disabled":""]]),onClick:n[0]||(n[0]=e=>o(a.unref(f).上一页))},null,2),a.createElementVNode("div",k,[a.withDirectives(a.createElementVNode("input",{class:"sakura-file-data__input","onUpdate:modelValue":n[1]||(n[1]=e=>t.value=e),onBlur:n[2]||(n[2]=e=>o(a.unref(f).改变))},null,544),[[a.vModelText,t.value]]),a.createElementVNode("span",g," / "+a.toDisplayString(e.total),1)]),a.createElementVNode("div",{class:a.normalizeClass(["sakura-file-data__arrow sakura-file-data__arrow-next",[e.nextPageDisabled?"is-disabled":""]]),onClick:n[3]||(n[3]=e=>o(a.unref(f).下一页))},null,2)],64)):a.createCommentVNode("",!0),e.enableScale?(a.openBlock(),a.createElementBlock("div",b,[a.createElementVNode("div",{class:"sakura-file-data__icon sakura-file-data__minus",onClick:n[4]||(n[4]=e=>o(a.unref(f).缩小))}),a.createElementVNode("span",w,a.toDisplayString(e.scaleText),1),a.createElementVNode("div",{class:"sakura-file-data__icon sakura-file-data__plus",onClick:n[5]||(n[5]=e=>o(a.unref(f).放大))})])):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)]))}}),y={class:"sakura-file-data"},_=a.defineComponent({__name:"Pdf",props:a.mergeModels({enablePagination:{type:Boolean,default:!0},enableScale:{type:Boolean,default:!0},enableMove:{type:Boolean,default:!0},fileUrl:{},showTools:{type:Boolean,default:!0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:a.mergeModels([f.完成],["update:modelValue"]),setup(e,{emit:t}){const r=e,s=t,i=a.useModel(e,"modelValue"),u=a.computed(()=>({url:r.fileUrl,fontExtraProperties:!0,cMapUrl:"./cmaps/",cMapPacked:!0,disableFontFace:!1,enableXfa:!0,fontLoadTimeout:3e4,verbosity:0})),c=a.reactive({pageNum:1,total:0,isError:!1}),d=a.ref(0),m=async e=>{var o;c.total=e._pdfInfo.numPages,await a.nextTick(),await l.sleep(50),d.value=(null==(o=document.querySelector(".vue-file-dataembed"))?void 0:o.clientHeight)??0},v=()=>{c.isError=!0},k=async()=>{await l.sleep(300),i.value=!1,s(f.完成)},{prevPageDisabled:g,nextPageDisabled:b,nextPage:w,_pageNum:_,onPageNumChange:B,prevPage:V}=(e=>{const l=a.computed(()=>e.pageNum>=e.total),o=n.useThrottleFn(()=>{l.value||e.pageNum++},500),t=a.computed(()=>e.pageNum<=1),r=n.useThrottleFn(()=>{t.value||e.pageNum--},500),s=a.ref(1);return a.watchEffect(()=>{s.value=e.pageNum}),{nextPage:o,nextPageDisabled:l,prevPage:r,prevPageDisabled:t,_pageNum:s,onPageNumChange:()=>{const{total:a}=e;e.pageNum=Math.max(Math.min(s.value,a),1)}}})(c),N=()=>{i.value=!0,_.value=1,l.extend(c,{pageNum:1,total:0,isError:!1})};a.watch(()=>r.fileUrl,N),a.onMounted(N);const{pageNum:E}=a.toRefs(c),{fileUrl:S}=a.toRefs(r),{onWheel:M,clickMinusScale:x,clickPlusScale:C,isMouseDown:P,scaleText:T,onMouseStart:U,wrapperStyle:F}=p(S,E);return(l,t)=>(a.openBlock(),a.createElementBlock("div",y,[a.createElementVNode("div",{ref:"wrapperRef",class:a.normalizeClass(["sakura-file-data__wrapper",[a.unref(P)?"is-drag":""]]),onMousedown:t[0]||(t[0]=l=>e.enableMove&&a.unref(U)(l)),onWheel:t[1]||(t[1]=l=>e.enableScale&&a.unref(M)(l))},[a.createElementVNode("div",{style:a.normalizeStyle([a.unref(F)])},[a.createVNode(a.unref(o),{class:"pdf",source:u.value,page:e.enablePagination?c.pageNum:void 0,scale:1,onLoaded:m,onRendered:k,onError:v},null,8,["source","page"])],4)],34),e.enablePagination||e.enableScale||e.showTools?(a.openBlock(),a.createBlock(h,{key:0,modelValue:a.unref(_),"onUpdate:modelValue":t[2]||(t[2]=e=>a.isRef(_)?_.value=e:null),total:c.total,"prev-page-disabled":a.unref(g),"next-page-disabled":a.unref(b),"scale-text":a.unref(T),"show-tools":e.showTools,"enable-pagination":e.enablePagination,"enable-scale":e.enableScale,"enable-move":e.enableMove,onChange:a.unref(B),onNext:a.unref(w),onPrev:a.unref(V),onZoomIn:a.unref(C),onZoomOut:a.unref(x)},{default:a.withCtx(()=>[a.renderSlot(l.$slots,"default",{fileDataState:c})]),_:3},8,["modelValue","total","prev-page-disabled","next-page-disabled","scale-text","show-tools","enable-pagination","enable-scale","enable-move","onChange","onNext","onPrev","onZoomIn","onZoomOut"])):a.createCommentVNode("",!0)]))}}),B={class:"sakura-file-data"},V=a.defineComponent({__name:"Word",props:a.mergeModels({enablePagination:{type:Boolean},enableScale:{type:Boolean},enableMove:{type:Boolean},fileUrl:{},showTools:{type:Boolean,default:!0},isLocalFile:{type:Boolean,default:!1},enableWrapper:{type:Boolean,default:!0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:a.mergeModels([f.完成],["update:modelValue"]),setup(e,{emit:o}){const t=e,n=a.useModel(e,"modelValue"),s=a.useTemplateRef("wordFileRef"),i=async()=>{try{n.value=!0,s.value&&(s.value.innerHTML="");const e=await(async()=>{const e=await fetch(t.fileUrl),a=await e.blob();return l.base64ToFile(await l.blobToBase64(a),l.generateId()+".docx")})();await r.renderAsync(e,s.value,void 0,{className:"docx",inWrapper:t.enableWrapper,ignoreWidth:!0,ignoreHeight:!1,ignoreFonts:!0,breakPages:!0,ignoreLastRenderedPageBreak:!0,experimental:!1,trimXmlDeclaration:!0}),await a.nextTick()}catch(e){console.log("fileUrl---",t.fileUrl),console.log("加载word文件失败----",e)}finally{n.value=!1}};a.onMounted(i),a.watch(()=>t.fileUrl,i);const{fileUrl:u}=a.toRefs(t),{onWheel:c,clickMinusScale:d,clickPlusScale:m,isMouseDown:f,scaleText:v,onMouseStart:k,wrapperStyle:g}=p(u);return(l,o)=>(a.openBlock(),a.createElementBlock("div",B,[a.createElementVNode("div",{ref:"wrapperRef",class:a.normalizeClass(["sakura-file-data__wrapper",[a.unref(f)?"is-drag":"",e.enableWrapper?"is-enable-wrapper":""]]),onMousedown:o[0]||(o[0]=l=>e.enableMove&&a.unref(k)(l)),onWheel:o[1]||(o[1]=l=>e.enableScale&&a.unref(c)(l))},[a.createElementVNode("div",{ref_key:"wordFileRef",ref:s,style:a.normalizeStyle([a.unref(g)])},null,4)],34),e.enablePagination||e.enableScale||e.showTools?(a.openBlock(),a.createBlock(h,{key:0,"scale-text":a.unref(v),"show-tools":e.showTools,"enable-scale":e.enableScale,"enable-move":e.enableMove,onZoomIn:a.unref(m),onZoomOut:a.unref(d)},{default:a.withCtx(()=>[a.renderSlot(l.$slots,"default")]),_:3},8,["scale-text","show-tools","enable-scale","enable-move","onZoomIn","onZoomOut"])):a.createCommentVNode("",!0)]))}}),N={width:"24",height:"24",fill:"none"};const E=i({},[["render",function(e,l){return a.openBlock(),a.createElementBlock("svg",N,[...l[0]||(l[0]=[a.createElementVNode("circle",{cx:"10.5",cy:"10.5",r:"6.5",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M15.5 15.5L20 20",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])}]]),S={width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const M=i({},[["render",function(e,l){return a.openBlock(),a.createElementBlock("svg",S,[...l[0]||(l[0]=[a.createElementVNode("circle",{cx:"10.5",cy:"10.5",r:"6.5",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M7.5 10.5H13.5",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M15.5 15.5L20 20",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])}]]),x={width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const C=i({},[["render",function(e,l){return a.openBlock(),a.createElementBlock("svg",x,[...l[0]||(l[0]=[a.createElementVNode("path",{d:"M7 7L17 17",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M7 17L17 7",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])}]]),P={class:"sakura-file-data"},T={class:"sakura-file-data__wrapper is-image"},U=["src"],F={class:"sakura-preview__image--data"},z=["src"],D={key:0,class:"sakura-preview__image--tools"},L=a.defineComponent({__name:"Image",props:a.mergeModels({enablePagination:{type:Boolean},enableScale:{type:Boolean},enableMove:{type:Boolean},fileUrl:{},showTools:{type:Boolean}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const o=e,t=a.useModel(e,"modelValue"),r=()=>{t.value=!1},{width:s,height:i}=n.useWindowSize(),u=a.ref(0),c=a.ref(0);a.onMounted(async()=>{const e=o.fileUrl;u.value=0,c.value=0;const a=new Image;a.src=e,a.onload=()=>{u.value=a.width,c.value=a.height}});const d=a.computed(()=>u.value>s.value?{width:"auto",height:l.addUnit(i.value)}:{width:l.addUnit(u.value),height:l.addUnit(c.value)}),{fileUrl:m}=a.toRefs(o),{onWheel:f,onMouseStart:v,isMouseDown:k,clickMinusScale:g,clickPlusScale:b,wrapperStyle:w}=p(m),h=a.ref(!1),y=()=>{h.value=!h.value};return(l,o)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",P,[a.createElementVNode("div",T,[a.createElementVNode("img",{class:"sakura-file-data__image",src:a.unref(m),alt:"",onLoad:r,onClick:y},null,40,U)])]),(a.openBlock(),a.createBlock(a.Teleport,{to:"body"},[a.createElementVNode("div",{class:a.normalizeClass(["sakura-preview-dialog",[h.value?"is-visible":""]])},[o[2]||(o[2]=a.createElementVNode("div",{class:"sakura-preview__image--mark"},null,-1)),a.createElementVNode("div",{ref:"wrapperRef",class:a.normalizeClass(["sakura-preview__image",[a.unref(k)?"is-drag":""]]),onMousedown:o[0]||(o[0]=l=>e.enableMove&&a.unref(v)(l)),onWheel:o[1]||(o[1]=l=>e.enableScale&&a.unref(f)(l))},[a.createElementVNode("div",F,[a.createElementVNode("img",{class:"dot-move",src:a.unref(m),style:a.normalizeStyle([d.value,a.unref(w)]),alt:""},null,12,z)]),a.createElementVNode("div",{class:"sakura-preview__image--close",onClick:y},[a.createVNode(C)]),e.enableScale?(a.openBlock(),a.createElementBlock("div",D,[a.createVNode(E,{onClick:a.unref(b)},null,8,["onClick"]),a.createVNode(M,{onClick:a.unref(g)},null,8,["onClick"])])):a.createCommentVNode("",!0)],34)],2)]))],64))}}),$=Symbol("PreviewFile"),W=a.defineComponent({__name:"preview-file",props:{width:{default:"100%"},height:{default:"100%"},src:{},enablePagination:{type:Boolean,default:!0},enableScale:{type:Boolean,default:!0},enableMove:{type:Boolean,default:!0},loadingType:{default:"circle"},loadingState:{default:()=>({})},convertToLocalFileUrl:{type:Boolean,default:!1},themeColor:{default:"#409eff"}},setup(e){const o=e;a.provide($,o);const t=((e,l)=>{const o=a.unref(l)??"sakura"??e,t=e=>`${o}-${e}`,n=(e,a)=>`${o}-${e}-${a}`;return{b:(a="")=>c(o,e,a,"",""),e:(a="")=>a?c(o,e,"",a,""):"",m:(a="")=>a?c(o,e,"","",a):"",be:(a="",l="")=>a&&l?c(o,e,a,l,""):"",em:(a="",l="")=>a&&l?c(o,e,"",a,l):"",bm:(a="",l="")=>a&&l?c(o,e,a,"",l):"",bem:(a="",l="",t="")=>a&&l&&t?c(o,e,a,l,t):"",is:(e,...a)=>(!a.length||a[0])&&e?"is-"+e:"",cssVar:e=>{const a={};for(const l in e)e[l]&&(a[`--${o}-${l} `]=e[l]);return a},cssBlockVar:(e,a)=>{const l={};for(const t in a)a[t]&&(l[`--${o}-${e}-${t}`]=a[t]);return l},cssVarName:t,cssBlockVarName:n,cssVarNameValue:e=>`var(--${t(e)})`,cssBlockVarNameValue:(e,a)=>`var(--${n(e,a)})`}})("preview-file"),n=a.computed(()=>{const{width:e,height:a,themeColor:t}=o,n={"--preview-file-primary-color":t};return l.isEmpty(e)||(n.width=l.addUnit(e)),l.isEmpty(a)||(n.height=l.addUnit(a)),n}),{fileType:r,fileUrl:s}=d(o),i=a.ref(!0),m=a.computed(()=>{const{loadingType:e}=o;switch(e){case"circle":return u.Circle;case"dot":return u.Dot;case"cube":return u.Cube;case"progress":default:return u.Progress}});return(u,c)=>(a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(a.unref(t).b()),style:a.normalizeStyle([n.value])},[a.unref(l.isEmpty)(a.unref(s))?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass([a.unref(t).e("wrapper")])},[a.unref(l.isPdfFile)(a.unref(r))?(a.openBlock(),a.createBlock(_,{key:0,modelValue:i.value,"onUpdate:modelValue":c[0]||(c[0]=e=>i.value=e),"file-url":a.unref(s),"show-tools":!u.$slots.default,"enable-pagination":e.enablePagination,"enable-scale":e.enableScale,"enable-move":e.enableMove},{default:a.withCtx(({fileDataState:e})=>[a.renderSlot(u.$slots,"default",{fileState:e,data:o})]),_:3},8,["modelValue","file-url","show-tools","enable-pagination","enable-scale","enable-move"])):a.createCommentVNode("",!0),a.unref(l.isWordFile)(a.unref(r))?(a.openBlock(),a.createBlock(V,{key:1,modelValue:i.value,"onUpdate:modelValue":c[1]||(c[1]=e=>i.value=e),"file-url":a.unref(s),"show-tools":!u.$slots.default,"enable-pagination":e.enablePagination,"enable-scale":e.enableScale,"enable-move":e.enableMove,"is-local-file":e.convertToLocalFileUrl},null,8,["modelValue","file-url","show-tools","enable-pagination","enable-scale","enable-move","is-local-file"])):a.unref(l.isImageFile)(a.unref(r))?(a.openBlock(),a.createBlock(L,{key:2,modelValue:i.value,"onUpdate:modelValue":c[2]||(c[2]=e=>i.value=e),"file-url":a.unref(s),"show-tools":!u.$slots.default,"enable-scale":e.enableScale,"enable-move":e.enableMove},null,8,["modelValue","file-url","show-tools","enable-scale","enable-move"])):a.createCommentVNode("",!0)],2)),a.withDirectives(a.createElementVNode("div",{class:a.normalizeClass([a.unref(t).e("loading")])},[a.createElementVNode("div",{class:a.normalizeClass([a.unref(t).e("loading-spinner")])},[(a.openBlock(),a.createBlock(a.resolveDynamicComponent(m.value),a.normalizeProps(a.guardReactiveProps({...e.loadingState,color:e.themeColor})),null,16))],2)],2),[[a.vShow,i.value]])],6))}});W.install=e=>{e.component("PreviewFile",W),e.component("Loading",u)},e.Loading=u,e.default=W,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("vue"),require("sakura-utils"),require("vue-pdf-embed"),require("pdfjs-dist"),require("@vueuse/core"),require("docx-preview")):"function"==typeof define&&define.amd?define(["exports","vue","sakura-utils","vue-pdf-embed","pdfjs-dist","@vueuse/core","docx-preview"],a):a((e="undefined"!=typeof globalThis?globalThis:e||self).SakuraPreviewFile={},e.Vue,e.sakuraUtils,e.VuePdfEmbed,null,e.core,e.docxPreview)}(this,(function(e,a,l,o,t,n,r){"use strict";const s=["stroke"],i=(e,a)=>{const l=e.__vccOpts||e;for(const[o,t]of a)l[o]=t;return l},u={Circle:i(a.defineComponent({__name:"Circle",props:{size:{default:50},color:{default:"#409eff"},duration:{default:2}},setup(e){const o=e,t=a.computed(()=>{const{size:e,duration:a}=o;return{"--circle-size":l.addUnit(e),"--circle-duration":a+"s"}});return(l,o)=>(a.openBlock(),a.createElementBlock("svg",{class:"circular",viewBox:"0 0 50 50",style:a.normalizeStyle([t.value])},[a.createElementVNode("circle",{class:"circular__path-inner",cx:"25",cy:"25",r:"20",fill:"none",stroke:e.color,"stroke-width":"4","stroke-miterlimit":"10"},null,8,s)],4))}}),[["__scopeId","data-v-51d1fa15"]]),Dot:i(a.defineComponent({__name:"Dot",props:{gap:{default:6},color:{default:"var(--preview-file-primary-color)"},size:{default:10},duration:{default:1.4}},setup(e){const o=e,t=a.computed(()=>{const{size:e,gap:a,duration:t,color:n}=o;return{"--dot-size":l.addUnit(e),"--dot-duration":t+"s","--dot-gap":l.addUnit(a),"--dot-color":n}});return(e,l)=>(a.openBlock(),a.createElementBlock("div",{class:"dot",style:a.normalizeStyle([t.value])},[...l[0]||(l[0]=[a.createElementVNode("div",{class:"dot__item"},null,-1),a.createElementVNode("div",{class:"dot__item"},null,-1),a.createElementVNode("div",{class:"dot__item"},null,-1)])],4))}}),[["__scopeId","data-v-2acd99b5"]]),Progress:i(a.defineComponent({__name:"Progress",props:{width:{default:200},height:{default:4},background:{default:"#ebeef5"},radius:{},color:{default:"var(--preview-file-primary-color)"},duration:{default:2}},setup(e){const o=e,t=a.computed(()=>{const{width:e,height:a,color:t,duration:n,radius:r,background:s}=o;return{"--progress-width":l.addUnit(e),"--progress-height":l.addUnit(a),"--progress-border-radius":l.addUnit(r||Number(a)/2),"--progress-background":s,"--progress-duration":n+"s","--progress-color":t}});return(e,l)=>(a.openBlock(),a.createElementBlock("div",{class:"progress",style:a.normalizeStyle([t.value])},[...l[0]||(l[0]=[a.createElementVNode("div",{class:"progress__bar"},null,-1)])],4))}}),[["__scopeId","data-v-3a710001"]]),Cube:i(a.defineComponent({__name:"Cube",props:{size:{default:40},color:{default:"var(--preview-file-primary-color)"},duration:{default:1.3}},setup(e){const o=e,t=a.computed(()=>{const{size:e,duration:a,color:t}=o;return{"--cube-size":l.addUnit(e),"--cube-color":t,"--cube-duration":a+"s"}});return(e,l)=>(a.openBlock(),a.createElementBlock("div",{class:"cube",style:a.normalizeStyle([t.value])},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(9,e=>a.createElementVNode("div",{key:e,class:"cube__item"})),64))],4))}}),[["__scopeId","data-v-0e6bb9d0"]])},c=(e,a,l,o,t)=>{let n=e+"-"+a;return l&&(n+="-"+l),o&&(n+="__"+o),t&&(n+="--"+t),n},d=e=>{const o=a.ref(""),t=a.computed(()=>l.isEmpty(o.value)?l.FILE_TYPE.IMAGE:l.getFileType(e.convertToLocalFileUrl?e.src:o.value));return a.watchEffect(async()=>{const{src:a}=e;o.value="",a instanceof Blob?o.value=l.base64ToFileUrl(await l.blobToBase64(a)):l.isBase64File(a)?o.value=l.base64ToFileUrl(a):o.value=e.convertToLocalFileUrl?await l.networkFileUrlToLocalFileUrl(a):a}),{fileType:t,fileUrl:o}},m=(e={})=>{const{maxScale:o=3,minScale:t=.4,stepNum:r=.2,wheelNum:s=.3}=e,i=a.ref(1),u=a.computed(()=>l.numberToFixed(100*i.value,0)+"%"),c=(e=r)=>{i.value=Math.max(t,i.value-=e)},d=(e=r)=>{i.value=(i.value+=e)>o?o:i.value},m=n.useThrottleFn(()=>c(),300),p=n.useThrottleFn(()=>d(),300);return{clickMinusScale:m,clickPlusScale:p,scale:i,scaleText:u,onWheel:e=>{e.ctrlKey&&(e.preventDefault(),e.deltaY>0?c(Math.random()*s):d(Math.random()*s))},resetWheelState:()=>{i.value=1}}},p=(e,l)=>{const{onWheel:o,clickMinusScale:t,clickPlusScale:n,resetWheelState:r,scale:s,scaleText:i}=m(),{isMouseDown:u,onMouseStart:c,resetMouseState:d,translateX:p,translateY:f}=(()=>{const e=a.ref(!1),l=a.ref(0),o=a.ref(0),t=a.ref(0),n=a.ref(0),r=a=>{if(!e.value)return;a.preventDefault();const r=a.clientX,s=a.clientY;t.value=r-l.value,n.value=s-o.value},s=()=>{e.value=!1,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s)};return{resetMouseState:()=>{l.value=0,o.value=0,t.value=0,n.value=0,e.value=!1},onMouseStart:a=>{e.value=!0,l.value=a.clientX-t.value,o.value=a.clientY-n.value,window.addEventListener("mousemove",r),window.addEventListener("mouseup",s)},translateX:t,translateY:n,isMouseDown:e}})(),v=a.computed(()=>({transform:`translate(${p.value}px, ${f.value}px) scale(${s.value})`,transformOrigin:"center center"})),k=()=>{d(),r()};a.watch(()=>null==l?void 0:l.value,k);const g=a.ref(null);return a.watch(()=>e.value,()=>{g.value&&(g.value.scrollTop=0,k())}),{wrapperRef:g,onWheel:o,clickMinusScale:t,clickPlusScale:n,resetWheelState:r,scale:s,scaleText:i,isMouseDown:u,onMouseStart:c,resetMouseState:d,translateX:p,translateY:f,wrapperStyle:v}};var f=(e=>(e["完成"]="loaded",e["改变"]="change",e["下一页"]="next",e["上一页"]="prev",e["放大"]="zoomIn",e["缩小"]="zoomOut",e))(f||{});const v={class:"sakura-file-data__tools"},k={class:"sakura-file-data__page"},g={class:"sakura-file-data__text"},b={key:1,class:"sakura-file-data__scale"},w={class:"sakura-file-data__scale-text"},h=a.defineComponent({__name:"Tools",props:a.mergeModels({showTools:{type:Boolean},total:{},scaleText:{},nextPageDisabled:{type:Boolean},prevPageDisabled:{type:Boolean},enablePagination:{type:Boolean},enableMove:{type:Boolean},enableScale:{type:Boolean}},{modelValue:{type:Number,default:1},modelModifiers:{}}),emits:a.mergeModels([f.改变,f.下一页,f.上一页,f.放大,f.缩小],["update:modelValue"]),setup(e,{emit:l}){const o=l,t=a.useModel(e,"modelValue");return(l,n)=>(a.openBlock(),a.createElementBlock("div",v,[a.renderSlot(l.$slots,"default"),e.showTools?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[e.enablePagination?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createElementVNode("div",{class:a.normalizeClass(["sakura-file-data__arrow sakura-file-data__arrow-prev",[e.prevPageDisabled?"is-disabled":""]]),onClick:n[0]||(n[0]=e=>o(a.unref(f).上一页))},null,2),a.createElementVNode("div",k,[a.withDirectives(a.createElementVNode("input",{class:"sakura-file-data__input","onUpdate:modelValue":n[1]||(n[1]=e=>t.value=e),onBlur:n[2]||(n[2]=e=>o(a.unref(f).改变))},null,544),[[a.vModelText,t.value,void 0,{number:!0}]]),a.createElementVNode("span",g," / "+a.toDisplayString(e.total),1)]),a.createElementVNode("div",{class:a.normalizeClass(["sakura-file-data__arrow sakura-file-data__arrow-next",[e.nextPageDisabled?"is-disabled":""]]),onClick:n[3]||(n[3]=e=>o(a.unref(f).下一页))},null,2)],64)):a.createCommentVNode("",!0),e.enableScale?(a.openBlock(),a.createElementBlock("div",b,[a.createElementVNode("div",{class:"sakura-file-data__icon sakura-file-data__minus",onClick:n[4]||(n[4]=e=>o(a.unref(f).缩小))}),a.createElementVNode("span",w,a.toDisplayString(e.scaleText),1),a.createElementVNode("div",{class:"sakura-file-data__icon sakura-file-data__plus",onClick:n[5]||(n[5]=e=>o(a.unref(f).放大))})])):a.createCommentVNode("",!0)],64)):a.createCommentVNode("",!0)]))}}),y={class:"sakura-file-data"},_=a.defineComponent({__name:"Pdf",props:a.mergeModels({enablePagination:{type:Boolean,default:!0},enableScale:{type:Boolean,default:!0},enableMove:{type:Boolean,default:!0},fileUrl:{},showTools:{type:Boolean,default:!0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:a.mergeModels([f.完成],["update:modelValue"]),setup(e,{emit:t}){const r=e,s=t,i=a.useModel(e,"modelValue"),u=a.computed(()=>({url:r.fileUrl,fontExtraProperties:!0,cMapUrl:"./cmaps/",cMapPacked:!0,disableFontFace:!1,enableXfa:!0,fontLoadTimeout:3e4,verbosity:0})),c=a.reactive({pageNum:1,total:0,isError:!1}),d=a.ref(0),m=async e=>{var o;c.total=e._pdfInfo.numPages,await a.nextTick(),await l.sleep(50),d.value=(null==(o=document.querySelector(".vue-file-dataembed"))?void 0:o.clientHeight)??0},v=()=>{c.isError=!0},k=async()=>{await l.sleep(300),i.value=!1,s(f.完成)},{prevPageDisabled:g,nextPageDisabled:b,nextPage:w,_pageNum:_,onPageNumChange:B,prevPage:V}=(e=>{const l=a.computed(()=>e.pageNum>=e.total),o=n.useThrottleFn(()=>{l.value||e.pageNum++},500),t=a.computed(()=>e.pageNum<=1),r=n.useThrottleFn(()=>{t.value||e.pageNum--},500),s=a.ref(1);return a.watchEffect(()=>{s.value=e.pageNum}),{nextPage:o,nextPageDisabled:l,prevPage:r,prevPageDisabled:t,_pageNum:s,onPageNumChange:()=>{const{total:a}=e;e.pageNum=Math.max(Math.min(s.value,a),1)}}})(c),N=()=>{i.value=!0,_.value=1,l.extend(c,{pageNum:1,total:0,isError:!1})};a.watch(()=>r.fileUrl,N),a.onMounted(N);const{pageNum:E}=a.toRefs(c),{fileUrl:S}=a.toRefs(r),{onWheel:M,clickMinusScale:x,clickPlusScale:C,isMouseDown:P,scaleText:T,onMouseStart:U,wrapperStyle:F}=p(S,E);return(l,t)=>(a.openBlock(),a.createElementBlock("div",y,[a.createElementVNode("div",{ref:"wrapperRef",class:a.normalizeClass(["sakura-file-data__wrapper",[a.unref(P)?"is-drag":""]]),onMousedown:t[0]||(t[0]=l=>e.enableMove&&a.unref(U)(l)),onWheel:t[1]||(t[1]=l=>e.enableScale&&a.unref(M)(l))},[a.createElementVNode("div",{style:a.normalizeStyle([a.unref(F)])},[a.createVNode(a.unref(o),{class:"pdf",source:u.value,page:e.enablePagination?c.pageNum:void 0,scale:1,onLoaded:m,onRendered:k,onError:v},null,8,["source","page"])],4)],34),e.enablePagination||e.enableScale||e.showTools?(a.openBlock(),a.createBlock(h,{key:0,modelValue:a.unref(_),"onUpdate:modelValue":t[2]||(t[2]=e=>a.isRef(_)?_.value=e:null),total:c.total,"prev-page-disabled":a.unref(g),"next-page-disabled":a.unref(b),"scale-text":a.unref(T),"show-tools":e.showTools,"enable-pagination":e.enablePagination,"enable-scale":e.enableScale,"enable-move":e.enableMove,onChange:a.unref(B),onNext:a.unref(w),onPrev:a.unref(V),onZoomIn:a.unref(C),onZoomOut:a.unref(x)},{default:a.withCtx(()=>[a.renderSlot(l.$slots,"default",{fileDataState:c})]),_:3},8,["modelValue","total","prev-page-disabled","next-page-disabled","scale-text","show-tools","enable-pagination","enable-scale","enable-move","onChange","onNext","onPrev","onZoomIn","onZoomOut"])):a.createCommentVNode("",!0)]))}}),B={class:"sakura-file-data"},V=a.defineComponent({__name:"Word",props:a.mergeModels({enablePagination:{type:Boolean},enableScale:{type:Boolean},enableMove:{type:Boolean},fileUrl:{},showTools:{type:Boolean,default:!0},isLocalFile:{type:Boolean,default:!1},enableWrapper:{type:Boolean,default:!0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:a.mergeModels([f.完成],["update:modelValue"]),setup(e,{emit:o}){const t=e,n=a.useModel(e,"modelValue"),s=a.useTemplateRef("wordFileRef"),i=async()=>{try{n.value=!0,s.value&&(s.value.innerHTML="");const e=await(async()=>{const e=await fetch(t.fileUrl),a=await e.blob();return l.base64ToFile(await l.blobToBase64(a),l.generateId()+".docx")})();await r.renderAsync(e,s.value,void 0,{className:"docx",inWrapper:t.enableWrapper,ignoreWidth:!0,ignoreHeight:!1,ignoreFonts:!0,breakPages:!0,ignoreLastRenderedPageBreak:!0,experimental:!1,trimXmlDeclaration:!0}),await a.nextTick()}catch(e){console.log("fileUrl---",t.fileUrl),console.log("加载word文件失败----",e)}finally{n.value=!1}};a.onMounted(i),a.watch(()=>t.fileUrl,i);const{fileUrl:u}=a.toRefs(t),{onWheel:c,clickMinusScale:d,clickPlusScale:m,isMouseDown:f,scaleText:v,onMouseStart:k,wrapperStyle:g}=p(u);return(l,o)=>(a.openBlock(),a.createElementBlock("div",B,[a.createElementVNode("div",{ref:"wrapperRef",class:a.normalizeClass(["sakura-file-data__wrapper",[a.unref(f)?"is-drag":"",e.enableWrapper?"is-enable-wrapper":""]]),onMousedown:o[0]||(o[0]=l=>e.enableMove&&a.unref(k)(l)),onWheel:o[1]||(o[1]=l=>e.enableScale&&a.unref(c)(l))},[a.createElementVNode("div",{ref_key:"wordFileRef",ref:s,style:a.normalizeStyle([a.unref(g)])},null,4)],34),e.enablePagination||e.enableScale||e.showTools?(a.openBlock(),a.createBlock(h,{key:0,"scale-text":a.unref(v),"show-tools":e.showTools,"enable-scale":e.enableScale,"enable-move":e.enableMove,onZoomIn:a.unref(m),onZoomOut:a.unref(d)},{default:a.withCtx(()=>[a.renderSlot(l.$slots,"default")]),_:3},8,["scale-text","show-tools","enable-scale","enable-move","onZoomIn","onZoomOut"])):a.createCommentVNode("",!0)]))}}),N={width:"24",height:"24",fill:"none"};const E=i({},[["render",function(e,l){return a.openBlock(),a.createElementBlock("svg",N,[...l[0]||(l[0]=[a.createElementVNode("circle",{cx:"10.5",cy:"10.5",r:"6.5",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M15.5 15.5L20 20",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])}]]),S={width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const M=i({},[["render",function(e,l){return a.openBlock(),a.createElementBlock("svg",S,[...l[0]||(l[0]=[a.createElementVNode("circle",{cx:"10.5",cy:"10.5",r:"6.5",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M7.5 10.5H13.5",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M15.5 15.5L20 20",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])}]]),x={width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};const C=i({},[["render",function(e,l){return a.openBlock(),a.createElementBlock("svg",x,[...l[0]||(l[0]=[a.createElementVNode("path",{d:"M7 7L17 17",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),a.createElementVNode("path",{d:"M7 17L17 7",stroke:"#fff","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])}]]),P={class:"sakura-file-data"},T={class:"sakura-file-data__wrapper is-image"},U=["src"],F={class:"sakura-preview__image--data"},z=["src"],D={key:0,class:"sakura-preview__image--tools"},L=a.defineComponent({__name:"Image",props:a.mergeModels({enablePagination:{type:Boolean},enableScale:{type:Boolean},enableMove:{type:Boolean},fileUrl:{},showTools:{type:Boolean}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const o=e,t=a.useModel(e,"modelValue"),r=()=>{t.value=!1},{width:s,height:i}=n.useWindowSize(),u=a.ref(0),c=a.ref(0);a.onMounted(async()=>{const e=o.fileUrl;u.value=0,c.value=0;const a=new Image;a.src=e,a.onload=()=>{u.value=a.width,c.value=a.height}});const d=a.computed(()=>u.value>s.value?{width:"auto",height:l.addUnit(i.value)}:{width:l.addUnit(u.value),height:l.addUnit(c.value)}),{fileUrl:m}=a.toRefs(o),{onWheel:f,onMouseStart:v,isMouseDown:k,clickMinusScale:g,clickPlusScale:b,wrapperStyle:w}=p(m),h=a.ref(!1),y=()=>{h.value=!h.value};return(l,o)=>(a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",P,[a.createElementVNode("div",T,[a.createElementVNode("img",{class:"sakura-file-data__image",src:a.unref(m),alt:"",onLoad:r,onClick:y},null,40,U)])]),(a.openBlock(),a.createBlock(a.Teleport,{to:"body"},[a.createElementVNode("div",{class:a.normalizeClass(["sakura-preview-dialog",[h.value?"is-visible":""]])},[o[2]||(o[2]=a.createElementVNode("div",{class:"sakura-preview__image--mark"},null,-1)),a.createElementVNode("div",{ref:"wrapperRef",class:a.normalizeClass(["sakura-preview__image",[a.unref(k)?"is-drag":""]]),onMousedown:o[0]||(o[0]=l=>e.enableMove&&a.unref(v)(l)),onWheel:o[1]||(o[1]=l=>e.enableScale&&a.unref(f)(l))},[a.createElementVNode("div",F,[a.createElementVNode("img",{class:"dot-move",src:a.unref(m),style:a.normalizeStyle([d.value,a.unref(w)]),alt:""},null,12,z)]),a.createElementVNode("div",{class:"sakura-preview__image--close",onClick:y},[a.createVNode(C)]),e.enableScale?(a.openBlock(),a.createElementBlock("div",D,[a.createVNode(E,{onClick:a.unref(b)},null,8,["onClick"]),a.createVNode(M,{onClick:a.unref(g)},null,8,["onClick"])])):a.createCommentVNode("",!0)],34)],2)]))],64))}}),$=Symbol("PreviewFile"),W=a.defineComponent({__name:"preview-file",props:{width:{default:"100%"},height:{default:"100%"},src:{},enablePagination:{type:Boolean,default:!0},enableScale:{type:Boolean,default:!0},enableMove:{type:Boolean,default:!0},loadingType:{default:"circle"},loadingState:{default:()=>({})},convertToLocalFileUrl:{type:Boolean,default:!1},themeColor:{default:"#409eff"}},setup(e){const o=e;a.provide($,o);const t=((e,l)=>{const o=a.unref(l)??"sakura"??e,t=e=>`${o}-${e}`,n=(e,a)=>`${o}-${e}-${a}`;return{b:(a="")=>c(o,e,a,"",""),e:(a="")=>a?c(o,e,"",a,""):"",m:(a="")=>a?c(o,e,"","",a):"",be:(a="",l="")=>a&&l?c(o,e,a,l,""):"",em:(a="",l="")=>a&&l?c(o,e,"",a,l):"",bm:(a="",l="")=>a&&l?c(o,e,a,"",l):"",bem:(a="",l="",t="")=>a&&l&&t?c(o,e,a,l,t):"",is:(e,...a)=>(!a.length||a[0])&&e?"is-"+e:"",cssVar:e=>{const a={};for(const l in e)e[l]&&(a[`--${o}-${l} `]=e[l]);return a},cssBlockVar:(e,a)=>{const l={};for(const t in a)a[t]&&(l[`--${o}-${e}-${t}`]=a[t]);return l},cssVarName:t,cssBlockVarName:n,cssVarNameValue:e=>`var(--${t(e)})`,cssBlockVarNameValue:(e,a)=>`var(--${n(e,a)})`}})("preview-file"),n=a.computed(()=>{const{width:e,height:a,themeColor:t}=o,n={"--preview-file-primary-color":t};return l.isEmpty(e)||(n.width=l.addUnit(e)),l.isEmpty(a)||(n.height=l.addUnit(a)),n}),{fileType:r,fileUrl:s}=d(o),i=a.ref(!0),m=a.computed(()=>{const{loadingType:e}=o;switch(e){case"circle":return u.Circle;case"dot":return u.Dot;case"cube":return u.Cube;case"progress":default:return u.Progress}});return(u,c)=>(a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(a.unref(t).b()),style:a.normalizeStyle([n.value])},[a.unref(l.isEmpty)(a.unref(s))?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass([a.unref(t).e("wrapper")])},[a.unref(l.isPdfFile)(a.unref(r))?(a.openBlock(),a.createBlock(_,{key:0,modelValue:i.value,"onUpdate:modelValue":c[0]||(c[0]=e=>i.value=e),"file-url":a.unref(s),"show-tools":!u.$slots.default,"enable-pagination":e.enablePagination,"enable-scale":e.enableScale,"enable-move":e.enableMove},{default:a.withCtx(({fileDataState:e})=>[a.renderSlot(u.$slots,"default",{fileState:e,data:o})]),_:3},8,["modelValue","file-url","show-tools","enable-pagination","enable-scale","enable-move"])):a.createCommentVNode("",!0),a.unref(l.isWordFile)(a.unref(r))?(a.openBlock(),a.createBlock(V,{key:1,modelValue:i.value,"onUpdate:modelValue":c[1]||(c[1]=e=>i.value=e),"file-url":a.unref(s),"show-tools":!u.$slots.default,"enable-pagination":e.enablePagination,"enable-scale":e.enableScale,"enable-move":e.enableMove,"is-local-file":e.convertToLocalFileUrl},null,8,["modelValue","file-url","show-tools","enable-pagination","enable-scale","enable-move","is-local-file"])):a.unref(l.isImageFile)(a.unref(r))?(a.openBlock(),a.createBlock(L,{key:2,modelValue:i.value,"onUpdate:modelValue":c[2]||(c[2]=e=>i.value=e),"file-url":a.unref(s),"show-tools":!u.$slots.default,"enable-scale":e.enableScale,"enable-move":e.enableMove},null,8,["modelValue","file-url","show-tools","enable-scale","enable-move"])):a.createCommentVNode("",!0)],2)),a.withDirectives(a.createElementVNode("div",{class:a.normalizeClass([a.unref(t).e("loading")])},[a.createElementVNode("div",{class:a.normalizeClass([a.unref(t).e("loading-spinner")])},[(a.openBlock(),a.createBlock(a.resolveDynamicComponent(m.value),a.normalizeProps(a.guardReactiveProps({...e.loadingState,color:e.themeColor})),null,16))],2)],2),[[a.vShow,i.value]])],6))}});W.install=e=>{e.component("PreviewFile",W),e.component("Loading",u)},e.Loading=u,e.default=W,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";@tailwind base;@tailwind components;@tailwind utilities;*,*:before,*:after{box-sizing:border-box;margin:0;font-weight:400;color:#2b2b2d}.sakura-preview-file{display:flex;flex-direction:column;flex:1;overflow:hidden;position:relative;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.sakura-preview-file__wrapper{flex:1;overflow:hidden;display:flex;flex-direction:column}.sakura-preview-file__loading{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(255,255,255,.9)}.sakura-file-data{flex:1;display:flex;flex-direction:column;overflow:hidden}.sakura-file-data__wrapper{flex:1;overflow-y:auto;overflow-x:hidden;scrollbar-width:none}.sakura-file-data__wrapper.is-drag{cursor:move}.sakura-file-data__wrapper.is-enable-wrapper{background-color:gray}.sakura-file-data__wrapper.is-image{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:none;height:100%;cursor:pointer}.sakura-file-data__tools{display:flex;flex-direction:row;align-items:center;justify-content:center;height:44px;border-top:1px solid #d9dceb}.sakura-file-data__page{display:flex;flex-direction:row;align-items:center;margin:0 12px}.sakura-file-data__input{width:24px;height:24px;border:1px solid #d9dceb;border-radius:4px;color:var(--preview-file-primary-color);outline:none;text-align:center;margin-right:10px}.sakura-file-data__text{font-size:16px;height:24px;line-height:24px;position:relative;top:-2px}.sakura-file-data__arrow{display:flex;flex-direction:row;align-items:center;justify-content:center;position:relative;width:24px;height:24px;cursor:pointer}.sakura-file-data__arrow.is-disabled{cursor:not-allowed}.sakura-file-data__arrow.is-disabled:before{color:#939393}.sakura-file-data__arrow:before{content:"";position:absolute;width:8px;height:8px;border-style:solid;border-width:1px 1px 0 0;transition:all .3s ease;color:#2b2b2d}.sakura-file-data__arrow-prev{transform:rotate(-135deg)}.sakura-file-data__arrow-next{transform:rotate(45deg)}.sakura-file-data__scale{display:flex;flex-direction:row;align-items:center;position:absolute;right:24px}.sakura-file-data__scale-text{margin:0 12px;font-size:16px;font-weight:700}.sakura-file-data__icon{width:14px;height:14px;position:relative;cursor:pointer}.sakura-file-data__plus:before,.sakura-file-data__plus:after{content:"";position:absolute;background-color:#9d9da5}.sakura-file-data__plus:before{width:14px;height:2px;top:50%;left:0;transform:translateY(-50%)}.sakura-file-data__plus:after{width:2px;height:14px;top:0;left:50%;transform:translate(-50%)}.sakura-file-data__minus:before{content:"";position:absolute;width:14px;height:2px;top:50%;left:0;transform:translateY(-50%);background-color:#9d9da5}.sakura-file-data__image{width:100%;height:auto;cursor:pointer}.sakura-preview-dialog.is-visible .sakura-preview__image{width:100%;height:100%;opacity:1;z-index:9}.sakura-preview-dialog.is-visible .sakura-preview__image--data{transform:scale(1)}.sakura-preview-dialog.is-visible .sakura-preview__image--mark{opacity:1;display:block;width:100%;height:100%}.sakura-preview__image{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;opacity:0;width:0;height:0;z-index:-9;transition:opacity .15s}.sakura-preview__image--data{display:inline-block;transform:scale(1.25);transition:transform .25s}.sakura-preview__image .dot-move{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;pointer-events:none}.sakura-preview__image.is-drag{cursor:move}.sakura-preview__image--mark{background:rgba(0,0,0,.5);display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;left:0;top:0;width:0;height:0;transition:opacity .25s;opacity:0;display:none}.sakura-preview__image--close{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;right:40px;top:40px;width:44px;height:44px;border-radius:50%;background-color:#606266;color:#fff;z-index:9;cursor:pointer}.sakura-preview__image--tools{display:flex;flex-direction:row;align-items:center;justify-content:center;background:#606266;position:absolute;z-index:9;bottom:30px;height:44px;border-radius:22px;padding:0 24px}.sakura-preview__image--tools svg{cursor:pointer}.sakura-preview__image--tools svg:last-child{margin-left:20px}.circular[data-v-51d1fa15]{position:relative;width:var(--circle-size);height:var(--circle-size)}.circular__path-inner[data-v-51d1fa15]{animation:dash-51d1fa15 var(--circle-duration) ease-in-out infinite;stroke-linecap:round}@keyframes dash-51d1fa15{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}.dot[data-v-2acd99b5]{display:flex;align-items:center;justify-content:center;gap:var(--dot-gap)}.dot__item[data-v-2acd99b5]{width:var(--dot-size);height:var(--dot-size);border-radius:50%;background-color:var(--dot-color);animation:bounce-2acd99b5 var(--dot-duration) ease-in-out infinite}.dot__item[data-v-2acd99b5]:nth-child(2){animation-delay:-.32s}.dot__item[data-v-2acd99b5]:nth-child(3){animation-delay:-.16s}@keyframes bounce-2acd99b5{0%,80%,to{transform:scale(0);opacity:.5}40%{transform:scale(1);opacity:1}}.progress[data-v-3a710001]{width:var(--progress-width);height:var(--progress-height);background-color:var(--progress-background);border-radius:var(--progress-border-radius);overflow:hidden;position:relative}.progress__bar[data-v-3a710001]{position:absolute;width:100%;height:100%;background-color:var(--progress-color);border-radius:var(--progress-border-radius);animation:progress-3a710001 var(--progress-duration) ease-in-out infinite}@keyframes progress-3a710001{0%{transform:translate(-100%)}to{transform:translate(100%)}}.cube[data-v-0e6bb9d0]{width:var(--cube-size);height:var(--cube-size);position:relative;display:flex;flex-wrap:wrap}.cube__item[data-v-0e6bb9d0]{width:33%;height:33%;background-color:var(--cube-color);animation:cubeGrid-0e6bb9d0 var(--cube-duration) infinite ease-in-out}.cube__item[data-v-0e6bb9d0]:nth-child(1){animation-delay:.2s}.cube__item[data-v-0e6bb9d0]:nth-child(2){animation-delay:.3s}.cube__item[data-v-0e6bb9d0]:nth-child(3){animation-delay:.4s}.cube__item[data-v-0e6bb9d0]:nth-child(4){animation-delay:.1s}.cube__item[data-v-0e6bb9d0]:nth-child(5){animation-delay:.2s}.cube__item[data-v-0e6bb9d0]:nth-child(6){animation-delay:.3s}.cube__item[data-v-0e6bb9d0]:nth-child(7){animation-delay:0s}.cube__item[data-v-0e6bb9d0]:nth-child(8){animation-delay:.1s}.cube__item[data-v-0e6bb9d0]:nth-child(9){animation-delay:.2s}@keyframes cubeGrid-0e6bb9d0{0%,70%,to{transform:scaleZ(1)}35%{transform:scale3D(0,0,1)}}
|
|
1
|
+
@charset "UTF-8";@tailwind base;@tailwind components;@tailwind utilities;*,*:before,*:after{box-sizing:border-box;margin:0;font-weight:400;color:#2b2b2d}.sakura-preview-file{display:flex;flex-direction:column;flex:1;overflow:hidden;position:relative;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.sakura-preview-file__wrapper{flex:1;overflow:hidden;display:flex;flex-direction:column}.sakura-preview-file__loading{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(255,255,255,.9)}.sakura-file-data{flex:1;display:flex;flex-direction:column;overflow:hidden}.sakura-file-data__wrapper{flex:1;overflow-y:auto;overflow-x:hidden;scrollbar-width:none}.sakura-file-data__wrapper.is-drag{cursor:move}.sakura-file-data__wrapper.is-enable-wrapper{background-color:gray}.sakura-file-data__wrapper.is-image{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:none;height:100%;cursor:pointer}.sakura-file-data__tools{display:flex;flex-direction:row;align-items:center;justify-content:center;height:44px;border-top:1px solid #d9dceb}.sakura-file-data__page{display:flex;flex-direction:row;align-items:center;margin:0 12px}.sakura-file-data__input{width:24px;height:24px;border:1px solid #d9dceb;border-radius:4px;color:var(--preview-file-primary-color);outline:none;text-align:center;margin-right:10px}.sakura-file-data__text{font-size:16px;height:24px;line-height:24px;position:relative;top:-2px}.sakura-file-data__arrow{display:flex;flex-direction:row;align-items:center;justify-content:center;position:relative;width:24px;height:24px;cursor:pointer}.sakura-file-data__arrow.is-disabled{cursor:not-allowed}.sakura-file-data__arrow.is-disabled:before{color:#939393}.sakura-file-data__arrow:before{content:"";position:absolute;width:8px;height:8px;border-style:solid;border-width:1px 1px 0 0;transition:all .3s ease;color:#2b2b2d;font-weight:700}.sakura-file-data__arrow-prev{transform:rotate(-135deg)}.sakura-file-data__arrow-next{transform:rotate(45deg)}.sakura-file-data__scale{display:flex;flex-direction:row;align-items:center;position:absolute;right:24px}.sakura-file-data__scale-text{margin:0 12px;font-size:16px;font-weight:700}.sakura-file-data__icon{width:14px;height:14px;position:relative;cursor:pointer}.sakura-file-data__plus:before,.sakura-file-data__plus:after{content:"";position:absolute;background-color:#9d9da5}.sakura-file-data__plus:before{width:14px;height:2px;top:50%;left:0;transform:translateY(-50%)}.sakura-file-data__plus:after{width:2px;height:14px;top:0;left:50%;transform:translate(-50%)}.sakura-file-data__minus:before{content:"";position:absolute;width:14px;height:2px;top:50%;left:0;transform:translateY(-50%);background-color:#9d9da5}.sakura-file-data__image{width:100%;height:auto;cursor:pointer}.sakura-preview-dialog.is-visible .sakura-preview__image{width:100%;height:100%;opacity:1;z-index:9}.sakura-preview-dialog.is-visible .sakura-preview__image--data{transform:scale(1)}.sakura-preview-dialog.is-visible .sakura-preview__image--mark{opacity:1;display:block;width:100%;height:100%}.sakura-preview__image{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;opacity:0;width:0;height:0;z-index:-9;transition:opacity .15s}.sakura-preview__image--data{display:inline-block;transform:scale(1.25);transition:transform .25s}.sakura-preview__image .dot-move{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;pointer-events:none}.sakura-preview__image.is-drag{cursor:move}.sakura-preview__image--mark{background:rgba(0,0,0,.5);display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;left:0;top:0;width:0;height:0;transition:opacity .25s;opacity:0;display:none}.sakura-preview__image--close{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;right:40px;top:40px;width:44px;height:44px;border-radius:50%;background-color:#606266;color:#fff;z-index:9;cursor:pointer}.sakura-preview__image--tools{display:flex;flex-direction:row;align-items:center;justify-content:center;background:#606266;position:absolute;z-index:9;bottom:30px;height:44px;border-radius:22px;padding:0 24px}.sakura-preview__image--tools svg{cursor:pointer}.sakura-preview__image--tools svg:last-child{margin-left:20px}.circular[data-v-51d1fa15]{position:relative;width:var(--circle-size);height:var(--circle-size)}.circular__path-inner[data-v-51d1fa15]{animation:dash-51d1fa15 var(--circle-duration) ease-in-out infinite;stroke-linecap:round}@keyframes dash-51d1fa15{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}.dot[data-v-2acd99b5]{display:flex;align-items:center;justify-content:center;gap:var(--dot-gap)}.dot__item[data-v-2acd99b5]{width:var(--dot-size);height:var(--dot-size);border-radius:50%;background-color:var(--dot-color);animation:bounce-2acd99b5 var(--dot-duration) ease-in-out infinite}.dot__item[data-v-2acd99b5]:nth-child(2){animation-delay:-.32s}.dot__item[data-v-2acd99b5]:nth-child(3){animation-delay:-.16s}@keyframes bounce-2acd99b5{0%,80%,to{transform:scale(0);opacity:.5}40%{transform:scale(1);opacity:1}}.progress[data-v-3a710001]{width:var(--progress-width);height:var(--progress-height);background-color:var(--progress-background);border-radius:var(--progress-border-radius);overflow:hidden;position:relative}.progress__bar[data-v-3a710001]{position:absolute;width:100%;height:100%;background-color:var(--progress-color);border-radius:var(--progress-border-radius);animation:progress-3a710001 var(--progress-duration) ease-in-out infinite}@keyframes progress-3a710001{0%{transform:translate(-100%)}to{transform:translate(100%)}}.cube[data-v-0e6bb9d0]{width:var(--cube-size);height:var(--cube-size);position:relative;display:flex;flex-wrap:wrap}.cube__item[data-v-0e6bb9d0]{width:33%;height:33%;background-color:var(--cube-color);animation:cubeGrid-0e6bb9d0 var(--cube-duration) infinite ease-in-out}.cube__item[data-v-0e6bb9d0]:nth-child(1){animation-delay:.2s}.cube__item[data-v-0e6bb9d0]:nth-child(2){animation-delay:.3s}.cube__item[data-v-0e6bb9d0]:nth-child(3){animation-delay:.4s}.cube__item[data-v-0e6bb9d0]:nth-child(4){animation-delay:.1s}.cube__item[data-v-0e6bb9d0]:nth-child(5){animation-delay:.2s}.cube__item[data-v-0e6bb9d0]:nth-child(6){animation-delay:.3s}.cube__item[data-v-0e6bb9d0]:nth-child(7){animation-delay:0s}.cube__item[data-v-0e6bb9d0]:nth-child(8){animation-delay:.1s}.cube__item[data-v-0e6bb9d0]:nth-child(9){animation-delay:.2s}@keyframes cubeGrid-0e6bb9d0{0%,70%,to{transform:scaleZ(1)}35%{transform:scale3D(0,0,1)}}
|
package/index.d.ts
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
import type { DefineComponent } from 'vue'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 预览文件props
|
|
5
|
-
*/
|
|
6
|
-
export type PreviewFileProps = {
|
|
7
|
-
// 宽度
|
|
8
|
-
width?: string | number
|
|
9
|
-
// 高度
|
|
10
|
-
height?: string | number
|
|
11
|
-
// 浏览地址
|
|
12
|
-
src: string | Blob
|
|
13
|
-
// 是否启用分页
|
|
14
|
-
enablePagination?: boolean
|
|
15
|
-
// 是否启用缩放
|
|
16
|
-
enableScale?: boolean
|
|
17
|
-
// 是否启用拖拽
|
|
18
|
-
enableMove?: boolean
|
|
19
|
-
// 加载类型
|
|
20
|
-
loadingType?: 'circle' | 'cube' | 'dot' | 'progress'
|
|
21
|
-
// 加载属性
|
|
22
|
-
loadingState?: LoadingProps
|
|
23
|
-
// 是否转换为本地文件地址
|
|
24
|
-
convertToLocalFileUrl?: boolean
|
|
25
|
-
// 主题颜色
|
|
26
|
-
themeColor?: string
|
|
27
|
-
}
|
|
1
|
+
import type { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue'
|
|
28
2
|
|
|
29
3
|
/**
|
|
30
4
|
* 圆形加载props
|
|
@@ -72,32 +46,201 @@ export type ProgressProps = {
|
|
|
72
46
|
export type LoadingProps = CircleProps & DotProps & CubeProps & ProgressProps
|
|
73
47
|
|
|
74
48
|
/**
|
|
75
|
-
*
|
|
49
|
+
* 预览文件props
|
|
76
50
|
*/
|
|
77
|
-
export
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
export type PreviewFileProps = {
|
|
52
|
+
width?: string | number
|
|
53
|
+
height?: string | number
|
|
54
|
+
src: string | Blob
|
|
55
|
+
enablePagination?: boolean
|
|
56
|
+
enableScale?: boolean
|
|
57
|
+
enableMove?: boolean
|
|
58
|
+
loadingType?: 'circle' | 'cube' | 'dot' | 'progress'
|
|
59
|
+
loadingState?: LoadingProps
|
|
60
|
+
convertToLocalFileUrl?: boolean
|
|
61
|
+
themeColor?: string
|
|
82
62
|
}
|
|
83
63
|
|
|
84
64
|
/**
|
|
85
|
-
*
|
|
65
|
+
* 预览文件插槽参数类型
|
|
86
66
|
*/
|
|
87
|
-
export
|
|
88
|
-
|
|
67
|
+
export type PreviewFileSlotProps = {
|
|
68
|
+
fileState: {
|
|
69
|
+
pageNum: number
|
|
70
|
+
total: number
|
|
71
|
+
isError: boolean
|
|
72
|
+
}
|
|
73
|
+
data: Readonly<{
|
|
74
|
+
src: string | Blob
|
|
75
|
+
}> & {
|
|
76
|
+
readonly width: string | number
|
|
77
|
+
readonly height: string | number
|
|
78
|
+
readonly enablePagination: boolean
|
|
79
|
+
readonly loadingType: 'circle' | 'cube' | 'dot' | 'progress'
|
|
80
|
+
readonly enableScale: boolean
|
|
81
|
+
readonly enableMove: boolean
|
|
82
|
+
readonly convertToLocalFileUrl: boolean
|
|
83
|
+
readonly themeColor: string
|
|
84
|
+
readonly loadingState: LoadingProps
|
|
85
|
+
}
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
/**
|
|
92
|
-
*
|
|
89
|
+
* 预览文件插槽类型
|
|
93
90
|
*/
|
|
94
|
-
|
|
91
|
+
export type PreviewFileSlots = {
|
|
92
|
+
default?: (props: PreviewFileSlotProps) => any
|
|
93
|
+
}
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
/**
|
|
96
|
+
* PreviewFile组件类型
|
|
97
|
+
*/
|
|
98
|
+
export declare const PreviewFile: DefineComponent<
|
|
99
|
+
PreviewFileProps,
|
|
100
|
+
{},
|
|
101
|
+
{},
|
|
102
|
+
{},
|
|
103
|
+
{},
|
|
104
|
+
ComponentOptionsMixin,
|
|
105
|
+
ComponentOptionsMixin,
|
|
106
|
+
{},
|
|
107
|
+
string,
|
|
108
|
+
PublicProps,
|
|
109
|
+
Readonly<PreviewFileProps> & Readonly<{}>,
|
|
110
|
+
{
|
|
111
|
+
enablePagination: boolean
|
|
112
|
+
enableMove: boolean
|
|
113
|
+
enableScale: boolean
|
|
114
|
+
width: string | number
|
|
115
|
+
height: string | number
|
|
116
|
+
loadingType: 'circle' | 'cube' | 'dot' | 'progress'
|
|
117
|
+
loadingState: LoadingProps
|
|
118
|
+
convertToLocalFileUrl: boolean
|
|
119
|
+
themeColor: string
|
|
120
|
+
},
|
|
121
|
+
{},
|
|
122
|
+
{},
|
|
123
|
+
{},
|
|
124
|
+
string,
|
|
125
|
+
ComponentProvideOptions,
|
|
126
|
+
false,
|
|
127
|
+
{},
|
|
128
|
+
any
|
|
129
|
+
> & {
|
|
130
|
+
install: (app: any) => void
|
|
131
|
+
}
|
|
97
132
|
|
|
98
133
|
/**
|
|
99
|
-
*
|
|
134
|
+
* Loading组件类型
|
|
100
135
|
*/
|
|
101
|
-
declare const Loading:
|
|
136
|
+
export declare const Loading: {
|
|
137
|
+
Circle: DefineComponent<
|
|
138
|
+
CircleProps,
|
|
139
|
+
{},
|
|
140
|
+
{},
|
|
141
|
+
{},
|
|
142
|
+
{},
|
|
143
|
+
ComponentOptionsMixin,
|
|
144
|
+
ComponentOptionsMixin,
|
|
145
|
+
{},
|
|
146
|
+
string,
|
|
147
|
+
PublicProps,
|
|
148
|
+
Readonly<CircleProps> & Readonly<{}>,
|
|
149
|
+
{
|
|
150
|
+
size: string | number
|
|
151
|
+
color: string
|
|
152
|
+
duration: number | string
|
|
153
|
+
},
|
|
154
|
+
{},
|
|
155
|
+
{},
|
|
156
|
+
{},
|
|
157
|
+
string,
|
|
158
|
+
ComponentProvideOptions,
|
|
159
|
+
false,
|
|
160
|
+
{},
|
|
161
|
+
any
|
|
162
|
+
>
|
|
163
|
+
Dot: DefineComponent<
|
|
164
|
+
DotProps,
|
|
165
|
+
{},
|
|
166
|
+
{},
|
|
167
|
+
{},
|
|
168
|
+
{},
|
|
169
|
+
ComponentOptionsMixin,
|
|
170
|
+
ComponentOptionsMixin,
|
|
171
|
+
{},
|
|
172
|
+
string,
|
|
173
|
+
PublicProps,
|
|
174
|
+
Readonly<DotProps> & Readonly<{}>,
|
|
175
|
+
{
|
|
176
|
+
size: string | number
|
|
177
|
+
color: string
|
|
178
|
+
duration: number | string
|
|
179
|
+
gap: string | number
|
|
180
|
+
},
|
|
181
|
+
{},
|
|
182
|
+
{},
|
|
183
|
+
{},
|
|
184
|
+
string,
|
|
185
|
+
ComponentProvideOptions,
|
|
186
|
+
false,
|
|
187
|
+
{},
|
|
188
|
+
any
|
|
189
|
+
>
|
|
190
|
+
Progress: DefineComponent<
|
|
191
|
+
ProgressProps,
|
|
192
|
+
{},
|
|
193
|
+
{},
|
|
194
|
+
{},
|
|
195
|
+
{},
|
|
196
|
+
ComponentOptionsMixin,
|
|
197
|
+
ComponentOptionsMixin,
|
|
198
|
+
{},
|
|
199
|
+
string,
|
|
200
|
+
PublicProps,
|
|
201
|
+
Readonly<ProgressProps> & Readonly<{}>,
|
|
202
|
+
{
|
|
203
|
+
width: string | number
|
|
204
|
+
height: string | number
|
|
205
|
+
color: string
|
|
206
|
+
duration: string | number
|
|
207
|
+
background: string
|
|
208
|
+
},
|
|
209
|
+
{},
|
|
210
|
+
{},
|
|
211
|
+
{},
|
|
212
|
+
string,
|
|
213
|
+
ComponentProvideOptions,
|
|
214
|
+
false,
|
|
215
|
+
{},
|
|
216
|
+
any
|
|
217
|
+
>
|
|
218
|
+
Cube: DefineComponent<
|
|
219
|
+
CubeProps,
|
|
220
|
+
{},
|
|
221
|
+
{},
|
|
222
|
+
{},
|
|
223
|
+
{},
|
|
224
|
+
ComponentOptionsMixin,
|
|
225
|
+
ComponentOptionsMixin,
|
|
226
|
+
{},
|
|
227
|
+
string,
|
|
228
|
+
PublicProps,
|
|
229
|
+
Readonly<CubeProps> & Readonly<{}>,
|
|
230
|
+
{
|
|
231
|
+
size: string | number
|
|
232
|
+
color: string
|
|
233
|
+
duration: string | number
|
|
234
|
+
},
|
|
235
|
+
{},
|
|
236
|
+
{},
|
|
237
|
+
{},
|
|
238
|
+
string,
|
|
239
|
+
ComponentProvideOptions,
|
|
240
|
+
false,
|
|
241
|
+
{},
|
|
242
|
+
any
|
|
243
|
+
>
|
|
244
|
+
}
|
|
102
245
|
|
|
103
|
-
export
|
|
246
|
+
export default PreviewFile
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sakura-preview-file",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "预览文件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"dev": "vite",
|
|
29
29
|
"build": "vite build",
|
|
30
|
+
"build:types": "npx vue-tsc --declaration --emitDeclarationOnly --outDir dist/types",
|
|
30
31
|
"type-check": "npx vue-tsc --noEmit",
|
|
31
32
|
"test": "vitest",
|
|
32
33
|
"test:ui": "vitest --ui",
|
|
@@ -58,7 +59,5 @@
|
|
|
58
59
|
"vitest": "^0.34.0",
|
|
59
60
|
"vue-tsc": "^3.2.1"
|
|
60
61
|
},
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"sakura-preview-file": "file:.yalc/sakura-preview-file"
|
|
63
|
-
}
|
|
62
|
+
"dependencies": {}
|
|
64
63
|
}
|