@lm_fe/utils 0.1.201 → 0.2.2

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,8 +1,10 @@
1
1
  import dayjs, { ConfigType, QUnitType, OpUnitType, Dayjs as Dayjs$1 } from 'dayjs';
2
2
  export { default as dayjs } from 'dayjs';
3
3
  import { AxiosRequestConfig, AxiosError, AxiosResponse, AxiosInstance } from 'axios';
4
+ export { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
4
5
  import ReconnectingWebSocket from 'reconnecting-websocket';
5
6
  import { FC } from 'react';
7
+ import { FormInstance } from 'antd';
6
8
 
7
9
  interface ICommonOption {
8
10
  value?: any;
@@ -737,8 +739,9 @@ declare function unicodeToChar(u: number): string | null;
737
739
  declare function unicode_to_UTF8(u: number): number[] | null;
738
740
  declare function getFilledArray(n: number): any[];
739
741
  declare function copyText(text: string): boolean;
742
+ declare function dyn_cb<T>(cb: (ctx: T) => void, g_ctx: () => T): boolean;
740
743
  declare function safeExec<T extends (...args: any) => any>(fn?: T, ...args: Parameters<T>): any;
741
- declare function safeGetFromFuncOrData(fn: any): any;
744
+ declare function safeGetFromFuncOrData(fn: any, default_v?: any): any;
742
745
  declare function numberLikeCompare(a: number | string | boolean | null, b: number | string | boolean | null): boolean;
743
746
  declare function warpBase64Type(str: string, type: 'img' | 'pdf'): string;
744
747
  declare function safe_number_parse(value: any, defaultValue?: number): number;
@@ -863,7 +866,7 @@ declare function isMoment(m: any): boolean;
863
866
  */
864
867
  declare function getFutureDate(num: number): any;
865
868
  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;
869
+ declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): number;
867
870
 
868
871
  interface ISpectialOption {
869
872
  sp?: ICommonOption[];
@@ -983,6 +986,7 @@ declare function makeEventStore<T extends AnyObject>(key?: string, data?: T): TE
983
986
 
984
987
  declare class AppEnv<T = string> {
985
988
  static get singleton(): AppEnv;
989
+ static get client_mode(): boolean;
986
990
  _appName?: T;
987
991
  _globalCache: {
988
992
  [x: string]: any;
@@ -995,8 +999,11 @@ declare class AppEnv<T = string> {
995
999
  pop_global_cache(k: string): AnyObject | undefined;
996
1000
  _isDev?: boolean;
997
1001
  is(type: T): boolean;
1002
+ not(type: T): boolean;
998
1003
  in(types: T[]): boolean;
999
1004
  get isSp(): boolean;
1005
+ get is_single(): boolean;
1006
+ get is_new(): (string | boolean)[];
1000
1007
  get isDev(): boolean;
1001
1008
  set isDev(value: boolean);
1002
1009
  get appName(): T | undefined;
@@ -1006,15 +1013,15 @@ declare class AppEnv<T = string> {
1006
1013
  get tokenKey(): string;
1007
1014
  get loginRememberKey(): string;
1008
1015
  constructor(appName?: T);
1009
- get loginRemember(): AnyObject | undefined | null;
1010
- set loginRemember(value: AnyObject | undefined | null);
1016
+ get loginRemember(): AnyObject<any> | null;
1017
+ set loginRemember(value: AnyObject<any> | null);
1011
1018
  get token(): string | null;
1012
1019
  set token(value: string | null);
1013
1020
  get rawToken(): string | string[];
1014
- reload(path?: string): void;
1021
+ reload(path?: string | URL): void;
1015
1022
  open(url?: string | URL, target?: string, features?: string): Window | null;
1016
- logout(path?: string): void;
1017
- logout_clean(path?: string): void;
1023
+ logout(path?: string | URL): void;
1024
+ logout_clean(path?: string | URL): void;
1018
1025
  getToken(): string | null;
1019
1026
  getTokenFromSearchParam(): string | null;
1020
1027
  setTokenToSearchParam(url: URL): URL;
@@ -1049,12 +1056,13 @@ type TRequest_SimpleReq = <T = any, R = AxiosResponse<T>, D = any>(url: string,
1049
1056
  type TRequest_PreReq = <T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: IRequest_AxiosRequestConfig<D>) => Promise<R>;
1050
1057
 
1051
1058
  declare class Request extends EventEmitter<{
1052
- beforeRequest: any;
1053
- afterResponse: any;
1054
- responseErr: any;
1059
+ request: any;
1060
+ response: any;
1061
+ error: any;
1055
1062
  message: [boolean, string, any];
1056
1063
  }> {
1057
1064
  ins: AxiosInstance;
1065
+ token?: string;
1058
1066
  constructor(config?: IRequest_SpawnConfig);
1059
1067
  static CONFIG: {
1060
1068
  successCode: number[];
@@ -1072,11 +1080,12 @@ declare class Request extends EventEmitter<{
1072
1080
  }>): any;
1073
1081
  static getRemoteMessage(res?: AxiosResponse<any>): any;
1074
1082
  static getHeaderMessage(res?: AxiosResponse<any>): string | undefined;
1075
- displayMsg(res: AxiosResponse<{
1083
+ displayMsg(res?: AxiosResponse<{
1076
1084
  data?: any;
1077
1085
  code?: number;
1078
1086
  msg?: string;
1079
1087
  }>): void;
1088
+ config: IRequest_SpawnConfig;
1080
1089
  spawn(spawnConfig?: IRequest_SpawnConfig): AxiosInstance;
1081
1090
  gen(spawnConfig?: IRequest_SpawnConfig): AxiosInstance;
1082
1091
  get: TRequest_SimpleReq;
@@ -1085,6 +1094,15 @@ declare class Request extends EventEmitter<{
1085
1094
  post: TRequest_PreReq;
1086
1095
  put: TRequest_PreReq;
1087
1096
  }
1097
+ declare const request: Request;
1098
+
1099
+ type T_FETCH_OPTIONS = ((f?: FormInstance) => (Promise<ICommonOption[]> | ICommonOption[])) | {
1100
+ url: string | (() => string);
1101
+ labelKey?: string;
1102
+ valueKey?: string;
1103
+ method?: 'get' | 'post';
1104
+ };
1105
+ declare function safe_fetch_options(cb: T_FETCH_OPTIONS, f?: FormInstance): Promise<ICommonOption[]>;
1088
1106
 
1089
1107
  declare const codeMessage: {
1090
1108
  200: string;
@@ -1104,7 +1122,8 @@ declare const codeMessage: {
1104
1122
  504: string;
1105
1123
  };
1106
1124
 
1107
- declare const request: Request;
1125
+ declare function createInstance(defaultConfig?: {}): AxiosInstance;
1126
+
1108
1127
  declare const rawRequest: AxiosInstance;
1109
1128
  declare const asRequest: Request;
1110
1129
  declare const fubaoRequest: Request;
@@ -1135,6 +1154,10 @@ declare function formatRangeDateTime(data: {
1135
1154
  }, cKeys?: string[]): {
1136
1155
  [x: string]: string | null;
1137
1156
  };
1157
+ declare function diff_hour_minute(inputA: any, inputB: any): {
1158
+ h: number;
1159
+ m: number;
1160
+ };
1138
1161
 
1139
1162
  declare class Event {
1140
1163
  target: any;
@@ -1184,55 +1207,23 @@ declare class BaseWsService<T = any> extends EventEmitter<{
1184
1207
  }
1185
1208
 
1186
1209
  declare function getTimeSlice(hour?: number, isShowSecond?: boolean): string[];
1210
+ declare function is_fuck_abnormal(conf?: {
1211
+ isNormal?: 'true' | 'false' | null;
1212
+ }): boolean;
1187
1213
 
1188
1214
  /**
1189
1215
  * 计算BMI
1190
1216
  */
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;
1217
+ declare function getBMI(weight: number, height: number): number;
1218
+ declare const calc_bmi: typeof getBMI;
1209
1219
  /**
1210
1220
  * 获取本周五、下周五、下下周五时间
1211
1221
  */
1212
1222
  declare function getOrderTime(orderDate: '本周五' | '下周五' | '下下周五'): dayjs.Dayjs;
1213
- /**
1214
- * 根据末次月经计算预产期B超
1215
- */
1216
- declare function getExpected(date: string): string;
1217
1223
  /**
1218
1224
  * 计算两个日期相隔的年数
1219
1225
  */
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;
1226
+ declare function getDiffYears(a: string, b: string): number;
1236
1227
  /**根据出生日期计算年龄 */
1237
1228
  declare function GetAgeByBirthDay(strBirthday: string): number | null;
1238
1229
  declare const getDataSource: (url: string, params: object, processFromApi?: (v: any) => any) => Promise<{
@@ -1243,18 +1234,18 @@ declare function gen_id_form_item_config(name?: string): {
1243
1234
  inputType: "id";
1244
1235
  dataIndex: string;
1245
1236
  name: string;
1237
+ form_hidden: boolean;
1246
1238
  };
1247
- declare const calGestationalWeekByLmp: (lmp: Dayjs$1, defaultDate?: dayjs.Dayjs) => string;
1248
- declare const calGestationalWeekBySureEdd: (sureEdd: any, defaultDate?: dayjs.Dayjs) => string | number;
1249
1239
  declare function format_gp(data: {
1250
1240
  gravidity?: any;
1251
1241
  parity?: any;
1252
1242
  }): string;
1253
- declare function unmarshalGestationWeek(weekStr?: string): {
1254
- week: number;
1243
+ declare function unmarshal_gestationWeek(weekStr?: string): {
1255
1244
  day: number;
1256
- };
1257
- declare function marshalGestationWeek(week?: string | number, day?: string | number): string;
1245
+ days: number;
1246
+ week: number;
1247
+ } | null;
1248
+ declare function marshal_gestationWeek(week?: string | number, day?: string | number): string;
1258
1249
 
1259
1250
  declare const Browser: {
1260
1251
  client: {
@@ -1299,5 +1290,42 @@ declare function temp_reander(config: {
1299
1290
  exclusive?: boolean;
1300
1291
  }): () => void;
1301
1292
 
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 };
1293
+ /**
1294
+ * 计算孕周
1295
+ * gesDate:预产期-B超
1296
+ * date:产检/报告日期
1297
+ */
1298
+ declare function getGesWeek(gesDate: string, date: string): string;
1299
+ /**
1300
+ * 计算停经孕周
1301
+ * @param checkData 当前日期
1302
+ * @param lmp 末次月经
1303
+ * @returns
1304
+ */
1305
+ declare const menopauseWeek: (checkData: string, lmp: string) => string;
1306
+ /**
1307
+ * 计算孕周对应的天数
1308
+ */
1309
+ declare function getGestationalDays(gestationalWeek: string): number;
1310
+ /**
1311
+ * 根据末次月经计算预产期B超
1312
+ */
1313
+ declare function getExpected(date: string): string;
1314
+ /**
1315
+ * 根据 预产期B超 日期获取孕周
1316
+ * 得出 ${孕周周数}+${孕周天数}
1317
+ * 预产期B超
1318
+ */
1319
+ declare const getGestationalWeekBySureEdd: (sureEdd: string) => string;
1320
+ /**
1321
+ * 根据末次月经计算预产期B超
1322
+ */
1323
+ declare function calEddByLmp(lmp: Dayjs$1): dayjs.Dayjs;
1324
+ declare function cal_edd_by_lmp(lmp: any): string;
1325
+ declare function calc_edd_by_IVF(移植时间: string, 天数: number): string | null;
1326
+ declare function calc_edd_by_ntExam(checkdate: DayjsConfigType, gestationalWeek: string): string | null;
1327
+ declare const calGestationalWeekByLmp: (lmp: Dayjs$1, defaultDate?: dayjs.Dayjs) => string;
1328
+ declare const calGestationalWeekBySureEdd: (sureEdd: any, defaultDate?: dayjs.Dayjs) => string | number;
1329
+
1330
+ 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, 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 };
1331
+ 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.2",
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": "1ff13bdf8a20c78515bef188000c3855aa4663a5"
39
39
  }