Yansen il y a 5 ans
Parent
révision
dc103533a1
3 fichiers modifiés avec 67 ajouts et 59 suppressions
  1. 1
    1
      config/config.js
  2. 13
    0
      config/routes.js
  3. 53
    58
      src/components/Wangedit/Wangedit.jsx

+ 1
- 1
config/config.js Voir le fichier

@@ -134,7 +134,7 @@ export default {
134 134
   proxy: {
135 135
     '/api': {
136 136
       // target: 'https://dev.fangdeal.cn',
137
-      target: 'http://192.168.0.195:8080/',
137
+      target: 'http://127.0.0.1:8080/',
138 138
       changeOrigin: true,
139 139
       // pathRewrite: { '^/server': '' },
140 140
     },

+ 13
- 0
config/routes.js Voir le fichier

@@ -211,6 +211,19 @@ export default [
211 211
             ],
212 212
           },
213 213
 
214
+          {
215
+            path: '/officenews',
216
+            name: '资讯管理',
217
+            component: '../layouts/BlankLayout',
218
+            routes: [
219
+              {
220
+                path: '/officenews',
221
+                name: '资讯管理',
222
+                component: './resource/openScreen',
223
+              },
224
+            ],
225
+          },
226
+
214 227
           {
215 228
             component: './404',
216 229
           },

+ 53
- 58
src/components/Wangedit/Wangedit.jsx Voir le fichier

@@ -11,82 +11,74 @@ class Wangedit extends React.Component {
11 11
     super(props, context);
12 12
     this.state = {
13 13
       html: undefined,
14
-      contenteditable: props.contenteditable == false ? false : true
15
-    }
14
+      contenteditable: props.contenteditable == false ? false : true,
15
+    };
16 16
     this.editor = undefined;
17 17
   }
18 18
 
19
-  render() {
20
-    return (
21
-      <div ref="editorElem" style={{ textAlign: 'left' }}>
22
-      </div>
23
-    );
24
-  }
25
-
26 19
   componentDidMount() {
27
-    const elem = this.refs.editorElem
28
-    this.editor = new E(elem)
20
+    const elem = this.refs.editorElem;
21
+    this.editor = new E(elem);
29 22
     // 使用 onchange 函数监听内容的变化
30 23
     this.editor.customConfig.onchange = html => {
31
-      this.setState({ html })
24
+      this.setState({ html });
32 25
 
33 26
       if (typeof this.props.onChange === 'function') {
34
-        this.props.onChange(html)
27
+        this.props.onChange(html);
35 28
       }
36
-    }
37
-    this.editor.customConfig.zIndex = 100
38
-    this.editor.customConfig.uploadImgMaxLength = 1
39
-    this.editor.customConfig.customUploadImg = function (files, insert) {
40
-      if (!files.length) return
41
-      
42
-      const data = new FormData()
43
-      data.append('file', files[0])
29
+    };
30
+    this.editor.customConfig.zIndex = 100;
31
+    this.editor.customConfig.uploadImgMaxLength = 1;
32
+    this.editor.customConfig.customUploadImg = function(files, insert) {
33
+      if (!files.length) return;
44 34
 
45
-      fetch(apis.image.upload)({data}).then(insert)
46
-    }
35
+      const data = new FormData();
36
+      data.append('file', files[0]);
37
+
38
+      fetch(apis.image.upload)({ data }).then(insert);
39
+    };
47 40
     this.editor.customConfig.menus = [
48
-      'head',  // 标题
49
-      'bold',  // 粗体
50
-      'fontSize',  // 字号
51
-      'fontName',  // 字体
52
-      'italic',  // 斜体
53
-      'underline',  // 下划线
54
-      'strikeThrough',  // 删除线
55
-      'foreColor',  // 文字颜色
56
-      'backColor',  // 背景颜色
57
-      'list',  // 列表
58
-      'justify',  // 对齐方式
59
-      'quote',  // 引用
60
-      'image',  // 插入图片
61
-      'undo',  // 撤销
62
-      'redo'  // 重复
63
-    ]
64
-    
41
+      'head', // 标题
42
+      'bold', // 粗体
43
+      'fontSize', // 字号
44
+      'fontName', // 字体
45
+      'italic', // 斜体
46
+      'underline', // 下划线
47
+      'strikeThrough', // 删除线
48
+      'foreColor', // 文字颜色
49
+      'backColor', // 背景颜色
50
+      'list', // 列表
51
+      'justify', // 对齐方式
52
+      'quote', // 引用
53
+      'image', // 插入图片
54
+      'undo', // 撤销
55
+      'redo', // 重复
56
+    ];
57
+
65 58
     // 过滤 word 字符
66
-    this.editor.customConfig.pasteFilterStyle = false
59
+    this.editor.customConfig.pasteFilterStyle = false;
67 60
     this.editor.customConfig.pasteTextHandle = function(content) {
68 61
       const regs = [
69
-        /<!--\[if [\s\S]*?endif\]-->/ig,
70
-        /<[a-zA-Z0-9]+\:[^>]+>[^>]*<\/[a-zA-Z0-9]+\:[^>]+>/ig,
71
-        /<[a-zA-Z0-9]+\:[^>]+\/>/ig,
72
-        /<style>[\s\S]*?<\/style>/ig,
73
-      ]
62
+        /<!--\[if [\s\S]*?endif\]-->/gi,
63
+        /<[a-zA-Z0-9]+\:[^>]+>[^>]*<\/[a-zA-Z0-9]+\:[^>]+>/gi,
64
+        /<[a-zA-Z0-9]+\:[^>]+\/>/gi,
65
+        /<style>[\s\S]*?<\/style>/gi,
66
+        new RegExp('\u2029', 'ig'), // 替换word分隔符 序号 8233
67
+      ];
74 68
 
75
-      return regs.reduce((acc, reg) => {
76
-        return acc.replace(reg, '')
77
-      }, content)
78
-    }
69
+      return regs.reduce((acc, reg) => acc.replace(reg, ''), content);
70
+    };
79 71
 
80
-    this.editor.create()
81
-    this.editor.$textElem.attr('contenteditable',this.state.contenteditable);
82
-    this.editor.customConfig.uploadImgShowBase64 = true
83
-    this.editor.txt.html(this.props.value)
72
+    this.editor.create();
73
+    this.editor.$textElem.attr('contenteditable', this.state.contenteditable);
74
+    this.editor.customConfig.uploadImgShowBase64 = true;
75
+    this.editor.txt.html(this.props.value);
84 76
   }
85 77
 
86 78
   componentDidUpdate(props, state) {
87 79
     if (this.props.value && !state.html) {
88 80
       if (this.editor) {
89
-        this.editor.txt.html(this.props.value)
81
+        this.editor.txt.html(this.props.value);
90 82
       }
91 83
     }
92 84
   }
@@ -100,9 +92,12 @@ class Wangedit extends React.Component {
100 92
    * @memberof Wangedit
101 93
    */
102 94
   shouldComponentUpdate(nextProps) {
103
-    return nextProps.value !== this.editor.txt.html()
95
+    return nextProps.value !== this.editor.txt.html();
104 96
   }
105
-}
106 97
 
107
-export default Wangedit
98
+  render() {
99
+    return <div ref="editorElem" style={{ textAlign: 'left' }}></div>;
100
+  }
101
+}
108 102
 
103
+export default Wangedit;