lanjianrong hace 4 años
padre
commit
57a5ae2b93

+ 3 - 1
package.json

@@ -60,6 +60,7 @@
     "classnames": "^2.2.6",
     "crypto-js": "^4.0.0",
     "dayjs": "^1.10.4",
+    "easymde": "^2.15.0",
     "install": "^0.13.0",
     "lodash-es": "^4.17.21",
     "markdown-it": "^12.2.0",
@@ -70,7 +71,8 @@
     "react-dom": "17.0.2",
     "react-helmet-async": "^1.0.4",
     "react-infinite-scroll-component": "^6.1.0",
-    "react-markdown-editor-lite": "^1.3.1",
+    "react-markdown": "^7.0.1",
+    "react-simplemde-editor": "5.0.2",
     "umi": "3.5.4"
   },
   "devDependencies": {

+ 12 - 14
src/pages/Hr/Notification/components/RighEditor.jsx

@@ -1,24 +1,22 @@
 import React, { useState } from 'react'
-import MarkdownIt from 'markdown-it'
-import MdEditor from 'react-markdown-editor-lite'
-import 'react-markdown-editor-lite/lib/index.css'
-
-const mdParser = new MarkdownIt()
+import SimpleMDE from 'react-simplemde-editor'
+import 'easymde/dist/easymde.min.css'
 
 const RighEditor = ({ value, onChange }) => {
   const [cValue, setValue] = useState(value)
   // 完成!
-  function handleEditorChange({ text, html }) {
-    setValue(text)
-    onChange(JSON.stringify(html))
+  function handleEditorChange(content) {
+    setValue(content)
+    onChange(content)
   }
   return (
-    <MdEditor
-      style={{ height: '300px' }}
-      value={cValue}
-      renderHTML={text => mdParser.render(text)}
-      onChange={handleEditorChange}
-    />
+    // <MdEditor
+    //   style={{ height: '300px' }}
+    //   value={cValue}
+    //   renderHTML={text => mdParser.render(text)}
+    //   onChange={handleEditorChange}
+    // />
+    <SimpleMDE value={cValue} onChange={handleEditorChange} style={{ height: '300px' }} />
   )
 }
 

+ 6 - 5
src/pages/Hr/Notification/index.jsx

@@ -29,13 +29,13 @@ const Notification = () => {
   const initData = async params => {
     setState({ ...state, loading: true })
     const {
-      data: { message = [], total },
+      data: { message: list = [], total },
       code = -1
     } = await queryMessageList({ ...params, pageSize: state.pageSize })
     if (code === consts.RET_CODE.SUCCESS) {
       setState({
         ...state,
-        message: params?.current === 1 ? message : state.message.concat(message),
+        list: params?.current === 1 ? list : state.list.concat(message),
         total,
         loading: false,
         hasMore: total > params.current * state.pageSize,
@@ -52,7 +52,7 @@ const Notification = () => {
 
   const { run: trySendMessage } = useRequest(sendMessage, {
     manual: true,
-    onSuccess: result => {
+    onSuccess: () => {
       tRef.current?.reload()
       // sendMsg(cmdType.Notice, result)
     },
@@ -74,11 +74,12 @@ const Notification = () => {
           hasMore={state.hasMore}
           loader={<Skeleton avatar paragraph={{ rows: 1 }} active />}
           endMessage={<Divider plain>别再滚啦,已是尽头</Divider>}
-          scrollableTarget="scrollableDiv">
+          scrollableTarget="scrollableDiv"
+        >
           <List
             itemLayout="horizontal"
             // pagination={{ pageSize: 5 }}
-            dataSource={state.message}
+            dataSource={state.list}
             renderItem={item => (
               <List.Item key={item.id}>
                 <List.Item.Meta