bonree-custom-utils
Advanced tools
Comparing version 0.0.13 to 0.0.14
13
index.js
@@ -299,4 +299,16 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
console.log("\u672A\u627E\u5230key\u4E3A\uFF1A" + key + "\u7684\u914D\u7F6E"); | ||
return null; | ||
} | ||
// 通过key获取第一张图片 | ||
function getImageByKey(key) { | ||
var config = getConfig(key); | ||
if (config) { | ||
var medias = config === null || config === void 0 ? void 0 : config.medias; | ||
if (medias && medias.length > 0) { | ||
return window.location.origin + "/" + medias[0]; | ||
} | ||
} | ||
return ""; | ||
} | ||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ | ||
@@ -310,2 +322,3 @@ getConfig: getConfig, | ||
getConfigByKey: getConfigByKey, | ||
getImageByKey: getImageByKey, | ||
hasConfig: hasConfig, | ||
@@ -312,0 +325,0 @@ hasSwitchConfigOpened: hasSwitchConfigOpened, |
@@ -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 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("/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 l(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)}))}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: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?l(String("/"+e.css)):console.error("未构建样式或样式构建失败"):console.error("themes.json加载失败!"),[2]}}))}))},setTheme:l,getConfigsByKeyPrefix:d,getConfigByKey:function(e){var t=d(e);return t.length>0?t[0]:null},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:()=>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(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])}}))}))}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/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("/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 p(e,t){return h(e).some((function(e){var n=e.key.split("_"),r=n[n.length-1];return t(e,r)}))}const g={getConfig:a,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:function(e){var t=h(e);return t.length>0?t[0]:(console.log("未找到key为:"+e+"的配置"),null)},getImageByKey:function(e){var t=a(e);if(t){var n=null==t?void 0:t.medias;if(n&&n.length>0)return window.location.origin+"/"+n[0]}return""},hasConfig:p,hasSwitchConfigOpened:function(e){return p(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]}}))}))}}})(),o=o.default})()})); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "bonree-custom-utils", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "bonree-custom-utils", | ||
@@ -5,0 +5,0 @@ "main": "./index.min.js", |
@@ -26,2 +26,3 @@ export interface Config { | ||
declare function getConfigByKey(key: string): Config | null; | ||
declare function getImageByKey(key: string): string; | ||
declare const _default: { | ||
@@ -35,2 +36,3 @@ getConfig: typeof getConfig; | ||
getConfigByKey: typeof getConfigByKey; | ||
getImageByKey: typeof getImageByKey; | ||
hasConfig: typeof hasConfig; | ||
@@ -37,0 +39,0 @@ hasSwitchConfigOpened: typeof hasSwitchConfigOpened; |
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
44371
385