Skip to content

Commit

Permalink
chore: 避免重复定义不可修改属性
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Feb 26, 2025
1 parent 346a391 commit e3db83a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/amis-core/src/store/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const FormStore = ServiceStore.named('FormStore')

changeReason &&
Object.isExtensible(data) &&
!data.__changeReason &&
Object.defineProperty(data, '__changeReason', {
value: changeReason,
enumerable: false,
Expand Down Expand Up @@ -307,6 +308,7 @@ export const FormStore = ServiceStore.named('FormStore')

changeReason &&
Object.isExtensible(data) &&
!data.__changeReason &&
Object.defineProperty(data, '__changeReason', {
value: changeReason,
enumerable: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/amis-core/src/store/iRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const iRendererStore = StoreNode.named('iRendererStore')

changeReason &&
Object.isExtensible(data) &&
!(data as any).__changeReason &&
Object.defineProperty(data, '__changeReason', {
value: changeReason,
enumerable: false,
Expand Down Expand Up @@ -135,6 +136,7 @@ export const iRendererStore = StoreNode.named('iRendererStore')

changeReason &&
Object.isExtensible(newData) &&
!(newData as any).__changeReason &&
Object.defineProperty(newData, '__changeReason', {
value: changeReason,
enumerable: false,
Expand Down Expand Up @@ -210,6 +212,7 @@ export const iRendererStore = StoreNode.named('iRendererStore')

changeReason &&
Object.isExtensible(data) &&
!data.__changeReason &&
Object.defineProperty(data, '__changeReason', {
value: changeReason,
enumerable: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/amis-core/src/store/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export const Row = types
let data = immutableExtends(self.data, values);

Object.isExtensible(data) &&
!data.__pristine &&
Object.defineProperty(data, '__pristine', {
value: savePristine ? data : self.pristine,
enumerable: false,
Expand Down Expand Up @@ -511,6 +512,7 @@ export const Row = types
};

Object.isExtensible(data) &&
!data.__pristine &&
Object.defineProperty(data, '__pristine', {
value: self.data.__pristine || self.pristine,
enumerable: false,
Expand Down

0 comments on commit e3db83a

Please sign in to comment.