Skip to content

Commit 8941273

Browse files
committed
fix: 调整 JSExpression 保留原有属性
1 parent f6305c2 commit 8941273

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

packages/designer/src/designer/setting/setting-field.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export class SettingField extends SettingPropEntry implements ISettingField {
274274
if (isJSExpression(value)) {
275275
this.setValue(
276276
{
277+
...value,
277278
type: 'JSExpression',
278279
value: value.value,
279280
mock: oldValue.mock,
@@ -285,6 +286,7 @@ export class SettingField extends SettingPropEntry implements ISettingField {
285286
} else {
286287
this.setValue(
287288
{
289+
...oldValue,
288290
type: 'JSExpression',
289291
value: oldValue.value,
290292
mock: value,

packages/designer/src/designer/setting/setting-prop-entry.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,20 @@ export class SettingPropEntry implements ISettingPropEntry {
355355

356356
setVariableValue(value: string) {
357357
const v = this.getValue();
358-
this.setValue({
359-
type: 'JSExpression',
360-
value,
361-
mock: isJSExpression(v) ? v.mock : v,
362-
});
358+
if (isJSExpression(v)) {
359+
this.setValue({
360+
...v,
361+
type: 'JSExpression',
362+
value,
363+
mock: v.mock,
364+
});
365+
} else {
366+
this.setValue({
367+
type: 'JSExpression',
368+
value,
369+
mock: v,
370+
});
371+
}
363372
}
364373

365374
setUseVariable(flag: boolean) {

packages/engine/src/modules/live-editing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const liveEditingSaveHander: SaveHandler = {
6464
data = content;
6565
if (isJSExpression(v)) {
6666
prop.setValue({
67+
...v,
6768
type: 'JSExpression',
6869
value: v.value,
6970
mock: data,

0 commit comments

Comments
 (0)