diff --git a/packages/devkit/lib/store/entity-store/entity-data-loader.ts b/packages/devkit/lib/store/entity-store/entity-data-loader.ts index 886e432acc09f9fe6227be862f331aecba708aa5..b7be132ab571a95e4ac797918622068b30fab2ce 100644 --- a/packages/devkit/lib/store/entity-store/entity-data-loader.ts +++ b/packages/devkit/lib/store/entity-store/entity-data-loader.ts @@ -2,6 +2,7 @@ import { FieldType, EntitySchema, EntityFieldSchema, PrimitiveFieldSchema, Entit import { Entity } from './entity'; import { createEntityBySchema } from './entity-creator'; import { createEntityListBySchema } from './entity-list-creator'; +import { Locale } from '../../i18n'; /** * 实体数据加载器 @@ -45,11 +46,17 @@ class EntityDataLoader { const multiLanguage = fieldSchema.multiLanguage; const dataField = multiLanguage ? `${fieldSchema.name}_MULTILANGUAGE` : fieldSchema.name; const propName = fieldSchema.name; - if (entityData.hasOwnProperty(dataField)) { - entity[propName] = entityData[dataField]; + const localeId = Locale.getLocaleId(); + if (multiLanguage) { + if (entityData.hasOwnProperty(dataField)) { + entity[propName] = entityData[dataField]; + } else { + entity[propName] = { [localeId]: entityData[propName] }; + } } else { entity[propName] = entityData[propName]; } + }); } diff --git a/packages/devkit/lib/store/entity-store/entity-state-updater.ts b/packages/devkit/lib/store/entity-store/entity-state-updater.ts index 92377189ca14829e3630631cedde4251ac0177f7..5c0e037706269107737a5c65eda542bdae635525 100644 --- a/packages/devkit/lib/store/entity-store/entity-state-updater.ts +++ b/packages/devkit/lib/store/entity-store/entity-state-updater.ts @@ -8,6 +8,8 @@ import { Entity } from './entity'; import { EntityList } from './entity-list'; import { EntityStateQuery } from './entity-state-query'; import { EntityState, EntityStore } from './entity-store'; +import { FieldType, PrimitiveFieldSchema } from './entity-schema'; +import { isEqual } from 'lodash-es'; /** * 实体状态更新 @@ -148,6 +150,14 @@ class EntityStateUpdater { if (oldValue === newValue) { return; } + const fieldSchema = this.entityStore.getEntitySchema().getFieldSchemaByPath(path); + if (fieldSchema && fieldSchema.type === FieldType.Primitive) { + const primitiveFielsSchema = fieldSchema as PrimitiveFieldSchema; + const { multiLanguage } = primitiveFielsSchema; + if (multiLanguage && isEqual(oldValue, newValue)) { + return; + } + } entity[fieldName] = newValue; const change: ChangeValueChange = { diff --git a/packages/ui-vue/components/dynamic-view/src/dynamic-view.component.tsx b/packages/ui-vue/components/dynamic-view/src/dynamic-view.component.tsx index b573096446169715e731a12b0fd1e2c738d29e33..a22fc7fe349faed79f9e774607fecb54c183b24e 100644 --- a/packages/ui-vue/components/dynamic-view/src/dynamic-view.component.tsx +++ b/packages/ui-vue/components/dynamic-view/src/dynamic-view.component.tsx @@ -195,7 +195,7 @@ const FDynamicView = defineComponent({ if (children && children.length > 0) { vnode = createVNode(componentType, { ...props }, children); } else { - vnode = createVNode(componentType, { ...props }, null); + vnode = createVNode(componentType, { ...props }, null); } return vnode; @@ -343,12 +343,12 @@ const FDynamicView = defineComponent({ if (!currentState) { state.set(viewSchema.id, reactive({ props: modelProps })); } else { - mergeWith(currentState?.props, modelProps, (objValue, srcValue) => { - if (Array.isArray(srcValue)) { - return srcValue; - } - return undefined; + const currentProps = { ...currentState?.props }; + Object.keys(modelProps).forEach(key => { + currentProps[key] = modelProps[key]; }); + Object.assign(currentState?.props, currentProps); + } // state.set(viewSchema.id, reactive({ props: { ...currentProps, ...modelProps } })); }