bonree-custom-utils
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -293,2 +293,9 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
// 通过import直接初始化配置 | ||
function initConfigsSync(configsData) { | ||
configs = configsData; | ||
if (configs instanceof Array && configs.length > 0) { | ||
console.log("加载配置成功"); | ||
} | ||
} | ||
// 通过key获取配置 | ||
@@ -326,2 +333,3 @@ function getConfigByKey(key) { | ||
initConfigs: initConfigs, | ||
initConfigsSync: initConfigsSync, | ||
}); | ||
@@ -328,0 +336,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:()=>g});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 p(e){var t=d(e);return t.length>0?t[0]:(console.log("未找到key为:"+e+"的配置"),null)}const g={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: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: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]}}))}))}}})(),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,(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})()})); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "bonree-custom-utils", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "bonree-custom-utils", | ||
@@ -5,0 +5,0 @@ "main": "./index.min.js", |
@@ -25,2 +25,3 @@ export interface Config { | ||
declare function initConfigs(): Promise<Config[]>; | ||
declare function initConfigsSync(configsData: any): void; | ||
declare function getConfigByKey(key: string): Config | null; | ||
@@ -40,4 +41,5 @@ declare function getImageByKey(key: string): string; | ||
initConfigs: typeof initConfigs; | ||
initConfigsSync: typeof initConfigsSync; | ||
}; | ||
export default _default; | ||
//# sourceMappingURL=index.d.ts.map |
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
45666
396