CzRger il y a 2 semaines
Parent
commit
ba899502ff

+ 53 - 2
src/api/interceptors.ts

@@ -1,5 +1,6 @@
 import axios from 'axios'
-import { ElMessage, ElNotification } from 'element-plus'
+import { ElButton, ElMessage, ElNotification } from 'element-plus'
+import { h } from 'vue'
 
 // import {toLogin} from "@/utils/permissions";
 export class Interceptors {
@@ -64,12 +65,62 @@ export class Interceptors {
 
   private errorHandle(res: any) {
     console.error('错误接口:' + res.request.responseURL)
+    const exportLog = (arr) => {
+      // 将数据转换为字符串
+      const convertDataToText = (data) => {
+        let text = ''
+        for (const [key, value] of Object.entries(data)) {
+          text += `${key}: ${value}\n`
+        }
+        return text
+      }
+      let str = ''
+      arr.forEach((v) => {
+        if (typeof v === 'string') {
+          str += v
+        } else {
+          str += convertDataToText(v)
+        }
+        str += '\n\n'
+      })
+
+      const blob = new Blob([str], { type: 'text/plain' })
+      const url = URL.createObjectURL(blob)
+
+      const a = document.createElement('a')
+      a.href = url
+      a.download = '错误日志.txt'
+      document.body.appendChild(a)
+      a.click()
+      setTimeout(() => {
+        document.body.removeChild(a)
+        URL.revokeObjectURL(url)
+      }, 0)
+    }
     // 状态码判断
     switch (res.status) {
       case 400:
+        // ElNotification({
+        //   title: res.data.message,
+        //   message: res.data.data,
+        //   type: 'error',
+        //   duration: 0,
+        // })
         ElNotification({
           title: res.data.message,
-          message: res.data.data,
+          message: h('div', null, [
+            h(
+              ElButton,
+              {
+                type: 'warning',
+                size: 'small',
+                plain: true,
+                onClick: exportLog,
+              },
+              { default: () => '错误日志' },
+            ),
+            h('div', { class: 'mt-2' }, res.data.data),
+          ]),
           type: 'error',
           duration: 0,
         })

+ 10 - 1
src/views/manage/knowledge/detail.vue

@@ -146,7 +146,16 @@ const onSubmit = (isImport) => {
         content: `请确认是否${titleCpt.value}?${isImport ? '创建成功后将自动跳转至文档上传页面!' : ''}`,
         onSubmit: () => {
           state.loading = true
-          datasetsCreate({ ...state.form, ...ref_modelConfig.value.getData() })
+          datasetsCreate({
+            ...state.form,
+            ...ref_modelConfig.value.getData(),
+            contentConfig: {
+              maxParentSize: 500,
+              overlapSize: 20,
+              parentSeparator: '\n\n',
+              splitType: 'CustomSymbolSplitter',
+            },
+          })
             .then(({ data }: any) => {
               // ElMessage.success(`${titleCpt.value}成功!`)
               // if (isImport) {

+ 1 - 1
src/views/manage/knowledge/index.vue

@@ -251,7 +251,7 @@ const onPage = (pageNum, pageSize) => {
     pageSize: pageSize,
   }
   const params = {
-    tenantId: AppStore.tenantInfo?.id,
+    // tenantId: AppStore.tenantInfo?.id,
     page: state.query.page.pageNum,
     size: state.query.page.pageSize,
   }