@zhoucanyu/cc-tools
Version:
基于 Vue 自己封装的一些工具
2 lines • 18.5 kB
JavaScript
(function(e){function t(t){for(var r,i,c=t[0],u=t[1],l=t[2],s=0,f=[];s<c.length;s++)i=c[s],a[i]&&f.push(a[i][0]),a[i]=0;for(r in u)Object.prototype.hasOwnProperty.call(u,r)&&(e[r]=u[r]);d&&d(t);while(f.length)f.shift()();return o.push.apply(o,l||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],r=!0,i=1;i<n.length;i++){var c=n[i];0!==a[c]&&(r=!1)}r&&(o.splice(t--,1),e=u(u.s=n[0]))}return e}var r={},i={app:0},a={app:0},o=[];function c(e){return u.p+"js/"+({}[e]||e)+"."+{"chunk-0bedf760":"31a580ca","chunk-2d0c51a4":"d9508cfc","chunk-2d226387":"21a7f278","chunk-2d228ec3":"71fa21a9","chunk-6a1918bf":"0f629bc5","chunk-712f2df5":"1d6421e7","chunk-91da0c6c":"c0361cbb"}[e]+".js"}function u(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,u),n.l=!0,n.exports}u.e=function(e){var t=[],n={"chunk-0bedf760":1,"chunk-6a1918bf":1,"chunk-91da0c6c":1};i[e]?t.push(i[e]):0!==i[e]&&n[e]&&t.push(i[e]=new Promise(function(t,n){for(var r="css/"+({}[e]||e)+"."+{"chunk-0bedf760":"16667f35","chunk-2d0c51a4":"31d6cfe0","chunk-2d226387":"31d6cfe0","chunk-2d228ec3":"31d6cfe0","chunk-6a1918bf":"7de3d9ce","chunk-712f2df5":"31d6cfe0","chunk-91da0c6c":"18886e6c"}[e]+".css",a=u.p+r,o=document.getElementsByTagName("link"),c=0;c<o.length;c++){var l=o[c],s=l.getAttribute("data-href")||l.getAttribute("href");if("stylesheet"===l.rel&&(s===r||s===a))return t()}var f=document.getElementsByTagName("style");for(c=0;c<f.length;c++){l=f[c],s=l.getAttribute("data-href");if(s===r||s===a)return t()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=t,d.onerror=function(t){var r=t&&t.target&&t.target.src||a,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.code="CSS_CHUNK_LOAD_FAILED",o.request=r,delete i[e],d.parentNode.removeChild(d),n(o)},d.href=a;var p=document.getElementsByTagName("head")[0];p.appendChild(d)}).then(function(){i[e]=0}));var r=a[e];if(0!==r)if(r)t.push(r[2]);else{var o=new Promise(function(t,n){r=a[e]=[t,n]});t.push(r[2]=o);var l,s=document.createElement("script");s.charset="utf-8",s.timeout=120,u.nc&&s.setAttribute("nonce",u.nc),s.src=c(e),l=function(t){s.onerror=s.onload=null,clearTimeout(f);var n=a[e];if(0!==n){if(n){var r=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src,o=new Error("Loading chunk "+e+" failed.\n("+r+": "+i+")");o.type=r,o.request=i,n[1](o)}a[e]=void 0}};var f=setTimeout(function(){l({type:"timeout",target:s})},12e4);s.onerror=s.onload=l,document.head.appendChild(s)}return Promise.all(t)},u.m=e,u.c=r,u.d=function(e,t,n){u.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},u.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,t){if(1&t&&(e=u(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(u.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)u.d(n,r,function(t){return e[t]}.bind(null,r));return n},u.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return u.d(t,"a",t),t},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.p="/",u.oe=function(e){throw console.error(e),e};var l=window["webpackJsonp"]=window["webpackJsonp"]||[],s=l.push.bind(l);l.push=t,l=l.slice();for(var f=0;f<l.length;f++)t(l[f]);var d=s;o.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},"167a":function(e,t,n){},"3a0d":function(e,t,n){"use strict";var r=n("cebc"),i=n("a4bb"),a=n.n(i),o=n("5d73"),c=n.n(o),u=(n("6762"),n("2fdb"),n("96cf"),n("6b54"),n("3b8d")),l=n("a745"),s=n.n(l),f=n("75fc");n("3b2b"),n("a481"),n("7618");function d(e){return"function"===typeof e}function p(e){var t=Object.prototype.toString.call(e);return"[object File]"===t}function h(e){var t="[cc-tools-warn]";throw"".concat(t," ").concat(e)}var v=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",n=new Date(e),r={"M+":n.getMonth()+1,"d+":n.getDate(),"h+":n.getHours(),"m+":n.getMinutes(),"s+":n.getSeconds(),"q+":Math.floor((n.getMonth()+3)/3),S:n.getMilliseconds()};for(var i in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(n.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+i+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?r[i]:("00"+r[i]).substr((""+r[i]).length)));return t};function m(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return function(){clearTimeout(n),n=setTimeout(function(){return e.apply(void 0,arguments)},t)}}function g(e){var t;return(t=[]).concat.apply(t,Object(f["a"])(e.map(function(e){return s()(e)?g(e):e})))}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,n=!1;return function(){n||(e.apply(void 0,arguments),n=!0,setTimeout(function(){return n=!1},t))}}var y=function(e){var t=function t(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return r.length>=e.length?e.apply(void 0,r):function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return t.apply(void 0,r.concat(n))}};return t};function w(e){return x.apply(this,arguments)}function x(){return x=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t();case 3:return n=e.sent,e.abrupt("return",[n,null]);case 7:return e.prev=7,e.t0=e["catch"](0),e.abrupt("return",[null,!0]);case 10:case"end":return e.stop()}},e,null,[[0,7]])})),x.apply(this,arguments)}function k(e,t){d(e)&&d(t)||h("orientate函数 接受2个回调函数 你传的参数不符合函数类型"),window.addEventListener("onorientationchange"in window?"orientationchange":"resize",function(){180!==window.orientation&&0!==window.orientation?90!==window.orientation&&-90!==window.orientation||t():e()},!1)}function O(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)}function L(){var e=window.matchMedia("(orientation: portrait)");return!e.matches}function S(){return document.documentElement.scrollTop||document.body.scrollTop}function T(){var e=(new Date).getTime();window.performance&&"function"===typeof window.performance.now&&(e+=performance.now());var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)});return t}var _=["input","keydown","click"];function j(e,t,n,r){var i=null;t.$debounce=function(e){i&&clearTimeout(i),i=setTimeout(function(){return n(e)},r)},t.addEventListener(e,t.$debounce)}function M(e,t){return e.filter(function(e){return t.includes(e)})}function C(e,t,n,r){var i=!0,a=!1,o=void 0;try{for(var u,l=c()(n);!(i=(u=l.next()).done);i=!0){var s=u.value;j(s,e,t,r)}}catch(f){a=!0,o=f}finally{try{i||null==l.return||l.return()}finally{if(a)throw o}}}var E={bind:function(e,t){var n=t.value,r=t.modifiers,i=t.arg,o=i||300,u=M(_,a()(r)).filter(function(e){return"event"!==e});if(r.event)C(e,n,u,o);else{e.$debounce=m(n,o);var l=!0,s=!1,f=void 0;try{for(var d,p=c()(u);!(l=(d=p.next()).done);l=!0){var h=d.value;e.addEventListener(h,e.$debounce)}}catch(v){s=!0,f=v}finally{try{l||null==p.return||p.return()}finally{if(s)throw f}}}},unbind:function(e,t){var n=t.modifiers,r=M(_,a()(n)).filter(function(e){return"event"!==e}),i=!0,o=!1,u=void 0;try{for(var l,s=c()(r);!(i=(l=s.next()).done);i=!0){var f=l.value;e.removeEventListener(f,e.$debounce)}}catch(d){o=!0,u=d}finally{try{i||null==s.return||s.return()}finally{if(o)throw u}}}},P={true:"visible",false:"hidden"},R={inserted:function(e,t){var n=t.value;e.style.visibility=P[n]},update:function(e,t){var n=t.value;e.style.visibility=P[n]}};n("c5f6"),n("7514");function N(e){var t=a()(e),n=t.find(function(e){return!isNaN(Number(e))}),r=t.find(function(e){return isNaN(Number(e))});return{num:n?Number(n):120,color:r||"red"}}var $={inserted:function(e,t){var n=t.value,r=t.modifiers,i=N(r),a=i.num,o=i.color,c='\n ...<span id=key style="color:'.concat(o,';cursor:pointer">全文</span> \n '),u=e.innerHTML.substring(0,a)+c;e.innerHTML=u;var l=document.getElementById("key");l.onclick=n}},A=n("e814"),D=n.n(A),F=null,U={bind:function(e,t){var n=t.value,r=B(n),i="刚刚"===r||-1!==r.indexOf("小时前")||-1!==r.indexOf("分钟前");e.innerText=r,i&&(F=setInterval(function(){var t=B(n);e.innerText=t},3e5))},update:function(e,t){var n=t.value,r=B(n),i="刚刚"===r||-1!==r.indexOf("小时前")||-1!==r.indexOf("分钟前");e.innerText=r,i&&(F=setInterval(function(){var t=B(n);e.innerText=t},3e5))},unbind:function(){clearInterval(F)}};function I(e){return(1==String(e).length?"0":"")+e}function B(e){var t=D()((new Date).getTime()/1e3),n=t-e,r=new Date(1e3*t),i=new Date(1e3*e),a=i.getFullYear(),o=i.getMonth()+1,c=i.getDate(),u=i.getHours(),l=i.getMinutes();i.getSeconds();return n<60?"刚刚":n<3600?Math.floor(n/60)+"分钟前":n<86400?Math.floor(n/3600)+"小时前":86400<n&&n<172800?"一天前":r.getFullYear()==a?I(o)+"-"+I(c)+" "+I(u)+":"+I(l):a+"-"+I(o)+"-"+I(c)}var H=function(e){e.directive("debounce",E),e.directive("visibility",R),e.directive("text-hide",$),e.directive("time",U)},z=(n("7f7f"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{staticClass:"cc-uploader-warpper"},[n("div",{staticClass:"cc-file-list-warpper"},[n("transition-group",{staticClass:"cc-file-list-item-warpper",attrs:{name:"list-complete"}},[n("div",{key:"cc-uploader",staticClass:"cc-file-list-item"},[this.fileList.length<e.limit?n("div",{staticClass:"cc-file-uploader-warpper",style:e.style},[n("input",{staticClass:"cc-file-uploader",style:e.style,attrs:{accept:e.accept,type:"file"},on:{change:e.handlerUpload}}),n("div",{staticClass:"cc-upload"},[n("div",{staticClass:"add-icon"},[e._v("+")]),e.text?n("div",{staticStyle:{"font-size":"12px"},domProps:{textContent:e._s(e.text)}}):e._e()])]):e._e()]),e._l(e.fileList,function(t,r){return n("div",{key:t.uuid,staticClass:"cc-file-list-item"},[n("div",{staticClass:"cc-file-list-item-img-warpper",style:e.style},[n("div",{staticClass:"cc-file-action-warpper"},[n("i",{staticClass:"el-icon-view",on:{click:function(t){return e.preview(r)}}}),n("i",{staticClass:"el-icon-delete",on:{click:function(t){return e.remove(r)}}})]),100===t.percentage?n("transition",{attrs:{name:"fade"}},[n("img",{attrs:{src:t.url,alt:t.uuid}})]):n("transition",{attrs:{name:"fade"}},[n("div",{staticClass:"progress-warpper"},[n("Progress",{attrs:{type:"circle",width:e.width-10,percentage:t.percentage}})],1)])],1)])})],2)],1)])])}),Y=[],q=(n("6b30"),n("450d"),n("c284")),J=n.n(q);n("34ef"),n("4917"),n("28a5"),n("795b");function K(e,t){var n=new Image;n.onload=t,n.src=e}var V=n("bc3a"),G=n.n(V),Q=G.a.create();function W(e,t){return X.apply(this,arguments)}function X(){return X=Object(u["a"])(regeneratorRuntime.mark(function e(t,n){var r,i,a,o,c,u=arguments;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return r=u.length>2&&void 0!==u[2]?u[2]:function(){},i=new FormData,a=T(),o="".concat(n.dir).concat(a),i.append("OSSAccessKeyId",n.app_id),i.append("name",a),i.append("policy",n.policy),i.append("Signature",n.signature),i.append("key",o),i.append("region",n.region),i.append("dir",n.dir),i.append("success_action_status","200"),i.append("file",t,a),c="".concat(n.showurl,"/").concat(o),e.prev=14,e.next=17,Q.post(n.showurl,i,{onUploadProgress:r});case 17:return e.abrupt("return",{uuid:a,url:c,err:null});case 20:return e.prev=20,e.t0=e["catch"](14),console.log("上传OSS失败",e.t0),e.abrupt("return",{err:e.t0});case 24:case"end":return e.stop()}},e,null,[[14,20]])})),X.apply(this,arguments)}var Z={name:"CcUploader",components:{Progress:J.a},props:{text:{type:String,default:""},width:{type:[Number,String],default:100},list:{type:Array,default:function(){return[]}},accept:{type:String,default:".jpg,.jpeg,.png"},limit:{type:Number,default:6},ossOpts:{type:Object,default:null},beforeUpload:{type:Function,default:function(e){return e}},beforeRemove:{type:Function,default:function(){return!0}},onPreview:{type:Function,default:function(){}},onSuccess:{type:Function,default:function(){}},onError:{type:Function,default:function(){}}},data:function(){return{fileList:[]}},created:function(){this.init()},computed:{style:function(){return{width:"".concat(this.width,"px"),height:"".concat(this.width,"px")}}},methods:{init:function(){this.fileList=this.list.map(function(e){return{uuid:T(),percentage:100,url:e}})},remove:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.beforeRemove(Object(r["a"])({},this.fileList[t]),t);case 2:if(n=e.sent,n){e.next=5;break}return e.abrupt("return");case 5:this.fileList.splice(t,1);case 6:case"end":return e.stop()}},e,this)}));function t(t){return e.apply(this,arguments)}return t}(),preview:function(e){var t=this.fileList[e];this.onPreview(Object(r["a"])({},t),e)},handlerBeforeUpload:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.beforeUpload(t);case 3:if(n=e.sent,!p(n)){e.next=6;break}return e.abrupt("return",n);case 6:return h("beforeUpload 返回的结果不是一个有效的file对象"),e.abrupt("return",!1);case 10:return e.prev=10,e.t0=e["catch"](0),h("beforeUolader ".concat(e.t0)),e.abrupt("return",!1);case 14:case"end":return e.stop()}},e,this,[[0,10]])}));function t(t){return e.apply(this,arguments)}return t}(),handlerUpload:function(){var e=Object(u["a"])(regeneratorRuntime.mark(function e(t){var n,r,i,a,o,c,u=this;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return n=t.target.files,r=n[0],t.target.value="",e.next=5,this.handlerBeforeUpload(r);case 5:if(i=e.sent,i){e.next=8;break}return e.abrupt("return");case 8:if(this.ossOpts){e.next=10;break}return e.abrupt("return");case 10:return a=T(),this.fileList=[].concat(Object(f["a"])(this.fileList),[{uuid:a,url:"",percentage:0}]),e.next=14,this.$nextTick();case 14:return e.next=16,W(i,this.ossOpts,function(e){var t=e.loaded/e.total*60|0;u.fileList[u.fileList.length-1].percentage=t});case 16:if(o=e.sent,!o.err){e.next=21;break}return this.onError(o.err,i),setTimeout(function(){u.fileList.pop()},2e3),e.abrupt("return");case 21:c=setInterval(function(){u.fileList[u.fileList.length-1].percentage>=95?clearInterval(c):u.fileList[u.fileList.length-1].percentage=u.fileList[u.fileList.length-1].percentage+1},500),K(o.url,function(){clearInterval(c),u.fileList[u.fileList.length-1].url=o.url,u.fileList[u.fileList.length-1].percentage=100,u.onSuccess(o.url,i)});case 23:case"end":return e.stop()}},e,this)}));function t(t){return e.apply(this,arguments)}return t}()},watch:{list:function(e){this.init()}}},ee=Z,te=(n("cfa9"),n("2877")),ne=Object(te["a"])(ee,z,Y,!1,null,"72f8f5de",null),re=ne.exports;re.install=function(e){e.component(re.name,re)};var ie=re,ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return!e.isMobile||e.show?n("div",{staticClass:"mask",on:{touchmove:function(e){e.preventDefault()}}},[n("div",{staticClass:"title"},[e._v(e._s(e.txt))])]):e._e()},oe=[],ce={data:function(){return{show:!1,scrollTop:0}},methods:{handlerHorizontalScreen:function(){this.scrollTop=S(),window.scrollTo(0,0),this.show=!0},handlerVerticalScreen:function(){this.show=!1,window.scrollTo(0,this.scrollTop)}},created:function(){k(this.handlerVerticalScreen,this.handlerHorizontalScreen),!this.isMobile&&(document.body.parentNode.style.overflowY="hidden")},computed:{isMatches:L,isMobile:O,txt:function(){return this.isMobile?(this.isMatches,"请竖屏显示"):"请在移动端打开页面"}}},ue=ce,le=(n("fc63"),Object(te["a"])(ue,ae,oe,!1,null,"67e07df4",null)),se=le.exports,fe=function(e){var t=e.extend(se),n=new t({el:document.createElement("div")});document.body.appendChild(n.$el)};n.d(t,"b",function(){return de}),n.d(t,"a",function(){return ve}),n.d(t,"g",function(){return w}),n.d(t,"c",function(){return y}),n.d(t,"h",function(){return b}),n.d(t,"f",function(){return g}),n.d(t,"d",function(){return m});var de=function(){return n.e("chunk-91da0c6c").then(n.bind(null,"2eaa"))},pe={media:!1},he=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};H(e);var n=Object(r["a"])({},pe,{},t);n.media&&fe(e),e.filter("dateFormate",v)},ve=ie;t["e"]={install:he,CcUploader:ie}},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var r=n("2b0e"),i=n("3a34"),a=n.n(i),o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("div",{attrs:{id:"nav"}},e._l(e.routes,function(t){return n("router-link",{key:t.path,attrs:{to:t.path}},[e._v("\n "+e._s(t.name)+"\n ")])}),1),n("keep-alive",[n("router-view")],1)],1)},c=[],u=[{path:"/",name:"主页",component:function(){return n.e("chunk-712f2df5").then(n.bind(null,"bb51"))}},{path:"/debounce",name:"函数防抖",component:function(){return n.e("chunk-0bedf760").then(n.bind(null,"bae4"))}},{path:"/text-hide",name:"文本隐藏",component:function(){return n.e("chunk-6a1918bf").then(n.bind(null,"8fc8"))}},{path:"/tree-menu",name:"树形导航",component:function(){return n.e("chunk-2d228ec3").then(n.bind(null,"daf6"))}},{path:"/time",name:"时间指令",component:function(){return n.e("chunk-2d0c51a4").then(n.bind(null,"3e51"))}},{path:"/uploader",name:"图片上传",component:function(){return n.e("chunk-2d226387").then(n.bind(null,"e875"))}}],l={data:function(){return{routes:u}}},s=l,f=(n("bdfd"),n("2877")),d=Object(f["a"])(s,o,c,!1,null,"3d65d070",null),p=d.exports,h=n("8c4f");r["a"].use(h["a"]);var v=new h["a"]({mode:"history",base:"/",routes:u}),m=n("3a0d");r["a"].use(m["e"]),r["a"].config.productionTip=!1,new a.a,new r["a"]({router:v,render:function(e){return e(p)}}).$mount("#app")},"882a":function(e,t,n){},a854:function(e,t,n){},bdfd:function(e,t,n){"use strict";var r=n("a854"),i=n.n(r);i.a},cfa9:function(e,t,n){"use strict";var r=n("167a"),i=n.n(r);i.a},fc63:function(e,t,n){"use strict";var r=n("882a"),i=n.n(r);i.a}});
//# sourceMappingURL=app.00a5f98a.js.map