@ibiz-template/runtime 0.7.41-alpha.45 → 0.7.41-alpha.47

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.esm.js CHANGED
@@ -82899,6 +82899,9 @@ var WeChatUtil = class {
82899
82899
  }
82900
82900
  };
82901
82901
 
82902
+ // src/utils/json-util/json-util.ts
82903
+ import { isNil as isNil38 } from "ramda";
82904
+
82902
82905
  // src/utils/json-util/JsonContext.ts
82903
82906
  var JsonContext = class {
82904
82907
  constructor() {
@@ -83067,7 +83070,31 @@ var JsonParser = class {
83067
83070
  this.index++;
83068
83071
  break;
83069
83072
  }
83070
- stringAcc += char;
83073
+ if (char === "\\") {
83074
+ const next = this.jsonStr[this.index + 1];
83075
+ switch (next) {
83076
+ case "n":
83077
+ stringAcc += "\n";
83078
+ this.index += 2;
83079
+ continue;
83080
+ case "r":
83081
+ stringAcc += "\r";
83082
+ this.index += 2;
83083
+ continue;
83084
+ case "t":
83085
+ stringAcc += " ";
83086
+ this.index += 2;
83087
+ continue;
83088
+ case "\\":
83089
+ stringAcc += "\\";
83090
+ this.index += 2;
83091
+ continue;
83092
+ default:
83093
+ stringAcc += char;
83094
+ }
83095
+ } else {
83096
+ stringAcc += char;
83097
+ }
83071
83098
  this.index++;
83072
83099
  }
83073
83100
  } else {
@@ -83198,6 +83225,34 @@ var JsonUtil = class {
83198
83225
  loads(value, options = {}) {
83199
83226
  return loads(value, options);
83200
83227
  }
83228
+ /**
83229
+ * @description 判断给定的值是否为 JSON 对象
83230
+ * @param value
83231
+ * @returns boolean
83232
+ */
83233
+ isJsonObject(value) {
83234
+ if (typeof value !== "object" || isNil38(value) || Array.isArray(value)) {
83235
+ return false;
83236
+ }
83237
+ if (value.constructor && value.constructor !== Object) {
83238
+ return false;
83239
+ }
83240
+ return true;
83241
+ }
83242
+ /**
83243
+ * @description 判断给定的值是否为 JSON 数组
83244
+ * @param value
83245
+ * @returns boolean
83246
+ */
83247
+ isJsonArray(value) {
83248
+ if (isNil38(value)) {
83249
+ return false;
83250
+ }
83251
+ if (Array.isArray(value)) {
83252
+ return value.every((item) => this.isJsonObject(item));
83253
+ }
83254
+ return false;
83255
+ }
83201
83256
  /**
83202
83257
  * @description json修复,用于提取大语言模型中的json数据
83203
83258
  * @param {string} value
@@ -83208,17 +83263,23 @@ var JsonUtil = class {
83208
83263
  parseJson(value, options = {}) {
83209
83264
  const data = loads(value, options);
83210
83265
  if (data) {
83266
+ let success = true;
83211
83267
  const type = Array.isArray(data) ? "jsonarray" : "jsonobject";
83268
+ if (type === "jsonobject") {
83269
+ success = this.isJsonObject(data);
83270
+ } else if (type === "jsonarray") {
83271
+ success = this.isJsonArray(data);
83272
+ }
83212
83273
  return {
83213
- success: true,
83214
- data,
83215
- data_type: type,
83216
- message: ibiz.i18n.t("runtime.utils.jsonUtil.parseSuccess")
83274
+ success,
83275
+ data: success ? data : void 0,
83276
+ data_type: success ? type : "unknown",
83277
+ message: success ? ibiz.i18n.t("runtime.utils.jsonUtil.parseSuccess") : ibiz.i18n.t("runtime.utils.jsonUtil.parseError")
83217
83278
  };
83218
83279
  }
83219
83280
  return {
83220
83281
  success: false,
83221
- data: {},
83282
+ data: void 0,
83222
83283
  data_type: "unknown",
83223
83284
  message: ibiz.i18n.t("runtime.utils.jsonUtil.parseError")
83224
83285
  };
@@ -84054,7 +84115,7 @@ import { QXEvent as QXEvent14 } from "qx-util";
84054
84115
  // src/controller/notification/async-action.controller.ts
84055
84116
  import { QXEvent as QXEvent12 } from "qx-util";
84056
84117
  import { clone as clone60 } from "ramda";
84057
- import { isNil as isNil38, isNumber as isNumber5 } from "lodash-es";
84118
+ import { isNil as isNil39, isNumber as isNumber5 } from "lodash-es";
84058
84119
  import dayjs10 from "dayjs";
84059
84120
  var AsyncActionController = class {
84060
84121
  constructor() {
@@ -84132,14 +84193,14 @@ var AsyncActionController = class {
84132
84193
  data[key] = dayjs10(data[key]).format("YYYY-MM-DD HH:mm:ss");
84133
84194
  }
84134
84195
  });
84135
- if (!isNil38(data.actionresult)) {
84196
+ if (!isNil39(data.actionresult)) {
84136
84197
  try {
84137
84198
  const json = JSON.parse(data.actionresult);
84138
84199
  data.actionresult = json;
84139
84200
  } catch (error) {
84140
84201
  }
84141
84202
  }
84142
- if (!isNil38(data.completionrate)) {
84203
+ if (!isNil39(data.completionrate)) {
84143
84204
  const num = Number(data.completionrate);
84144
84205
  if (Number.isNaN(num)) {
84145
84206
  data.completionrate = void 0;
@@ -85422,7 +85483,7 @@ import {
85422
85483
  IBizContext as IBizContext10
85423
85484
  } from "@ibiz-template/core";
85424
85485
  import qs6 from "qs";
85425
- import { isNil as isNil39 } from "ramda";
85486
+ import { isNil as isNil40 } from "ramda";
85426
85487
  var ViewEngineBase = class {
85427
85488
  /**
85428
85489
  * 构造函数在视图控制器的构造函数逻辑内部执行
@@ -85910,7 +85971,7 @@ var ViewEngineBase = class {
85910
85971
  if (Object.prototype.hasOwnProperty.call(data, "srfreadonly")) {
85911
85972
  if (data.srfreadonly) {
85912
85973
  this.view.context.srfreadonly = true;
85913
- } else if (isNil39(this.view.context.srfreadonly)) {
85974
+ } else if (isNil40(this.view.context.srfreadonly)) {
85914
85975
  this.view.context.srfreadonly = false;
85915
85976
  }
85916
85977
  }