@esvndev/es-react-config-setting 1.0.72 → 1.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,11 @@ interface ISettingApp {
|
|
|
5
5
|
eventClose?: (obj: any) => void;
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
}
|
|
8
|
+
type key_format = 'text' | 'int' | 'decimal' | 'byte' | 'object';
|
|
8
9
|
|
|
9
10
|
declare const SettingApp: (props: ISettingApp) => react_jsx_runtime.JSX.Element;
|
|
10
11
|
|
|
11
12
|
declare const INIT_CONFIG_SETTING: () => void;
|
|
13
|
+
declare const get_conf: (key: string, type?: key_format) => any;
|
|
12
14
|
|
|
13
|
-
export { INIT_CONFIG_SETTING, SettingApp };
|
|
15
|
+
export { INIT_CONFIG_SETTING, SettingApp, get_conf };
|
package/dist/index.js
CHANGED
|
@@ -19035,6 +19035,54 @@ const INIT_CONFIG_SETTING = () => {
|
|
|
19035
19035
|
_FETCH_AND_UPDATE();
|
|
19036
19036
|
}, TIME_RELOAD);
|
|
19037
19037
|
};
|
|
19038
|
+
function base64ToBytesLength(base64String) {
|
|
19039
|
+
const base64 = base64String.split(',').pop() ?? '';
|
|
19040
|
+
const len = base64.length;
|
|
19041
|
+
const padding = (base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0);
|
|
19042
|
+
return Math.floor((len * 3) / 4) - padding;
|
|
19043
|
+
}
|
|
19044
|
+
//get data by key
|
|
19045
|
+
const get_conf = (key, type) => {
|
|
19046
|
+
let _ = null;
|
|
19047
|
+
if (GLOBAL_WINDOW_VARIABLE && GLOBAL_WINDOW_VARIABLE[key]) {
|
|
19048
|
+
if (type === undefined) {
|
|
19049
|
+
GLOBAL_WINDOW_VARIABLE[key].type;
|
|
19050
|
+
}
|
|
19051
|
+
switch (type) {
|
|
19052
|
+
case "text":
|
|
19053
|
+
_ = GLOBAL_WINDOW_VARIABLE[key].value;
|
|
19054
|
+
break;
|
|
19055
|
+
case "int":
|
|
19056
|
+
try {
|
|
19057
|
+
_ = parseInt(GLOBAL_WINDOW_VARIABLE[key].value);
|
|
19058
|
+
}
|
|
19059
|
+
catch (ex) { }
|
|
19060
|
+
break;
|
|
19061
|
+
case "decimal":
|
|
19062
|
+
try {
|
|
19063
|
+
_ = parseFloat(GLOBAL_WINDOW_VARIABLE[key].value);
|
|
19064
|
+
}
|
|
19065
|
+
catch (ex) { }
|
|
19066
|
+
break;
|
|
19067
|
+
case "byte":
|
|
19068
|
+
try {
|
|
19069
|
+
_ = base64ToBytesLength(GLOBAL_WINDOW_VARIABLE[key].value);
|
|
19070
|
+
}
|
|
19071
|
+
catch (ex) { }
|
|
19072
|
+
break;
|
|
19073
|
+
case "object":
|
|
19074
|
+
try {
|
|
19075
|
+
_ = JSON.parse(GLOBAL_WINDOW_VARIABLE[key].value);
|
|
19076
|
+
}
|
|
19077
|
+
catch (ex) { }
|
|
19078
|
+
break;
|
|
19079
|
+
default:
|
|
19080
|
+
_ = GLOBAL_WINDOW_VARIABLE[key].value;
|
|
19081
|
+
break;
|
|
19082
|
+
}
|
|
19083
|
+
}
|
|
19084
|
+
return _;
|
|
19085
|
+
};
|
|
19038
19086
|
const _FETCH_AND_UPDATE = () => {
|
|
19039
19087
|
GetSettingConfigClient((data) => {
|
|
19040
19088
|
try {
|
|
@@ -19075,4 +19123,5 @@ registerLicense('ORg4AjUWIQA/Gnt2VVhiQlFadVlJXmJWf1FpTGpQdk5yd19DaVZUTX1dQl9hSXl
|
|
|
19075
19123
|
|
|
19076
19124
|
exports.INIT_CONFIG_SETTING = INIT_CONFIG_SETTING;
|
|
19077
19125
|
exports.SettingApp = SettingApp;
|
|
19126
|
+
exports.get_conf = get_conf;
|
|
19078
19127
|
//# sourceMappingURL=index.js.map
|