UNPKG

32.9 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define([], factory);
6 else if(typeof exports === 'object')
7 exports["uploader"] = factory();
8 else
9 root["uploader"] = factory();
10})(this, function() {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId]) {
20/******/ return installedModules[moduleId].exports;
21/******/ }
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // identity function for calling harmony imports with the correct context
47/******/ __webpack_require__.i = function(value) { return value; };
48/******/
49/******/ // define getter function for harmony exports
50/******/ __webpack_require__.d = function(exports, name, getter) {
51/******/ if(!__webpack_require__.o(exports, name)) {
52/******/ Object.defineProperty(exports, name, {
53/******/ configurable: false,
54/******/ enumerable: true,
55/******/ get: getter
56/******/ });
57/******/ }
58/******/ };
59/******/
60/******/ // getDefaultExport function for compatibility with non-harmony modules
61/******/ __webpack_require__.n = function(module) {
62/******/ var getter = module && module.__esModule ?
63/******/ function getDefault() { return module['default']; } :
64/******/ function getModuleExports() { return module; };
65/******/ __webpack_require__.d(getter, 'a', getter);
66/******/ return getter;
67/******/ };
68/******/
69/******/ // Object.prototype.hasOwnProperty.call
70/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
71/******/
72/******/ // __webpack_public_path__
73/******/ __webpack_require__.p = "";
74/******/
75/******/ // Load entry module and return exports
76/******/ return __webpack_require__(__webpack_require__.s = 11);
77/******/ })
78/************************************************************************/
79/******/ ([
80/* 0 */
81/***/ (function(module, exports, __webpack_require__) {
82
83function injectStyle (ssrContext) {
84 __webpack_require__(8)
85}
86var Component = __webpack_require__(6)(
87 /* script */
88 __webpack_require__(2),
89 /* template */
90 __webpack_require__(7),
91 /* styles */
92 injectStyle,
93 /* scopeId */
94 null,
95 /* moduleIdentifier (server only) */
96 null
97)
98
99module.exports = Component.exports
100
101
102/***/ }),
103/* 1 */
104/***/ (function(module, exports, __webpack_require__) {
105
106"use strict";
107
108
109Object.defineProperty(exports, "__esModule", {
110 value: true
111});
112
113var _wx = __webpack_require__(3);
114
115var _uploader = __webpack_require__(0);
116
117var _uploader2 = _interopRequireDefault(_uploader);
118
119function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
120
121/**
122 *
123 *
124 * @return {Promise} {image, serverId}
125 */
126function uploadWechatImage(localId) {
127 var serverId = null;
128 return (0, _wx.uploadImage)(localId).then(function (_serverId) {
129 serverId = _serverId; // 记录serverId
130 return localId;
131 }).then(_wx.getLocalImgData) // 权限检测可能不应该这样使用
132 .then(function (imageData) {
133 return {
134 image: imageData,
135 serverId: serverId
136 };
137 });
138}
139
140/**
141 *
142 */
143exports.default = {
144 name: 'WechatUploader',
145 extends: _uploader2.default,
146 props: {
147 /**
148 * 是否使用微信的预览内容
149 */
150 useWechatPreview: {
151 type: Boolean,
152 default: true
153 }
154 },
155 data: function data() {
156 return {
157 /**
158 * 保存所有的serverId
159 */
160 serverIds: []
161 };
162 },
163
164 methods: {
165 /**
166 * @param {Array<{image, serverId}>} data
167 */
168 setImages: function setImages(data) {
169 var images = [];
170 var serverIds = [];
171 for (var i = 0, len = data.length; i < len; i++) {
172 images.push(data[i].image);
173 serverIds.push(data[i].serverId);
174 }
175 this.images = images;
176 this.serverIds = serverIds;
177 },
178
179 /**
180 * 添加图片
181 *
182 * @param {} image 图片内容
183 * @param {} serverId
184 */
185 add: function add(image, serverId) {
186 if (this.images.length < this.size) {
187 this.images.push(image);
188 this.serverIds.push(serverId);
189 this.$emit('add', {
190 image: image,
191 serverId: serverId
192 });
193 return true;
194 }
195 return false;
196 },
197
198 /**
199 * 获得所有的图片内容
200 *
201 * @return {Array<{image, serverId}>}
202 */
203 getImages: function getImages() {
204 var result = [];
205 for (var i = 0, len = this.images.length; i < len; i++) {
206 result.push({
207 image: this.images[i],
208 serverId: this.serverIds[i]
209 });
210 }
211 return result;
212 },
213
214 /**
215 * 删除图片
216 *
217 * @param {} index
218 */
219 remove: function remove(index) {
220 if (0 <= index && index < this.size) {
221 this.images.splice(index, 1);
222 this.serverIds.splice(index, 1);
223 this.$emit('remove', index);
224 return true;
225 }
226 return false;
227 },
228
229 /**
230 * 要求添加新的图片
231 */
232 onClickRequest: function onClickRequest() {
233 this.request();
234 },
235
236 /**
237 * 请求图片上传
238 */
239 request: function request() {
240 var vm = this;
241 return (0, _wx.chooseImage)(vm.size - vm.images.length).then(function (localIds) {
242 if (localIds.length > 0) {
243 vm.$emit('load');
244 return vm.uploadWechatImages(localIds).then(function () {
245 vm.$emit('finish');
246 });
247 }
248 });
249 },
250
251 /**
252 * 上传多张图片,需要保证一张上传完成之后,再上传另外一张
253 */
254 uploadWechatImages: function uploadWechatImages(localIds) {
255 var vm = this;
256 var localId = localIds.shift();
257 return uploadWechatImage(localId).then(function (_ref) {
258 var image = _ref.image,
259 serverId = _ref.serverId;
260
261 vm.add(image, serverId);
262 if (localIds.length > 0) {
263 return vm.uploadWechatImages(localIds);
264 }
265 });
266 }
267 },
268 mounted: function mounted() {
269 this.$on('click', function (index) {
270 (0, _wx.previewImage)(this.images[index], this.images);
271 });
272 }
273};
274
275/***/ }),
276/* 2 */
277/***/ (function(module, exports, __webpack_require__) {
278
279"use strict";
280
281
282Object.defineProperty(exports, "__esModule", {
283 value: true
284});
285//
286//
287//
288//
289//
290//
291//
292//
293//
294//
295//
296//
297//
298//
299//
300//
301//
302//
303//
304//
305//
306//
307//
308//
309//
310//
311//
312//
313//
314//
315//
316//
317//
318//
319
320/**
321 * @load 当图片上传开始时
322 * @finish 当图片上传结束时
323 */
324exports.default = {
325 name: 'ROUploader',
326 props: {
327 /**
328 * 允许上传图片个数
329 */
330 size: {
331 type: Number,
332 default: 1
333 },
334 /**
335 * 是否允许修改
336 */
337 canModify: {
338 type: Boolean,
339 default: true
340 },
341 /**
342 * 容器对象类
343 */
344 containerClass: {
345 type: [Object, Array],
346 default: function _default() {
347 return {};
348 }
349 },
350 /**
351 * 容器对象样式
352 */
353 containerStyle: {
354 type: Object,
355 default: function _default() {
356 return {};
357 }
358 },
359 /**
360 * 图片对象类
361 */
362 imageClass: {
363 type: [Object, Array],
364 default: function _default() {
365 return {};
366 }
367 },
368 /**
369 * 图片对象样式
370 */
371 imageStyle: {
372 type: Object,
373 default: function _default() {
374 return {};
375 }
376 },
377 /**
378 * wrap
379 */
380 imageWrapClass: {
381 type: [Object, Array],
382 default: function _default() {
383 return {};
384 }
385 },
386 /**
387 * wrap
388 */
389 imageWrapStyle: {
390 type: Object,
391 default: function _default() {
392 return {};
393 }
394 },
395 /**
396 * 请求对象类
397 */
398 requestClass: {
399 type: [Object, Array],
400 default: function _default() {
401 return {};
402 }
403 },
404 /**
405 * 请求对象样式
406 */
407 requestStyle: {
408 type: Object,
409 default: function _default() {
410 return {};
411 }
412 },
413 /**
414 * 删除按钮样式类
415 */
416 removeClass: {
417 type: [Object, Array],
418 default: function _default() {
419 return {};
420 }
421 },
422 /**
423 * 删除按钮样式
424 */
425 removeStyle: {
426 type: Object,
427 default: function _default() {
428 return {};
429 }
430 },
431 /**
432 * 调用lazyload,因为无法确定存在vue-lazyload库,所以默认false
433 */
434 lazyload: {
435 type: Boolean,
436 default: false
437 }
438 },
439 data: function data() {
440 return {
441 // 包含所有图片的数组
442 images: []
443 };
444 },
445
446 methods: {
447 /**
448 * 重置所有的images列表,不会触发任何的remove和add事件
449 */
450 setImages: function setImages(images) {
451 var tmp = [];
452 for (var i = 0, len = images.length; i < len; i++) {
453 tmp.push(images[i]);
454 }
455 this.images = tmp;
456 },
457
458 /**
459 * 添加图片
460 * 将触发@add(image)事件
461 *
462 * @param {string} image
463 *
464 * @return {boolean} 成功返回true,否则返回false
465 */
466 add: function add(image) {
467 if (this.images.length < this.size) {
468 this.images.push(image);
469 this.$emit('add', image);
470 return true;
471 }
472 return false;
473 },
474
475 /**
476 * 删除图片
477 * 将触发@remove(index)事件
478 *
479 * @param {number} index
480 *
481 * @return {boolean} true表示删除成功,false表示失败
482 */
483 remove: function remove(index) {
484 if (0 <= index && index < this.size) {
485 this.images.splice(index, 1);
486 this.$emit('remove', index);
487 return true;
488 }
489 return false;
490 },
491
492 /**
493 * 删除所有的图片
494 */
495 removeAll: function removeAll() {
496 for (var i = 0, len = this.images.length; i < len; i++) {
497 this.remove(i);
498 }
499 return true;
500 },
501
502 /**
503 * 获得所有图片
504 *
505 * @return {Array<string>}
506 */
507 getImages: function getImages() {
508 return this.images.slice(0);
509 },
510
511 /**
512 * 当点击图片时触发
513 *
514 * @param {number} index
515 */
516 onClickImage: function onClickImage(index) {
517 this.$emit('click', index);
518 },
519
520 /**
521 * 当点击删除按钮时触发
522 */
523 onClickRemove: function onClickRemove(index) {
524 this.remove(index);
525 },
526
527 /**
528 * 当点击添加按钮时
529 */
530 onClickRequest: function onClickRequest() {
531 this.$emit('request');
532 },
533
534 /**
535 * 当点击
536 */
537 onPress: function onPress(index) {
538 var _this = this;
539
540 return function () {
541 _this.$emit('menu', index);
542 };
543 },
544
545 /**
546 * 获得允许上传的容量
547 */
548 getSize: function getSize() {
549 return this.size;
550 },
551
552 /**
553 * 获得当前已经上传的图片的数量
554 */
555 getCount: function getCount() {
556 return this.images.length;
557 }
558 }
559};
560
561/***/ }),
562/* 3 */
563/***/ (function(module, exports, __webpack_require__) {
564
565"use strict";
566
567
568Object.defineProperty(exports, "__esModule", {
569 value: true
570});
571exports.previewImage = previewImage;
572exports.chooseImage = chooseImage;
573exports.uploadImage = uploadImage;
574exports.getLocalImgData = getLocalImgData;
575var isIOS = /iPhone/.test(navigator.userAgent);
576
577function previewImage(image, images) {
578 wx.previewImage({
579 current: image,
580 urls: images
581 });
582}
583
584/**
585 * @return {Promise} localIds: Array<string>
586 */
587function chooseImage(count) {
588 return new Promise(function (resolve, reject) {
589 wx.chooseImage({
590 count: count,
591 sizeType: ['compressed'],
592 success: function success(res) {
593 console.log('chooseImage', res);
594 return resolve(res.localIds);
595 }
596 });
597 });
598}
599
600/**
601 * 默认不显示progress
602 * @param localId
603 *
604 * @return {Promise} serverId
605 */
606function uploadImage(localId) {
607 return new Promise(function (resolve, reject) {
608 wx.uploadImage({
609 localId: localId,
610 isShowProgressTips: 0,
611 success: function success(res) {
612 return resolve(res.serverId);
613 }
614 });
615 });
616}
617
618/**
619 * @param localId
620 *
621 * @return {Promise} imageData
622 */
623function getLocalImgData(localId) {
624 if (!isIOS || !window.__wxjs_is_wkwebview) {
625 return localId;
626 }
627 return new Promise(function (resolve, reject) {
628 wx.getLocalImgData({
629 localId: localId,
630 success: function success(res) {
631 return resolve(res.localData);
632 }
633 });
634 });
635}
636
637/***/ }),
638/* 4 */
639/***/ (function(module, exports, __webpack_require__) {
640
641exports = module.exports = __webpack_require__(5)(undefined);
642// imports
643
644
645// module
646exports.push([module.i, ".ro-uploader-wrap{display:flex;background-color:#fff;text-decoration:none}.ro-uploader-wrap .ro-uploader-image-wrap{position:relative;margin-right:5px}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-image{vertical-align:middle;width:70px;height:70px;background-repeat:no-repeat;background-size:cover;background-position:50%;background-color:#aaa}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove{position:absolute;width:18px;height:18px;font-size:18px;line-height:18px;color:#fff;background-color:#aaa;top:0;right:0}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:after,.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:before{background-color:#fff;transform:translate(-50%,-50%) rotate(45deg)}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:before{width:2px;height:18px}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:after{width:18px;height:2px}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:active{border-color:#fff}.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:active:after,.ro-uploader-wrap .ro-uploader-image-wrap .ro-uploader-remove:active:before{background-color:#fff}.ro-uploader-wrap .ro-uploader-request{position:relative;width:70px;height:70px;border:1px solid #aaa;box-sizing:border-box}.ro-uploader-wrap .ro-uploader-request:after,.ro-uploader-wrap .ro-uploader-request:before{background-color:#bbb}.ro-uploader-wrap .ro-uploader-request:before{width:2px;height:35px}.ro-uploader-wrap .ro-uploader-request:after{width:35px;height:2px}.ro-uploader-wrap .ro-uploader-request:active{border-color:#888}.ro-uploader-wrap .ro-uploader-request:active:after,.ro-uploader-wrap .ro-uploader-request:active:before{background-color:#888}.ro-uploader-wrap .ro-uploader-remove:after,.ro-uploader-wrap .ro-uploader-remove:before,.ro-uploader-wrap .ro-uploader-request:after,.ro-uploader-wrap .ro-uploader-request:before{content:\" \";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}", ""]);
647
648// exports
649
650
651/***/ }),
652/* 5 */
653/***/ (function(module, exports) {
654
655/*
656 MIT License http://www.opensource.org/licenses/mit-license.php
657 Author Tobias Koppers @sokra
658*/
659// css base code, injected by the css-loader
660module.exports = function(useSourceMap) {
661 var list = [];
662
663 // return the list of modules as css string
664 list.toString = function toString() {
665 return this.map(function (item) {
666 var content = cssWithMappingToString(item, useSourceMap);
667 if(item[2]) {
668 return "@media " + item[2] + "{" + content + "}";
669 } else {
670 return content;
671 }
672 }).join("");
673 };
674
675 // import a list of modules into the list
676 list.i = function(modules, mediaQuery) {
677 if(typeof modules === "string")
678 modules = [[null, modules, ""]];
679 var alreadyImportedModules = {};
680 for(var i = 0; i < this.length; i++) {
681 var id = this[i][0];
682 if(typeof id === "number")
683 alreadyImportedModules[id] = true;
684 }
685 for(i = 0; i < modules.length; i++) {
686 var item = modules[i];
687 // skip already imported module
688 // this implementation is not 100% perfect for weird media query combinations
689 // when a module is imported multiple times with different media queries.
690 // I hope this will never occur (Hey this way we have smaller bundles)
691 if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
692 if(mediaQuery && !item[2]) {
693 item[2] = mediaQuery;
694 } else if(mediaQuery) {
695 item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
696 }
697 list.push(item);
698 }
699 }
700 };
701 return list;
702};
703
704function cssWithMappingToString(item, useSourceMap) {
705 var content = item[1] || '';
706 var cssMapping = item[3];
707 if (!cssMapping) {
708 return content;
709 }
710
711 if (useSourceMap && typeof btoa === 'function') {
712 var sourceMapping = toComment(cssMapping);
713 var sourceURLs = cssMapping.sources.map(function (source) {
714 return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
715 });
716
717 return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
718 }
719
720 return [content].join('\n');
721}
722
723// Adapted from convert-source-map (MIT)
724function toComment(sourceMap) {
725 // eslint-disable-next-line no-undef
726 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
727 var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
728
729 return '/*# ' + data + ' */';
730}
731
732
733/***/ }),
734/* 6 */
735/***/ (function(module, exports) {
736
737/* globals __VUE_SSR_CONTEXT__ */
738
739// this module is a runtime utility for cleaner component module output and will
740// be included in the final webpack user bundle
741
742module.exports = function normalizeComponent (
743 rawScriptExports,
744 compiledTemplate,
745 injectStyles,
746 scopeId,
747 moduleIdentifier /* server only */
748) {
749 var esModule
750 var scriptExports = rawScriptExports = rawScriptExports || {}
751
752 // ES6 modules interop
753 var type = typeof rawScriptExports.default
754 if (type === 'object' || type === 'function') {
755 esModule = rawScriptExports
756 scriptExports = rawScriptExports.default
757 }
758
759 // Vue.extend constructor export interop
760 var options = typeof scriptExports === 'function'
761 ? scriptExports.options
762 : scriptExports
763
764 // render functions
765 if (compiledTemplate) {
766 options.render = compiledTemplate.render
767 options.staticRenderFns = compiledTemplate.staticRenderFns
768 }
769
770 // scopedId
771 if (scopeId) {
772 options._scopeId = scopeId
773 }
774
775 var hook
776 if (moduleIdentifier) { // server build
777 hook = function (context) {
778 // 2.3 injection
779 context =
780 context || // cached call
781 (this.$vnode && this.$vnode.ssrContext) || // stateful
782 (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
783 // 2.2 with runInNewContext: true
784 if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
785 context = __VUE_SSR_CONTEXT__
786 }
787 // inject component styles
788 if (injectStyles) {
789 injectStyles.call(this, context)
790 }
791 // register component module identifier for async chunk inferrence
792 if (context && context._registeredComponents) {
793 context._registeredComponents.add(moduleIdentifier)
794 }
795 }
796 // used by ssr in case component is cached and beforeCreate
797 // never gets called
798 options._ssrRegister = hook
799 } else if (injectStyles) {
800 hook = injectStyles
801 }
802
803 if (hook) {
804 var functional = options.functional
805 var existing = functional
806 ? options.render
807 : options.beforeCreate
808 if (!functional) {
809 // inject component registration as beforeCreate hook
810 options.beforeCreate = existing
811 ? [].concat(existing, hook)
812 : [hook]
813 } else {
814 // register for functioal component in vue file
815 options.render = function renderWithStyleInjection (h, context) {
816 hook.call(context)
817 return existing(h, context)
818 }
819 }
820 }
821
822 return {
823 esModule: esModule,
824 exports: scriptExports,
825 options: options
826 }
827}
828
829
830/***/ }),
831/* 7 */
832/***/ (function(module, exports) {
833
834module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
835 return _c('div', {
836 staticClass: "ro-uploader-wrap",
837 class: _vm.containerClass,
838 style: (_vm.containerStyle)
839 }, [_vm._l((_vm.images), function(image, index) {
840 return _c('div', {
841 staticClass: "ro-uploader-image-wrap",
842 class: _vm.imageWrapClass,
843 style: (_vm.imageWrapStyle)
844 }, [(!_vm.lazyload) ? _c('div', {
845 directives: [{
846 name: "pressure-press",
847 rawName: "v-pressure-press",
848 value: (_vm.onPress(index)),
849 expression: "onPress(index)"
850 }],
851 staticClass: "ro-uploader-image",
852 class: _vm.imageClass,
853 style: ([{
854 'background-image': 'url(' + image + ')'
855 }, _vm.imageStyle]),
856 on: {
857 "click": function($event) {
858 _vm.onClickImage(index)
859 }
860 }
861 }) : _c('div', {
862 directives: [{
863 name: "lazy",
864 rawName: "v-lazy:background-image",
865 value: (image),
866 expression: "image",
867 arg: "background-image"
868 }, {
869 name: "pressure-press",
870 rawName: "v-pressure-press",
871 value: (_vm.onPress(index)),
872 expression: "onPress(index)"
873 }],
874 staticClass: "ro-uploader-image",
875 class: _vm.imageClass,
876 style: ([_vm.imageStyle]),
877 on: {
878 "click": function($event) {
879 _vm.onClickImage(index)
880 }
881 }
882 }), _vm._v(" "), (_vm.canModify) ? _c('div', {
883 staticClass: "ro-uploader-remove",
884 class: _vm.removeClass,
885 style: (_vm.removeStyle),
886 on: {
887 "click": function($event) {
888 _vm.onClickRemove(index)
889 }
890 }
891 }) : _vm._e()])
892 }), _vm._v(" "), (_vm.images.length < _vm.size && _vm.canModify) ? _c('div', {
893 staticClass: "ro-uploader-image-wrap ro-uploader-request",
894 class: _vm.requestClass,
895 style: (_vm.requestStyle),
896 on: {
897 "click": _vm.onClickRequest
898 }
899 }) : _vm._e()], 2)
900},staticRenderFns: []}
901
902/***/ }),
903/* 8 */
904/***/ (function(module, exports, __webpack_require__) {
905
906// style-loader: Adds some css to the DOM by adding a <style> tag
907
908// load the styles
909var content = __webpack_require__(4);
910if(typeof content === 'string') content = [[module.i, content, '']];
911if(content.locals) module.exports = content.locals;
912// add the styles to the DOM
913var update = __webpack_require__(9)("4fb8864b", content, true);
914
915/***/ }),
916/* 9 */
917/***/ (function(module, exports, __webpack_require__) {
918
919/*
920 MIT License http://www.opensource.org/licenses/mit-license.php
921 Author Tobias Koppers @sokra
922 Modified by Evan You @yyx990803
923*/
924
925var hasDocument = typeof document !== 'undefined'
926
927if (typeof DEBUG !== 'undefined' && DEBUG) {
928 if (!hasDocument) {
929 throw new Error(
930 'vue-style-loader cannot be used in a non-browser environment. ' +
931 "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
932 ) }
933}
934
935var listToStyles = __webpack_require__(10)
936
937/*
938type StyleObject = {
939 id: number;
940 parts: Array<StyleObjectPart>
941}
942
943type StyleObjectPart = {
944 css: string;
945 media: string;
946 sourceMap: ?string
947}
948*/
949
950var stylesInDom = {/*
951 [id: number]: {
952 id: number,
953 refs: number,
954 parts: Array<(obj?: StyleObjectPart) => void>
955 }
956*/}
957
958var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
959var singletonElement = null
960var singletonCounter = 0
961var isProduction = false
962var noop = function () {}
963
964// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
965// tags it will allow on a page
966var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
967
968module.exports = function (parentId, list, _isProduction) {
969 isProduction = _isProduction
970
971 var styles = listToStyles(parentId, list)
972 addStylesToDom(styles)
973
974 return function update (newList) {
975 var mayRemove = []
976 for (var i = 0; i < styles.length; i++) {
977 var item = styles[i]
978 var domStyle = stylesInDom[item.id]
979 domStyle.refs--
980 mayRemove.push(domStyle)
981 }
982 if (newList) {
983 styles = listToStyles(parentId, newList)
984 addStylesToDom(styles)
985 } else {
986 styles = []
987 }
988 for (var i = 0; i < mayRemove.length; i++) {
989 var domStyle = mayRemove[i]
990 if (domStyle.refs === 0) {
991 for (var j = 0; j < domStyle.parts.length; j++) {
992 domStyle.parts[j]()
993 }
994 delete stylesInDom[domStyle.id]
995 }
996 }
997 }
998}
999
1000function addStylesToDom (styles /* Array<StyleObject> */) {
1001 for (var i = 0; i < styles.length; i++) {
1002 var item = styles[i]
1003 var domStyle = stylesInDom[item.id]
1004 if (domStyle) {
1005 domStyle.refs++
1006 for (var j = 0; j < domStyle.parts.length; j++) {
1007 domStyle.parts[j](item.parts[j])
1008 }
1009 for (; j < item.parts.length; j++) {
1010 domStyle.parts.push(addStyle(item.parts[j]))
1011 }
1012 if (domStyle.parts.length > item.parts.length) {
1013 domStyle.parts.length = item.parts.length
1014 }
1015 } else {
1016 var parts = []
1017 for (var j = 0; j < item.parts.length; j++) {
1018 parts.push(addStyle(item.parts[j]))
1019 }
1020 stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts }
1021 }
1022 }
1023}
1024
1025function createStyleElement () {
1026 var styleElement = document.createElement('style')
1027 styleElement.type = 'text/css'
1028 head.appendChild(styleElement)
1029 return styleElement
1030}
1031
1032function addStyle (obj /* StyleObjectPart */) {
1033 var update, remove
1034 var styleElement = document.querySelector('style[data-vue-ssr-id~="' + obj.id + '"]')
1035
1036 if (styleElement) {
1037 if (isProduction) {
1038 // has SSR styles and in production mode.
1039 // simply do nothing.
1040 return noop
1041 } else {
1042 // has SSR styles but in dev mode.
1043 // for some reason Chrome can't handle source map in server-rendered
1044 // style tags - source maps in <style> only works if the style tag is
1045 // created and inserted dynamically. So we remove the server rendered
1046 // styles and inject new ones.
1047 styleElement.parentNode.removeChild(styleElement)
1048 }
1049 }
1050
1051 if (isOldIE) {
1052 // use singleton mode for IE9.
1053 var styleIndex = singletonCounter++
1054 styleElement = singletonElement || (singletonElement = createStyleElement())
1055 update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
1056 remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
1057 } else {
1058 // use multi-style-tag mode in all other cases
1059 styleElement = createStyleElement()
1060 update = applyToTag.bind(null, styleElement)
1061 remove = function () {
1062 styleElement.parentNode.removeChild(styleElement)
1063 }
1064 }
1065
1066 update(obj)
1067
1068 return function updateStyle (newObj /* StyleObjectPart */) {
1069 if (newObj) {
1070 if (newObj.css === obj.css &&
1071 newObj.media === obj.media &&
1072 newObj.sourceMap === obj.sourceMap) {
1073 return
1074 }
1075 update(obj = newObj)
1076 } else {
1077 remove()
1078 }
1079 }
1080}
1081
1082var replaceText = (function () {
1083 var textStore = []
1084
1085 return function (index, replacement) {
1086 textStore[index] = replacement
1087 return textStore.filter(Boolean).join('\n')
1088 }
1089})()
1090
1091function applyToSingletonTag (styleElement, index, remove, obj) {
1092 var css = remove ? '' : obj.css
1093
1094 if (styleElement.styleSheet) {
1095 styleElement.styleSheet.cssText = replaceText(index, css)
1096 } else {
1097 var cssNode = document.createTextNode(css)
1098 var childNodes = styleElement.childNodes
1099 if (childNodes[index]) styleElement.removeChild(childNodes[index])
1100 if (childNodes.length) {
1101 styleElement.insertBefore(cssNode, childNodes[index])
1102 } else {
1103 styleElement.appendChild(cssNode)
1104 }
1105 }
1106}
1107
1108function applyToTag (styleElement, obj) {
1109 var css = obj.css
1110 var media = obj.media
1111 var sourceMap = obj.sourceMap
1112
1113 if (media) {
1114 styleElement.setAttribute('media', media)
1115 }
1116
1117 if (sourceMap) {
1118 // https://developer.chrome.com/devtools/docs/javascript-debugging
1119 // this makes source maps inside style tags work properly in Chrome
1120 css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
1121 // http://stackoverflow.com/a/26603875
1122 css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
1123 }
1124
1125 if (styleElement.styleSheet) {
1126 styleElement.styleSheet.cssText = css
1127 } else {
1128 while (styleElement.firstChild) {
1129 styleElement.removeChild(styleElement.firstChild)
1130 }
1131 styleElement.appendChild(document.createTextNode(css))
1132 }
1133}
1134
1135
1136/***/ }),
1137/* 10 */
1138/***/ (function(module, exports) {
1139
1140/**
1141 * Translates the list format produced by css-loader into something
1142 * easier to manipulate.
1143 */
1144module.exports = function listToStyles (parentId, list) {
1145 var styles = []
1146 var newStyles = {}
1147 for (var i = 0; i < list.length; i++) {
1148 var item = list[i]
1149 var id = item[0]
1150 var css = item[1]
1151 var media = item[2]
1152 var sourceMap = item[3]
1153 var part = {
1154 id: parentId + ':' + i,
1155 css: css,
1156 media: media,
1157 sourceMap: sourceMap
1158 }
1159 if (!newStyles[id]) {
1160 styles.push(newStyles[id] = { id: id, parts: [part] })
1161 } else {
1162 newStyles[id].parts.push(part)
1163 }
1164 }
1165 return styles
1166}
1167
1168
1169/***/ }),
1170/* 11 */
1171/***/ (function(module, __webpack_exports__, __webpack_require__) {
1172
1173"use strict";
1174Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
1175/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_uploader_vue__ = __webpack_require__(0);
1176/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_uploader_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__src_uploader_vue__);
1177/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_wechat_uploader_js__ = __webpack_require__(1);
1178/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_wechat_uploader_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__src_wechat_uploader_js__);
1179/* harmony reexport (default from non-hamory) */ __webpack_require__.d(__webpack_exports__, "Uploader", function() { return __WEBPACK_IMPORTED_MODULE_0__src_uploader_vue___default.a; });
1180/* harmony reexport (default from non-hamory) */ __webpack_require__.d(__webpack_exports__, "WechatUploader", function() { return __WEBPACK_IMPORTED_MODULE_1__src_wechat_uploader_js___default.a; });
1181
1182
1183
1184
1185/***/ })
1186/******/ ]);
1187});
\No newline at end of file