UNPKG

aos-element

Version:

A Component Library for Vue.js.

673 lines (626 loc) 18.5 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/dist/"; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 207); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; }); /* globals __VUE_SSR_CONTEXT__ */ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). // This module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle. function normalizeComponent ( scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, /* server only */ shadowMode /* vue-cli only */ ) { // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (render) { options.render = render options.staticRenderFns = staticRenderFns options._compiled = true } // functional template if (functionalTemplate) { options.functional = true } // scopedId if (scopeId) { options._scopeId = 'data-v-' + scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || // cached call (this.$vnode && this.$vnode.ssrContext) || // stateful (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__ } // inject component styles if (injectStyles) { injectStyles.call(this, context) } // register component module identifier for async chunk inferrence if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier) } } // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook } else if (injectStyles) { hook = shadowMode ? function () { injectStyles.call( this, (options.functional ? this.parent : this).$root.$options.shadowRoot ) } : injectStyles } if (hook) { if (options.functional) { // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook // register for functional component in vue file var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) return originalRender(h, context) } } else { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } } return { exports: scriptExports, options: options } } /***/ }), /***/ 14: /***/ (function(module, exports) { module.exports = require("aos-element/lib/utils/popup"); /***/ }), /***/ 207: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/aos-upload/src/main.vue?vue&type=template&id=d5103414& var render = function() { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { staticClass: "aos-upload" }, [ _vm.edit ? _c( "el-upload", { ref: "aosUpload", attrs: { action: _vm.action, multiple: _vm.multiple, data: _vm.data, name: _vm.name, limit: _vm.limit, "on-exceed": _vm.onExceed, "show-file-list": _vm.showFileList, "file-list": _vm.fileList, "auto-upload": _vm.autoUpload, "http-request": _vm.httpRequest, drag: "", "before-upload": _vm.beforeUpload, "before-remove": _vm.beforeRemove, "on-success": _vm.onSuccess, "on-remove": _vm.onRemove, "on-error": _vm.onError, "on-progress": _vm.onProgress, "on-change": _vm.onChange, disabled: _vm.disabled, "on-preview": _vm.handlePreviewClick } }, [ _c("div", [ _c("i", { staticClass: "el-icon-upload" }), _c("div", { staticClass: "el-upload__text" }, [ _vm._v("将文件拖到此处,或"), _c("em", [_vm._v("点击上传")]) ]) ]) ] ) : _vm._e(), !_vm.edit ? _c( "div", { staticStyle: { padding: "10px 5px" } }, _vm._l(_vm.fileList, function(ele, index) { return _c( "div", { key: index, staticClass: "aos-upload__view", on: { click: function($event) { $event.stopPropagation() _vm.handlePreviewClick(ele) } } }, [ _c("i", { staticClass: "el-icon-document" }), _c("span", { staticStyle: { "margin-left": "10px" } }, [ _vm._v(_vm._s(ele.name)) ]) ] ) }), 0 ) : _vm._e(), _c( "el-dialog", { attrs: { title: "播放器", visible: _vm.showVideDialog, "append-to-body": "", "destroy-on-close": "", width: "30%" }, on: { "update:visible": function($event) { _vm.showVideDialog = $event }, close: _vm.handleVideoClose } }, [ _c( "div", { staticClass: "aos-upload__video" }, [ _c("aos-video", { ref: "aos-upload__video", attrs: { options: _vm.videoOptions } }) ], 1 ) ] ) ], 1 ) } var staticRenderFns = [] render._withStripped = true // CONCATENATED MODULE: ./packages/aos-upload/src/main.vue?vue&type=template&id=d5103414& // EXTERNAL MODULE: external "viewerjs-optimize" var external_viewerjs_optimize_ = __webpack_require__(29); var external_viewerjs_optimize_default = /*#__PURE__*/__webpack_require__.n(external_viewerjs_optimize_); // EXTERNAL MODULE: external "aos-element/lib/utils/popup" var popup_ = __webpack_require__(14); // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/aos-upload/src/main.vue?vue&type=script&lang=js& var _props; // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var mainvue_type_script_lang_js_ = ({ name: "AosUpload", data: function data() { return { copyData: {}, showVideDialog: false, videoOptions: {}, videoFileTypeList: ["mp4", "webm", "mov", "flv", "mp3", "wav", "ogg"], imgFileTypeList: ["png", "jpg", "jpeg", "gif", "tif", "tiff", "bmp", "svg", "webp", "ico"], viewer: "", currentContainer: "", currentContainerId: "" }; }, watch: { data: { handler: function handler(val) { if (val) { this.copyData = this.$_.cloneDeep(val); } else { this.copyData = {}; } }, immediate: true, deep: true } }, props: (_props = { //必选参数,上传的地址 action: { type: String, require: true }, //是否支持多选文件 multiple: { type: Boolean, default: false }, //是否编辑状态 edit: { type: Boolean, default: true }, //上传时附带的额外参数 data: { type: Object }, //上传的文件字段名 name: { type: String, default: "file" }, //最大允许上传个数 limit: { type: Number }, //文件超出个数限制时的钩子 onExceed: { type: Function }, //是否显示已上传文件列表 showFileList: { type: Boolean, default: true }, //是否在选取文件后立即进行上传 autoUpload: { type: Boolean, default: true }, //覆盖默认的上传行为,可以自定义上传的实现 httpRequest: { type: Function }, //上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传。 beforeUpload: { type: Function }, //删除文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止删除。 beforeRemove: { type: Function }, //文件上传成功时的钩子 onSuccess: { type: Function }, //文件列表移除文件时的钩子 onRemove: { type: Function }, //文件上传失败时的钩子 onError: { type: Function }, //文件上传时的钩子 onProgress: { type: Function }, //文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用 onChange: { type: Function }, //是否禁用 disabled: { type: Boolean, default: false }, fileList: { type: Array, default: [] } }, _props["edit"] = { type: Boolean, default: true }, _props), beforeDestroy: function beforeDestroy() { if (this.viewer) { this.viewer = null; } this.removeContainer(); }, components: {}, methods: { handlePreviewClick: function handlePreviewClick(file) { if (file) { var fileSuffix = file.name.split(".")[1].toLowerCase(); if (this.videoFileTypeList.indexOf(fileSuffix) > -1) { this.handleViewVideo(file, fileSuffix); } else if (fileSuffix.indexOf("pdf") > -1) { this.handleViewPdf(file); } else if (this.imgFileTypeList.indexOf(fileSuffix) > -1) { this.handleViewerImg(file); } else { this.handleDownloadFile(file); } } }, handleViewVideo: function handleViewVideo(item, data) { this.showVideDialog = true; this.videoOptions = { width: 400, sources: [{ src: item.url, type: "video/" + data }] }; }, handleVideoClose: function handleVideoClose() { this.$refs["aos-upload__video"].destory(); }, handleViewPdf: function handleViewPdf(item) { this.$openPdfViewer(item.url); }, handleDownloadFile: function handleDownloadFile(item) { var _this = this; var fileName = item.name; this.$http({ url: item.url, responseType: "blob" }).then(function (res) { _this.download(res.data, fileName); }); }, download: function download(blob, name) { var a = document.createElement("a"); var url = window.URL.createObjectURL(blob); a.href = url; a.download = name; document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(url); document.body.removeChild(a); }, handleViewerImg: function handleViewerImg(item) { //this.removeContainer(item.uid); aosUploadId this.removeContainer(item.id); var container = this.currentContainer; if (this.viewer) { this.viewer.destroy(); this.viewer = null; } if (!this.currentContainerId || this.currentContainer && this.currentContainer !== item.id) { container = this.createImgList(item, item.id); } this.currentContainerId = item.id; this.currentContainer = container; this.viewer = new external_viewerjs_optimize_default.a(document.getElementById("aos-upload-" + this.currentContainerId), { className: "aos-img-viewer-container " + ("aos-upload-" + this.currentContainerId), zIndex: popup_["PopupManager"].nextZIndex() + 101 }); container.children[0].click(); }, createImgList: function createImgList(item, id) { var container = document.createElement("div"); container.id = "aos-upload-" + id; container.style.position = "absolute"; container.style.top = "-10000px"; container.style.left = "-10000px"; if (item) { var imgItem = document.createElement("img"); imgItem.src = item.url; imgItem.alt = item.name; imgItem.title = item.name; container.appendChild(imgItem); } document.body.appendChild(container); return container; }, removeContainer: function removeContainer(id) { var dom = document.getElementById("aos-upload-" + this.currentContainerId); if (!id) { if (dom) { document.body.removeChild(dom); } } else if (this.currentContainerId && this.currentContainerId !== id) { if (dom) { document.body.removeChild(dom); } } else { if (dom) { document.body.removeChild(dom); } } } } }); // CONCATENATED MODULE: ./packages/aos-upload/src/main.vue?vue&type=script&lang=js& /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(0); // CONCATENATED MODULE: ./packages/aos-upload/src/main.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( src_mainvue_type_script_lang_js_, render, staticRenderFns, false, null, null, null ) /* hot reload */ if (false) { var api; } component.options.__file = "packages/aos-upload/src/main.vue" /* harmony default export */ var main = (component.exports); // CONCATENATED MODULE: ./packages/aos-upload/index.js main.install = function (Vue) { Vue.component(main.name, main); }; /* harmony default export */ var aos_upload = __webpack_exports__["default"] = (main); /***/ }), /***/ 29: /***/ (function(module, exports) { module.exports = require("viewerjs-optimize"); /***/ }) /******/ });