king
2025-02-06 d1cd5af5adb53e91efdd278328e1b6f8ad834fb5
src/tabviews/custom/components/editor/braft-editor/index.jsx
@@ -73,7 +73,7 @@
    }
    this.setState({
      data: _data,
      data: this.decodeHtml(_data, _config.wrap),
      BID: BID || '',
      config: _config,
    })
@@ -130,7 +130,7 @@
    let _data = window.GLOB.SyncData.get(config.dataName) || []
    this.setState({data: _data})
    this.setState({data: this.decodeHtml(_data, config.wrap)})
    window.GLOB.SyncData.delete(config.dataName)
@@ -158,7 +158,7 @@
        _data = [_data]
      }
      this.setState({data: _data})
      this.setState({data: this.decodeHtml(_data, config.wrap)})
    }
  }
@@ -224,7 +224,7 @@
    let result = await Api.genericInterface(param)
    if (result.status) {
      this.setState({
        data: result.data || [],
        data: this.decodeHtml(result.data, config.wrap),
        loading: false
      })
      
@@ -236,6 +236,35 @@
      
      UtilsDM.queryFail(result)
    }
  }
  decodeHtml = (data, wrap) => {
    if (!data || data.length === 0) return []
    data.forEach(item => {
      item.$html = item[wrap.field] || ''
      if (item.$html) {
        if (wrap.encryption === 'true') {
          try {
            item.$html = window.decodeURIComponent(window.atob(item.$html))
          } catch (e) {
            item.$html = item[wrap.field] || ''
          }
        }
        delete item[wrap.field]
        if (/\$[\s\S]+\$/.test(item.$html)) {
          Object.keys(item).forEach(key => {
            if (/^\$/.test(key)) return
            let reg = new RegExp('\\$' + key + '\\$', 'ig')
            item.$html = item.$html.replace(reg, item[key])
          })
        }
      }
    })
    return data
  }
  render() {
@@ -254,11 +283,10 @@
        <NormalHeader config={config}/>
        {config.wrap.datatype === 'static' ? <BraftContent
          value={config.html}
          encryption={'false'}
        /> : data.map((item, index) => <BraftContent
          key={index}
          value={item[config.wrap.field] || ''}
          encryption={config.wrap.encryption}
          value={item.$html}
          script={config.wrap.loaded === 'true' ? config.wrap.loadedfunc : ''}
        />)}
      </div>
    )