king
2023-07-25 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939
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