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 |   29 ++++++++++++-----------------
 1 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/components/editor/index.jsx b/src/components/editor/index.jsx
index f4d856c..fb02a69 100644
--- a/src/components/editor/index.jsx
+++ b/src/components/editor/index.jsx
@@ -14,17 +14,10 @@
 
 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 = {
-    Item: PropTypes.object,     // 琛ㄥ崟鍏冪礌
-    onChange: PropTypes.func,   // 琛ㄥ崟鏇存柊
+    config: PropTypes.object,
+    onChange: PropTypes.func
   }
 
   state = {
@@ -33,21 +26,22 @@
   }
 
   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
-    } else if (this.props.defaultValue) {
-      initVal = this.props.defaultValue || null
+    if (config && config.initval) {
+      initVal = config.initval
+    } else if (defaultValue) {
+      initVal = defaultValue
     }
 
-    if (this.props.Item && this.props.Item.encryption === 'true') {
+    if (config && config.encryption === 'true') {
       encryption = 'true'
       if (initVal) {
         try {
           initVal = window.decodeURIComponent(window.atob(initVal))
-        } catch {
+        } catch (e) {
           initVal = this.props['data-__meta'].initialValue || null
         }
       }
@@ -71,7 +65,7 @@
       if (encryption === 'true') {
         try {
           val = window.btoa(window.encodeURIComponent(val))
-        } catch {
+        } catch (e) {
           val = editorState.toHTML()
         }
       }
@@ -86,13 +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