vue-authorized
Version:
2 lines • 4.08 kB
JavaScript
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["Authorized"]=t(require("vue")):e["Authorized"]=t(e["Vue"])})("undefined"!==typeof self?self:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="fb15")}({8875:function(e,t,r){var n,o,u;(function(r,i){o=[],n=i,u="function"===typeof n?n.apply(t,o):n,void 0===u||(e.exports=u)})("undefined"!==typeof self&&self,(function(){function e(){var t=Object.getOwnPropertyDescriptor(document,"currentScript");if(!t&&"currentScript"in document&&document.currentScript)return document.currentScript;if(t&&t.get!==e&&document.currentScript)return document.currentScript;try{throw new Error}catch(p){var r,n,o,u=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,i=/@([^@]*):(\d+):(\d+)\s*$/gi,c=u.exec(p.stack)||i.exec(p.stack),a=c&&c[1]||!1,f=c&&c[2]||!1,s=document.location.href.replace(document.location.hash,""),d=document.getElementsByTagName("script");a===s&&(r=document.documentElement.outerHTML,n=new RegExp("(?:[^\\n]+?\\n){0,"+(f-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),o=r.replace(n,"$1").trim());for(var l=0;l<d.length;l++){if("interactive"===d[l].readyState)return d[l];if(d[l].src===a)return d[l];if(a===s&&d[l].innerHTML&&d[l].innerHTML.trim()===o)return d[l]}return null}}return e}))},"8bbf":function(t,r){t.exports=e},fb15:function(e,t,r){"use strict";if(r.r(t),r.d(t,"setPermissions",(function(){return m})),r.d(t,"checked",(function(){return y})),"undefined"!==typeof window){var n=window.document.currentScript,o=r("8875");n=o(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:o});var u=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);u&&(r.p=u[1])}var i=r("8bbf");function c(e,t,r,n,o,u){return e.hasPerm?Object(i["renderSlot"])(e.$slots,"default",{key:0}):Object(i["renderSlot"])(e.$slots,"no-match",{key:1})}var a=Object(i["reactive"])({value:[],hasPermission:!0}),f=new Map;function s(e){if(null===e||Array.isArray(e)&&0===e.length)return a.hasPermission=!1,void f.clear();if(Array.isArray(e)){f.clear();for(var t=0;t<e.length;t++)f.set(e[t],!0);e.length>0&&(a.hasPermission=!0),a.value=e}}function d(e,t){if(void 0===t&&(t=!0),void 0===t&&(t=!0),!e)return t;if("string"===typeof e||"boolean"===typeof e||"number"===typeof e||null==e)return!!f.has(e)&&t;if(Array.isArray(e)){for(var r=0;r<e.length;r++)if(f.has(e[r]))return t;return!1}throw new Error("[vue-authorized]: unsupported parameters")}var l=Object(i["defineComponent"])({name:"Authorized",emits:["no-match"],props:{authority:[String,Array,Boolean,Number]},setup:function(e,t){var r=Object(i["ref"])(d(e.authority));return(!a.hasPermission||!r.value&&f.size>0)&&t.emit("no-match",e.authority),Object(i["watch"])((function(){return a.hasPermission}),(function(r){r||t.emit("no-match",e.authority)})),Object(i["watch"])([function(){return a.value},function(){return e.authority}],(function(){r.value=d(e.authority),r.value||t.emit("no-match",e.authority)})),{hasPerm:r}}});l.render=c;var p=l;p.setPermissions=s,p.checked=d;var m=s,y=d,h=p;t["default"]=h}})}));
//# sourceMappingURL=Authorized.umd.min.js.map