mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 12:08:13 +08:00
fix: 修复 form 关联的数据在地址栏, 地址栏变化不会同步的问题 (#3108)
This commit is contained in:
parent
ee3783a319
commit
d545a5b07c
@ -10,7 +10,8 @@ import {
|
||||
extendObject,
|
||||
guid,
|
||||
isObjectShallowModified,
|
||||
syncDataFromSuper
|
||||
syncDataFromSuper,
|
||||
isSuperDataModified
|
||||
} from './utils/helper';
|
||||
import {dataMapping} from './utils/tpl-builtin';
|
||||
import {RootStoreContext} from './WithRootStore';
|
||||
@ -174,7 +175,9 @@ export function HocStoreFactory(renderer: {
|
||||
}
|
||||
} else if (
|
||||
shouldSync === true ||
|
||||
isObjectShallowModified(prevProps.data, props.data)
|
||||
isObjectShallowModified(prevProps.data, props.data) ||
|
||||
(props.syncSuperStore !== false &&
|
||||
isSuperDataModified(props.data, prevProps.data, store))
|
||||
) {
|
||||
if (props.store && props.store.data === props.data) {
|
||||
store.initData(
|
||||
|
@ -72,6 +72,30 @@ export function extendObject(
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function isSuperDataModified(
|
||||
data: any,
|
||||
prevData: any,
|
||||
store: IIRendererStore
|
||||
) {
|
||||
let keys: Array<string> = [];
|
||||
|
||||
if (store && store.storeType === 'FormStore') {
|
||||
keys = uniq(
|
||||
(store as IFormStore).items
|
||||
.map(item => `${item.name}`.replace(/\..*$/, ''))
|
||||
.concat(Object.keys(store.data))
|
||||
);
|
||||
} else {
|
||||
keys = Object.keys(store.data);
|
||||
}
|
||||
|
||||
if (Array.isArray(keys) && keys.length) {
|
||||
return keys.some(key => data[key] !== prevData[key]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function syncDataFromSuper(
|
||||
data: any,
|
||||
superObject: any,
|
||||
|
Loading…
Reference in New Issue
Block a user