@cc-component/cc-ex-component 1.6.9 → 1.7.0
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/assets/core/ViewModel.ts +11 -14
- package/package.json +1 -1
package/assets/core/ViewModel.ts
CHANGED
|
@@ -480,23 +480,20 @@ export function ViewModel<T extends new (...args: any[]) => Component>(Base: T)
|
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
function updateStatus(data: IBindingData, com: Component, value: any, self: any) {
|
|
483
|
-
if (value === undefined || value === null) {
|
|
484
|
-
return
|
|
485
|
-
}
|
|
486
483
|
const sx = data.dataPath.split('.').pop();
|
|
487
484
|
const tempData = { value: value, skip: false }
|
|
488
485
|
//console.log("updateStatus", data.propertyKey)
|
|
489
486
|
switch (data.type) {
|
|
490
487
|
case 'cc.Label':
|
|
491
488
|
if (data.reset) {
|
|
492
|
-
data.reset.call(self, value, com);
|
|
489
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
493
490
|
} else {
|
|
494
491
|
if (value != undefined && value !== null) (com as Label).string = value?.toString() || '';
|
|
495
492
|
}
|
|
496
493
|
break;
|
|
497
494
|
case 'cc.RichText':
|
|
498
495
|
if (data.reset) {
|
|
499
|
-
data.reset.call(self, value, com);
|
|
496
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
500
497
|
} else
|
|
501
498
|
if (value != undefined && value !== null)
|
|
502
499
|
(com as RichText).string = value?.toString() || '';
|
|
@@ -505,7 +502,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
505
502
|
// 假设 value 是 SpriteFrame 路径或资源
|
|
506
503
|
// 需要额外处理资源加载逻辑
|
|
507
504
|
if (data.reset) {
|
|
508
|
-
data.reset.call(self, value, com);
|
|
505
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
509
506
|
} else
|
|
510
507
|
if (value != undefined && value !== null) {
|
|
511
508
|
if (value instanceof SpriteFrame)
|
|
@@ -522,19 +519,19 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
522
519
|
case 'cc.Button':
|
|
523
520
|
const com_btn = (com as Button);
|
|
524
521
|
if (data.reset) {
|
|
525
|
-
data.reset.call(self, value, com);
|
|
522
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
526
523
|
} else
|
|
527
|
-
com_btn.node.active = value ?? true;
|
|
524
|
+
if (value !== undefined || value !== null) com_btn.node.active = value ?? true;
|
|
528
525
|
break;
|
|
529
526
|
case 'cc.ProgressBar':
|
|
530
527
|
if (data.reset) {
|
|
531
|
-
data.reset.call(self, value, com);
|
|
528
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
532
529
|
} else
|
|
533
530
|
if (value != undefined && value !== null) (com as ProgressBar).progress = Number(value) || 0;
|
|
534
531
|
break;
|
|
535
532
|
case 'sp.Skeleton':
|
|
536
533
|
if (data.reset) {
|
|
537
|
-
data.reset.call(self, value, com);
|
|
534
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
538
535
|
} else
|
|
539
536
|
if (value != undefined && value !== null)
|
|
540
537
|
if (value instanceof sp.SkeletonData)
|
|
@@ -557,7 +554,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
557
554
|
{
|
|
558
555
|
const com_sld = (com as Slider);
|
|
559
556
|
if (data.reset) {
|
|
560
|
-
data.reset.call(self, value, com);
|
|
557
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
561
558
|
} else
|
|
562
559
|
if (value != undefined && value !== null) com_sld.progress = Number(value) || 0;
|
|
563
560
|
}
|
|
@@ -566,7 +563,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
566
563
|
{
|
|
567
564
|
const com_tg = (com as Toggle);
|
|
568
565
|
if (data.reset) {
|
|
569
|
-
data.reset.call(self, value, com);
|
|
566
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
570
567
|
} else
|
|
571
568
|
if (value != undefined && value !== null) com_tg.isChecked = Boolean(value);
|
|
572
569
|
}
|
|
@@ -575,7 +572,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
575
572
|
{
|
|
576
573
|
const com_eb = (com as EditBox);
|
|
577
574
|
if (data.reset) {
|
|
578
|
-
data.reset.call(self, value, com);
|
|
575
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
579
576
|
} else
|
|
580
577
|
if (value != undefined && value !== null) com_eb.string = value?.toString() || '';
|
|
581
578
|
}
|
|
@@ -584,7 +581,7 @@ function updateStatus(data: IBindingData, com: Component, value: any, self: any)
|
|
|
584
581
|
{
|
|
585
582
|
const com_tgc = (com as ToggleContainer);
|
|
586
583
|
if (data.reset) {
|
|
587
|
-
data.reset.call(self, value, com);
|
|
584
|
+
if (value !== undefined || value !== null) data.reset.call(self, value, com);
|
|
588
585
|
}
|
|
589
586
|
//事件
|
|
590
587
|
if (com_tgc.checkEvents.length <= 0) {
|