icve-urc 1.0.0 → 1.1.0

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.
@@ -103501,6 +103501,13 @@ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADg
103501
103501
  module.exports = true;
103502
103502
 
103503
103503
 
103504
+ /***/ }),
103505
+
103506
+ /***/ "b948":
103507
+ /***/ (function(module, exports, __webpack_require__) {
103508
+
103509
+ module.exports = __webpack_require__.p + "img/error.00e84664.png";
103510
+
103504
103511
  /***/ }),
103505
103512
 
103506
103513
  /***/ "bc3a":
@@ -110874,6 +110881,13 @@ module.exports = { "default": __webpack_require__("f921"), __esModule: true };
110874
110881
 
110875
110882
  /***/ }),
110876
110883
 
110884
+ /***/ "f8b2":
110885
+ /***/ (function(module, exports, __webpack_require__) {
110886
+
110887
+ module.exports = __webpack_require__.p + "img/loading.cf538c14.gif";
110888
+
110889
+ /***/ }),
110890
+
110877
110891
  /***/ "f921":
110878
110892
  /***/ (function(module, exports, __webpack_require__) {
110879
110893
 
@@ -114074,26 +114088,1839 @@ var fileUpload_component = normalizeComponent(
114074
114088
  )
114075
114089
 
114076
114090
  /* harmony default export */ var components_fileUpload = (fileUpload_component.exports);
114077
- // CONCATENATED MODULE: ./index.js
114078
-
114079
-
114080
-
114081
- // 导出组件
114082
-
114083
-
114084
- // 添加 install 方法以支持 Vue.use()
114085
- /* harmony default export */ var index = ({
114086
- install(Vue) {
114087
- Vue.component('FileImport', fileImport)
114088
- Vue.component('FilePreview', components_filePreview)
114089
- Vue.component('FileUpload', components_fileUpload)
114091
+ // CONCATENATED MODULE: ./node_modules/vue-lazyload/vue-lazyload.esm.js
114092
+ /*!
114093
+ * Vue-Lazyload.js v1.3.3
114094
+ * (c) 2019 Awe <hilongjw@gmail.com>
114095
+ * Released under the MIT License.
114096
+ */
114097
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
114098
+ return typeof obj;
114099
+ } : function (obj) {
114100
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
114101
+ };
114102
+
114103
+
114104
+
114105
+
114106
+
114107
+
114108
+
114109
+
114110
+
114111
+
114112
+
114113
+ var classCallCheck = function (instance, Constructor) {
114114
+ if (!(instance instanceof Constructor)) {
114115
+ throw new TypeError("Cannot call a class as a function");
114116
+ }
114117
+ };
114118
+
114119
+ var createClass = function () {
114120
+ function defineProperties(target, props) {
114121
+ for (var i = 0; i < props.length; i++) {
114122
+ var descriptor = props[i];
114123
+ descriptor.enumerable = descriptor.enumerable || false;
114124
+ descriptor.configurable = true;
114125
+ if ("value" in descriptor) descriptor.writable = true;
114126
+ Object.defineProperty(target, descriptor.key, descriptor);
114127
+ }
114128
+ }
114129
+
114130
+ return function (Constructor, protoProps, staticProps) {
114131
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
114132
+ if (staticProps) defineProperties(Constructor, staticProps);
114133
+ return Constructor;
114134
+ };
114135
+ }();
114136
+
114137
+ /*!
114138
+ * is-primitive <https://github.com/jonschlinkert/is-primitive>
114139
+ *
114140
+ * Copyright (c) 2014-2015, Jon Schlinkert.
114141
+ * Licensed under the MIT License.
114142
+ */
114143
+
114144
+ // see http://jsperf.com/testing-value-is-primitive/7
114145
+
114146
+ var isPrimitive = function isPrimitive(value) {
114147
+ return value == null || typeof value !== 'function' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object';
114148
+ };
114149
+
114150
+ /*!
114151
+ * assign-symbols <https://github.com/jonschlinkert/assign-symbols>
114152
+ *
114153
+ * Copyright (c) 2015, Jon Schlinkert.
114154
+ * Licensed under the MIT License.
114155
+ */
114156
+
114157
+ var assignSymbols = function assignSymbols(receiver, objects) {
114158
+ if (receiver === null || typeof receiver === 'undefined') {
114159
+ throw new TypeError('expected first argument to be an object.');
114160
+ }
114161
+
114162
+ if (typeof objects === 'undefined' || typeof Symbol === 'undefined') {
114163
+ return receiver;
114164
+ }
114165
+
114166
+ if (typeof Object.getOwnPropertySymbols !== 'function') {
114167
+ return receiver;
114168
+ }
114169
+
114170
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
114171
+ var target = Object(receiver);
114172
+ var len = arguments.length,
114173
+ i = 0;
114174
+
114175
+ while (++i < len) {
114176
+ var provider = Object(arguments[i]);
114177
+ var names = Object.getOwnPropertySymbols(provider);
114178
+
114179
+ for (var j = 0; j < names.length; j++) {
114180
+ var key = names[j];
114181
+
114182
+ if (isEnumerable.call(provider, key)) {
114183
+ target[key] = provider[key];
114184
+ }
114185
+ }
114186
+ }
114187
+ return target;
114188
+ };
114189
+
114190
+ var vue_lazyload_esm_toString = Object.prototype.toString;
114191
+
114192
+ /**
114193
+ * Get the native `typeof` a value.
114194
+ *
114195
+ * @param {*} `val`
114196
+ * @return {*} Native javascript type
114197
+ */
114198
+
114199
+ var kindOf = function kindOf(val) {
114200
+ var type = typeof val === 'undefined' ? 'undefined' : _typeof(val);
114201
+
114202
+ // primitivies
114203
+ if (type === 'undefined') {
114204
+ return 'undefined';
114205
+ }
114206
+ if (val === null) {
114207
+ return 'null';
114208
+ }
114209
+ if (val === true || val === false || val instanceof Boolean) {
114210
+ return 'boolean';
114211
+ }
114212
+ if (type === 'string' || val instanceof String) {
114213
+ return 'string';
114214
+ }
114215
+ if (type === 'number' || val instanceof Number) {
114216
+ return 'number';
114217
+ }
114218
+
114219
+ // functions
114220
+ if (type === 'function' || val instanceof Function) {
114221
+ if (typeof val.constructor.name !== 'undefined' && val.constructor.name.slice(0, 9) === 'Generator') {
114222
+ return 'generatorfunction';
114223
+ }
114224
+ return 'function';
114225
+ }
114226
+
114227
+ // array
114228
+ if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
114229
+ return 'array';
114230
+ }
114231
+
114232
+ // check for instances of RegExp and Date before calling `toString`
114233
+ if (val instanceof RegExp) {
114234
+ return 'regexp';
114235
+ }
114236
+ if (val instanceof Date) {
114237
+ return 'date';
114238
+ }
114239
+
114240
+ // other objects
114241
+ type = vue_lazyload_esm_toString.call(val);
114242
+
114243
+ if (type === '[object RegExp]') {
114244
+ return 'regexp';
114245
+ }
114246
+ if (type === '[object Date]') {
114247
+ return 'date';
114248
+ }
114249
+ if (type === '[object Arguments]') {
114250
+ return 'arguments';
114251
+ }
114252
+ if (type === '[object Error]') {
114253
+ return 'error';
114254
+ }
114255
+ if (type === '[object Promise]') {
114256
+ return 'promise';
114257
+ }
114258
+
114259
+ // buffer
114260
+ if (isBuffer(val)) {
114261
+ return 'buffer';
114262
+ }
114263
+
114264
+ // es6: Map, WeakMap, Set, WeakSet
114265
+ if (type === '[object Set]') {
114266
+ return 'set';
114267
+ }
114268
+ if (type === '[object WeakSet]') {
114269
+ return 'weakset';
114270
+ }
114271
+ if (type === '[object Map]') {
114272
+ return 'map';
114273
+ }
114274
+ if (type === '[object WeakMap]') {
114275
+ return 'weakmap';
114276
+ }
114277
+ if (type === '[object Symbol]') {
114278
+ return 'symbol';
114279
+ }
114280
+
114281
+ if (type === '[object Map Iterator]') {
114282
+ return 'mapiterator';
114283
+ }
114284
+ if (type === '[object Set Iterator]') {
114285
+ return 'setiterator';
114286
+ }
114287
+ if (type === '[object String Iterator]') {
114288
+ return 'stringiterator';
114289
+ }
114290
+ if (type === '[object Array Iterator]') {
114291
+ return 'arrayiterator';
114292
+ }
114293
+
114294
+ // typed arrays
114295
+ if (type === '[object Int8Array]') {
114296
+ return 'int8array';
114297
+ }
114298
+ if (type === '[object Uint8Array]') {
114299
+ return 'uint8array';
114300
+ }
114301
+ if (type === '[object Uint8ClampedArray]') {
114302
+ return 'uint8clampedarray';
114303
+ }
114304
+ if (type === '[object Int16Array]') {
114305
+ return 'int16array';
114306
+ }
114307
+ if (type === '[object Uint16Array]') {
114308
+ return 'uint16array';
114309
+ }
114310
+ if (type === '[object Int32Array]') {
114311
+ return 'int32array';
114312
+ }
114313
+ if (type === '[object Uint32Array]') {
114314
+ return 'uint32array';
114315
+ }
114316
+ if (type === '[object Float32Array]') {
114317
+ return 'float32array';
114318
+ }
114319
+ if (type === '[object Float64Array]') {
114320
+ return 'float64array';
114321
+ }
114322
+
114323
+ // must be a plain object
114324
+ return 'object';
114325
+ };
114326
+
114327
+ /**
114328
+ * If you need to support Safari 5-7 (8-10 yr-old browser),
114329
+ * take a look at https://github.com/feross/is-buffer
114330
+ */
114331
+
114332
+ function isBuffer(val) {
114333
+ return val.constructor && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
114334
+ }
114335
+
114336
+ function vue_lazyload_esm_assign(target /*, objects*/) {
114337
+ target = target || {};
114338
+ var len = arguments.length,
114339
+ i = 0;
114340
+ if (len === 1) {
114341
+ return target;
114342
+ }
114343
+ while (++i < len) {
114344
+ var val = arguments[i];
114345
+ if (isPrimitive(target)) {
114346
+ target = val;
114347
+ }
114348
+ if (isObject$1(val)) {
114349
+ vue_lazyload_esm_extend(target, val);
114350
+ }
114351
+ }
114352
+ return target;
114353
+ }
114354
+
114355
+ /**
114356
+ * Shallow extend
114357
+ */
114358
+
114359
+ function vue_lazyload_esm_extend(target, obj) {
114360
+ assignSymbols(target, obj);
114361
+
114362
+ for (var key in obj) {
114363
+ if (key !== '__proto__' && vue_lazyload_esm_hasOwn(obj, key)) {
114364
+ var val = obj[key];
114365
+ if (isObject$1(val)) {
114366
+ if (kindOf(target[key]) === 'undefined' && kindOf(val) === 'function') {
114367
+ target[key] = val;
114368
+ }
114369
+ target[key] = vue_lazyload_esm_assign(target[key] || {}, val);
114370
+ } else {
114371
+ target[key] = val;
114372
+ }
114373
+ }
114374
+ }
114375
+ return target;
114376
+ }
114377
+
114378
+ /**
114379
+ * Returns true if the object is a plain object or a function.
114380
+ */
114381
+
114382
+ function isObject$1(obj) {
114383
+ return kindOf(obj) === 'object' || kindOf(obj) === 'function';
114384
+ }
114385
+
114386
+ /**
114387
+ * Returns true if the given `key` is an own property of `obj`.
114388
+ */
114389
+
114390
+ function vue_lazyload_esm_hasOwn(obj, key) {
114391
+ return Object.prototype.hasOwnProperty.call(obj, key);
114392
+ }
114393
+
114394
+ /**
114395
+ * Expose `assign`
114396
+ */
114397
+
114398
+ var assignDeep = vue_lazyload_esm_assign;
114399
+
114400
+ var inBrowser = typeof window !== 'undefined';
114401
+ var hasIntersectionObserver = checkIntersectionObserver();
114402
+
114403
+ function checkIntersectionObserver() {
114404
+ if (inBrowser && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
114405
+ // Minimal polyfill for Edge 15's lack of `isIntersecting`
114406
+ // See: https://github.com/w3c/IntersectionObserver/issues/211
114407
+ if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
114408
+ Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
114409
+ get: function get$$1() {
114410
+ return this.intersectionRatio > 0;
114411
+ }
114412
+ });
114413
+ }
114414
+ return true;
114415
+ }
114416
+ return false;
114417
+ }
114418
+
114419
+ var modeType = {
114420
+ event: 'event',
114421
+ observer: 'observer'
114422
+
114423
+ // CustomEvent polyfill
114424
+ };var CustomEvent = function () {
114425
+ if (!inBrowser) return;
114426
+ if (typeof window.CustomEvent === 'function') return window.CustomEvent;
114427
+ function CustomEvent(event, params) {
114428
+ params = params || { bubbles: false, cancelable: false, detail: undefined };
114429
+ var evt = document.createEvent('CustomEvent');
114430
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
114431
+ return evt;
114432
+ }
114433
+ CustomEvent.prototype = window.Event.prototype;
114434
+ return CustomEvent;
114435
+ }();
114436
+
114437
+ function remove(arr, item) {
114438
+ if (!arr.length) return;
114439
+ var index = arr.indexOf(item);
114440
+ if (index > -1) return arr.splice(index, 1);
114441
+ }
114442
+
114443
+ function some(arr, fn) {
114444
+ var has = false;
114445
+ for (var i = 0, len = arr.length; i < len; i++) {
114446
+ if (fn(arr[i])) {
114447
+ has = true;
114448
+ break;
114449
+ }
114450
+ }
114451
+ return has;
114452
+ }
114453
+
114454
+ function getBestSelectionFromSrcset(el, scale) {
114455
+ if (el.tagName !== 'IMG' || !el.getAttribute('data-srcset')) return;
114456
+
114457
+ var options = el.getAttribute('data-srcset');
114458
+ var result = [];
114459
+ var container = el.parentNode;
114460
+ var containerWidth = container.offsetWidth * scale;
114461
+
114462
+ var spaceIndex = void 0;
114463
+ var tmpSrc = void 0;
114464
+ var tmpWidth = void 0;
114465
+
114466
+ options = options.trim().split(',');
114467
+
114468
+ options.map(function (item) {
114469
+ item = item.trim();
114470
+ spaceIndex = item.lastIndexOf(' ');
114471
+ if (spaceIndex === -1) {
114472
+ tmpSrc = item;
114473
+ tmpWidth = 999998;
114474
+ } else {
114475
+ tmpSrc = item.substr(0, spaceIndex);
114476
+ tmpWidth = parseInt(item.substr(spaceIndex + 1, item.length - spaceIndex - 2), 10);
114477
+ }
114478
+ result.push([tmpWidth, tmpSrc]);
114479
+ });
114480
+
114481
+ result.sort(function (a, b) {
114482
+ if (a[0] < b[0]) {
114483
+ return 1;
114484
+ }
114485
+ if (a[0] > b[0]) {
114486
+ return -1;
114487
+ }
114488
+ if (a[0] === b[0]) {
114489
+ if (b[1].indexOf('.webp', b[1].length - 5) !== -1) {
114490
+ return 1;
114491
+ }
114492
+ if (a[1].indexOf('.webp', a[1].length - 5) !== -1) {
114493
+ return -1;
114494
+ }
114495
+ }
114496
+ return 0;
114497
+ });
114498
+ var bestSelectedSrc = '';
114499
+ var tmpOption = void 0;
114500
+
114501
+ for (var i = 0; i < result.length; i++) {
114502
+ tmpOption = result[i];
114503
+ bestSelectedSrc = tmpOption[1];
114504
+ var next = result[i + 1];
114505
+ if (next && next[0] < containerWidth) {
114506
+ bestSelectedSrc = tmpOption[1];
114507
+ break;
114508
+ } else if (!next) {
114509
+ bestSelectedSrc = tmpOption[1];
114510
+ break;
114511
+ }
114512
+ }
114513
+
114514
+ return bestSelectedSrc;
114515
+ }
114516
+
114517
+ function find(arr, fn) {
114518
+ var item = void 0;
114519
+ for (var i = 0, len = arr.length; i < len; i++) {
114520
+ if (fn(arr[i])) {
114521
+ item = arr[i];
114522
+ break;
114523
+ }
114524
+ }
114525
+ return item;
114526
+ }
114527
+
114528
+ var getDPR = function getDPR() {
114529
+ var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
114530
+ return inBrowser ? window.devicePixelRatio || scale : scale;
114531
+ };
114532
+
114533
+ function supportWebp() {
114534
+ if (!inBrowser) return false;
114535
+
114536
+ var support = true;
114537
+ var d = document;
114538
+
114539
+ try {
114540
+ var el = d.createElement('object');
114541
+ el.type = 'image/webp';
114542
+ el.style.visibility = 'hidden';
114543
+ el.innerHTML = '!';
114544
+ d.body.appendChild(el);
114545
+ support = !el.offsetWidth;
114546
+ d.body.removeChild(el);
114547
+ } catch (err) {
114548
+ support = false;
114549
+ }
114550
+
114551
+ return support;
114552
+ }
114553
+
114554
+ function throttle(action, delay) {
114555
+ var timeout = null;
114556
+ var lastRun = 0;
114557
+ return function () {
114558
+ if (timeout) {
114559
+ return;
114560
+ }
114561
+ var elapsed = Date.now() - lastRun;
114562
+ var context = this;
114563
+ var args = arguments;
114564
+ var runCallback = function runCallback() {
114565
+ lastRun = Date.now();
114566
+ timeout = false;
114567
+ action.apply(context, args);
114568
+ };
114569
+ if (elapsed >= delay) {
114570
+ runCallback();
114571
+ } else {
114572
+ timeout = setTimeout(runCallback, delay);
114573
+ }
114574
+ };
114575
+ }
114576
+
114577
+ function testSupportsPassive() {
114578
+ if (!inBrowser) return;
114579
+ var support = false;
114580
+ try {
114581
+ var opts = Object.defineProperty({}, 'passive', {
114582
+ get: function get$$1() {
114583
+ support = true;
114584
+ }
114585
+ });
114586
+ window.addEventListener('test', null, opts);
114587
+ } catch (e) {}
114588
+ return support;
114589
+ }
114590
+
114591
+ var supportsPassive = testSupportsPassive();
114592
+
114593
+ var _ = {
114594
+ on: function on(el, type, func) {
114595
+ var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
114596
+
114597
+ if (supportsPassive) {
114598
+ el.addEventListener(type, func, {
114599
+ capture: capture,
114600
+ passive: true
114601
+ });
114602
+ } else {
114603
+ el.addEventListener(type, func, capture);
114604
+ }
114605
+ },
114606
+ off: function off(el, type, func) {
114607
+ var capture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
114608
+
114609
+ el.removeEventListener(type, func, capture);
114610
+ }
114611
+ };
114612
+
114613
+ var loadImageAsync = function loadImageAsync(item, resolve, reject) {
114614
+ var image = new Image();
114615
+ if (!item || !item.src) {
114616
+ var err = new Error('image src is required');
114617
+ return reject(err);
114618
+ }
114619
+
114620
+ image.src = item.src;
114621
+
114622
+ image.onload = function () {
114623
+ resolve({
114624
+ naturalHeight: image.naturalHeight,
114625
+ naturalWidth: image.naturalWidth,
114626
+ src: image.src
114627
+ });
114628
+ };
114629
+
114630
+ image.onerror = function (e) {
114631
+ reject(e);
114632
+ };
114633
+ };
114634
+
114635
+ var style = function style(el, prop) {
114636
+ return typeof getComputedStyle !== 'undefined' ? getComputedStyle(el, null).getPropertyValue(prop) : el.style[prop];
114637
+ };
114638
+
114639
+ var overflow = function overflow(el) {
114640
+ return style(el, 'overflow') + style(el, 'overflow-y') + style(el, 'overflow-x');
114641
+ };
114642
+
114643
+ var scrollParent = function scrollParent(el) {
114644
+ if (!inBrowser) return;
114645
+ if (!(el instanceof HTMLElement)) {
114646
+ return window;
114647
+ }
114648
+
114649
+ var parent = el;
114650
+
114651
+ while (parent) {
114652
+ if (parent === document.body || parent === document.documentElement) {
114653
+ break;
114654
+ }
114655
+
114656
+ if (!parent.parentNode) {
114657
+ break;
114658
+ }
114659
+
114660
+ if (/(scroll|auto)/.test(overflow(parent))) {
114661
+ return parent;
114662
+ }
114663
+
114664
+ parent = parent.parentNode;
114665
+ }
114666
+
114667
+ return window;
114668
+ };
114669
+
114670
+ function vue_lazyload_esm_isObject(obj) {
114671
+ return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
114672
+ }
114673
+
114674
+ function ObjectKeys(obj) {
114675
+ if (!(obj instanceof Object)) return [];
114676
+ if (Object.keys) {
114677
+ return Object.keys(obj);
114678
+ } else {
114679
+ var keys = [];
114680
+ for (var key in obj) {
114681
+ if (obj.hasOwnProperty(key)) {
114682
+ keys.push(key);
114683
+ }
114684
+ }
114685
+ return keys;
114686
+ }
114687
+ }
114688
+
114689
+ function ArrayFrom(arrLike) {
114690
+ var len = arrLike.length;
114691
+ var list = [];
114692
+ for (var i = 0; i < len; i++) {
114693
+ list.push(arrLike[i]);
114694
+ }
114695
+ return list;
114696
+ }
114697
+
114698
+ function vue_lazyload_esm_noop() {}
114699
+
114700
+ var ImageCache = function () {
114701
+ function ImageCache(_ref) {
114702
+ var max = _ref.max;
114703
+ classCallCheck(this, ImageCache);
114704
+
114705
+ this.options = {
114706
+ max: max || 100
114707
+ };
114708
+ this._caches = [];
114709
+ }
114710
+
114711
+ createClass(ImageCache, [{
114712
+ key: 'has',
114713
+ value: function has(key) {
114714
+ return this._caches.indexOf(key) > -1;
114715
+ }
114716
+ }, {
114717
+ key: 'add',
114718
+ value: function add(key) {
114719
+ if (this.has(key)) return;
114720
+ this._caches.push(key);
114721
+ if (this._caches.length > this.options.max) {
114722
+ this.free();
114723
+ }
114724
+ }
114725
+ }, {
114726
+ key: 'free',
114727
+ value: function free() {
114728
+ this._caches.shift();
114729
+ }
114730
+ }]);
114731
+ return ImageCache;
114732
+ }();
114733
+
114734
+ // el: {
114735
+ // state,
114736
+ // src,
114737
+ // error,
114738
+ // loading
114739
+ // }
114740
+
114741
+ var ReactiveListener = function () {
114742
+ function ReactiveListener(_ref) {
114743
+ var el = _ref.el,
114744
+ src = _ref.src,
114745
+ error = _ref.error,
114746
+ loading = _ref.loading,
114747
+ bindType = _ref.bindType,
114748
+ $parent = _ref.$parent,
114749
+ options = _ref.options,
114750
+ elRenderer = _ref.elRenderer,
114751
+ imageCache = _ref.imageCache;
114752
+ classCallCheck(this, ReactiveListener);
114753
+
114754
+ this.el = el;
114755
+ this.src = src;
114756
+ this.error = error;
114757
+ this.loading = loading;
114758
+ this.bindType = bindType;
114759
+ this.attempt = 0;
114760
+
114761
+ this.naturalHeight = 0;
114762
+ this.naturalWidth = 0;
114763
+
114764
+ this.options = options;
114765
+
114766
+ this.rect = null;
114767
+
114768
+ this.$parent = $parent;
114769
+ this.elRenderer = elRenderer;
114770
+ this._imageCache = imageCache;
114771
+ this.performanceData = {
114772
+ init: Date.now(),
114773
+ loadStart: 0,
114774
+ loadEnd: 0
114775
+ };
114776
+
114777
+ this.filter();
114778
+ this.initState();
114779
+ this.render('loading', false);
114780
+ }
114781
+
114782
+ /*
114783
+ * init listener state
114784
+ * @return
114785
+ */
114786
+
114787
+
114788
+ createClass(ReactiveListener, [{
114789
+ key: 'initState',
114790
+ value: function initState() {
114791
+ if ('dataset' in this.el) {
114792
+ this.el.dataset.src = this.src;
114793
+ } else {
114794
+ this.el.setAttribute('data-src', this.src);
114795
+ }
114796
+
114797
+ this.state = {
114798
+ loading: false,
114799
+ error: false,
114800
+ loaded: false,
114801
+ rendered: false
114802
+ };
114803
+ }
114804
+
114805
+ /*
114806
+ * record performance
114807
+ * @return
114808
+ */
114809
+
114810
+ }, {
114811
+ key: 'record',
114812
+ value: function record(event) {
114813
+ this.performanceData[event] = Date.now();
114814
+ }
114815
+
114816
+ /*
114817
+ * update image listener data
114818
+ * @param {String} image uri
114819
+ * @param {String} loading image uri
114820
+ * @param {String} error image uri
114821
+ * @return
114822
+ */
114823
+
114824
+ }, {
114825
+ key: 'update',
114826
+ value: function update(_ref2) {
114827
+ var src = _ref2.src,
114828
+ loading = _ref2.loading,
114829
+ error = _ref2.error;
114830
+
114831
+ var oldSrc = this.src;
114832
+ this.src = src;
114833
+ this.loading = loading;
114834
+ this.error = error;
114835
+ this.filter();
114836
+ if (oldSrc !== this.src) {
114837
+ this.attempt = 0;
114838
+ this.initState();
114839
+ }
114840
+ }
114841
+
114842
+ /*
114843
+ * get el node rect
114844
+ * @return
114845
+ */
114846
+
114847
+ }, {
114848
+ key: 'getRect',
114849
+ value: function getRect() {
114850
+ this.rect = this.el.getBoundingClientRect();
114851
+ }
114852
+
114853
+ /*
114854
+ * check el is in view
114855
+ * @return {Boolean} el is in view
114856
+ */
114857
+
114858
+ }, {
114859
+ key: 'checkInView',
114860
+ value: function checkInView() {
114861
+ this.getRect();
114862
+ return this.rect.top < window.innerHeight * this.options.preLoad && this.rect.bottom > this.options.preLoadTop && this.rect.left < window.innerWidth * this.options.preLoad && this.rect.right > 0;
114863
+ }
114864
+
114865
+ /*
114866
+ * listener filter
114867
+ */
114868
+
114869
+ }, {
114870
+ key: 'filter',
114871
+ value: function filter() {
114872
+ var _this = this;
114873
+
114874
+ ObjectKeys(this.options.filter).map(function (key) {
114875
+ _this.options.filter[key](_this, _this.options);
114876
+ });
114877
+ }
114878
+
114879
+ /*
114880
+ * render loading first
114881
+ * @params cb:Function
114882
+ * @return
114883
+ */
114884
+
114885
+ }, {
114886
+ key: 'renderLoading',
114887
+ value: function renderLoading(cb) {
114888
+ var _this2 = this;
114889
+
114890
+ this.state.loading = true;
114891
+ loadImageAsync({
114892
+ src: this.loading
114893
+ }, function (data) {
114894
+ _this2.render('loading', false);
114895
+ _this2.state.loading = false;
114896
+ cb();
114897
+ }, function () {
114898
+ // handler `loading image` load failed
114899
+ cb();
114900
+ _this2.state.loading = false;
114901
+ if (!_this2.options.silent) console.warn('VueLazyload log: load failed with loading image(' + _this2.loading + ')');
114902
+ });
114903
+ }
114904
+
114905
+ /*
114906
+ * try load image and render it
114907
+ * @return
114908
+ */
114909
+
114910
+ }, {
114911
+ key: 'load',
114912
+ value: function load() {
114913
+ var _this3 = this;
114914
+
114915
+ var onFinish = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : vue_lazyload_esm_noop;
114916
+
114917
+ if (this.attempt > this.options.attempt - 1 && this.state.error) {
114918
+ if (!this.options.silent) console.log('VueLazyload log: ' + this.src + ' tried too more than ' + this.options.attempt + ' times');
114919
+ onFinish();
114920
+ return;
114921
+ }
114922
+ if (this.state.rendered && this.state.loaded) return;
114923
+ if (this._imageCache.has(this.src)) {
114924
+ this.state.loaded = true;
114925
+ this.render('loaded', true);
114926
+ this.state.rendered = true;
114927
+ return onFinish();
114928
+ }
114929
+
114930
+ this.renderLoading(function () {
114931
+ _this3.attempt++;
114932
+
114933
+ _this3.options.adapter['beforeLoad'] && _this3.options.adapter['beforeLoad'](_this3, _this3.options);
114934
+ _this3.record('loadStart');
114935
+
114936
+ loadImageAsync({
114937
+ src: _this3.src
114938
+ }, function (data) {
114939
+ _this3.naturalHeight = data.naturalHeight;
114940
+ _this3.naturalWidth = data.naturalWidth;
114941
+ _this3.state.loaded = true;
114942
+ _this3.state.error = false;
114943
+ _this3.record('loadEnd');
114944
+ _this3.render('loaded', false);
114945
+ _this3.state.rendered = true;
114946
+ _this3._imageCache.add(_this3.src);
114947
+ onFinish();
114948
+ }, function (err) {
114949
+ !_this3.options.silent && console.error(err);
114950
+ _this3.state.error = true;
114951
+ _this3.state.loaded = false;
114952
+ _this3.render('error', false);
114953
+ });
114954
+ });
114955
+ }
114956
+
114957
+ /*
114958
+ * render image
114959
+ * @param {String} state to render // ['loading', 'src', 'error']
114960
+ * @param {String} is form cache
114961
+ * @return
114962
+ */
114963
+
114964
+ }, {
114965
+ key: 'render',
114966
+ value: function render(state, cache) {
114967
+ this.elRenderer(this, state, cache);
114968
+ }
114969
+
114970
+ /*
114971
+ * output performance data
114972
+ * @return {Object} performance data
114973
+ */
114974
+
114975
+ }, {
114976
+ key: 'performance',
114977
+ value: function performance() {
114978
+ var state = 'loading';
114979
+ var time = 0;
114980
+
114981
+ if (this.state.loaded) {
114982
+ state = 'loaded';
114983
+ time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1000;
114984
+ }
114985
+
114986
+ if (this.state.error) state = 'error';
114987
+
114988
+ return {
114989
+ src: this.src,
114990
+ state: state,
114991
+ time: time
114992
+ };
114993
+ }
114994
+
114995
+ /*
114996
+ * $destroy
114997
+ * @return
114998
+ */
114999
+
115000
+ }, {
115001
+ key: '$destroy',
115002
+ value: function $destroy() {
115003
+ this.el = null;
115004
+ this.src = null;
115005
+ this.error = null;
115006
+ this.loading = null;
115007
+ this.bindType = null;
115008
+ this.attempt = 0;
115009
+ }
115010
+ }]);
115011
+ return ReactiveListener;
115012
+ }();
115013
+
115014
+ var DEFAULT_URL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
115015
+ var DEFAULT_EVENTS = ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove'];
115016
+ var DEFAULT_OBSERVER_OPTIONS = {
115017
+ rootMargin: '0px',
115018
+ threshold: 0
115019
+ };
115020
+
115021
+ var Lazy = function (Vue) {
115022
+ return function () {
115023
+ function Lazy(_ref) {
115024
+ var preLoad = _ref.preLoad,
115025
+ error = _ref.error,
115026
+ throttleWait = _ref.throttleWait,
115027
+ preLoadTop = _ref.preLoadTop,
115028
+ dispatchEvent = _ref.dispatchEvent,
115029
+ loading = _ref.loading,
115030
+ attempt = _ref.attempt,
115031
+ _ref$silent = _ref.silent,
115032
+ silent = _ref$silent === undefined ? true : _ref$silent,
115033
+ scale = _ref.scale,
115034
+ listenEvents = _ref.listenEvents,
115035
+ hasbind = _ref.hasbind,
115036
+ filter = _ref.filter,
115037
+ adapter = _ref.adapter,
115038
+ observer = _ref.observer,
115039
+ observerOptions = _ref.observerOptions;
115040
+ classCallCheck(this, Lazy);
115041
+
115042
+ this.version = '1.3.3';
115043
+ this.mode = modeType.event;
115044
+ this.ListenerQueue = [];
115045
+ this.TargetIndex = 0;
115046
+ this.TargetQueue = [];
115047
+ this.options = {
115048
+ silent: silent,
115049
+ dispatchEvent: !!dispatchEvent,
115050
+ throttleWait: throttleWait || 200,
115051
+ preLoad: preLoad || 1.3,
115052
+ preLoadTop: preLoadTop || 0,
115053
+ error: error || DEFAULT_URL,
115054
+ loading: loading || DEFAULT_URL,
115055
+ attempt: attempt || 3,
115056
+ scale: scale || getDPR(scale),
115057
+ ListenEvents: listenEvents || DEFAULT_EVENTS,
115058
+ hasbind: false,
115059
+ supportWebp: supportWebp(),
115060
+ filter: filter || {},
115061
+ adapter: adapter || {},
115062
+ observer: !!observer,
115063
+ observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
115064
+ };
115065
+ this._initEvent();
115066
+ this._imageCache = new ImageCache({ max: 200 });
115067
+ this.lazyLoadHandler = throttle(this._lazyLoadHandler.bind(this), this.options.throttleWait);
115068
+
115069
+ this.setMode(this.options.observer ? modeType.observer : modeType.event);
115070
+ }
115071
+
115072
+ /**
115073
+ * update config
115074
+ * @param {Object} config params
115075
+ * @return
115076
+ */
115077
+
115078
+
115079
+ createClass(Lazy, [{
115080
+ key: 'config',
115081
+ value: function config() {
115082
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
115083
+
115084
+ assignDeep(this.options, options);
115085
+ }
115086
+
115087
+ /**
115088
+ * output listener's load performance
115089
+ * @return {Array}
115090
+ */
115091
+
115092
+ }, {
115093
+ key: 'performance',
115094
+ value: function performance() {
115095
+ var list = [];
115096
+
115097
+ this.ListenerQueue.map(function (item) {
115098
+ list.push(item.performance());
115099
+ });
115100
+
115101
+ return list;
115102
+ }
115103
+
115104
+ /*
115105
+ * add lazy component to queue
115106
+ * @param {Vue} vm lazy component instance
115107
+ * @return
115108
+ */
115109
+
115110
+ }, {
115111
+ key: 'addLazyBox',
115112
+ value: function addLazyBox(vm) {
115113
+ this.ListenerQueue.push(vm);
115114
+ if (inBrowser) {
115115
+ this._addListenerTarget(window);
115116
+ this._observer && this._observer.observe(vm.el);
115117
+ if (vm.$el && vm.$el.parentNode) {
115118
+ this._addListenerTarget(vm.$el.parentNode);
115119
+ }
115120
+ }
115121
+ }
115122
+
115123
+ /*
115124
+ * add image listener to queue
115125
+ * @param {DOM} el
115126
+ * @param {object} binding vue directive binding
115127
+ * @param {vnode} vnode vue directive vnode
115128
+ * @return
115129
+ */
115130
+
115131
+ }, {
115132
+ key: 'add',
115133
+ value: function add(el, binding, vnode) {
115134
+ var _this = this;
115135
+
115136
+ if (some(this.ListenerQueue, function (item) {
115137
+ return item.el === el;
115138
+ })) {
115139
+ this.update(el, binding);
115140
+ return Vue.nextTick(this.lazyLoadHandler);
115141
+ }
115142
+
115143
+ var _valueFormatter2 = this._valueFormatter(binding.value),
115144
+ src = _valueFormatter2.src,
115145
+ loading = _valueFormatter2.loading,
115146
+ error = _valueFormatter2.error;
115147
+
115148
+ Vue.nextTick(function () {
115149
+ src = getBestSelectionFromSrcset(el, _this.options.scale) || src;
115150
+ _this._observer && _this._observer.observe(el);
115151
+
115152
+ var container = Object.keys(binding.modifiers)[0];
115153
+ var $parent = void 0;
115154
+
115155
+ if (container) {
115156
+ $parent = vnode.context.$refs[container];
115157
+ // if there is container passed in, try ref first, then fallback to getElementById to support the original usage
115158
+ $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
115159
+ }
115160
+
115161
+ if (!$parent) {
115162
+ $parent = scrollParent(el);
115163
+ }
115164
+
115165
+ var newListener = new ReactiveListener({
115166
+ bindType: binding.arg,
115167
+ $parent: $parent,
115168
+ el: el,
115169
+ loading: loading,
115170
+ error: error,
115171
+ src: src,
115172
+ elRenderer: _this._elRenderer.bind(_this),
115173
+ options: _this.options,
115174
+ imageCache: _this._imageCache
115175
+ });
115176
+
115177
+ _this.ListenerQueue.push(newListener);
115178
+
115179
+ if (inBrowser) {
115180
+ _this._addListenerTarget(window);
115181
+ _this._addListenerTarget($parent);
115182
+ }
115183
+
115184
+ _this.lazyLoadHandler();
115185
+ Vue.nextTick(function () {
115186
+ return _this.lazyLoadHandler();
115187
+ });
115188
+ });
115189
+ }
115190
+
115191
+ /**
115192
+ * update image src
115193
+ * @param {DOM} el
115194
+ * @param {object} vue directive binding
115195
+ * @return
115196
+ */
115197
+
115198
+ }, {
115199
+ key: 'update',
115200
+ value: function update(el, binding, vnode) {
115201
+ var _this2 = this;
115202
+
115203
+ var _valueFormatter3 = this._valueFormatter(binding.value),
115204
+ src = _valueFormatter3.src,
115205
+ loading = _valueFormatter3.loading,
115206
+ error = _valueFormatter3.error;
115207
+
115208
+ src = getBestSelectionFromSrcset(el, this.options.scale) || src;
115209
+
115210
+ var exist = find(this.ListenerQueue, function (item) {
115211
+ return item.el === el;
115212
+ });
115213
+ if (!exist) {
115214
+ this.add(el, binding, vnode);
115215
+ } else {
115216
+ exist.update({
115217
+ src: src,
115218
+ loading: loading,
115219
+ error: error
115220
+ });
115221
+ }
115222
+ if (this._observer) {
115223
+ this._observer.unobserve(el);
115224
+ this._observer.observe(el);
115225
+ }
115226
+ this.lazyLoadHandler();
115227
+ Vue.nextTick(function () {
115228
+ return _this2.lazyLoadHandler();
115229
+ });
115230
+ }
115231
+
115232
+ /**
115233
+ * remove listener form list
115234
+ * @param {DOM} el
115235
+ * @return
115236
+ */
115237
+
115238
+ }, {
115239
+ key: 'remove',
115240
+ value: function remove$$1(el) {
115241
+ if (!el) return;
115242
+ this._observer && this._observer.unobserve(el);
115243
+ var existItem = find(this.ListenerQueue, function (item) {
115244
+ return item.el === el;
115245
+ });
115246
+ if (existItem) {
115247
+ this._removeListenerTarget(existItem.$parent);
115248
+ this._removeListenerTarget(window);
115249
+ remove(this.ListenerQueue, existItem);
115250
+ existItem.$destroy();
115251
+ }
115252
+ }
115253
+
115254
+ /*
115255
+ * remove lazy components form list
115256
+ * @param {Vue} vm Vue instance
115257
+ * @return
115258
+ */
115259
+
115260
+ }, {
115261
+ key: 'removeComponent',
115262
+ value: function removeComponent(vm) {
115263
+ if (!vm) return;
115264
+ remove(this.ListenerQueue, vm);
115265
+ this._observer && this._observer.unobserve(vm.el);
115266
+ if (vm.$parent && vm.$el.parentNode) {
115267
+ this._removeListenerTarget(vm.$el.parentNode);
115268
+ }
115269
+ this._removeListenerTarget(window);
115270
+ }
115271
+ }, {
115272
+ key: 'setMode',
115273
+ value: function setMode(mode) {
115274
+ var _this3 = this;
115275
+
115276
+ if (!hasIntersectionObserver && mode === modeType.observer) {
115277
+ mode = modeType.event;
115278
+ }
115279
+
115280
+ this.mode = mode; // event or observer
115281
+
115282
+ if (mode === modeType.event) {
115283
+ if (this._observer) {
115284
+ this.ListenerQueue.forEach(function (listener) {
115285
+ _this3._observer.unobserve(listener.el);
115286
+ });
115287
+ this._observer = null;
115288
+ }
115289
+
115290
+ this.TargetQueue.forEach(function (target) {
115291
+ _this3._initListen(target.el, true);
115292
+ });
115293
+ } else {
115294
+ this.TargetQueue.forEach(function (target) {
115295
+ _this3._initListen(target.el, false);
115296
+ });
115297
+ this._initIntersectionObserver();
115298
+ }
115299
+ }
115300
+
115301
+ /*
115302
+ *** Private functions ***
115303
+ */
115304
+
115305
+ /*
115306
+ * add listener target
115307
+ * @param {DOM} el listener target
115308
+ * @return
115309
+ */
115310
+
115311
+ }, {
115312
+ key: '_addListenerTarget',
115313
+ value: function _addListenerTarget(el) {
115314
+ if (!el) return;
115315
+ var target = find(this.TargetQueue, function (target) {
115316
+ return target.el === el;
115317
+ });
115318
+ if (!target) {
115319
+ target = {
115320
+ el: el,
115321
+ id: ++this.TargetIndex,
115322
+ childrenCount: 1,
115323
+ listened: true
115324
+ };
115325
+ this.mode === modeType.event && this._initListen(target.el, true);
115326
+ this.TargetQueue.push(target);
115327
+ } else {
115328
+ target.childrenCount++;
115329
+ }
115330
+ return this.TargetIndex;
115331
+ }
115332
+
115333
+ /*
115334
+ * remove listener target or reduce target childrenCount
115335
+ * @param {DOM} el or window
115336
+ * @return
115337
+ */
115338
+
115339
+ }, {
115340
+ key: '_removeListenerTarget',
115341
+ value: function _removeListenerTarget(el) {
115342
+ var _this4 = this;
115343
+
115344
+ this.TargetQueue.forEach(function (target, index) {
115345
+ if (target.el === el) {
115346
+ target.childrenCount--;
115347
+ if (!target.childrenCount) {
115348
+ _this4._initListen(target.el, false);
115349
+ _this4.TargetQueue.splice(index, 1);
115350
+ target = null;
115351
+ }
115352
+ }
115353
+ });
115354
+ }
115355
+
115356
+ /*
115357
+ * add or remove eventlistener
115358
+ * @param {DOM} el DOM or Window
115359
+ * @param {boolean} start flag
115360
+ * @return
115361
+ */
115362
+
115363
+ }, {
115364
+ key: '_initListen',
115365
+ value: function _initListen(el, start) {
115366
+ var _this5 = this;
115367
+
115368
+ this.options.ListenEvents.forEach(function (evt) {
115369
+ return _[start ? 'on' : 'off'](el, evt, _this5.lazyLoadHandler);
115370
+ });
115371
+ }
115372
+ }, {
115373
+ key: '_initEvent',
115374
+ value: function _initEvent() {
115375
+ var _this6 = this;
115376
+
115377
+ this.Event = {
115378
+ listeners: {
115379
+ loading: [],
115380
+ loaded: [],
115381
+ error: []
115382
+ }
115383
+ };
115384
+
115385
+ this.$on = function (event, func) {
115386
+ if (!_this6.Event.listeners[event]) _this6.Event.listeners[event] = [];
115387
+ _this6.Event.listeners[event].push(func);
115388
+ };
115389
+
115390
+ this.$once = function (event, func) {
115391
+ var vm = _this6;
115392
+ function on() {
115393
+ vm.$off(event, on);
115394
+ func.apply(vm, arguments);
115395
+ }
115396
+ _this6.$on(event, on);
115397
+ };
115398
+
115399
+ this.$off = function (event, func) {
115400
+ if (!func) {
115401
+ if (!_this6.Event.listeners[event]) return;
115402
+ _this6.Event.listeners[event].length = 0;
115403
+ return;
115404
+ }
115405
+ remove(_this6.Event.listeners[event], func);
115406
+ };
115407
+
115408
+ this.$emit = function (event, context, inCache) {
115409
+ if (!_this6.Event.listeners[event]) return;
115410
+ _this6.Event.listeners[event].forEach(function (func) {
115411
+ return func(context, inCache);
115412
+ });
115413
+ };
115414
+ }
115415
+
115416
+ /**
115417
+ * find nodes which in viewport and trigger load
115418
+ * @return
115419
+ */
115420
+
115421
+ }, {
115422
+ key: '_lazyLoadHandler',
115423
+ value: function _lazyLoadHandler() {
115424
+ var _this7 = this;
115425
+
115426
+ var freeList = [];
115427
+ this.ListenerQueue.forEach(function (listener, index) {
115428
+ if (!listener.el || !listener.el.parentNode) {
115429
+ freeList.push(listener);
115430
+ }
115431
+ var catIn = listener.checkInView();
115432
+ if (!catIn) return;
115433
+ listener.load();
115434
+ });
115435
+ freeList.forEach(function (item) {
115436
+ remove(_this7.ListenerQueue, item);
115437
+ item.$destroy();
115438
+ });
115439
+ }
115440
+ /**
115441
+ * init IntersectionObserver
115442
+ * set mode to observer
115443
+ * @return
115444
+ */
115445
+
115446
+ }, {
115447
+ key: '_initIntersectionObserver',
115448
+ value: function _initIntersectionObserver() {
115449
+ var _this8 = this;
115450
+
115451
+ if (!hasIntersectionObserver) return;
115452
+ this._observer = new IntersectionObserver(this._observerHandler.bind(this), this.options.observerOptions);
115453
+ if (this.ListenerQueue.length) {
115454
+ this.ListenerQueue.forEach(function (listener) {
115455
+ _this8._observer.observe(listener.el);
115456
+ });
115457
+ }
115458
+ }
115459
+
115460
+ /**
115461
+ * init IntersectionObserver
115462
+ * @return
115463
+ */
115464
+
115465
+ }, {
115466
+ key: '_observerHandler',
115467
+ value: function _observerHandler(entries, observer) {
115468
+ var _this9 = this;
115469
+
115470
+ entries.forEach(function (entry) {
115471
+ if (entry.isIntersecting) {
115472
+ _this9.ListenerQueue.forEach(function (listener) {
115473
+ if (listener.el === entry.target) {
115474
+ if (listener.state.loaded) return _this9._observer.unobserve(listener.el);
115475
+ listener.load();
115476
+ }
115477
+ });
115478
+ }
115479
+ });
115480
+ }
115481
+
115482
+ /**
115483
+ * set element attribute with image'url and state
115484
+ * @param {object} lazyload listener object
115485
+ * @param {string} state will be rendered
115486
+ * @param {bool} inCache is rendered from cache
115487
+ * @return
115488
+ */
115489
+
115490
+ }, {
115491
+ key: '_elRenderer',
115492
+ value: function _elRenderer(listener, state, cache) {
115493
+ if (!listener.el) return;
115494
+ var el = listener.el,
115495
+ bindType = listener.bindType;
115496
+
115497
+
115498
+ var src = void 0;
115499
+ switch (state) {
115500
+ case 'loading':
115501
+ src = listener.loading;
115502
+ break;
115503
+ case 'error':
115504
+ src = listener.error;
115505
+ break;
115506
+ default:
115507
+ src = listener.src;
115508
+ break;
115509
+ }
115510
+
115511
+ if (bindType) {
115512
+ el.style[bindType] = 'url("' + src + '")';
115513
+ } else if (el.getAttribute('src') !== src) {
115514
+ el.setAttribute('src', src);
115515
+ }
115516
+
115517
+ el.setAttribute('lazy', state);
115518
+
115519
+ this.$emit(state, listener, cache);
115520
+ this.options.adapter[state] && this.options.adapter[state](listener, this.options);
115521
+
115522
+ if (this.options.dispatchEvent) {
115523
+ var event = new CustomEvent(state, {
115524
+ detail: listener
115525
+ });
115526
+ el.dispatchEvent(event);
115527
+ }
115528
+ }
115529
+
115530
+ /**
115531
+ * generate loading loaded error image url
115532
+ * @param {string} image's src
115533
+ * @return {object} image's loading, loaded, error url
115534
+ */
115535
+
115536
+ }, {
115537
+ key: '_valueFormatter',
115538
+ value: function _valueFormatter(value) {
115539
+ var src = value;
115540
+ var loading = this.options.loading;
115541
+ var error = this.options.error;
115542
+
115543
+ // value is object
115544
+ if (vue_lazyload_esm_isObject(value)) {
115545
+ if (!value.src && !this.options.silent) console.error('Vue Lazyload warning: miss src with ' + value);
115546
+ src = value.src;
115547
+ loading = value.loading || this.options.loading;
115548
+ error = value.error || this.options.error;
115549
+ }
115550
+ return {
115551
+ src: src,
115552
+ loading: loading,
115553
+ error: error
115554
+ };
115555
+ }
115556
+ }]);
115557
+ return Lazy;
115558
+ }();
115559
+ };
115560
+
115561
+ var LazyComponent = (function (lazy) {
115562
+ return {
115563
+ props: {
115564
+ tag: {
115565
+ type: String,
115566
+ default: 'div'
115567
+ }
115568
+ },
115569
+ render: function render(h) {
115570
+ if (this.show === false) {
115571
+ return h(this.tag);
115572
+ }
115573
+ return h(this.tag, null, this.$slots.default);
115574
+ },
115575
+ data: function data() {
115576
+ return {
115577
+ el: null,
115578
+ state: {
115579
+ loaded: false
115580
+ },
115581
+ rect: {},
115582
+ show: false
115583
+ };
115584
+ },
115585
+ mounted: function mounted() {
115586
+ this.el = this.$el;
115587
+ lazy.addLazyBox(this);
115588
+ lazy.lazyLoadHandler();
115589
+ },
115590
+ beforeDestroy: function beforeDestroy() {
115591
+ lazy.removeComponent(this);
115592
+ },
115593
+
115594
+ methods: {
115595
+ getRect: function getRect() {
115596
+ this.rect = this.$el.getBoundingClientRect();
115597
+ },
115598
+ checkInView: function checkInView() {
115599
+ this.getRect();
115600
+ return inBrowser && this.rect.top < window.innerHeight * lazy.options.preLoad && this.rect.bottom > 0 && this.rect.left < window.innerWidth * lazy.options.preLoad && this.rect.right > 0;
115601
+ },
115602
+ load: function load() {
115603
+ this.show = true;
115604
+ this.state.loaded = true;
115605
+ this.$emit('show', this);
115606
+ },
115607
+ destroy: function destroy() {
115608
+ return this.$destroy;
115609
+ }
115610
+ }
115611
+ };
115612
+ });
115613
+
115614
+ var LazyContainerMananger = function () {
115615
+ function LazyContainerMananger(_ref) {
115616
+ var lazy = _ref.lazy;
115617
+ classCallCheck(this, LazyContainerMananger);
115618
+
115619
+ this.lazy = lazy;
115620
+ lazy.lazyContainerMananger = this;
115621
+ this._queue = [];
115622
+ }
115623
+
115624
+ createClass(LazyContainerMananger, [{
115625
+ key: 'bind',
115626
+ value: function bind(el, binding, vnode) {
115627
+ var container = new LazyContainer$1({ el: el, binding: binding, vnode: vnode, lazy: this.lazy });
115628
+ this._queue.push(container);
115629
+ }
115630
+ }, {
115631
+ key: 'update',
115632
+ value: function update(el, binding, vnode) {
115633
+ var container = find(this._queue, function (item) {
115634
+ return item.el === el;
115635
+ });
115636
+ if (!container) return;
115637
+ container.update({ el: el, binding: binding, vnode: vnode });
115638
+ }
115639
+ }, {
115640
+ key: 'unbind',
115641
+ value: function unbind(el, binding, vnode) {
115642
+ var container = find(this._queue, function (item) {
115643
+ return item.el === el;
115644
+ });
115645
+ if (!container) return;
115646
+ container.clear();
115647
+ remove(this._queue, container);
115648
+ }
115649
+ }]);
115650
+ return LazyContainerMananger;
115651
+ }();
115652
+
115653
+ var defaultOptions = {
115654
+ selector: 'img'
115655
+ };
115656
+
115657
+ var LazyContainer$1 = function () {
115658
+ function LazyContainer(_ref2) {
115659
+ var el = _ref2.el,
115660
+ binding = _ref2.binding,
115661
+ vnode = _ref2.vnode,
115662
+ lazy = _ref2.lazy;
115663
+ classCallCheck(this, LazyContainer);
115664
+
115665
+ this.el = null;
115666
+ this.vnode = vnode;
115667
+ this.binding = binding;
115668
+ this.options = {};
115669
+ this.lazy = lazy;
115670
+
115671
+ this._queue = [];
115672
+ this.update({ el: el, binding: binding });
115673
+ }
115674
+
115675
+ createClass(LazyContainer, [{
115676
+ key: 'update',
115677
+ value: function update(_ref3) {
115678
+ var _this = this;
115679
+
115680
+ var el = _ref3.el,
115681
+ binding = _ref3.binding;
115682
+
115683
+ this.el = el;
115684
+ this.options = assignDeep({}, defaultOptions, binding.value);
115685
+
115686
+ var imgs = this.getImgs();
115687
+ imgs.forEach(function (el) {
115688
+ _this.lazy.add(el, assignDeep({}, _this.binding, {
115689
+ value: {
115690
+ src: 'dataset' in el ? el.dataset.src : el.getAttribute('data-src'),
115691
+ error: ('dataset' in el ? el.dataset.error : el.getAttribute('data-error')) || _this.options.error,
115692
+ loading: ('dataset' in el ? el.dataset.loading : el.getAttribute('data-loading')) || _this.options.loading
115693
+ }
115694
+ }), _this.vnode);
115695
+ });
115696
+ }
115697
+ }, {
115698
+ key: 'getImgs',
115699
+ value: function getImgs() {
115700
+ return ArrayFrom(this.el.querySelectorAll(this.options.selector));
115701
+ }
115702
+ }, {
115703
+ key: 'clear',
115704
+ value: function clear() {
115705
+ var _this2 = this;
115706
+
115707
+ var imgs = this.getImgs();
115708
+ imgs.forEach(function (el) {
115709
+ return _this2.lazy.remove(el);
115710
+ });
115711
+
115712
+ this.vnode = null;
115713
+ this.binding = null;
115714
+ this.lazy = null;
115715
+ }
115716
+ }]);
115717
+ return LazyContainer;
115718
+ }();
115719
+
115720
+ var LazyImage = (function (lazyManager) {
115721
+ return {
115722
+ props: {
115723
+ src: [String, Object],
115724
+ tag: {
115725
+ type: String,
115726
+ default: 'img'
115727
+ }
115728
+ },
115729
+ render: function render(h) {
115730
+ return h(this.tag, {
115731
+ attrs: {
115732
+ src: this.renderSrc
115733
+ }
115734
+ }, this.$slots.default);
115735
+ },
115736
+ data: function data() {
115737
+ return {
115738
+ el: null,
115739
+ options: {
115740
+ src: '',
115741
+ error: '',
115742
+ loading: '',
115743
+ attempt: lazyManager.options.attempt
115744
+ },
115745
+ state: {
115746
+ loaded: false,
115747
+ error: false,
115748
+ attempt: 0
115749
+ },
115750
+ rect: {},
115751
+ renderSrc: ''
115752
+ };
115753
+ },
115754
+
115755
+ watch: {
115756
+ src: function src() {
115757
+ this.init();
115758
+ lazyManager.addLazyBox(this);
115759
+ lazyManager.lazyLoadHandler();
115760
+ }
115761
+ },
115762
+ created: function created() {
115763
+ this.init();
115764
+ this.renderSrc = this.options.loading;
115765
+ },
115766
+ mounted: function mounted() {
115767
+ this.el = this.$el;
115768
+ lazyManager.addLazyBox(this);
115769
+ lazyManager.lazyLoadHandler();
115770
+ },
115771
+ beforeDestroy: function beforeDestroy() {
115772
+ lazyManager.removeComponent(this);
115773
+ },
115774
+
115775
+ methods: {
115776
+ init: function init() {
115777
+ var _lazyManager$_valueFo = lazyManager._valueFormatter(this.src),
115778
+ src = _lazyManager$_valueFo.src,
115779
+ loading = _lazyManager$_valueFo.loading,
115780
+ error = _lazyManager$_valueFo.error;
115781
+
115782
+ this.state.loaded = false;
115783
+ this.options.src = src;
115784
+ this.options.error = error;
115785
+ this.options.loading = loading;
115786
+ this.renderSrc = this.options.loading;
115787
+ },
115788
+ getRect: function getRect() {
115789
+ this.rect = this.$el.getBoundingClientRect();
115790
+ },
115791
+ checkInView: function checkInView() {
115792
+ this.getRect();
115793
+ return inBrowser && this.rect.top < window.innerHeight * lazyManager.options.preLoad && this.rect.bottom > 0 && this.rect.left < window.innerWidth * lazyManager.options.preLoad && this.rect.right > 0;
115794
+ },
115795
+ load: function load() {
115796
+ var _this = this;
115797
+
115798
+ var onFinish = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : vue_lazyload_esm_noop;
115799
+
115800
+ if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
115801
+ if (!lazyManager.options.silent) console.log('VueLazyload log: ' + this.options.src + ' tried too more than ' + this.options.attempt + ' times');
115802
+ onFinish();
115803
+ return;
115804
+ }
115805
+ var src = this.options.src;
115806
+ loadImageAsync({ src: src }, function (_ref) {
115807
+ var src = _ref.src;
115808
+
115809
+ _this.renderSrc = src;
115810
+ _this.state.loaded = true;
115811
+ }, function (e) {
115812
+ _this.state.attempt++;
115813
+ _this.renderSrc = _this.options.error;
115814
+ _this.state.error = true;
115815
+ });
115816
+ }
115817
+ }
115818
+ };
115819
+ });
115820
+
115821
+ var index = {
115822
+ /*
115823
+ * install function
115824
+ * @param {Vue} Vue
115825
+ * @param {object} options lazyload options
115826
+ */
115827
+ install: function install(Vue) {
115828
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
115829
+
115830
+ var LazyClass = Lazy(Vue);
115831
+ var lazy = new LazyClass(options);
115832
+ var lazyContainer = new LazyContainerMananger({ lazy: lazy });
115833
+
115834
+ var isVue2 = Vue.version.split('.')[0] === '2';
115835
+
115836
+ Vue.prototype.$Lazyload = lazy;
115837
+
115838
+ if (options.lazyComponent) {
115839
+ Vue.component('lazy-component', LazyComponent(lazy));
115840
+ }
115841
+
115842
+ if (options.lazyImage) {
115843
+ Vue.component('lazy-image', LazyImage(lazy));
115844
+ }
115845
+
115846
+ if (isVue2) {
115847
+ Vue.directive('lazy', {
115848
+ bind: lazy.add.bind(lazy),
115849
+ update: lazy.update.bind(lazy),
115850
+ componentUpdated: lazy.lazyLoadHandler.bind(lazy),
115851
+ unbind: lazy.remove.bind(lazy)
115852
+ });
115853
+ Vue.directive('lazy-container', {
115854
+ bind: lazyContainer.bind.bind(lazyContainer),
115855
+ componentUpdated: lazyContainer.update.bind(lazyContainer),
115856
+ unbind: lazyContainer.unbind.bind(lazyContainer)
115857
+ });
115858
+ } else {
115859
+ Vue.directive('lazy', {
115860
+ bind: lazy.lazyLoadHandler.bind(lazy),
115861
+ update: function update(newValue, oldValue) {
115862
+ assignDeep(this.vm.$refs, this.vm.$els);
115863
+ lazy.add(this.el, {
115864
+ modifiers: this.modifiers || {},
115865
+ arg: this.arg,
115866
+ value: newValue,
115867
+ oldValue: oldValue
115868
+ }, {
115869
+ context: this.vm
115870
+ });
115871
+ },
115872
+ unbind: function unbind() {
115873
+ lazy.remove(this.el);
115874
+ }
115875
+ });
115876
+
115877
+ Vue.directive('lazy-container', {
115878
+ update: function update(newValue, oldValue) {
115879
+ lazyContainer.update(this.el, {
115880
+ modifiers: this.modifiers || {},
115881
+ arg: this.arg,
115882
+ value: newValue,
115883
+ oldValue: oldValue
115884
+ }, {
115885
+ context: this.vm
115886
+ });
115887
+ },
115888
+ unbind: function unbind() {
115889
+ lazyContainer.unbind(this.el);
115890
+ }
115891
+ });
115892
+ }
115893
+ }
115894
+ };
115895
+
115896
+ /* harmony default export */ var vue_lazyload_esm = (index);
115897
+
115898
+ // CONCATENATED MODULE: ./index.js
115899
+
115900
+
115901
+
115902
+ // 新增:导入vue-lazyload插件
115903
+ // 导出组件
115904
+
115905
+
115906
+ // 添加 install 方法以支持 Vue.use()
115907
+ /* harmony default export */ var index_0 = ({
115908
+ install(Vue) {
115909
+ Vue.component('FileImport', fileImport)
115910
+ Vue.component('FilePreview', components_filePreview)
115911
+ Vue.component('FileUpload', components_fileUpload)
115912
+ // 新增:安装vue-lazyload插件(使用与原项目一致的配置)
115913
+ Vue.use(vue_lazyload_esm, {
115914
+ loading: __webpack_require__("f8b2"),
115915
+ error: __webpack_require__("b948")
115916
+ })
114090
115917
  },
114091
115918
  });
114092
115919
 
114093
115920
  // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
114094
115921
 
114095
115922
 
114096
- /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (index);
115923
+ /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (index_0);
114097
115924
 
114098
115925
 
114099
115926