vxe-pc-ui 4.7.8 → 4.7.9
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/es/icon/style.css +1 -1
- package/es/image/src/group.js +21 -5
- package/es/image/src/image.js +25 -5
- package/es/image/src/preview.js +20 -13
- package/es/image/src/util.js +11 -0
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/image/src/group.js +19 -5
- package/lib/image/src/group.min.js +1 -1
- package/lib/image/src/image.js +23 -5
- package/lib/image/src/image.min.js +1 -1
- package/lib/image/src/preview.js +28 -14
- package/lib/image/src/preview.min.js +1 -1
- package/lib/image/src/util.js +14 -0
- package/lib/image/src/util.min.js +1 -1
- package/lib/index.umd.js +86 -26
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +1 -1
- package/packages/image/src/group.ts +22 -5
- package/packages/image/src/image.ts +26 -5
- package/packages/image/src/preview.ts +20 -13
- package/packages/image/src/util.ts +12 -1
- package/types/components/image-group.d.ts +23 -2
- package/types/components/image-preview.d.ts +12 -2
- package/types/components/image.d.ts +27 -3
- /package/es/icon/{iconfont.1752545171984.ttf → iconfont.1752551365876.ttf} +0 -0
- /package/es/icon/{iconfont.1752545171984.woff → iconfont.1752551365876.woff} +0 -0
- /package/es/icon/{iconfont.1752545171984.woff2 → iconfont.1752551365876.woff2} +0 -0
- /package/es/{iconfont.1752545171984.ttf → iconfont.1752551365876.ttf} +0 -0
- /package/es/{iconfont.1752545171984.woff → iconfont.1752551365876.woff} +0 -0
- /package/es/{iconfont.1752545171984.woff2 → iconfont.1752551365876.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1752545171984.ttf → iconfont.1752551365876.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1752545171984.woff → iconfont.1752551365876.woff} +0 -0
- /package/lib/icon/style/{iconfont.1752545171984.woff2 → iconfont.1752551365876.woff2} +0 -0
- /package/lib/{iconfont.1752545171984.ttf → iconfont.1752551365876.ttf} +0 -0
- /package/lib/{iconfont.1752545171984.woff → iconfont.1752551365876.woff} +0 -0
- /package/lib/{iconfont.1752545171984.woff2 → iconfont.1752551365876.woff2} +0 -0
package/lib/image/src/preview.js
CHANGED
|
@@ -39,7 +39,7 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
39
39
|
beforeDownloadMethod: Function,
|
|
40
40
|
downloadMethod: Function
|
|
41
41
|
},
|
|
42
|
-
emits: ['update:modelValue', 'change', 'download', 'download-fail', 'close'],
|
|
42
|
+
emits: ['update:modelValue', 'change', 'download', 'download-fail', 'rotate', 'close'],
|
|
43
43
|
setup(props, context) {
|
|
44
44
|
const {
|
|
45
45
|
emit
|
|
@@ -234,7 +234,7 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
234
234
|
reactData.offsetScale = Number(Math.max(-0.9, offsetScale - stepNum).toFixed(2));
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
const
|
|
237
|
+
const handleChangeEvent = (evnt, isNext) => {
|
|
238
238
|
let activeIndex = reactData.activeIndex || 0;
|
|
239
239
|
const imgList = computeImgList.value;
|
|
240
240
|
if (isNext) {
|
|
@@ -250,11 +250,21 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
250
250
|
activeIndex--;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
const imgUrl = imgList[activeIndex || 0];
|
|
254
254
|
reactData.activeIndex = activeIndex;
|
|
255
|
+
resetStyle();
|
|
255
256
|
emitModel(activeIndex);
|
|
257
|
+
dispatchEvent('change', {
|
|
258
|
+
url: imgUrl,
|
|
259
|
+
activeIndex
|
|
260
|
+
}, evnt);
|
|
256
261
|
};
|
|
257
|
-
const
|
|
262
|
+
const handleRotateImgEvent = (evnt, isRight) => {
|
|
263
|
+
const imgList = computeImgList.value;
|
|
264
|
+
const {
|
|
265
|
+
activeIndex
|
|
266
|
+
} = reactData;
|
|
267
|
+
const imgUrl = imgList[activeIndex || 0];
|
|
258
268
|
let offsetRotate = reactData.offsetRotate;
|
|
259
269
|
if (isRight) {
|
|
260
270
|
offsetRotate += 90;
|
|
@@ -262,6 +272,10 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
262
272
|
offsetRotate -= 90;
|
|
263
273
|
}
|
|
264
274
|
reactData.offsetRotate = offsetRotate;
|
|
275
|
+
dispatchEvent('rotate', {
|
|
276
|
+
url: imgUrl,
|
|
277
|
+
rotateValue: offsetRotate
|
|
278
|
+
}, evnt);
|
|
265
279
|
};
|
|
266
280
|
const handlePct11 = () => {
|
|
267
281
|
resetStyle();
|
|
@@ -359,10 +373,10 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
359
373
|
handlePct11();
|
|
360
374
|
break;
|
|
361
375
|
case 'rotateLeft':
|
|
362
|
-
|
|
376
|
+
handleRotateImgEvent(evnt, false);
|
|
363
377
|
break;
|
|
364
378
|
case 'rotateRight':
|
|
365
|
-
|
|
379
|
+
handleRotateImgEvent(evnt, true);
|
|
366
380
|
break;
|
|
367
381
|
case 'print':
|
|
368
382
|
handlePrintImg();
|
|
@@ -444,21 +458,21 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
444
458
|
if (hasShiftKey) {
|
|
445
459
|
reactData.offsetLeft -= 1;
|
|
446
460
|
} else {
|
|
447
|
-
|
|
461
|
+
handleChangeEvent(evnt, false);
|
|
448
462
|
}
|
|
449
463
|
} else if (isRightArrow) {
|
|
450
464
|
evnt.preventDefault();
|
|
451
465
|
if (hasShiftKey) {
|
|
452
466
|
reactData.offsetLeft += 1;
|
|
453
467
|
} else {
|
|
454
|
-
|
|
468
|
+
handleChangeEvent(evnt, true);
|
|
455
469
|
}
|
|
456
470
|
} else if (isR && isControlKey) {
|
|
457
471
|
evnt.preventDefault();
|
|
458
472
|
if (hasShiftKey) {
|
|
459
|
-
|
|
473
|
+
handleRotateImgEvent(evnt, false);
|
|
460
474
|
} else {
|
|
461
|
-
|
|
475
|
+
handleRotateImgEvent(evnt, true);
|
|
462
476
|
}
|
|
463
477
|
} else if (isP && isControlKey) {
|
|
464
478
|
evnt.preventDefault();
|
|
@@ -538,15 +552,15 @@ var _default = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
538
552
|
class: 'vxe-image-preview--close-bg'
|
|
539
553
|
})]), imgList.length > 1 ? (0, _vue.h)('div', {
|
|
540
554
|
class: 'vxe-image-preview--previous-btn',
|
|
541
|
-
onClick() {
|
|
542
|
-
|
|
555
|
+
onClick(evnt) {
|
|
556
|
+
handleChangeEvent(evnt, false);
|
|
543
557
|
}
|
|
544
558
|
}, [(0, _vue.h)('i', {
|
|
545
559
|
class: (0, _ui.getIcon)().IMAGE_PREVIEW_PREVIOUS
|
|
546
560
|
})]) : (0, _ui.renderEmptyElement)($xeImagePreview), imgList.length > 1 ? (0, _vue.h)('div', {
|
|
547
561
|
class: 'vxe-image-preview--next-btn',
|
|
548
|
-
onClick() {
|
|
549
|
-
|
|
562
|
+
onClick(evnt) {
|
|
563
|
+
handleChangeEvent(evnt, true);
|
|
550
564
|
}
|
|
551
565
|
}, [(0, _vue.h)('i', {
|
|
552
566
|
class: (0, _ui.getIcon)().IMAGE_PREVIEW_NEXT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_comp=require("../../ui/src/comp"),_ui=require("../../ui"),_xeUtils=_interopRequireDefault(require("xe-utils")),_dom=require("../../ui/src/dom");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeImagePreview",props:{modelValue:Number,urlList:Array,urlField:{type:String,default:()=>(0,_ui.getConfig)().imagePreview.urlField},maskClosable:{type:Boolean,default:()=>(0,_ui.getConfig)().imagePreview.maskClosable},marginSize:{type:String,default:()=>(0,_ui.getConfig)().imagePreview.marginSize},showPrintButton:{type:Boolean,default:()=>(0,_ui.getConfig)().imagePreview.showPrintButton},showDownloadButton:{type:Boolean,default:()=>(0,_ui.getConfig)().imagePreview.showDownloadButton},toolbarConfig:Object,beforeDownloadMethod:Function,downloadMethod:Function},emits:["update:modelValue","change","download","download-fail","close"],setup(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_comp=require("../../ui/src/comp"),_ui=require("../../ui"),_xeUtils=_interopRequireDefault(require("xe-utils")),_dom=require("../../ui/src/dom");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeImagePreview",props:{modelValue:Number,urlList:Array,urlField:{type:String,default:()=>(0,_ui.getConfig)().imagePreview.urlField},maskClosable:{type:Boolean,default:()=>(0,_ui.getConfig)().imagePreview.maskClosable},marginSize:{type:String,default:()=>(0,_ui.getConfig)().imagePreview.marginSize},showPrintButton:{type:Boolean,default:()=>(0,_ui.getConfig)().imagePreview.showPrintButton},showDownloadButton:{type:Boolean,default:()=>(0,_ui.getConfig)().imagePreview.showDownloadButton},toolbarConfig:Object,beforeDownloadMethod:Function,downloadMethod:Function},emits:["update:modelValue","change","download","download-fail","rotate","close"],setup(u,e){const a=e["emit"];var t=_xeUtils.default.uniqueId();const i=(0,_vue.ref)(),o={refElem:i},c=(0,_vue.reactive)({activeIndex:u.modelValue||0,offsetPct11:!1,offsetScale:0,offsetRotate:0,offsetLeft:0,offsetTop:0}),r=(0,_vue.computed)(()=>u.urlField||"url"),_=(0,_vue.computed)(()=>_xeUtils.default.toNumber(u.marginSize||0)||16),s=(0,_vue.computed)(()=>Object.assign({},(0,_ui.getConfig)().imagePreview.toolbarConfig,u.toolbarConfig)),l=(0,_vue.computed)(()=>{var e=c["offsetRotate"];return e?e+"°":"0°"}),v=(0,_vue.computed)(()=>{var e=c["offsetScale"];return e?_xeUtils.default.ceil(100*(1+e))+"%":"100%"}),d=(0,_vue.computed)(()=>{var e=u["urlList"];const t=r.value;return e&&e.length?e.map(e=>_xeUtils.default.isString(e)?e:e[t]||""):[]}),n=(0,_vue.computed)(()=>{var{offsetScale:e,offsetRotate:o,offsetLeft:a,offsetTop:i}=c,r=[];let n=1;if(e&&(n=1+e,r.push(`scale(${n})`)),o&&r.push(`rotate(${o}deg)`),a||i){let e=a/=n,t=i/=n;if(o)switch(o%360){case 90:case-270:e=i,t=-a;break;case 180:case-180:e=-a,t=-i;break;case 270:case-90:e=-i,t=a}r.push(`translate(${e}px, ${t}px)`)}return r.length?r.join(" "):""}),f={computeImgList:d},m={xID:t,props:u,context:e,reactData:c,getRefMaps:()=>o,getComputeMaps:()=>f},p=(e,t,o)=>{a(e,(0,_ui.createEvent)(o,{$imagePreview:m},t))};t={dispatchEvent:p};const g=e=>{c.activeIndex=e,a("update:modelValue",e)},E=e=>{p("close",{},e)};const h=()=>{var e=i.value;(0,_dom.removeClass)(e,"is--move"),Object.assign(c,{offsetPct11:!1,offsetScale:0,offsetRotate:0,offsetLeft:0,offsetTop:0})},w=()=>{var e=c["offsetScale"];let t=.02;return t=-.6<=e&&(t=.04,-.4<=e)&&(t=.07,0<=e)&&(t=.1,3<=e)&&(t=.25,8<=e)&&(t=.4,16<=e)&&(t=.6,24<=e)&&(t=.9,32<=e)&&(t=1.3,39<=e)&&(t=1.9,45<=e)?2.5:t},x=e=>{var t=c["offsetScale"],o=w();c.offsetScale=e?Number(Math.min(49,t+o).toFixed(2)):Number(Math.max(-.9,t-o).toFixed(2))},I=(e,t)=>{let o=c.activeIndex||0;var a=d.value,t=(t?o>=a.length-1?o=0:o++:o<=0?o=a.length-1:o--,a[o||0]);c.activeIndex=o,h(),g(o),p("change",{url:t,activeIndex:o},e)},b=(e,t)=>{var o=d.value,a=c["activeIndex"],o=o[a||0];let i=c.offsetRotate;t?i+=90:i-=90,c.offsetRotate=i,p("rotate",{url:o,rotateValue:i},e)},P=()=>{var e=c["activeIndex"],e=d.value[e||0];_ui.VxeUI.print&&_ui.VxeUI.print({align:"center",pageBreaks:[{bodyHtml:`<img src="${e}" style="max-width:100%;max-height:100%;">`}]})},R=(e,t)=>{p("download",{url:t},e)},V=a=>{const i=c["activeIndex"];var e=s.value.download,e=!_xeUtils.default.isBoolean(e)&&e?Object.assign({},e):{};const r=d.value[i||0];var t=u.beforeDownloadMethod||e.beforeDownloadMethod||(0,_ui.getConfig)().imagePreview.beforeDownloadMethod;const n=u.downloadMethod||e.downloadMethod||(0,_ui.getConfig)().imagePreview.downloadMethod;Promise.resolve(!t||t({$imagePreview:m,url:r,index:i||0})).then(e=>{var t,o;e&&(n?Promise.resolve(n({$imagePreview:m,url:r,index:i||0})).then(()=>{R(a,r)}).catch(e=>e):(t=a,o=r,_ui.VxeUI.saveFile&&fetch(o).then(e=>e.blob().then(e=>{_ui.VxeUI.saveFile({filename:o,content:e}),R(t,o)})).catch(()=>{_ui.VxeUI.modal&&_ui.VxeUI.modal.message({content:(0,_ui.getI18n)("vxe.error.downErr"),status:"error"})})))})},O=(e,t)=>{var o=c["activeIndex"];if(d.value[o||0])switch(t){case"zoomOut":x(!1);break;case"zoomIn":x(!0);break;case"pctFull":h();break;case"pct11":h(),c.offsetPct11=!0;break;case"rotateLeft":b(e,!1);break;case"rotateRight":b(e,!0);break;case"print":P();break;case"download":V(e)}},L=e=>{e=e.deltaY;0<e?x(!1):e<0&&x(!0)},C=e=>{const{offsetTop:r,offsetLeft:n}=c,u=i.value,t=(e.preventDefault(),document.onmousemove),o=document.onmouseup,s=e.pageX,l=e.pageY,v=_.value;document.onmousemove=e=>{var{pageX:t,pageY:o}=e,{visibleHeight:a,visibleWidth:i}=(0,_dom.getDomNode)();e.preventDefault(),(0,_dom.addClass)(u,"is--move"),t>v&&o>v&&t<i-v&&o<a-v&&(c.offsetLeft=n+t-s,c.offsetTop=r+o-l)},document.onmouseup=()=>{document.onmousemove=t,document.onmouseup=o,(0,_dom.removeClass)(u,"is--move")}},M=e=>{var t=(0,_dom.hasControlKey)(e),o=e.shiftKey,a=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),i=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN),r=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_LEFT),n=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_RIGHT),u=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.R),s=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.P);a?(e.preventDefault(),o?--c.offsetTop:x(!0)):i?(e.preventDefault(),o?c.offsetTop+=1:x(!1)):r?(e.preventDefault(),o?--c.offsetLeft:I(e,!1)):n?(e.preventDefault(),o?c.offsetLeft+=1:I(e,!0)):u&&t?(e.preventDefault(),o?b(e,!1):b(e,!0)):s&&t&&(e.preventDefault(),P())},T=e=>{u.maskClosable&&e.target===e.currentTarget&&p("close",{},e)},y=(Object.assign(m,t,{}),(t,e)=>{var o=s.value[t],a=!_xeUtils.default.isBoolean(o)&&o?Object.assign({},o):{};return!1!==o?(0,_vue.h)("div",{class:"vxe-image-preview--operation-btn",title:(0,_ui.getI18n)("vxe.imagePreview.operBtn."+t),onClick(e){O(e,t)}},[(0,_vue.h)("i",{class:a.icon||(0,_ui.getIcon)()[e]})]):(0,_ui.renderEmptyElement)(m)});e=()=>{var e=c["offsetPct11"];return(0,_vue.h)("div",{ref:i,class:["vxe-image-preview",{"is--pct11":e}],onWheel:L},[(()=>{const o=c["activeIndex"];var e=d.value;const a=n.value;return(0,_vue.h)("div",{class:"vxe-image-preview--img-list",onClick:T},e.map((e,t)=>{t=o===t;return(0,_vue.h)("img",{class:["vxe-image-preview--img-item",{"is--active":t}],src:e,style:t?{transform:a}:null,onMousedown(e){C(e)}})}))})(),(()=>{var{showPrintButton:e,showDownloadButton:t}=u,o=c["activeIndex"],a=d.value,i=l.value,r=v.value,n=s.value;return(0,_vue.h)("div",{class:"vxe-image-preview--btn-wrapper"},[(0,_vue.h)("div",{class:"vxe-image-preview--close-wrapper"},[(0,_vue.h)("div",{class:"vxe-image-preview--close-btn",onClick:E},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().IMAGE_PREVIEW_CLOSE})]),(0,_vue.h)("div",{class:"vxe-image-preview--close-bg"})]),1<a.length?(0,_vue.h)("div",{class:"vxe-image-preview--previous-btn",onClick(e){I(e,!1)}},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().IMAGE_PREVIEW_PREVIOUS})]):(0,_ui.renderEmptyElement)(m),1<a.length?(0,_vue.h)("div",{class:"vxe-image-preview--next-btn",onClick(e){I(e,!0)}},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().IMAGE_PREVIEW_NEXT})]):(0,_ui.renderEmptyElement)(m),(0,_vue.h)("div",{class:"vxe-image-preview--operation-info"},[(0,_vue.h)("div",{class:"vxe-image-preview--operation-deg"},i),(0,_vue.h)("div",{class:"vxe-image-preview--operation-pct"},r)]),(0,_vue.h)("div",{class:"vxe-image-preview--operation-wrapper"},[(0,_vue.h)("div",{class:"vxe-image-preview--operation-active-count"},[(0,_vue.h)("span",{class:"vxe-image-preview--operation-active-current"},""+((o||0)+1)),(0,_vue.h)("span",{class:"vxe-image-preview--operation-active-total"},"/"+a.length)]),y("zoomOut","IMAGE_PREVIEW_ZOOM_OUT"),y("zoomIn","IMAGE_PREVIEW_ZOOM_IN"),y("pctFull","IMAGE_PREVIEW_PCT_FULL"),y("pct11","IMAGE_PREVIEW_PCT_1_1"),y("rotateLeft","IMAGE_PREVIEW_ROTATE_LEFT"),y("rotateRight","IMAGE_PREVIEW_ROTATE_RIGHT"),e||n.print?y("print","IMAGE_PREVIEW_PRINT"):(0,_ui.renderEmptyElement)(m),t||n.download?y("download","IMAGE_PREVIEW_DOWNLOAD"):(0,_ui.renderEmptyElement)(m)])])})()])};return(0,_vue.watch)(()=>u.modelValue,e=>{c.activeIndex=e,h()}),(0,_vue.onMounted)(()=>{_ui.globalEvents.on(m,"keydown",M)}),(0,_vue.onBeforeUnmount)(()=>{var e=i.value;e&&(0,_dom.removeClass)(e,"is--move")}),(0,_vue.onUnmounted)(()=>{_ui.globalEvents.off(m,"keydown")}),(0,_vue.provide)("$xeImagePreview",m),m.renderVN=e}});
|
package/lib/image/src/util.js
CHANGED
|
@@ -18,6 +18,10 @@ const openPreviewImage = options => {
|
|
|
18
18
|
urlList,
|
|
19
19
|
activeIndex
|
|
20
20
|
} = opts;
|
|
21
|
+
const {
|
|
22
|
+
rotate,
|
|
23
|
+
change
|
|
24
|
+
} = opts.events || {};
|
|
21
25
|
const modalId = _xeUtils.default.uniqueId('image-preview');
|
|
22
26
|
_core.VxeUI.modal.open({
|
|
23
27
|
id: modalId,
|
|
@@ -44,6 +48,16 @@ const openPreviewImage = options => {
|
|
|
44
48
|
downloadMethod: opts.downloadMethod,
|
|
45
49
|
onClose() {
|
|
46
50
|
_core.VxeUI.modal.close(modalId);
|
|
51
|
+
},
|
|
52
|
+
onChange(eventParams) {
|
|
53
|
+
if (change) {
|
|
54
|
+
change.call(this, eventParams);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
onRotate(eventParams) {
|
|
58
|
+
if (rotate) {
|
|
59
|
+
rotate.call(this, eventParams);
|
|
60
|
+
}
|
|
47
61
|
}
|
|
48
62
|
});
|
|
49
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.openPreviewImage=void 0;var _vue=require("vue"),_core=require("@vxe-ui/core"),_preview=_interopRequireDefault(require("./preview")),_xeUtils=_interopRequireDefault(require("xe-utils"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const openPreviewImage=e=>{if(_core.VxeUI.modal){const o=Object.assign({escClosable:!0},e),{urlList:r,activeIndex:t}=o,i=_xeUtils.default.uniqueId("image-preview");_core.VxeUI.modal.open({id:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.openPreviewImage=void 0;var _vue=require("vue"),_core=require("@vxe-ui/core"),_preview=_interopRequireDefault(require("./preview")),_xeUtils=_interopRequireDefault(require("xe-utils"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const openPreviewImage=e=>{if(_core.VxeUI.modal){const o=Object.assign({escClosable:!0},e),{urlList:r,activeIndex:t}=o,{rotate:i,change:l}=o.events||{},a=_xeUtils.default.uniqueId("image-preview");_core.VxeUI.modal.open({id:a,title:"预览",width:"100%",height:"100%",showHeader:!1,showFooter:!1,padding:!1,escClosable:o.escClosable,className:"vxe-image-preview-popup-wrapper",slots:{default(){return(0,_vue.h)(_preview.default,{modelValue:t,urlList:r,urlField:o.urlField,marginSize:o.marginSize,maskClosable:o.maskClosable,toolbarConfig:o.toolbarConfig,showPrintButton:o.showPrintButton,showDownloadButton:o.showDownloadButton,beforeDownloadMethod:o.beforeDownloadMethod,downloadMethod:o.downloadMethod,onClose(){_core.VxeUI.modal.close(a)},onChange(e){l&&l.call(this,e)},onRotate(e){i&&i.call(this,e)}})}}})}return Promise.resolve()};exports.openPreviewImage=openPreviewImage;
|
package/lib/index.umd.js
CHANGED
|
@@ -4278,14 +4278,14 @@ function checkDynamic() {
|
|
|
4278
4278
|
}
|
|
4279
4279
|
;// CONCATENATED MODULE: ./packages/ui/src/log.ts
|
|
4280
4280
|
|
|
4281
|
-
const log_version = `ui v${"4.7.
|
|
4281
|
+
const log_version = `ui v${"4.7.9"}`;
|
|
4282
4282
|
const warnLog = log.create('warn', log_version);
|
|
4283
4283
|
const errLog = log.create('error', log_version);
|
|
4284
4284
|
;// CONCATENATED MODULE: ./packages/ui/index.ts
|
|
4285
4285
|
|
|
4286
4286
|
|
|
4287
4287
|
|
|
4288
|
-
const ui_version = "4.7.
|
|
4288
|
+
const ui_version = "4.7.9";
|
|
4289
4289
|
index_esm_VxeUI.uiVersion = ui_version;
|
|
4290
4290
|
index_esm_VxeUI.dynamicApp = dynamicApp;
|
|
4291
4291
|
function config(options) {
|
|
@@ -23042,7 +23042,7 @@ const IconPicker = VxeIconPicker;
|
|
|
23042
23042
|
beforeDownloadMethod: Function,
|
|
23043
23043
|
downloadMethod: Function
|
|
23044
23044
|
},
|
|
23045
|
-
emits: ['update:modelValue', 'change', 'download', 'download-fail', 'close'],
|
|
23045
|
+
emits: ['update:modelValue', 'change', 'download', 'download-fail', 'rotate', 'close'],
|
|
23046
23046
|
setup(props, context) {
|
|
23047
23047
|
const {
|
|
23048
23048
|
emit
|
|
@@ -23237,7 +23237,7 @@ const IconPicker = VxeIconPicker;
|
|
|
23237
23237
|
reactData.offsetScale = Number(Math.max(-0.9, offsetScale - stepNum).toFixed(2));
|
|
23238
23238
|
}
|
|
23239
23239
|
};
|
|
23240
|
-
const
|
|
23240
|
+
const handleChangeEvent = (evnt, isNext) => {
|
|
23241
23241
|
let activeIndex = reactData.activeIndex || 0;
|
|
23242
23242
|
const imgList = computeImgList.value;
|
|
23243
23243
|
if (isNext) {
|
|
@@ -23253,11 +23253,21 @@ const IconPicker = VxeIconPicker;
|
|
|
23253
23253
|
activeIndex--;
|
|
23254
23254
|
}
|
|
23255
23255
|
}
|
|
23256
|
-
|
|
23256
|
+
const imgUrl = imgList[activeIndex || 0];
|
|
23257
23257
|
reactData.activeIndex = activeIndex;
|
|
23258
|
+
resetStyle();
|
|
23258
23259
|
emitModel(activeIndex);
|
|
23260
|
+
dispatchEvent('change', {
|
|
23261
|
+
url: imgUrl,
|
|
23262
|
+
activeIndex
|
|
23263
|
+
}, evnt);
|
|
23259
23264
|
};
|
|
23260
|
-
const
|
|
23265
|
+
const handleRotateImgEvent = (evnt, isRight) => {
|
|
23266
|
+
const imgList = computeImgList.value;
|
|
23267
|
+
const {
|
|
23268
|
+
activeIndex
|
|
23269
|
+
} = reactData;
|
|
23270
|
+
const imgUrl = imgList[activeIndex || 0];
|
|
23261
23271
|
let offsetRotate = reactData.offsetRotate;
|
|
23262
23272
|
if (isRight) {
|
|
23263
23273
|
offsetRotate += 90;
|
|
@@ -23265,6 +23275,10 @@ const IconPicker = VxeIconPicker;
|
|
|
23265
23275
|
offsetRotate -= 90;
|
|
23266
23276
|
}
|
|
23267
23277
|
reactData.offsetRotate = offsetRotate;
|
|
23278
|
+
dispatchEvent('rotate', {
|
|
23279
|
+
url: imgUrl,
|
|
23280
|
+
rotateValue: offsetRotate
|
|
23281
|
+
}, evnt);
|
|
23268
23282
|
};
|
|
23269
23283
|
const handlePct11 = () => {
|
|
23270
23284
|
resetStyle();
|
|
@@ -23362,10 +23376,10 @@ const IconPicker = VxeIconPicker;
|
|
|
23362
23376
|
handlePct11();
|
|
23363
23377
|
break;
|
|
23364
23378
|
case 'rotateLeft':
|
|
23365
|
-
|
|
23379
|
+
handleRotateImgEvent(evnt, false);
|
|
23366
23380
|
break;
|
|
23367
23381
|
case 'rotateRight':
|
|
23368
|
-
|
|
23382
|
+
handleRotateImgEvent(evnt, true);
|
|
23369
23383
|
break;
|
|
23370
23384
|
case 'print':
|
|
23371
23385
|
handlePrintImg();
|
|
@@ -23447,21 +23461,21 @@ const IconPicker = VxeIconPicker;
|
|
|
23447
23461
|
if (hasShiftKey) {
|
|
23448
23462
|
reactData.offsetLeft -= 1;
|
|
23449
23463
|
} else {
|
|
23450
|
-
|
|
23464
|
+
handleChangeEvent(evnt, false);
|
|
23451
23465
|
}
|
|
23452
23466
|
} else if (isRightArrow) {
|
|
23453
23467
|
evnt.preventDefault();
|
|
23454
23468
|
if (hasShiftKey) {
|
|
23455
23469
|
reactData.offsetLeft += 1;
|
|
23456
23470
|
} else {
|
|
23457
|
-
|
|
23471
|
+
handleChangeEvent(evnt, true);
|
|
23458
23472
|
}
|
|
23459
23473
|
} else if (isR && isControlKey) {
|
|
23460
23474
|
evnt.preventDefault();
|
|
23461
23475
|
if (hasShiftKey) {
|
|
23462
|
-
|
|
23476
|
+
handleRotateImgEvent(evnt, false);
|
|
23463
23477
|
} else {
|
|
23464
|
-
|
|
23478
|
+
handleRotateImgEvent(evnt, true);
|
|
23465
23479
|
}
|
|
23466
23480
|
} else if (isP && isControlKey) {
|
|
23467
23481
|
evnt.preventDefault();
|
|
@@ -23541,15 +23555,15 @@ const IconPicker = VxeIconPicker;
|
|
|
23541
23555
|
class: 'vxe-image-preview--close-bg'
|
|
23542
23556
|
})]), imgList.length > 1 ? (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
|
|
23543
23557
|
class: 'vxe-image-preview--previous-btn',
|
|
23544
|
-
onClick() {
|
|
23545
|
-
|
|
23558
|
+
onClick(evnt) {
|
|
23559
|
+
handleChangeEvent(evnt, false);
|
|
23546
23560
|
}
|
|
23547
23561
|
}, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('i', {
|
|
23548
23562
|
class: getIcon().IMAGE_PREVIEW_PREVIOUS
|
|
23549
23563
|
})]) : renderEmptyElement($xeImagePreview), imgList.length > 1 ? (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
|
|
23550
23564
|
class: 'vxe-image-preview--next-btn',
|
|
23551
|
-
onClick() {
|
|
23552
|
-
|
|
23565
|
+
onClick(evnt) {
|
|
23566
|
+
handleChangeEvent(evnt, true);
|
|
23553
23567
|
}
|
|
23554
23568
|
}, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('i', {
|
|
23555
23569
|
class: getIcon().IMAGE_PREVIEW_NEXT
|
|
@@ -23616,6 +23630,10 @@ const openPreviewImage = options => {
|
|
|
23616
23630
|
urlList,
|
|
23617
23631
|
activeIndex
|
|
23618
23632
|
} = opts;
|
|
23633
|
+
const {
|
|
23634
|
+
rotate,
|
|
23635
|
+
change
|
|
23636
|
+
} = opts.events || {};
|
|
23619
23637
|
const modalId = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().uniqueId('image-preview');
|
|
23620
23638
|
index_esm_VxeUI.modal.open({
|
|
23621
23639
|
id: modalId,
|
|
@@ -23642,6 +23660,16 @@ const openPreviewImage = options => {
|
|
|
23642
23660
|
downloadMethod: opts.downloadMethod,
|
|
23643
23661
|
onClose() {
|
|
23644
23662
|
index_esm_VxeUI.modal.close(modalId);
|
|
23663
|
+
},
|
|
23664
|
+
onChange(eventParams) {
|
|
23665
|
+
if (change) {
|
|
23666
|
+
change.call(this, eventParams);
|
|
23667
|
+
}
|
|
23668
|
+
},
|
|
23669
|
+
onRotate(eventParams) {
|
|
23670
|
+
if (rotate) {
|
|
23671
|
+
rotate.call(this, eventParams);
|
|
23672
|
+
}
|
|
23645
23673
|
}
|
|
23646
23674
|
});
|
|
23647
23675
|
}
|
|
@@ -23687,9 +23715,10 @@ const openPreviewImage = options => {
|
|
|
23687
23715
|
size: {
|
|
23688
23716
|
type: String,
|
|
23689
23717
|
default: () => getConfig().image.size || getConfig().size
|
|
23690
|
-
}
|
|
23718
|
+
},
|
|
23719
|
+
getThumbnailUrlMethod: Function
|
|
23691
23720
|
},
|
|
23692
|
-
emits: ['click'],
|
|
23721
|
+
emits: ['click', 'change', 'rotate'],
|
|
23693
23722
|
setup(props, context) {
|
|
23694
23723
|
const {
|
|
23695
23724
|
emit
|
|
@@ -23751,6 +23780,14 @@ const openPreviewImage = options => {
|
|
|
23751
23780
|
const imgItem = computeImgItem.value;
|
|
23752
23781
|
return imgItem ? `${imgItem.url || ''}` : '';
|
|
23753
23782
|
});
|
|
23783
|
+
const computeImgThumbnailUrl = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
|
|
23784
|
+
const getThumbnailUrlFn = props.getThumbnailUrlMethod || getConfig().image.getThumbnailUrlMethod;
|
|
23785
|
+
const imgUrl = computeImgUrl.value;
|
|
23786
|
+
return getThumbnailUrlFn ? getThumbnailUrlFn({
|
|
23787
|
+
url: imgUrl,
|
|
23788
|
+
$image: $xeImage
|
|
23789
|
+
}) : '';
|
|
23790
|
+
});
|
|
23754
23791
|
const computeMaps = {
|
|
23755
23792
|
computeSize
|
|
23756
23793
|
};
|
|
@@ -23790,10 +23827,18 @@ const openPreviewImage = options => {
|
|
|
23790
23827
|
toolbarConfig,
|
|
23791
23828
|
showPrintButton,
|
|
23792
23829
|
showDownloadButton,
|
|
23793
|
-
maskClosable
|
|
23830
|
+
maskClosable,
|
|
23831
|
+
events: {
|
|
23832
|
+
change(eventParams) {
|
|
23833
|
+
$xeImage.dispatchEvent('click', eventParams, eventParams.$event);
|
|
23834
|
+
},
|
|
23835
|
+
rotate(eventParams) {
|
|
23836
|
+
$xeImage.dispatchEvent('click', eventParams, eventParams.$event);
|
|
23837
|
+
}
|
|
23838
|
+
}
|
|
23794
23839
|
});
|
|
23795
23840
|
}
|
|
23796
|
-
|
|
23841
|
+
$xeImage.dispatchEvent('click', {
|
|
23797
23842
|
url: imgUrl
|
|
23798
23843
|
}, evnt);
|
|
23799
23844
|
}
|
|
@@ -23808,6 +23853,7 @@ const openPreviewImage = options => {
|
|
|
23808
23853
|
} = props;
|
|
23809
23854
|
const imgStyle = computeImgStyle.value;
|
|
23810
23855
|
const imgUrl = computeImgUrl.value;
|
|
23856
|
+
const imgThumbnailUrl = computeImgThumbnailUrl.value;
|
|
23811
23857
|
const vSize = computeSize.value;
|
|
23812
23858
|
return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('img', {
|
|
23813
23859
|
ref: refElem,
|
|
@@ -23815,7 +23861,7 @@ const openPreviewImage = options => {
|
|
|
23815
23861
|
[`size--${vSize}`]: vSize,
|
|
23816
23862
|
'is--circle': circle
|
|
23817
23863
|
}],
|
|
23818
|
-
src: imgUrl,
|
|
23864
|
+
src: imgThumbnailUrl || imgUrl,
|
|
23819
23865
|
alt,
|
|
23820
23866
|
loading,
|
|
23821
23867
|
style: imgStyle,
|
|
@@ -23870,9 +23916,10 @@ const image_Image = VxeImage;
|
|
|
23870
23916
|
showDownloadButton: {
|
|
23871
23917
|
type: Boolean,
|
|
23872
23918
|
default: () => getConfig().imageGroup.showDownloadButton
|
|
23873
|
-
}
|
|
23919
|
+
},
|
|
23920
|
+
getThumbnailUrlMethod: Function
|
|
23874
23921
|
},
|
|
23875
|
-
emits: ['click'],
|
|
23922
|
+
emits: ['click', 'change', 'rotate'],
|
|
23876
23923
|
setup(props, context) {
|
|
23877
23924
|
const {
|
|
23878
23925
|
emit
|
|
@@ -23904,6 +23951,9 @@ const image_Image = VxeImage;
|
|
|
23904
23951
|
const computeImgStyleOpts = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
|
|
23905
23952
|
return Object.assign({}, getConfig().imageGroup.imageStyle, props.imageStyle);
|
|
23906
23953
|
});
|
|
23954
|
+
const computeGetThumbnailUrlMethod = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
|
|
23955
|
+
return props.getThumbnailUrlMethod || getConfig().imageGroup.getThumbnailUrlMethod;
|
|
23956
|
+
});
|
|
23907
23957
|
const computeMaps = {
|
|
23908
23958
|
computeSize
|
|
23909
23959
|
};
|
|
@@ -23938,10 +23988,18 @@ const image_Image = VxeImage;
|
|
|
23938
23988
|
urlList: imgList,
|
|
23939
23989
|
toolbarConfig,
|
|
23940
23990
|
showPrintButton,
|
|
23941
|
-
showDownloadButton
|
|
23991
|
+
showDownloadButton,
|
|
23992
|
+
events: {
|
|
23993
|
+
change(eventParams) {
|
|
23994
|
+
$xeImageGroup.dispatchEvent('click', eventParams, eventParams.$event);
|
|
23995
|
+
},
|
|
23996
|
+
rotate(eventParams) {
|
|
23997
|
+
$xeImageGroup.dispatchEvent('click', eventParams, eventParams.$event);
|
|
23998
|
+
}
|
|
23999
|
+
}
|
|
23942
24000
|
});
|
|
23943
24001
|
}
|
|
23944
|
-
|
|
24002
|
+
$xeImageGroup.dispatchEvent('click', {
|
|
23945
24003
|
url,
|
|
23946
24004
|
urlList: imgList
|
|
23947
24005
|
}, evnt);
|
|
@@ -23952,6 +24010,7 @@ const image_Image = VxeImage;
|
|
|
23952
24010
|
const imgList = computeImgList.value;
|
|
23953
24011
|
const vSize = computeSize.value;
|
|
23954
24012
|
const imgStyleOpts = computeImgStyleOpts.value;
|
|
24013
|
+
const getThumbnailUrlMethod = computeGetThumbnailUrlMethod.value;
|
|
23955
24014
|
return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
|
|
23956
24015
|
class: ['vxe-image-group', {
|
|
23957
24016
|
[`size--${vSize}`]: vSize
|
|
@@ -23962,7 +24021,8 @@ const image_Image = VxeImage;
|
|
|
23962
24021
|
src: item.url,
|
|
23963
24022
|
alt: item.alt,
|
|
23964
24023
|
width: imgStyleOpts.width,
|
|
23965
|
-
height: imgStyleOpts.height
|
|
24024
|
+
height: imgStyleOpts.height,
|
|
24025
|
+
getThumbnailUrlMethod
|
|
23966
24026
|
});
|
|
23967
24027
|
}) : []);
|
|
23968
24028
|
};
|