From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 17 八月 2023 16:22:15 +0800
Subject: [PATCH] 2023-08-17

---
 src/components/editor/index.jsx |   56 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/src/components/editor/index.jsx b/src/components/editor/index.jsx
index b7745fe..fb02a69 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'
@@ -14,40 +14,62 @@
 
 BraftEditor.use(Table())
 
-let service = ''
-if (process.env.NODE_ENV === 'production') {
-  service = document.location.origin + '/' + window.GLOB.service
-} else {
-  service = window.GLOB.location + '/' + window.GLOB.service
-}
-
 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)
     }
   }
 
@@ -58,12 +80,14 @@
     form.append('file', _param.binary)
     form.append('fileMd5', params.file.fileMd5)
     form.append('shardingMd5', _param.chunkMd5)
-    form.append('baseDomain', service)
+    form.append('baseDomain', window.GLOB.baseurl)
     form.append('rootPath', 'Content/images/upload/')
     form.append('fileName', params.file.fileName)
     form.append('fileExt', params.file.fileType)
     form.append('shardingCnt', _param.chunks)
     form.append('shardingNo', _param.chunk)
+    form.append('LoginUID', sessionStorage.getItem('LoginUID') || '')
+    form.append('UserID', sessionStorage.getItem('UserID') || '')
 
     Api.getLargeFileUpload(form).then(res => {
       if (res.status) {

--
Gitblit v1.8.0