lsc 7 months ago
parent
commit
62e4afcc65
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/components/pages/aiAddCourse/addCourse.vue

+ 5 - 1
src/components/pages/aiAddCourse/addCourse.vue

@@ -18115,7 +18115,11 @@ ${this.courseText && this.aiCallBack[0] == 2 ? '注意,优化原有的<参考
                     let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                     let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                     let match = data.message.match(regex);
                     let match = data.message.match(regex);
                     // eval("var aaa = " + match[0])
                     // eval("var aaa = " + match[0])
-                    dArray = JSON.parse(match[0].replace(/\n/g, '      ').replace(/\s{2,}/g, '      '));
+                    if(match && match[0]){
+                      dArray = JSON.parse(match[0].replace(/\n/g, '      ').replace(/\s{2,}/g, '      '));
+                    }else {
+                      dArray = JSON.parse(data.message.replace(/\n/g, '      ').replace(/\s{2,}/g, '      '));
+                    }
 
 
                 } catch (error) {
                 } catch (error) {
                   _this.$message.error('返回json格式不正确')
                   _this.$message.error('返回json格式不正确')