all-viewer 0.0.1
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.css +1 -0
- package/dist/index.js +1 -0
- package/package.json +54 -0
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.av-image-viewer__wrapper{inset:0;position:fixed}.av-image-viewer__wrapper .av-image-viewer__mask{background:#000;height:100%;left:0;opacity:.5;position:absolute;top:0;width:100%;z-index:-1}.av-image-viewer__wrapper .av-image-viewer__close{background-color:#d0d0d0;border-color:#fff;color:#fff;font-size:24px;height:44px;width:44px;right:40px;top:40px}.av-image-viewer__wrapper .av-image-viewer__btn{align-items:center;border-radius:50%;box-sizing:border-box;cursor:pointer;display:flex;justify-content:center;opacity:.8;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:1}.av-image-viewer__wrapper .av-image-viewer__btn .av-icon{cursor:pointer}.av-image-viewer__wrapper .wdbox{width:900px;height:900px}.av-image-viewer__wrapper .av-image-viewer__actions{background-color:#d0d0d0;border-color:#fff;border-radius:22px;bottom:30px;height:44px;left:50%;padding:0 23px;transform:translate(-50%)}.av-image-viewer__wrapper .av-image-viewer__actions .av-image-viewer__actions__inner{align-items:center;color:#fff;cursor:default;display:flex;font-size:23px;gap:22px;height:100%;justify-content:space-around;padding:0 6px;width:100%}.av-image-viewer__wrapper .av-image-viewer__actions .av-image-viewer__actions__inner .av-image-viewer__actions__divider{margin:0 -6px}.av-image-viewer__wrapper .av-image-viewer__canvas{align-items:center;display:flex;height:100%;justify-content:center;position:static;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.av-image-viewer__wrapper .av-icon{--color: inherit;align-items:center;display:inline-flex;height:1em;justify-content:center;line-height:1em;position:relative;width:1em;fill:currentColor;color:var(--color);font-size:inherit}.av-image-viewer__wrapper .av-icon svg{height:1em;width:1em}.av-image-viewer__wrapper .av-image-viewer__next,.av-image-viewer__wrapper .av-image-viewer__prev{background-color:#d0d0d0;border-color:#fff;color:#fff;font-size:24px;height:44px;top:50%;transform:translateY(-50%);width:44px}.av-image-viewer__wrapper .av-image-viewer__prev{left:40px}.av-image-viewer__wrapper .av-image-viewer__next{right:40px;text-indent:2px}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveComponent as e,openBlock as a,createBlock as l,Transition as i,withCtx as n,createElementVNode as o,normalizeStyle as t,withModifiers as r,createElementBlock as s,Fragment as c,normalizeClass as u,createCommentVNode as v,renderList as d,withDirectives as f,vShow as m,ref as w,computed as g,watch as p,nextTick as x,onMounted as _}from"vue";import L from"@vue-office/docx";import"@vue-office/docx/lib/index.css";import M from"@vue-office/excel";import"@vue-office/excel/lib/index.css";import b from"@vue-office/pdf";var k=(e,a)=>{const l=e.__vccOpts||e;for(const[i,n]of a)l[i]=n;return l};const z="Space",y="ArrowLeft",A="ArrowUp",C="ArrowRight",V="ArrowDown",O="Escape",E=function(e){let a=!1;return function(...l){a||(a=!0,window.requestAnimationFrame(()=>{e.apply(this,l),a=!1}))}},I={CONTAIN:{name:"contain",icon:"av-icon-full-screen"},ORIGINAL:{name:"original",icon:"av-icon-c-scale-to-original"}},D=window.navigator.userAgent.match(/firefox/i)?"DOMMouseScroll":"mousewheel",T="close",B="switch",S={name:"all-viewer",components:{VueOfficeDocx:L,VueOfficeExcel:M,VueOfficePdf:b},props:{urlList:{type:Array,default:()=>[]},zIndex:{type:Number,default:2e3},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:{type:Boolean,default:!1}},emits:[T,B],setup(e,{emit:a}){let l=null,i=null,n=null;const o=w(!0),t=w(e.initialIndex),r=w(null),s=w(null),c=w(I.CONTAIN),u=w({scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),v=g(()=>{const{urlList:a}=e;return a.length<=1}),d=g(()=>0===t.value),f=g(()=>t.value===e.urlList.length-1),m=g(()=>e.urlList[t.value]);const L=g(()=>{const{scale:e,deg:a,offsetX:l,offsetY:i,enableTransition:n}=u.value,o={transform:`scale(${e}) rotate(${a}deg)`,transition:n?"transform .3s":"",marginLeft:`${l}px`,marginTop:`${i}px`};return c.value.name===I.CONTAIN.name&&(o.maxWidth=o.maxHeight="100%"),o});function M(){document.removeEventListener("keydown",l,!1),document.removeEventListener(D,i,!1),l=null,i=null,a(T)}function b(){u.value={scale:1,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}function k(){if(o.value)return;const e=Object.keys(I),a=Object.values(I),l=c.value.name,i=(a.findIndex(e=>e.name===l)+1)%e.length;c.value=I[e[i]],b()}function S(){if(d.value&&!e.infinite)return;const a=e.urlList.length;t.value=(t.value-1+a)%a}function N(){if(f.value&&!e.infinite)return;const a=e.urlList.length;t.value=(t.value+1)%a}function H(e,a={}){if(o.value)return;const{zoomRate:l,rotateDeg:i,enableTransition:n}={zoomRate:.2,rotateDeg:90,enableTransition:!0,...a};switch(e){case"zoomOut":u.value.scale>.2&&(u.value.scale=parseFloat((u.value.scale-l).toFixed(3)));break;case"zoomIn":u.value.scale=parseFloat((u.value.scale+l).toFixed(3));break;case"clocelise":u.value.deg+=i;break;case"anticlocelise":u.value.deg-=i}u.value.enableTransition=n}return p(m,()=>{x(()=>{s.value.complete||(o.value=!0)})}),p(t,e=>{b(),a(B,e)}),_(()=>{l=E(e=>{switch(e.code){case O:M();break;case z:k();break;case y:S();break;case A:H("zoomIn");break;case C:N();break;case V:H("zoomOut")}}),i=E(e=>{H((e.wheelDelta?e.wheelDelta:-e.detail)>0?"zoomIn":"zoomOut",{zoomRate:.015,enableTransition:!1})}),document.addEventListener("keydown",l,!1),document.addEventListener(D,i,!1),r.value?.focus?.()}),{index:t,wrapper:r,media:s,isSingle:v,isFirst:d,isLast:f,currentMedia:m,isImage:function(e){return 1==e.file_typeid},isVideo:function(e){return 2==e.file_typeid},isDoc:function(e){return 3==e.file_typeid},getSuff:function(e){let a=e.url.split("?")[0].split(".");return a[a.length-1]},mediaStyle:L,mode:c,handleActions:H,prev:S,next:N,hide:M,toggleMode:k,handleMediaLoad:function(){o.value=!1},handleMediaError:function(e){o.value=!1},handleMouseDown:function(e){if(o.value||0!==e.button)return;const{offsetX:a,offsetY:l}=u.value,i=e.pageX,t=e.pageY,s=r.value.clientLeft,c=r.value.clientLeft+r.value.clientWidth,v=r.value.clientTop,d=r.value.clientTop+r.value.clientHeight;n=E(e=>{u.value={...u.value,offsetX:a+e.pageX-i,offsetY:l+e.pageY-t}}),document.addEventListener("mousemove",n,!1),document.addEventListener("mouseup",e=>{const a=e.pageX,l=e.pageY;(a<s||a>c||l<v||l>d)&&b(),document.removeEventListener("mousemove",n,!1)},!1),e.preventDefault()}}}},N={key:1,class:"av-image-viewer__btn av-image-viewer__actions"},H={class:"av-image-viewer__actions__inner"},X={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},Y={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},F={class:"av-image-viewer__canvas"},R=["src"],$=["src"];var j=/* @__PURE__ */k(S,[["render",function(w,g,p,x,_,L){const M=e("VueOfficeDocx"),b=e("VueOfficeExcel"),k=e("VueOfficePdf");return a(),l(i,{name:"viewer-fade"},{default:n(()=>[o("div",{ref:"wrapper",tabindex:-1,class:"av-image-viewer__wrapper",style:t({zIndex:p.zIndex})},[o("div",{class:"av-image-viewer__mask",onClick:g[0]||(g[0]=r(e=>p.hideOnClickModal&&x.hide(),["self"]))}),o("span",{class:"av-image-viewer__btn av-image-viewer__close",onClick:g[1]||(g[1]=(...e)=>x.hide&&x.hide(...e))},[...g[15]||(g[15]=[o("i",{class:"av-icon close"},[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})])],-1)])]),x.isSingle?v("",!0):(a(),s(c,{key:0},[o("span",{class:u(["av-image-viewer__btn av-image-viewer__prev",{"is-disabled":!p.infinite&&x.isFirst}]),onClick:g[2]||(g[2]=(...e)=>x.prev&&x.prev(...e))},[...g[16]||(g[16]=[o("i",{class:"av-icon left-arrow"},[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"})])],-1)])],2),o("span",{class:u(["av-image-viewer__btn av-image-viewer__next",{"is-disabled":!p.infinite&&x.isLast}]),onClick:g[3]||(g[3]=(...e)=>x.next&&x.next(...e))},[...g[17]||(g[17]=[o("i",{class:"av-icon right-arrow"},[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"})])],-1)])],2)],64)),1==p.urlList[x.index].file_typeid?(a(),s("div",N,[o("div",H,[o("i",{class:"av-icon zoom-out",onClick:g[4]||(g[4]=e=>x.handleActions("zoomOut"))},[...g[18]||(g[18]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704M352 448h256a32 32 0 0 1 0 64H352a32 32 0 0 1 0-64"})],-1)])]),o("i",{class:"av-icon zoom-in",onClick:g[5]||(g[5]=e=>x.handleActions("zoomIn"))},[...g[19]||(g[19]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704m-32-384v-96a32 32 0 0 1 64 0v96h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64z"})],-1)])]),g[24]||(g[24]=o("i",{class:"av-image-viewer__actions__divider"},null,-1)),o("i",{class:"av-icon",onClick:g[6]||(g[6]=(...e)=>x.toggleMode&&x.toggleMode(...e))},[x.mode.icon.includes("full-screen")?(a(),s("svg",X,[...g[20]||(g[20]=[o("path",{fill:"currentColor",d:"m160 96.064 192 .192a32 32 0 0 1 0 64l-192-.192V352a32 32 0 0 1-64 0V96h64zm0 831.872V928H96V672a32 32 0 1 1 64 0v191.936l192-.192a32 32 0 1 1 0 64zM864 96.064V96h64v256a32 32 0 1 1-64 0V160.064l-192 .192a32 32 0 1 1 0-64l192-.192zm0 831.872-192-.192a32 32 0 0 1 0-64l192 .192V672a32 32 0 1 1 64 0v256h-64z"},null,-1)])])):(a(),s("svg",Y,[...g[21]||(g[21]=[o("path",{fill:"currentColor",d:"M813.176 180.706a60.235 60.235 0 0 1 60.236 60.235v481.883a60.235 60.235 0 0 1-60.236 60.235H210.824a60.235 60.235 0 0 1-60.236-60.235V240.94a60.235 60.235 0 0 1 60.236-60.235h602.352zm0-60.235H210.824A120.47 120.47 0 0 0 90.353 240.94v481.883a120.47 120.47 0 0 0 120.47 120.47h602.353a120.47 120.47 0 0 0 120.471-120.47V240.94a120.47 120.47 0 0 0-120.47-120.47zm-120.47 180.705a30.118 30.118 0 0 0-30.118 30.118v301.177a30.118 30.118 0 0 0 60.236 0V331.294a30.118 30.118 0 0 0-30.118-30.118zm-361.412 0a30.118 30.118 0 0 0-30.118 30.118v301.177a30.118 30.118 0 1 0 60.236 0V331.294a30.118 30.118 0 0 0-30.118-30.118M512 361.412a30.118 30.118 0 0 0-30.118 30.117v30.118a30.118 30.118 0 0 0 60.236 0V391.53A30.118 30.118 0 0 0 512 361.412M512 512a30.118 30.118 0 0 0-30.118 30.118v30.117a30.118 30.118 0 0 0 60.236 0v-30.117A30.118 30.118 0 0 0 512 512"},null,-1)])]))]),g[25]||(g[25]=o("i",{class:"av-image-viewer__actions__divider"},null,-1)),o("i",{class:"av-icon refresh-left",onClick:g[7]||(g[7]=e=>x.handleActions("anticlocelise"))},[...g[22]||(g[22]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"M289.088 296.704h92.992a32 32 0 0 1 0 64H232.96a32 32 0 0 1-32-32V179.712a32 32 0 0 1 64 0v50.56a384 384 0 0 1 643.84 282.88 384 384 0 0 1-383.936 384 384 384 0 0 1-384-384h64a320 320 0 1 0 640 0 320 320 0 0 0-555.712-216.448z"})],-1)])]),o("i",{class:"av-icon refresh-right",onClick:g[8]||(g[8]=e=>x.handleActions("clocelise"))},[...g[23]||(g[23]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[o("path",{fill:"currentColor",d:"M784.512 230.272v-50.56a32 32 0 1 1 64 0v149.056a32 32 0 0 1-32 32H667.52a32 32 0 1 1 0-64h92.992A320 320 0 1 0 524.8 833.152a320 320 0 0 0 320-320h64a384 384 0 0 1-384 384 384 384 0 0 1-384-384 384 384 0 0 1 643.712-282.88z"})],-1)])])])])):v("",!0),o("div",F,[(a(!0),s(c,null,d(p.urlList,(e,i)=>(a(),s("div",null,[x.isImage(e)?f((a(),s("img",{ref_for:!0,ref:"media",key:e.url,src:e.url.replaceAll("//","/").replace(":/","://"),style:t(x.mediaStyle),class:"av-image-viewer__img",onLoad:g[9]||(g[9]=(...e)=>x.handleMediaLoad&&x.handleMediaLoad(...e)),onError:g[10]||(g[10]=(...e)=>x.handleMediaError&&x.handleMediaError(...e)),onMousedown:g[11]||(g[11]=(...e)=>x.handleMouseDown&&x.handleMouseDown(...e))},null,44,R)),[[m,i===x.index]]):v("",!0),x.isVideo(e)?f((a(),s("video",{controls:"controls",key:e.url,ref_for:!0,ref:"media",src:e.url.replaceAll("//","/").replace(":/","://"),style:t(x.mediaStyle),class:"av-image-viewer__img",onCanplay:g[12]||(g[12]=(...e)=>x.handleMediaLoad&&x.handleMediaLoad(...e)),onError:g[13]||(g[13]=(...e)=>x.handleMediaError&&x.handleMediaError(...e)),onMousedown:g[14]||(g[14]=(...e)=>x.handleMouseDown&&x.handleMouseDown(...e))},null,44,$)),[[m,i===x.index]]):v("",!0),["doc","docx"].includes(x.getSuff(e))?f((a(),l(M,{class:"wdbox",key:e.url,src:e.url.replaceAll("//","/").replace(":/","://")},null,8,["src"])),[[m,i===x.index]]):v("",!0),["xlsx","xls"].includes(x.getSuff(e))?f((a(),l(b,{class:"wdbox",key:e.url,src:e.url.replaceAll("//","/").replace(":/","://")},null,8,["src"])),[[m,i===x.index]]):v("",!0),"pdf"===x.getSuff(e)?f((a(),l(k,{class:"wdbox",key:e.url,src:e.url.replaceAll("//","/").replace(":/","://")},null,8,["src"])),[[m,i===x.index]]):v("",!0)]))),256))])],4)]),_:1})}]]);var P={install:e=>{e.component("allViewer",j)},allViewer:j};export{j as allViewer,P as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "all-viewer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "vue3 图片视频word elsx pdf通用切换预览插件",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"author": "Eric-tu",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vue3",
|
|
15
|
+
"sass",
|
|
16
|
+
"view",
|
|
17
|
+
"viewer"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./dist/*.css": {
|
|
24
|
+
"import": "./dist/*.css"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "vite --host",
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"bap": "yarn build && yarn pack --force",
|
|
31
|
+
"release-patch": "npm version patch && npm run bap",
|
|
32
|
+
"release-minor": "npm version minor && npm run bap",
|
|
33
|
+
"release-major": "npm version major && npm run bap"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"vue": "^3.5.28",
|
|
37
|
+
"vue-demi": "^0.14.10",
|
|
38
|
+
"@vue-office/docx": "^1.6.3",
|
|
39
|
+
"@vue-office/excel": "^1.7.14",
|
|
40
|
+
"@vue-office/pdf": "^2.0.10"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
44
|
+
"@vue-office/docx": "^1.6.3",
|
|
45
|
+
"@vue-office/excel": "^1.7.14",
|
|
46
|
+
"@vue-office/pdf": "^2.0.10",
|
|
47
|
+
"sass-embedded": "^1.97.3",
|
|
48
|
+
"terser": "^5.46.0",
|
|
49
|
+
"vite": "^7.3.1",
|
|
50
|
+
"vue": "^3.5.28",
|
|
51
|
+
"vue-demi": "^0.14.10"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {}
|
|
54
|
+
}
|