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/code/sand-box/index.jsx | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx index 0663d06..a9edce6 100644 --- a/src/tabviews/custom/components/code/sand-box/index.jsx +++ b/src/tabviews/custom/components/code/sand-box/index.jsx @@ -24,6 +24,8 @@ html: '', } + loaded = false + UNSAFE_componentWillMount () { const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() @@ -49,12 +51,15 @@ if (_sync && data) { _data = data[_config.dataName] || {} _sync = false + this.loaded = true } else if (_sync && initdata) { _data = initdata || {} _sync = false + this.loaded = true } } else { _data = {} + this.loaded = true } if (_config.css) { @@ -84,13 +89,13 @@ } componentDidMount () { - const { config, sync } = this.state + const { config } = this.state MKEmitter.addListener('reloadData', this.reloadData) - 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 this.setState({data: res[0]}, () => { this.renderView() @@ -121,6 +126,8 @@ if (nextProps.data && nextProps.data[config.dataName]) { _data = nextProps.data[config.dataName] } + + this.loaded = true this.setState({sync: false, data: _data}) @@ -159,6 +166,7 @@ data: {}, loading: false }) + this.loaded = true return } @@ -180,6 +188,7 @@ if (result.status) { let _data = result.data || {} + this.loaded = true if (config.$cache) { Api.writeCacheConfig(config.uuid, result.data || '') } -- Gitblit v1.8.0