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/code/sand-box/index.jsx | 77 +++++++++++++++++++++++++++++--------- 1 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx index 0a9b6a3..9027a05 100644 --- a/src/tabviews/custom/components/code/sand-box/index.jsx +++ b/src/tabviews/custom/components/code/sand-box/index.jsx @@ -42,6 +42,8 @@ } if (_config.wrap.datatype !== 'static') { + _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true' + if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) { _data = window.GLOB.SyncData.get(_config.dataName) || [] @@ -55,8 +57,6 @@ window.GLOB.SyncData.delete(_config.dataName) } - } else { - this.loaded = true } if (_config.css) { @@ -73,14 +73,7 @@ data: _data, BID: BID || '', config: _config, - arr_field: _config.columns.map(col => col.field).join(','), - }, () => { - if (_config.wrap.datatype !== 'static' && config.setting.sync !== 'true' && _config.setting.onload === 'true') { - setTimeout(() => { - this.loadData() - }, _config.setting.delay || 0) - } - this.renderView() + arr_field: _config.columns.map(col => col.field).join(',') }) } @@ -97,15 +90,7 @@ MKEmitter.addListener('transferSyncData', this.transferSyncData) } - if (config.$cache && !this.loaded) { - Api.getLCacheConfig(config.uuid).then(res => { - if (!res || this.loaded) return - - this.setState({data: res}, () => { - this.renderView() - }) - }) - } + this.initExec() } shouldComponentUpdate (nextProps, nextState) { @@ -121,6 +106,60 @@ MKEmitter.removeListener('transferSyncData', this.transferSyncData) } + initExec = () => { + const { config } = this.state + + if (config.wrap.datatype !== 'static') { + 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.setState({data: res}, () => { + this.renderView() + }) + }) + } else { + this.renderView() + } + } else { + if (!this.loaded) { + Api.getLCacheConfig(config.uuid, 0).then(res => { + if (!res || this.loaded) return + + this.setState({data: res}, () => { + this.renderView() + }) + }) + } + + if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.renderView() + } + } + } else if (config.setting.onload === 'true') { + setTimeout(() => { + this.loadData() + }, config.setting.delay || 0) + } else if (this.loaded) { + this.renderView() + } + } else { + this.renderView() + } + } + transferSyncData = (syncId) => { const { config } = this.state -- Gitblit v1.8.0