From 0d12d793e40b39f4a63bc0ecd03cc32794e18a5b Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Sat, 16 Nov 2019 16:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AD=90=20=20store=20?= =?UTF-8?q?=E4=B8=8D=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/factory.tsx | 24 +++++++++++------------- src/renderers/Chart.tsx | 5 ++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/factory.tsx b/src/factory.tsx index fef67a2f..d26c5dd8 100644 --- a/src/factory.tsx +++ b/src/factory.tsx @@ -728,20 +728,18 @@ export function HocStoreFactory(renderer: { ); } else if (isObjectShallowModified(props.data, nextProps.data)) { if (nextProps.store && nextProps.store.data === nextProps.data) { - const diff = syncDataFromSuper( - store.data, - nextProps.store.data, - props.scope, - nextProps.dataUpdatedAt !== props.dataUpdatedAt, - store + store.initData( + createObject( + nextProps.store.data, + syncDataFromSuper( + store.data, + nextProps.store.data, + props.scope, + nextProps.dataUpdatedAt !== props.dataUpdatedAt, + store + ) + ) ); - - if (Object.keys(diff).length) { - const newData = createObject(nextProps.store.data, diff); - - // todo fix: dialog 种数据从孩子 form 同步过来后,会走这个逻辑让 form 更新 data,会导致里面的 __prev 丢失。 - store.initData(newData); - } } else if (nextProps.data && (nextProps.data as any).__super) { store.initData(extendObject(nextProps.data)); } else { diff --git a/src/renderers/Chart.tsx b/src/renderers/Chart.tsx index b8ae767a..6c754c54 100644 --- a/src/renderers/Chart.tsx +++ b/src/renderers/Chart.tsx @@ -34,7 +34,7 @@ export class Chart extends React.Component { echarts: any; unSensor: Function; pending?: object; - timer: number; + timer: NodeJS.Timeout; mounted: boolean; reloadCancel: Function; @@ -148,6 +148,9 @@ export class Chart extends React.Component { cancelExecutor: (executor: Function) => (this.reloadCancel = executor) }) .then(result => { + if (!result.ok) { + return env.notify('error', result.msg || '加载失败,请重试!'); + } delete this.reloadCancel; this.renderChart(result.data || {}); this.echarts && this.echarts.hideLoading();