@jhqn/utils-core 0.0.3-beta.4 → 0.0.3-beta.6

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.cjs CHANGED
@@ -115,22 +115,24 @@ const isURL = (val) => getVariableType(val) === "url";
115
115
  const isError = (val) => getVariableType(val) === "error";
116
116
  const isDef = (val) => !isNull(val) && !isUndefined(val);
117
117
  const isJSONStr = (str) => {
118
- if (isDef(str))
118
+ if (isDef(str)) {
119
119
  try {
120
120
  JSON.parse(str);
121
121
  return true;
122
122
  } catch (e) {
123
123
  return false;
124
124
  }
125
+ }
125
126
  return false;
126
127
  };
127
128
  const isArrStr = (str) => {
128
- if (isDef(str))
129
+ if (isDef(str)) {
129
130
  try {
130
131
  return Array.isArray(JSON.parse(str));
131
132
  } catch (e) {
132
133
  return false;
133
134
  }
135
+ }
134
136
  return false;
135
137
  };
136
138
  const isValidKey = (key, object) => key in object;
@@ -415,11 +417,11 @@ const recoverFile = (resource) => {
415
417
  const attachFmt = (data) => {
416
418
  let attachList = [];
417
419
  const prototype = Object.prototype.toString.call(data);
418
- if (!data)
420
+ if (!data) {
419
421
  attachList = [];
420
- else if (Array.isArray(data))
422
+ } else if (Array.isArray(data)) {
421
423
  attachList = data.filter(Boolean);
422
- else if (typeof data === "string") {
424
+ } else if (typeof data === "string") {
423
425
  if (isArrStr(data)) {
424
426
  attachList = (parseToJSON(data) || []).filter(Boolean);
425
427
  } else {
@@ -430,8 +432,9 @@ const attachFmt = (data) => {
430
432
  else
431
433
  attachList = [{ id: data, name: "name", uri: data, group: "default" }];
432
434
  }
433
- } else if (prototype === "[object Object]")
435
+ } else if (prototype === "[object Object]") {
434
436
  attachList = [data];
437
+ }
435
438
  return attachList.map(recoverFile);
436
439
  };
437
440
 
@@ -456,7 +459,8 @@ const getHostEnv = () => {
456
459
  const ua = userAgent.toLowerCase();
457
460
  const zlb = ua.includes("@zlb");
458
461
  const zyd = ua.includes("saas");
459
- const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
462
+ const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd") || ua.includes("dingtalk-win");
463
+ const dd = ua.includes("taurusapp");
460
464
  const wx = ua.includes("micromessenger");
461
465
  const zfb = ua.includes("alipay");
462
466
  const mini = ua.includes("miniprogram");
@@ -464,6 +468,7 @@ const getHostEnv = () => {
464
468
  zlb,
465
469
  zyd,
466
470
  zzd,
471
+ dd,
467
472
  wx,
468
473
  zfb,
469
474
  mini
package/dist/index.d.cts CHANGED
@@ -327,6 +327,10 @@ interface HostEnv {
327
327
  * 是否是浙政钉
328
328
  */
329
329
  readonly zzd: boolean
330
+ /**
331
+ * 是否是钉钉/专有钉/浙政钉
332
+ */
333
+ readonly dd: boolean
330
334
  /**
331
335
  * 是否是微信
332
336
  */
@@ -368,6 +372,7 @@ declare const userAgent: string;
368
372
  * hostEnv.zlb // 浙里办
369
373
  * hostEnv.zyd // 专有钉
370
374
  * hostEnv.zzd // 浙政钉
375
+ * hostEnv.dd // 钉钉/专有钉/浙政钉
371
376
  * hostEnv.wx // 微信
372
377
  * hostEnv.zfb // 支付宝
373
378
  * hostEnv.mini // 小程序
@@ -431,7 +436,6 @@ declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
431
436
 
432
437
  /**
433
438
  * 设置文件基本路径
434
- * @param key
435
439
  * @param baseUrl
436
440
  */
437
441
  declare function setBaseAttachUrl(baseUrl: string): void;
package/dist/index.d.mts CHANGED
@@ -327,6 +327,10 @@ interface HostEnv {
327
327
  * 是否是浙政钉
328
328
  */
329
329
  readonly zzd: boolean
330
+ /**
331
+ * 是否是钉钉/专有钉/浙政钉
332
+ */
333
+ readonly dd: boolean
330
334
  /**
331
335
  * 是否是微信
332
336
  */
@@ -368,6 +372,7 @@ declare const userAgent: string;
368
372
  * hostEnv.zlb // 浙里办
369
373
  * hostEnv.zyd // 专有钉
370
374
  * hostEnv.zzd // 浙政钉
375
+ * hostEnv.dd // 钉钉/专有钉/浙政钉
371
376
  * hostEnv.wx // 微信
372
377
  * hostEnv.zfb // 支付宝
373
378
  * hostEnv.mini // 小程序
@@ -431,7 +436,6 @@ declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
431
436
 
432
437
  /**
433
438
  * 设置文件基本路径
434
- * @param key
435
439
  * @param baseUrl
436
440
  */
437
441
  declare function setBaseAttachUrl(baseUrl: string): void;
package/dist/index.d.ts CHANGED
@@ -327,6 +327,10 @@ interface HostEnv {
327
327
  * 是否是浙政钉
328
328
  */
329
329
  readonly zzd: boolean
330
+ /**
331
+ * 是否是钉钉/专有钉/浙政钉
332
+ */
333
+ readonly dd: boolean
330
334
  /**
331
335
  * 是否是微信
332
336
  */
@@ -368,6 +372,7 @@ declare const userAgent: string;
368
372
  * hostEnv.zlb // 浙里办
369
373
  * hostEnv.zyd // 专有钉
370
374
  * hostEnv.zzd // 浙政钉
375
+ * hostEnv.dd // 钉钉/专有钉/浙政钉
371
376
  * hostEnv.wx // 微信
372
377
  * hostEnv.zfb // 支付宝
373
378
  * hostEnv.mini // 小程序
@@ -431,7 +436,6 @@ declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
431
436
 
432
437
  /**
433
438
  * 设置文件基本路径
434
- * @param key
435
439
  * @param baseUrl
436
440
  */
437
441
  declare function setBaseAttachUrl(baseUrl: string): void;
package/dist/index.mjs CHANGED
@@ -104,22 +104,24 @@ const isURL = (val) => getVariableType(val) === "url";
104
104
  const isError = (val) => getVariableType(val) === "error";
105
105
  const isDef = (val) => !isNull(val) && !isUndefined(val);
106
106
  const isJSONStr = (str) => {
107
- if (isDef(str))
107
+ if (isDef(str)) {
108
108
  try {
109
109
  JSON.parse(str);
110
110
  return true;
111
111
  } catch (e) {
112
112
  return false;
113
113
  }
114
+ }
114
115
  return false;
115
116
  };
116
117
  const isArrStr = (str) => {
117
- if (isDef(str))
118
+ if (isDef(str)) {
118
119
  try {
119
120
  return Array.isArray(JSON.parse(str));
120
121
  } catch (e) {
121
122
  return false;
122
123
  }
124
+ }
123
125
  return false;
124
126
  };
125
127
  const isValidKey = (key, object) => key in object;
@@ -404,11 +406,11 @@ const recoverFile = (resource) => {
404
406
  const attachFmt = (data) => {
405
407
  let attachList = [];
406
408
  const prototype = Object.prototype.toString.call(data);
407
- if (!data)
409
+ if (!data) {
408
410
  attachList = [];
409
- else if (Array.isArray(data))
411
+ } else if (Array.isArray(data)) {
410
412
  attachList = data.filter(Boolean);
411
- else if (typeof data === "string") {
413
+ } else if (typeof data === "string") {
412
414
  if (isArrStr(data)) {
413
415
  attachList = (parseToJSON(data) || []).filter(Boolean);
414
416
  } else {
@@ -419,8 +421,9 @@ const attachFmt = (data) => {
419
421
  else
420
422
  attachList = [{ id: data, name: "name", uri: data, group: "default" }];
421
423
  }
422
- } else if (prototype === "[object Object]")
424
+ } else if (prototype === "[object Object]") {
423
425
  attachList = [data];
426
+ }
424
427
  return attachList.map(recoverFile);
425
428
  };
426
429
 
@@ -445,7 +448,8 @@ const getHostEnv = () => {
445
448
  const ua = userAgent.toLowerCase();
446
449
  const zlb = ua.includes("@zlb");
447
450
  const zyd = ua.includes("saas");
448
- const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
451
+ const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd") || ua.includes("dingtalk-win");
452
+ const dd = ua.includes("taurusapp");
449
453
  const wx = ua.includes("micromessenger");
450
454
  const zfb = ua.includes("alipay");
451
455
  const mini = ua.includes("miniprogram");
@@ -453,6 +457,7 @@ const getHostEnv = () => {
453
457
  zlb,
454
458
  zyd,
455
459
  zzd,
460
+ dd,
456
461
  wx,
457
462
  zfb,
458
463
  mini
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jhqn/utils-core",
3
3
  "type": "module",
4
- "version": "0.0.3-beta.4",
4
+ "version": "0.0.3-beta.6",
5
5
  "author": "jade-gjz <jiangang.zhang@jaderd.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/jaderd-jh/utils/tree/main/packages/core#readme",