@yoooloo42/joker 1.0.162 → 1.0.164

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
@@ -16194,7 +16194,7 @@ const isNumber = typeOfTest('number');
16194
16194
  *
16195
16195
  * @returns {boolean} True if value is an Object, otherwise false
16196
16196
  */
16197
- const isObject = (thing) => thing !== null && typeof thing === 'object';
16197
+ const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
16198
16198
 
16199
16199
  /**
16200
16200
  * Determine if a value is a Boolean
@@ -16229,7 +16229,7 @@ const isPlainObject = (val) => {
16229
16229
  */
16230
16230
  const isEmptyObject = (val) => {
16231
16231
  // Early return for non-objects or Buffers to prevent RangeError
16232
- if (!isObject(val) || isBuffer$1(val)) {
16232
+ if (!isObject$1(val) || isBuffer$1(val)) {
16233
16233
  return false;
16234
16234
  }
16235
16235
 
@@ -16284,7 +16284,7 @@ const isFileList = kindOfTest('FileList');
16284
16284
  *
16285
16285
  * @returns {boolean} True if value is a Stream, otherwise false
16286
16286
  */
16287
- const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
16287
+ const isStream = (val) => isObject$1(val) && isFunction$1(val.pipe);
16288
16288
 
16289
16289
  /**
16290
16290
  * Determine if a value is a FormData
@@ -16735,7 +16735,7 @@ const toJSONObject = (obj) => {
16735
16735
 
16736
16736
  const visit = (source, i) => {
16737
16737
 
16738
- if (isObject(source)) {
16738
+ if (isObject$1(source)) {
16739
16739
  if (stack.indexOf(source) >= 0) {
16740
16740
  return;
16741
16741
  }
@@ -16769,7 +16769,7 @@ const toJSONObject = (obj) => {
16769
16769
  const isAsyncFn = kindOfTest('AsyncFunction');
16770
16770
 
16771
16771
  const isThenable = (thing) =>
16772
- thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
16772
+ thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
16773
16773
 
16774
16774
  // original code
16775
16775
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -16814,7 +16814,7 @@ var utils$1 = {
16814
16814
  isString,
16815
16815
  isNumber,
16816
16816
  isBoolean,
16817
- isObject,
16817
+ isObject: isObject$1,
16818
16818
  isPlainObject,
16819
16819
  isEmptyObject,
16820
16820
  isReadableStream,
@@ -22313,6 +22313,13 @@ function typeOfValue(value) {
22313
22313
  return className.toLowerCase();
22314
22314
  }
22315
22315
 
22316
+ /**
22317
+ * 判断是否为普通对象(排除 null 和 Array)
22318
+ */
22319
+ function isObject(val) {
22320
+ return typeof val === 'object' && val !== null && !Array.isArray(val);
22321
+ }
22322
+
22316
22323
  /**
22317
22324
  * 判断一个字符串是否是有效的 JSON 格式
22318
22325
  *
@@ -22568,47 +22575,66 @@ function getNodeValue(tree, nodeName) {
22568
22575
  }
22569
22576
 
22570
22577
  /**
22571
- * 深度非侵入式合并函数 (Deep Non-Destructive Merge)
22572
- * * 特点:
22573
- * 1. 深度递归地合并对象属性。
22574
- * 2. 源对象中缺失的属性不会删除或覆盖目标对象中已存在的对应属性。
22575
- * 3. 数组会被源对象中的数组完全覆盖。
22576
- * * @param {Object} target 目标对象(将被修改)
22578
+ * 深度合并 (Deep Merge)
22579
+ * 1. 深度递归地合并对象属性
22580
+ * 2. 目标对象中已存在的属性会被源对象中对应(同级、同名)的属性覆盖,缺失的,会从源对象中获取
22581
+ * 3. 数组视同简单值不进行递归处理
22582
+ * 适用场景:配置更新、状态同步
22583
+ * @param {Object} target 目标对象(将被修改)
22577
22584
  * @param {Object} source 源对象
22578
22585
  * @returns {Object} 修改后的目标对象
22579
22586
  */
22580
22587
  function deepMerge(target, source) {
22581
- // 确保源对象是一个有效的对象,如果不是则直接返回目标对象
22582
- if (typeof source !== 'object' || source === null) {
22583
- return target;
22584
- }
22588
+ if (!isObject(source)) return target;
22589
+ if (!isObject(target)) return source;
22585
22590
 
22586
22591
  for (const key in source) {
22587
- // 确保只处理源对象自身的属性
22588
22592
  if (Object.prototype.hasOwnProperty.call(source, key)) {
22589
22593
  const sourceValue = source[key];
22590
22594
  const targetValue = target[key];
22591
22595
 
22592
- // 1. 如果源属性的值是对象且目标属性的值也是对象,则递归合并
22593
- if (
22594
- typeof sourceValue === 'object' && sourceValue !== null &&
22595
- !Array.isArray(sourceValue) &&
22596
- typeof targetValue === 'object' && targetValue !== null &&
22597
- !Array.isArray(targetValue)
22598
- ) {
22599
- // 递归调用自身进行深度合并
22596
+ if (isObject(sourceValue) && isObject(targetValue)) {
22597
+ // 递归合并
22600
22598
  target[key] = deepMerge(targetValue, sourceValue);
22601
- }
22602
- // 2. 对于其他类型(基本类型、数组、null),直接覆盖
22603
- else {
22604
- // 这里的关键是:只有源对象中存在的属性,才会覆盖目标对象的属性。
22605
- // 如果源对象中不存在某个键(key),则不会进入此循环,
22606
- // 从而目标对象中已有的该属性得以保留。
22599
+ } else {
22600
+ // 覆盖:包含基本类型、数组或目标缺失的情况
22607
22601
  target[key] = sourceValue;
22608
22602
  }
22609
22603
  }
22610
22604
  }
22605
+ return target;
22606
+ }
22607
+
22608
+ /**
22609
+ * 深度默认值 (Deep Defaults)
22610
+ * 1. 深度递归地合并对象属性
22611
+ * 2. 目标对象中已存在的属性不会被源对象影响,缺失的,会从源对象中获取
22612
+ * 3. 数组视同简单值不进行递归处理
22613
+ * 适用场景:初始化配置,并确保目标对象结构的完整性
22614
+ * @param {Object} target 目标对象(将被修改)
22615
+ * @param {Object} source 源对象(提供默认值的参考对象)
22616
+ * @returns {Object} 修改后的目标对象
22617
+ */
22618
+ function deepDefaults(target, source) {
22619
+ if (!isObject(source)) return target;
22620
+ // 如果 target 不是对象,为了填充属性,需将其初始化为对象
22621
+ if (!isObject(target)) target = {};
22622
+
22623
+ for (const key in source) {
22624
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
22625
+ const sourceValue = source[key];
22626
+ const targetValue = target[key];
22611
22627
 
22628
+ if (!(key in target)) {
22629
+ // 目标完全没有这个键,直接取源的值
22630
+ target[key] = sourceValue;
22631
+ } else if (isObject(sourceValue) && isObject(targetValue)) {
22632
+ // 目标和源都有此对象,递归检查内部缺失
22633
+ deepDefaults(targetValue, sourceValue);
22634
+ }
22635
+ // 目标已有基本类型值或数组,跳过
22636
+ }
22637
+ }
22612
22638
  return target;
22613
22639
  }
22614
22640
  var deepClone = {
@@ -22620,7 +22646,8 @@ var deepClone = {
22620
22646
  arrayToTree,
22621
22647
  getLeafValue,
22622
22648
  getNodeValue,
22623
- deepMerge
22649
+ deepMerge,
22650
+ deepDefaults
22624
22651
  };
22625
22652
 
22626
22653
  var unclassified = {
@@ -22720,9 +22747,9 @@ const popupFind = async _ref5 => {
22720
22747
  scopeThis
22721
22748
  } = _ref5;
22722
22749
  scopeThis.formData = scopeThis.query && scopeThis.query.formData ? unclassified.deepClone.deepClone(scopeThis.query.formData) : null;
22723
- scopeThis.TableProps.query.sort = scopeThis.query && scopeThis.query.sort ? JSON.parse(JSON.stringify(scopeThis.query.sort)) : null;
22724
- scopeThis.TableProps.query.pageSize = scopeThis.query && scopeThis.query.pageSize ? scopeThis.query.pageSize : ly0default$4.pageSize;
22725
- scopeThis.TableProps.query.currentPage = scopeThis.query && scopeThis.query.currentPage ? scopeThis.query.currentPage : 1;
22750
+ scopeThis.tableData.query.sort = scopeThis.query && scopeThis.query.sort ? JSON.parse(JSON.stringify(scopeThis.query.sort)) : null;
22751
+ scopeThis.tableData.query.pageSize = scopeThis.query && scopeThis.query.pageSize ? scopeThis.query.pageSize : ly0default$4.pageSize;
22752
+ scopeThis.tableData.query.currentPage = scopeThis.query && scopeThis.query.currentPage ? scopeThis.query.currentPage : 1;
22726
22753
  scopeThis.formProps = unclassified.deepClone.deepClone(scopeThis.find.formProps);
22727
22754
  // 弹出窗口
22728
22755
  scopeThis.formProps.popup = unclassified.deepClone.deepMerge(scopeThis.formProps.popup, {
@@ -24367,10 +24394,7 @@ const props = __props;
24367
24394
 
24368
24395
  // 顶层组件的props属性需做响应性包装,页面和js可以使用相同的命名
24369
24396
  let formData_box = reactive(props.modelValue);
24370
- const formProps_box = reactive(unclassified.deepClone.deepMerge(
24371
- unclassified.deepClone.deepClone(ly0default$3.myProps),
24372
- props.myProps
24373
- ));
24397
+ const formProps_box = reactive(unclassified.deepClone.deepDefaults(props.myProps, ly0default$3.myProps));
24374
24398
  const scopeThis_box = reactive(props.scopeThis);
24375
24399
 
24376
24400
  return (_ctx, _cache) => {
@@ -42140,7 +42164,6 @@ return (_ctx, _cache) => {
42140
42164
  }), 128 /* KEYED_FRAGMENT */))
42141
42165
  ], 4 /* STYLE */))
42142
42166
  : createCommentVNode("v-if", true),
42143
- createTextVNode(" " + toDisplayString('测试loading: '+unref(tableProps_box).table.loading.visible) + " ", 1 /* TEXT */),
42144
42167
  createCommentVNode(" 表体 "),
42145
42168
  withDirectives((openBlock(), createBlock(_component_el_table, {
42146
42169
  data: unref(tableData_box).data,
@@ -42478,11 +42501,8 @@ var script$c = {
42478
42501
  const props = __props;
42479
42502
 
42480
42503
  // 顶层组件的props属性需做响应性包装,页面和js可以使用相同的命名
42481
- let tableData_box = reactive(unclassified.deepClone.deepMerge(props.modelValue, ly0default$1.modelValue));
42482
- const tableProps_box = reactive(unclassified.deepClone.deepMerge(props.myProps, ly0default$1.myProps));
42483
-
42484
- console.log('测试 000', tableData_box);
42485
- console.log('测试 111', tableProps_box);
42504
+ let tableData_box = reactive(unclassified.deepClone.deepDefaults(props.modelValue, ly0default$1.modelValue));
42505
+ const tableProps_box = reactive(unclassified.deepClone.deepDefaults(props.myProps, ly0default$1.myProps));
42486
42506
 
42487
42507
  const scopeThis_box = reactive(props.scopeThis);
42488
42508