bonree-custom-utils
Advanced tools
Comparing version 0.0.16 to 0.1.1
23
index.js
@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
root["index"] = factory(root["axios"]); | ||
})(self, function(__WEBPACK_EXTERNAL_MODULE__300__) { | ||
})(self, (__WEBPACK_EXTERNAL_MODULE__300__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
@@ -130,2 +130,15 @@ /******/ "use strict"; | ||
var configsInited = false; | ||
// 获取基础路由地址,如/cloud | ||
function getRouteBase() { | ||
// @ts-ignore | ||
if (window.routerBase) { | ||
// @ts-ignore | ||
var routerBase = window.routerBase; | ||
if (routerBase.endsWith('/')) { | ||
routerBase = routerBase.substring(0, routerBase.length - 1); | ||
} | ||
return routerBase; | ||
} | ||
return ''; | ||
} | ||
// 获取定制配置项 | ||
@@ -137,3 +150,3 @@ function getConfig(key) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, axios__WEBPACK_IMPORTED_MODULE_0___default().get("/customs/configs.json?t=" + new Date().getTime())]; | ||
case 0: return [4 /*yield*/, axios__WEBPACK_IMPORTED_MODULE_0___default().get(getRouteBase() + "/customs/configs.json?t=" + new Date().getTime())]; | ||
case 1: | ||
@@ -159,3 +172,3 @@ resp = _a.sent(); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, axios__WEBPACK_IMPORTED_MODULE_0___default().get("/customs/configs.json?t=" + new Date().getTime())]; | ||
case 0: return [4 /*yield*/, axios__WEBPACK_IMPORTED_MODULE_0___default().get(getRouteBase() + "/customs/configs.json?t=" + new Date().getTime())]; | ||
case 1: | ||
@@ -197,3 +210,3 @@ resp = _a.sent(); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, axios__WEBPACK_IMPORTED_MODULE_0___default().get("/customs/themes.json?t=" + new Date().getTime())]; | ||
case 0: return [4 /*yield*/, axios__WEBPACK_IMPORTED_MODULE_0___default().get(getRouteBase() + "/customs/themes.json?t=" + new Date().getTime())]; | ||
case 1: | ||
@@ -311,3 +324,3 @@ resp = _a.sent(); | ||
} | ||
console.log("\u672A\u627E\u5230key\u4E3A\uFF1A" + key + "\u7684\u914D\u7F6E"); | ||
console.log("\u672A\u627E\u5230key\u4E3A\uFF1A".concat(key, "\u7684\u914D\u7F6E")); | ||
return null; | ||
@@ -314,0 +327,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios")):"function"==typeof define&&define.amd?define(["axios"],t):"object"==typeof exports?exports.index=t(require("axios")):e.index=t(e.axios)}(self,(function(e){return(()=>{"use strict";var t={300:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};return(()=>{r.d(o,{default:()=>p});var e=r(300),t=r.n(e),n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,s)}c((r=r.apply(e,t||[])).next())}))},i=function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},u="customCss",s=[],c=!1;function a(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,t().get("/customs/configs.json?t="+(new Date).getTime())];case 1:return 200==(e=n.sent()).status?[2,e.data||[]]:(console.error("获取定制配置项失败,请确认public/customs/configs.json文件是否存在"),[2,[]])}}))}))}function l(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,t().get("/customs/themes.json?t="+(new Date).getTime())];case 1:return 200==(e=n.sent()).status?[2,(e.data||[]).find((function(e){return 1==e.enable}))]:(console.error("获取定制主题失败,请确认public/customs/themes.json文件是否存在"),[2,null])}}))}))}function f(e){var t;document.getElementById(u)?(t=document.getElementById(u)).href=e:((t=document.createElement("link")).rel="stylesheet",t.type="text/css",t.href=e,t.id="customCss",document.getElementsByTagName("head")[0].appendChild(t))}function d(e){return c||console.error("功能配置没有初始化"),s.filter((function(t){return t.key.startsWith(e)}))}function h(e,t){return d(e).some((function(e){var n=e.key.split("_"),r=n[n.length-1];return t(e,r)}))}function g(e){var t=d(e);return t.length>0?t[0]:(console.log("未找到key为:"+e+"的配置"),null)}const p={getConfig:function(e){return n(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,t().get("/customs/configs.json?t="+(new Date).getTime())];case 1:return 200==(n=r.sent()).status?[2,(n.data||[]).find((function(t){return t.key===e}))]:(console.error("获取定制配置项失败,请确认public/customs/configs.json文件是否存在"),[2,null])}}))}))},getConfigs:function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,a()];case 1:return[2,t.sent().filter((function(t){return null!=e.find((function(e){return t.key===e}))}))]}}))}))},getTheme:l,initTheme:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,l()];case 1:return(e=t.sent())?e.css?f(String("/"+e.css)):console.error("未构建样式或样式构建失败"):console.error("themes.json加载失败!"),[2]}}))}))},setTheme:f,getConfigsByKeyPrefix:d,getConfigByKey:g,getImageByKey:function(e){var t=g(e);if(t){var n=null==t?void 0:t.medias;if(n&&n.length>0)return window.location.origin+"/"+n[0]}return""},hasConfig:h,hasSwitchConfigOpened:function(e){return h(e,(function(e){return"1"==e.value}))},initConfigs:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,a()];case 1:return(e=t.sent()).length<=0&&console.log("没找到任何配置项"),s=e,c=!0,[2,e]}}))}))},initConfigsSync:function(e){(s=e)instanceof Array&&s.length>0&&console.log("加载配置成功")}}})(),o=o.default})()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios")):"function"==typeof define&&define.amd?define(["axios"],t):"object"==typeof exports?exports.index=t(require("axios")):e.index=t(e.axios)}(self,(e=>(()=>{"use strict";var t={300:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};return(()=>{r.d(o,{default:()=>v});var e=r(300),t=r.n(e),n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,s)}c((r=r.apply(e,t||[])).next())}))},i=function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},u="customCss",s=[],c=!1;function a(){if(window.routerBase){var e=window.routerBase;return e.endsWith("/")&&(e=e.substring(0,e.length-1)),e}return""}function l(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,t().get(a()+"/customs/configs.json?t="+(new Date).getTime())];case 1:return 200==(e=n.sent()).status?[2,e.data||[]]:(console.error("获取定制配置项失败,请确认public/customs/configs.json文件是否存在"),[2,[]])}}))}))}function f(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,t().get(a()+"/customs/themes.json?t="+(new Date).getTime())];case 1:return 200==(e=n.sent()).status?[2,(e.data||[]).find((function(e){return 1==e.enable}))]:(console.error("获取定制主题失败,请确认public/customs/themes.json文件是否存在"),[2,null])}}))}))}function d(e){var t;document.getElementById(u)?(t=document.getElementById(u)).href=e:((t=document.createElement("link")).rel="stylesheet",t.type="text/css",t.href=e,t.id="customCss",document.getElementsByTagName("head")[0].appendChild(t))}function h(e){return c||console.error("功能配置没有初始化"),s.filter((function(t){return t.key.startsWith(e)}))}function g(e,t){return h(e).some((function(e){var n=e.key.split("_"),r=n[n.length-1];return t(e,r)}))}function p(e){var t=h(e);return t.length>0?t[0]:(console.log("未找到key为:".concat(e,"的配置")),null)}const v={getConfig:function(e){return n(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,t().get(a()+"/customs/configs.json?t="+(new Date).getTime())];case 1:return 200==(n=r.sent()).status?[2,(n.data||[]).find((function(t){return t.key===e}))]:(console.error("获取定制配置项失败,请确认public/customs/configs.json文件是否存在"),[2,null])}}))}))},getConfigs:function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,l()];case 1:return[2,t.sent().filter((function(t){return null!=e.find((function(e){return t.key===e}))}))]}}))}))},getTheme:f,initTheme:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,f()];case 1:return(e=t.sent())?e.css?d(String("/"+e.css)):console.error("未构建样式或样式构建失败"):console.error("themes.json加载失败!"),[2]}}))}))},setTheme:d,getConfigsByKeyPrefix:h,getConfigByKey:p,getImageByKey:function(e){var t=p(e);if(t){var n=null==t?void 0:t.medias;if(n&&n.length>0)return window.location.origin+"/"+n[0]}return""},hasConfig:g,hasSwitchConfigOpened:function(e){return g(e,(function(e){return"1"==e.value}))},initConfigs:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,l()];case 1:return(e=t.sent()).length<=0&&console.log("没找到任何配置项"),s=e,c=!0,[2,e]}}))}))},initConfigsSync:function(e){(s=e)instanceof Array&&s.length>0&&console.log("加载配置成功")}}})(),o=o.default})())); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "bonree-custom-utils", | ||
"version": "0.0.16", | ||
"version": "0.1.1", | ||
"description": "bonree-custom-utils", | ||
@@ -5,0 +5,0 @@ "main": "./index.min.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47520
409