Explorar el Código

AI一键生成内容格式化处理

雷佳斌 hace 2 meses
padre
commit
fcf3e5f9f9
Se han modificado 3 ficheros con 21640 adiciones y 11 borrados
  1. 21627 0
      package-lock.json
  2. 2 1
      package.json
  3. 11 10
      src/pages/reportdetail/reportdetail.js

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 21627 - 0
package-lock.json


+ 2 - 1
package.json

@@ -44,7 +44,8 @@
 		"redux": "^4.0.0",
 		"redux-logger": "^3.0.6",
 		"redux-thunk": "^2.3.0",
-		"tslib": "^1.8.0"
+		"tslib": "^1.8.0",
+		"marked": "5.0.1"
 	},
 	"devDependencies": {
 		"@tarojs/cli": "1.3.4",

+ 11 - 10
src/pages/reportdetail/reportdetail.js

@@ -7,6 +7,7 @@ import { getWindowHeight } from '@utils/style'
 import ImagePicker from '../../components/imagePicker'
 import RuiEditor from '../../components/editor'
 import './reportdetail.scss'
+import { marked } from "marked"
 
 @connect(state => state.home, { ...actions, })
 class ReportDetail extends Component {
@@ -100,10 +101,10 @@ class ReportDetail extends Component {
     })
 
     this.props.generatePlus(payload).then((res) => {
+      console.log(res)
       Taro.hideLoading()
       chapters.forEach(item => {
-        console.log(item)
-        item.content = res[item.title];
+        item.content = marked.parse(res[item.title])
       });
 
       this.setState({ chapters });
@@ -128,13 +129,13 @@ class ReportDetail extends Component {
       const chaplist = this.state.data.chapters
       chaplist.forEach(function (item, index) {
         if (index == i) {
-          const paragraphs = res.split('\n').map((paragraph) =>
-            !!paragraph
-              ? `<p>${paragraph.trim()}</p>`
-              : `\n`
-          );
-          item.content = paragraphs.join('');
-          // item.content = res
+          // const paragraphs = res.split('\n').map((paragraph) =>
+          //   !!paragraph
+          //     ? `<p>${paragraph.trim()}</p>`
+          //     : `\n`
+          // );
+          // item.content = paragraphs.join('');
+          item.content = marked.parse(res)
         }
       })
       this.setState({
@@ -523,7 +524,7 @@ class ReportDetail extends Component {
               />
             </View>
             <View className='home-item-vals-bt'>
-              <Button size='mini' type='primary' onClick={this.getGeneratePlus}>Al一键生成</Button>
+              <Button size='mini' type='primary' onClick={this.getGeneratePlus}>AI一键生成</Button>
             </View>
           </View>
         </View>