From 97e18fa9b628357fa43013cfefc96eec078de25e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 16 一月 2023 15:58:12 +0800 Subject: [PATCH] 2023-01-16 --- src/tabviews/custom/components/card/balcony/index.jsx | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index 2103653..bf037dd 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -31,6 +31,8 @@ checked: false } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -59,16 +61,21 @@ _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } else if (_sync && initdata) { _data = initdata if (Array.isArray(_data)) { _data = _data[0] || {$$empty: true} } _sync = false + this.loaded = true } } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { _data = window.GLOB.CacheData.get(_config.wrap.publicId) _data = fromJS(_data).toJS() + this.loaded = true + } else if (_config.wrap.datatype === 'static') { + this.loaded = true } _data.$$BID = BID || '' @@ -127,7 +134,7 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('syncBalconyData', this.syncBalconyData) @@ -144,9 +151,9 @@ this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) } - if (config.$cache && (config.setting.sync !== 'true' || sync)) { + if (config.$cache && !this.loaded) { Api.getLCacheConfig(config.uuid).then(res => { - if (!res) return + if (!res || this.loaded) return let _data = res[0] _data.$$uuid = _data[config.setting.primaryKey] || '' @@ -192,6 +199,9 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.loaded = true + this.setState({sync: false, data: _data}) } } @@ -205,6 +215,8 @@ _data.$$BID = BID || '' _data.$$BData = BData || '' _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.loaded = true this.setState({data: _data}) } @@ -313,6 +325,7 @@ this.setState({ data: {$$BID: BID || '', $$BData: BData, $$empty: true}, }) + this.loaded = true return } @@ -331,6 +344,7 @@ if (result.status) { let _data = {} + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } -- Gitblit v1.8.0