From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 01 九月 2021 10:31:45 +0800
Subject: [PATCH] 2021-09-01

---
 src/components/editor/index.jsx |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/components/editor/index.jsx b/src/components/editor/index.jsx
index b7745fe..e18f2b8 100644
--- a/src/components/editor/index.jsx
+++ b/src/components/editor/index.jsx
@@ -4,7 +4,7 @@
 import BraftEditor from 'braft-editor'
 import 'braft-editor/dist/index.css'
 import 'braft-extensions/dist/table.css'
-import 'braft-editor/dist/output.css'
+// import 'braft-editor/dist/output.css'
 import Table from 'braft-extensions/dist/table'
 import SparkMD5 from 'spark-md5'
 import moment from 'moment'
@@ -23,31 +23,60 @@
 
 class NormalEditor extends Component {
   static propTpyes = {
-    card: PropTypes.object,  // 鏉$爜璁剧疆
-    value: PropTypes.any,    // 鏉$爜鍊�
+    config: PropTypes.object,
+    onChange: PropTypes.func
   }
 
   state = {
-    editorState: ''
+    editorState: '',
+    encryption: 'false',
   }
 
   UNSAFE_componentWillMount () {
+    const { config, defaultValue } = this.props
     let initVal = null
+    let encryption = 'false'
 
-    if (this.props['data-__meta']) {
-      initVal = this.props['data-__meta'].initialValue || null
+    if (config && config.initval) {
+      initVal = config.initval
+    } else if (defaultValue) {
+      initVal = defaultValue
+    }
+
+    if (config && config.encryption === 'true') {
+      encryption = 'true'
+      if (initVal) {
+        try {
+          initVal = window.decodeURIComponent(window.atob(initVal))
+        } catch (e) {
+          initVal = this.props['data-__meta'].initialValue || null
+        }
+      }
     }
     
-    this.setState({editorState: BraftEditor.createEditorState(initVal)})
+    this.setState({
+      editorState: BraftEditor.createEditorState(initVal),
+      encryption
+    })
   }
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.props), fromJS(nextProps))
   }
 
   handleEditorChange = (editorState) => {
+    const { encryption } = this.state
+
     this.setState({ editorState })
     if (this.props.onChange) {
-      this.props.onChange(editorState.toHTML())
+      let val = editorState.toHTML()
+      if (encryption === 'true') {
+        try {
+          val = window.btoa(window.encodeURIComponent(val))
+        } catch (e) {
+          val = editorState.toHTML()
+        }
+      }
+      this.props.onChange(val)
     }
   }
 
@@ -64,6 +93,7 @@
     form.append('fileExt', params.file.fileType)
     form.append('shardingCnt', _param.chunks)
     form.append('shardingNo', _param.chunk)
+    form.append('LoginUID', sessionStorage.getItem('LoginUID') || '')
 
     Api.getLargeFileUpload(form).then(res => {
       if (res.status) {

--
Gitblit v1.8.0