UNPKG

cyl-hooks-tools

Version:

基于react上下文实现的权限管理

1 lines 5.59 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cylHooksTools=e():t.cylHooksTools=e()}(self,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=o(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,i=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){l=!0,c=t},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw c}}}}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function c(t,e){var n,r={"Y+":e.getFullYear().toString(),"m+":(e.getMonth()+1).toString(),"d+":e.getDate().toString(),"H+":e.getHours().toString(),"M+":e.getMinutes().toString(),"S+":e.getSeconds().toString()};for(var o in r)(n=new RegExp("("+o+")").exec(t))&&(t=t.replace(n[1],1==n[1].length?r[o]:r[o].padStart(n[1].length,"0")));return t}t.d(e,{default:()=>i});const i={parseJsonGraceful:function(t){try{return JSON.parse(t)}catch(t){return null}},sleep:function(t){return new Promise((function(e){return setTimeout(e,t)}))},logger:{info:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"blue",r=new Date(e);console.info("%c".concat(c("YYYY-mm-dd HH:MM:SS",r)," INFO: "),"color: ".concat(n,";"),t)},error:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"red",r=new Date(e);console.error("%c".concat(c("YYYY-mm-dd HH:MM:SS",r)," ERROR: "),"color: ".concat(n,";"),t)},warn:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"black",r=new Date(e);console.warn("%c".concat(c("YYYY-mm-dd HH:MM:SS",r)," WARN: "),"color: ".concat(n,";"),t)},log:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),n=new Date(e);console.log("".concat(c("YYYY-mm-dd HH:MM:SS",n),": "),t)},success:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"green",r=new Date(e);console.log("%c".concat(c("YYYY-mm-dd HH:MM:SS",r)," SUCCESS: "),"color: ".concat(n,";"),t)}},makeFriendly:function(t){return t>=1e8?t=Math.round(t/1e7)/10+"亿":t>=1e4&&(t=Math.round(t/1e3)/10+"万"),t},formatSeconds:function(t){if("number"!=typeof t)throw new Error("value需要number类型");var e=parseInt(t),n=0,r=0;e>60&&(n=parseInt(e/60),e=parseInt(e%60),n>60&&(r=parseInt(n/60),n=parseInt(n%60)));var o=parseInt(e)+"秒";return n>0&&(o=parseInt(n)+"分"+o),r>0&&(o=parseInt(r)+"小时"+o),o},Uint8ArrayToString:function(t){for(var e="",n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e},dataSourceSliceOfECharts:function(t,e){var o,a,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60,i=arguments.length>3?arguments[3]:void 0,l=0,u=[],f=r(t);try{var d=function(){var t=a.value;if(null==t||!t.timeStamp)throw new Error("no timeStamp"+JSON.stringify(t));var r=Math.round(t.timeStamp/1e3);if(0===l){var c;u.push([1e3*r].concat(n(null===(c=e(t,l,r))||void 0===c?void 0:c.map((function(e){return t[e]})))))}else{for(var i,f=l+1;f<r;f++){var d;u.push([1e3*f].concat(n(null===(d=e(o,f,r))||void 0===d?void 0:d.map((function(e){return t[e]})))))}u.push([1e3*r].concat(n(null===(i=e(t,l,r))||void 0===i?void 0:i.map((function(e){return t[e]})))))}l=r,o=t};for(f.s();!(a=f.n()).done;)d()}catch(t){f.e(t)}finally{f.f()}if(u.length>c)u=u.slice(u.length-c),i&&i(u,u.length-c);else if(u.length<c)for(var s=u.length;s<c;s++)l+=1,u.push([1e3*l,null]);return u},ninePath:function(t,e){var n=t.scale||2;return{"border-image-slice":"".concat(t.top," ").concat(t.right," ").concat(t.bottom," ").concat(t.left," fill"),"border-image-width":"".concat(t.top/n,"px ").concat(t.right/n,"px ").concat(t.bottom/n,"px ").concat(t.left/n,"px"),"border-image-outset":"0px 0px 0px 0px","border-image-repeat":"stretch stretch","border-image-source":"url(".concat(t.source,")"),"border-width":"".concat(e.top/n,"px ").concat(e.right/n,"px ").concat(e.bottom/n,"px ").concat(e.left/n,"px"),"border-style":"solid","box-sizing":"border-box","min-width":"".concat((t.left+t.right)/n,"px"),"min-height":"".concat((t.top+t.bottom)/n,"px")}}};return e=e.default})()));