@lm_fe/utils 0.1.201 → 0.2.5

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/types.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import dayjs, { ConfigType, QUnitType, OpUnitType, Dayjs as Dayjs$1 } from 'dayjs';
2
2
  export { default as dayjs } from 'dayjs';
3
+ import * as axios from 'axios';
3
4
  import { AxiosRequestConfig, AxiosError, AxiosResponse, AxiosInstance } from 'axios';
5
+ export { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
4
6
  import ReconnectingWebSocket from 'reconnecting-websocket';
5
7
  import { FC } from 'react';
8
+ import { FormInstance } from 'antd';
6
9
 
7
10
  interface ICommonOption {
8
11
  value?: any;
9
12
  label?: string;
13
+ tip?: string;
10
14
  prefix?: string;
11
15
  sufix?: string;
12
16
  suffix?: string;
@@ -18,6 +22,7 @@ interface ICommonOption {
18
22
  id?: any;
19
23
  text?: any;
20
24
  code?: any;
25
+ disabled?: boolean;
21
26
  }
22
27
 
23
28
  type PropertyKey$1 = string | number | symbol;
@@ -705,7 +710,7 @@ declare const isPromise: (value: any) => value is Promise<any>;
705
710
  declare const isEmpty: (value: any) => boolean;
706
711
  declare const isEqual: <TType>(x: TType, y: TType) => boolean;
707
712
 
708
- declare function get<T = any>(value: T, path: string, defaultValue?: T | undefined): T;
713
+ declare function get<T = any>(value: any, path: string, defaultValue?: T | undefined): T;
709
714
  declare function identity<T>(value: T): T;
710
715
  declare function isBoolean(value: any): value is boolean;
711
716
  declare function isObjectLike(value: any): boolean;
@@ -737,8 +742,9 @@ declare function unicodeToChar(u: number): string | null;
737
742
  declare function unicode_to_UTF8(u: number): number[] | null;
738
743
  declare function getFilledArray(n: number): any[];
739
744
  declare function copyText(text: string): boolean;
745
+ declare function dyn_cb<T>(cb: (ctx: T) => void, g_ctx: () => T): boolean;
740
746
  declare function safeExec<T extends (...args: any) => any>(fn?: T, ...args: Parameters<T>): any;
741
- declare function safeGetFromFuncOrData(fn: any): any;
747
+ declare function safeGetFromFuncOrData(fn: any, default_v?: any): any;
742
748
  declare function numberLikeCompare(a: number | string | boolean | null, b: number | string | boolean | null): boolean;
743
749
  declare function warpBase64Type(str: string, type: 'img' | 'pdf'): string;
744
750
  declare function safe_number_parse(value: any, defaultValue?: number): number;
@@ -762,6 +768,7 @@ declare function simple_decrypt(code: number[]): AnyObject | null;
762
768
  declare function simple_encrypt_str(data: string, sp?: string): string | null;
763
769
  declare function simple_decrypt_str(code: string, sp?: string): string | null;
764
770
  declare function text_ellipsis(text: string, max: number): string;
771
+ declare function calc_number(data: AnyObject | any[] | number | string | boolean): number;
765
772
 
766
773
  interface ILL {
767
774
  log?(...optionalParams: any[]): void;
@@ -863,7 +870,7 @@ declare function isMoment(m: any): boolean;
863
870
  */
864
871
  declare function getFutureDate(num: number): any;
865
872
  declare function dayjs_quarter(input: Dayjs, which_quarter?: number): [Dayjs, number];
866
- declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): any;
873
+ declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): number;
867
874
 
868
875
  interface ISpectialOption {
869
876
  sp?: ICommonOption[];
@@ -983,6 +990,7 @@ declare function makeEventStore<T extends AnyObject>(key?: string, data?: T): TE
983
990
 
984
991
  declare class AppEnv<T = string> {
985
992
  static get singleton(): AppEnv;
993
+ static get client_mode(): boolean;
986
994
  _appName?: T;
987
995
  _globalCache: {
988
996
  [x: string]: any;
@@ -995,8 +1003,11 @@ declare class AppEnv<T = string> {
995
1003
  pop_global_cache(k: string): AnyObject | undefined;
996
1004
  _isDev?: boolean;
997
1005
  is(type: T): boolean;
1006
+ not(type: T): boolean;
998
1007
  in(types: T[]): boolean;
999
1008
  get isSp(): boolean;
1009
+ get is_single(): boolean;
1010
+ get is_new(): (string | boolean)[];
1000
1011
  get isDev(): boolean;
1001
1012
  set isDev(value: boolean);
1002
1013
  get appName(): T | undefined;
@@ -1006,15 +1017,15 @@ declare class AppEnv<T = string> {
1006
1017
  get tokenKey(): string;
1007
1018
  get loginRememberKey(): string;
1008
1019
  constructor(appName?: T);
1009
- get loginRemember(): AnyObject | undefined | null;
1010
- set loginRemember(value: AnyObject | undefined | null);
1020
+ get loginRemember(): AnyObject<any> | null;
1021
+ set loginRemember(value: AnyObject<any> | null);
1011
1022
  get token(): string | null;
1012
1023
  set token(value: string | null);
1013
1024
  get rawToken(): string | string[];
1014
- reload(path?: string): void;
1025
+ reload(path?: string | URL): void;
1015
1026
  open(url?: string | URL, target?: string, features?: string): Window | null;
1016
- logout(path?: string): void;
1017
- logout_clean(path?: string): void;
1027
+ logout(path?: string | URL): void;
1028
+ logout_clean(path?: string | URL): void;
1018
1029
  getToken(): string | null;
1019
1030
  getTokenFromSearchParam(): string | null;
1020
1031
  setTokenToSearchParam(url: URL): URL;
@@ -1049,12 +1060,13 @@ type TRequest_SimpleReq = <T = any, R = AxiosResponse<T>, D = any>(url: string,
1049
1060
  type TRequest_PreReq = <T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: IRequest_AxiosRequestConfig<D>) => Promise<R>;
1050
1061
 
1051
1062
  declare class Request extends EventEmitter<{
1052
- beforeRequest: any;
1053
- afterResponse: any;
1054
- responseErr: any;
1063
+ request: any;
1064
+ response: any;
1065
+ error: any;
1055
1066
  message: [boolean, string, any];
1056
1067
  }> {
1057
1068
  ins: AxiosInstance;
1069
+ token?: string;
1058
1070
  constructor(config?: IRequest_SpawnConfig);
1059
1071
  static CONFIG: {
1060
1072
  successCode: number[];
@@ -1072,11 +1084,12 @@ declare class Request extends EventEmitter<{
1072
1084
  }>): any;
1073
1085
  static getRemoteMessage(res?: AxiosResponse<any>): any;
1074
1086
  static getHeaderMessage(res?: AxiosResponse<any>): string | undefined;
1075
- displayMsg(res: AxiosResponse<{
1087
+ displayMsg(res?: AxiosResponse<{
1076
1088
  data?: any;
1077
1089
  code?: number;
1078
1090
  msg?: string;
1079
1091
  }>): void;
1092
+ config: IRequest_SpawnConfig;
1080
1093
  spawn(spawnConfig?: IRequest_SpawnConfig): AxiosInstance;
1081
1094
  gen(spawnConfig?: IRequest_SpawnConfig): AxiosInstance;
1082
1095
  get: TRequest_SimpleReq;
@@ -1085,6 +1098,15 @@ declare class Request extends EventEmitter<{
1085
1098
  post: TRequest_PreReq;
1086
1099
  put: TRequest_PreReq;
1087
1100
  }
1101
+ declare const request: Request;
1102
+
1103
+ type T_FETCH_OPTIONS = ((f?: FormInstance) => (Promise<ICommonOption[]> | ICommonOption[])) | {
1104
+ url: string | (() => string);
1105
+ labelKey?: string;
1106
+ valueKey?: string;
1107
+ method?: 'get' | 'post';
1108
+ };
1109
+ declare function safe_fetch_options(cb: T_FETCH_OPTIONS, f?: FormInstance): Promise<ICommonOption[]>;
1088
1110
 
1089
1111
  declare const codeMessage: {
1090
1112
  200: string;
@@ -1104,8 +1126,9 @@ declare const codeMessage: {
1104
1126
  504: string;
1105
1127
  };
1106
1128
 
1107
- declare const request: Request;
1108
- declare const rawRequest: AxiosInstance;
1129
+ declare function createInstance(defaultConfig?: {}): AxiosInstance;
1130
+
1131
+ declare const rawRequest: axios.AxiosInstance;
1109
1132
  declare const asRequest: Request;
1110
1133
  declare const fubaoRequest: Request;
1111
1134
 
@@ -1135,6 +1158,10 @@ declare function formatRangeDateTime(data: {
1135
1158
  }, cKeys?: string[]): {
1136
1159
  [x: string]: string | null;
1137
1160
  };
1161
+ declare function diff_hour_minute(inputA: any, inputB: any): {
1162
+ h: number;
1163
+ m: number;
1164
+ };
1138
1165
 
1139
1166
  declare class Event {
1140
1167
  target: any;
@@ -1184,55 +1211,23 @@ declare class BaseWsService<T = any> extends EventEmitter<{
1184
1211
  }
1185
1212
 
1186
1213
  declare function getTimeSlice(hour?: number, isShowSecond?: boolean): string[];
1214
+ declare function is_fuck_abnormal(conf?: {
1215
+ isNormal?: 'true' | 'false' | null;
1216
+ }): boolean;
1187
1217
 
1188
1218
  /**
1189
1219
  * 计算BMI
1190
1220
  */
1191
- declare function getBMI(weight: number, height: number): string | 0;
1192
- /**
1193
- * 计算孕周
1194
- * gesDate:预产期-B超
1195
- * date:产检/报告日期
1196
- */
1197
- declare function getGesWeek(gesDate: string, date: string): string;
1198
- /**
1199
- * 计算停经孕周
1200
- * @param checkData 当前日期
1201
- * @param lmp 末次月经
1202
- * @returns
1203
- */
1204
- declare const menopauseWeek: (checkData: string, lmp: string) => string;
1205
- /**
1206
- * 计算孕周对应的天数
1207
- */
1208
- declare function getGestationalDays(gestationalWeek: string): number;
1221
+ declare function getBMI(weight: number, height: number): number;
1222
+ declare const calc_bmi: typeof getBMI;
1209
1223
  /**
1210
1224
  * 获取本周五、下周五、下下周五时间
1211
1225
  */
1212
1226
  declare function getOrderTime(orderDate: '本周五' | '下周五' | '下下周五'): dayjs.Dayjs;
1213
- /**
1214
- * 根据末次月经计算预产期B超
1215
- */
1216
- declare function getExpected(date: string): string;
1217
1227
  /**
1218
1228
  * 计算两个日期相隔的年数
1219
1229
  */
1220
- declare function getDiffYears(date: string, preDate: string): number;
1221
- /**
1222
- * 获取两个字符串日期 YYYY-MM-dd 间隔的天数
1223
- * 始终返回一个正数
1224
- */
1225
- declare const getDays: (str1: string, str2: string) => number;
1226
- /**
1227
- * 根据 预产期B超 日期获取孕周
1228
- * 得出 ${孕周周数}+${孕周天数}
1229
- * 预产期B超
1230
- */
1231
- declare const getGestationalWeekBySureEdd: (sureEdd: string) => string;
1232
- /**
1233
- * 根据末次月经计算预产期B超
1234
- */
1235
- declare function calEddByLmp(lmp: Dayjs$1): dayjs.Dayjs;
1230
+ declare function getDiffYears(a: string, b: string): number;
1236
1231
  /**根据出生日期计算年龄 */
1237
1232
  declare function GetAgeByBirthDay(strBirthday: string): number | null;
1238
1233
  declare const getDataSource: (url: string, params: object, processFromApi?: (v: any) => any) => Promise<{
@@ -1243,18 +1238,18 @@ declare function gen_id_form_item_config(name?: string): {
1243
1238
  inputType: "id";
1244
1239
  dataIndex: string;
1245
1240
  name: string;
1241
+ form_hidden: boolean;
1246
1242
  };
1247
- declare const calGestationalWeekByLmp: (lmp: Dayjs$1, defaultDate?: dayjs.Dayjs) => string;
1248
- declare const calGestationalWeekBySureEdd: (sureEdd: any, defaultDate?: dayjs.Dayjs) => string | number;
1249
1243
  declare function format_gp(data: {
1250
1244
  gravidity?: any;
1251
1245
  parity?: any;
1252
1246
  }): string;
1253
- declare function unmarshalGestationWeek(weekStr?: string): {
1254
- week: number;
1247
+ declare function unmarshal_gestationWeek(weekStr?: string): {
1255
1248
  day: number;
1256
- };
1257
- declare function marshalGestationWeek(week?: string | number, day?: string | number): string;
1249
+ days: number;
1250
+ week: number;
1251
+ } | null;
1252
+ declare function marshal_gestationWeek(week?: string | number, day?: string | number): string;
1258
1253
 
1259
1254
  declare const Browser: {
1260
1255
  client: {
@@ -1299,5 +1294,42 @@ declare function temp_reander(config: {
1299
1294
  exclusive?: boolean;
1300
1295
  }): () => void;
1301
1296
 
1302
- export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, AppEnv, BaseWsService, Browser, EMPTY_PLACEHOLDER, EnumItem, EventBus, EventEmitter, EventEmitter_Old, GetAgeByBirthDay, MyLog, ROMAN_NUMERALS, Request, TOKEN_KEY, all, alphabetical, appEnv, asRequest, assign, base64ToBinary, base64_to_image, boil, cache_fetch, calEddByLmp, calGestationalWeekByLmp, calGestationalWeekBySureEdd, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, codeMessage, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, event, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatRangeDate, formatRangeDateTime, formatTime, format_gp, fubaoRequest, genEnum, genHappyPath, gen_encoded_char_svg, gen_id_form_item_config, get, getBMI, getChromeVersion, getDataSource, getDays, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDiffYears, getDualModeOptions, getExpected, getFilledArray, getFuckTimeInterval, getFutureDate, getGesWeek, getGestationalDays, getGestationalWeekBySureEdd, getHappyConfig, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getOrderTime, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, getTimeSlice, get_global, get_global_happy_arg, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isIE, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, makeEventStore, map, mapEntries, mapKeys, mapValues, marshalGestationWeek, max, memo, menopauseWeek, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, protocolCheck, proxied, random, randomHex, random_word, range, rawRequest, reduce, replace, replaceOrAppend, request, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, setSearchParamsAll, setSearchParamsValue, shake, shift, shuffle, sift, simple_decrypt, simple_decrypt_str, simple_encrypt, simple_encrypt_str, size, sleep, snake, sort, speculate_on_display, sum, temp_reander, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, transmit_happy, transmit_happy_pre, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, unmarshalGestationWeek, upperize, uuid, warpBase64Type, zip, zipToObject };
1303
- export type { AnyObject, Dayjs, DayjsConfigType, EventCallback_Old, ICommonOption, IGlobalEnumItem, IRequest_AxiosRequestConfig, IRequest_ResponseError, IRequest_SpawnConfig, PartialAll, PartialSome, PropertyKey$1 as PropertyKey, TCommonFileType, TEventBus, TEventStore, TRequest_PreReq, TRequest_SimpleReq };
1297
+ /**
1298
+ * 计算孕周
1299
+ * gesDate:预产期-B超
1300
+ * date:产检/报告日期
1301
+ */
1302
+ declare function getGesWeek(gesDate: string, date: string): string;
1303
+ /**
1304
+ * 计算停经孕周
1305
+ * @param checkData 当前日期
1306
+ * @param lmp 末次月经
1307
+ * @returns
1308
+ */
1309
+ declare const menopauseWeek: (checkData: string, lmp: string) => string;
1310
+ /**
1311
+ * 计算孕周对应的天数
1312
+ */
1313
+ declare function getGestationalDays(gestationalWeek: string): number;
1314
+ /**
1315
+ * 根据末次月经计算预产期B超
1316
+ */
1317
+ declare function getExpected(date: string): string;
1318
+ /**
1319
+ * 根据 预产期B超 日期获取孕周
1320
+ * 得出 ${孕周周数}+${孕周天数}
1321
+ * 预产期B超
1322
+ */
1323
+ declare const getGestationalWeekBySureEdd: (sureEdd: string) => string;
1324
+ /**
1325
+ * 根据末次月经计算预产期B超
1326
+ */
1327
+ declare function calEddByLmp(lmp: Dayjs$1): dayjs.Dayjs;
1328
+ declare function cal_edd_by_lmp(lmp: any): string;
1329
+ declare function calc_edd_by_IVF(移植时间: string, 天数: number): string | null;
1330
+ declare function calc_edd_by_ntExam(checkdate: DayjsConfigType, gestationalWeek: string): string | null;
1331
+ declare const calGestationalWeekByLmp: (lmp: Dayjs$1, defaultDate?: dayjs.Dayjs) => string;
1332
+ declare const calGestationalWeekBySureEdd: (sureEdd: any, defaultDate?: dayjs.Dayjs) => string | number;
1333
+
1334
+ export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, AppEnv, BaseWsService, Browser, EMPTY_PLACEHOLDER, EnumItem, EventBus, EventEmitter, EventEmitter_Old, GetAgeByBirthDay, MyLog, ROMAN_NUMERALS, Request, TOKEN_KEY, all, alphabetical, appEnv, asRequest, assign, base64ToBinary, base64_to_image, boil, cache_fetch, calEddByLmp, calGestationalWeekByLmp, calGestationalWeekBySureEdd, cal_edd_by_lmp, calc_bmi, calc_edd_by_IVF, calc_edd_by_ntExam, calc_number, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, codeMessage, compose, confirm_operation, construct, copyText, counting, createInstance, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, diff_hour_minute, downloadFile, draw, dyn_cb, event, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatRangeDate, formatRangeDateTime, formatTime, format_gp, fubaoRequest, genEnum, genHappyPath, gen_encoded_char_svg, gen_id_form_item_config, get, getBMI, getChromeVersion, getDataSource, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDiffYears, getDualModeOptions, getExpected, getFilledArray, getFuckTimeInterval, getFutureDate, getGesWeek, getGestationalDays, getGestationalWeekBySureEdd, getHappyConfig, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getOrderTime, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, getTimeSlice, get_global, get_global_happy_arg, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isIE, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, is_fuck_abnormal, iterate, keys, last, list, listify, load_src, lowerize, makeEventStore, map, mapEntries, mapKeys, mapValues, marshal_gestationWeek, max, memo, menopauseWeek, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, protocolCheck, proxied, random, randomHex, random_word, range, rawRequest, reduce, replace, replaceOrAppend, request, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_fetch_options, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, setSearchParamsAll, setSearchParamsValue, shake, shift, shuffle, sift, simple_decrypt, simple_decrypt_str, simple_encrypt, simple_encrypt_str, size, sleep, snake, sort, speculate_on_display, sum, temp_reander, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, transmit_happy, transmit_happy_pre, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, unmarshal_gestationWeek, upperize, uuid, warpBase64Type, zip, zipToObject };
1335
+ export type { AnyObject, Dayjs, DayjsConfigType, EventCallback_Old, ICommonOption, IGlobalEnumItem, IRequest_AxiosRequestConfig, IRequest_ResponseError, IRequest_SpawnConfig, PartialAll, PartialSome, PropertyKey$1 as PropertyKey, TCommonFileType, TEventBus, TEventStore, TRequest_PreReq, TRequest_SimpleReq, T_FETCH_OPTIONS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lm_fe/utils",
3
- "version": "0.1.201",
3
+ "version": "0.2.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -21,19 +21,19 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
- "@noah-libjs/utils": "^0.0.7",
25
24
  "rollup": "^2.70.2"
26
25
  },
27
26
  "dependencies": {
28
27
  "@lm_fe/static": "*",
28
+ "@noah-libjs/request": "*",
29
+ "@noah-libjs/utils": "*",
29
30
  "axios": ">=0.26.1",
30
31
  "dayjs": "^1.11.13",
31
- "lodash": "*",
32
32
  "reconnecting-websocket": "4.x",
33
33
  "store": "2.x"
34
34
  },
35
35
  "keywords": [],
36
36
  "author": "",
37
37
  "license": "MIT",
38
- "gitHead": "ec1dcf6e3b2d06782779a21f536300bb2536ea6b"
38
+ "gitHead": "41645962e95f6657643e6c6cb16320dd78f4cfcd"
39
39
  }