From 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 25 七月 2023 16:36:23 +0800 Subject: [PATCH] 2023-07-25 --- src/tabviews/custom/components/chart/antv-G6/index.jsx | 93 +++++++++++++++++++++++++++++++--------------- 1 files changed, 63 insertions(+), 30 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-G6/index.jsx b/src/tabviews/custom/components/chart/antv-G6/index.jsx index 51977d6..53d4d4f 100644 --- a/src/tabviews/custom/components/chart/antv-G6/index.jsx +++ b/src/tabviews/custom/components/chart/antv-G6/index.jsx @@ -831,18 +831,22 @@ BID = BData.$BID || '' } - if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { - this.data = window.GLOB.SyncData.get(_config.dataName) || [] + if (_config.setting.sync === 'true') { + _config.setting.onload = 'false' - if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + if (window.GLOB.SyncData.has(_config.dataName)) { + this.data = window.GLOB.SyncData.get(_config.dataName) || [] + + if (_config.$cache) { + Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS()) + } + + _config.setting.sync = 'false' + + this.loaded = true + + window.GLOB.SyncData.delete(_config.dataName) } - - _config.setting.sync = 'false' - - this.loaded = true - - window.GLOB.SyncData.delete(_config.dataName) } _config.plot.height = Utils.getHeight(_config.plot.height) @@ -858,17 +862,7 @@ BData: BData || '', arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot - }, () => { - if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } }) - - if (this.data.length > 0) { - this.handleData() - } let that = this @@ -1015,16 +1009,7 @@ MKEmitter.addListener('transferSyncData', this.transferSyncData) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - if (!is(fromJS(this.data), fromJS(res))) { - this.data = res - this.handleData() - } - }) - } + this.initExec() } /** @@ -1040,6 +1025,54 @@ MKEmitter.removeListener('transferSyncData', this.transferSyncData) } + initExec = () => { + const { config } = this.state + + if (config.$cache) { + if (config.$time) { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, config.$time).then(res => { + if (!res && config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } + + if (!res || this.loaded) return + + this.data = res + this.handleData() + }) + } else { + this.handleData() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.data = res + this.handleData() + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.handleData() + } + } + transferSyncData = (syncId) => { const { config } = this.state -- Gitblit v1.8.0