chd 1 tháng trước cách đây
mục cha
commit
7a8f3936e1

+ 1 - 1
.env

@@ -1,6 +1,6 @@
 VITE_OPENAI_API_KEY_TONG=sk-e9855234f47346049809ce23ed3ebe3f
 VITE_MAX_FILE_NUMBER=10
-VITE_APP_BASE_API='http://192.168.1.166:7777'
+VITE_APP_BASE_API='http://192.168.1.166:5555'
 
 
 # 接口地址 (WebSocket) 

+ 2 - 0
src/entrypoints/background.js

@@ -3,6 +3,8 @@ export default defineBackground(() => {
   let arr = []
   let token = ''
   let userId = ''
+  console.log();
+  chrome.runtime.getPlatformInfo().then(res => console.log(res))
   const url = import.meta.env.VITE_APP_BASE_API +  '/behavior/user/adds'
   // Executed when background is loaded
   chrome.sidePanel

+ 7 - 301
src/entrypoints/sidepanel/AdvancedMode.vue

@@ -121,45 +121,31 @@
 import { ref, onMounted, nextTick, inject, useTemplateRef, reactive,onBeforeMount } from 'vue'
 import { ElScrollbar, ElAvatar, ElInput, ElButton } from 'element-plus'
 import moment from 'moment'
-import fileLogo from '@/assets/svg/file.svg'
+
 import {
-  getFileContent,
-  buildObjPrompt,
   controllerList,
-  formatMessage
 } from '@/entrypoints/sidepanel/utils/ai-service.js'
 import { storeToRefs } from 'pinia'
-import { ElMessage } from 'element-plus'
 import { useMsg } from '@/entrypoints/sidepanel/hook/useMsg.ts'
-import Tools from '@/entrypoints/sidepanel/component/tools.vue'
-import historyComponent from '@/entrypoints/sidepanel/component/historyComponent.vue'
 import document from '@/entrypoints/sidepanel/component/document.vue'
-import pageMask from '@/entrypoints/sidepanel/component/pageMask.vue'
 import ScrollToBottom from '@/entrypoints/sidepanel/component/ScrollToBottom.vue'
-import formTable from '@/entrypoints/sidepanel/component/formTable.vue'
 import StepsDisplay from './component/StepsDisplay.vue'
 import userAvatar from '@/assets/images/user.png'
 import avatar from '@/public/icon/icon.png'
-import {  options, FunctionList } from '@/entrypoints/sidepanel/mock'
+import {  FunctionList } from '@/entrypoints/sidepanel/mock'
 import { useAutoResizeTextarea } from '@/entrypoints/sidepanel/hook/useAutoResizeTextarea.ts'
-import { getPageInfo, getPageInfoClean, handleInput,downloadFile } from './utils/index.js'
 import { useMsgStore } from '@/store/modules/msg.ts'
 import { useUserStore } from '@/store/modules/user'
-// import { putChat, uploadFile } from "@/api/index.js";
-// import {askQues,getFormKey} from '@/api/modal.js'
 import { debounce } from 'lodash'
 const userStore = useUserStore()
 // 在其他状态变量附近添加
 const isLoadingMore = ref(false)
-import { v4 as uuidv4 } from 'uuid';
-import { getPlan,getPlan2 } from '@/api/advance.js'
+import { getPlan2 } from '@/api/advance.js'
 // 滚动条引用
 const scrollbar = ref(null)
 const scrollToBottomRef = ref(null)
-const xlsxData = ref({})
 const isShowPage = ref(false)
 const tareRef = useTemplateRef('textareaRef')
-const drawerRef = useTemplateRef('historyComponentRef')
 const disSend = computed(() => {
   if (pageInfoList.value.length && type.value === FunctionList.Intelligent_Form_filling) return true
   if (sendLoading.value) return true
@@ -168,14 +154,13 @@ const disSend = computed(() => {
 })
 // 获取父组件提供的 Hook 实例
 const msgStore = useMsgStore()
-const { pageInfoList, messages, msgUuid, AIModel,page,hasNext,msgLoading,selectModal } = storeToRefs(useMsgStore())
+const { pageInfoList, messages, msgUuid,hasNext,msgLoading } = storeToRefs(useMsgStore())
 const formInfo = ref('')
 const {
   taklToHtml,
   sendLoading,
   type,
   fetchRes
-
 } = useMsg(scrollbar)
 const inputMessage = ref('')
 const pageInfo = ref('')
@@ -234,7 +219,6 @@ const handleScrollToTop = debounce(async function () {
 const handleStepChange = (step) => {
   console.log('当前步骤:', step)
 }
-
 const handleComplete = () => {
   console.log('所有步骤已完成')
 }
@@ -272,166 +256,16 @@ async function addMessage(msg, raw, type) {
   return newMessage
 }
 
-const handleSummary = async () => {
-  if(sendLoading.value) return
-  handleAsk(`请帮我总结当前${summaryHtml.value ? '页面' : '文件'}`)
-  summaryHtml.value = false
-}
-const handleSummaryFile = async () => {
-  if (sendLoading.value) return
- try {
-   sendLoading.value = true
-   const  userMsg = await addMessage(JSON.stringify([...pageInfoList.value, { type: 'text', value: '抽取表单' }]), '抽取表单', 'document')
-    userMsg.fileId = pageInfoList.value[0].fileId
-    userMsg.redisKey = pageInfoList.value[0].redisKey
-   await putChat(userMsg)
-   createWS(userMsg)
-    formInfo.value = ''
-  //   const msg = reactive({
-  //   type: '',
-  //   rawContent: '',
-  //   senderId: -1,
-  //   receiverId: userStore.userInfo.id, //大模型
-  //   content: '',
-  //   sortKey: moment().valueOf(),
-  //   role: 'system',
-  //   conversationId: msgUuid.value,
-  //   })
-  // messages.value.push(msg)
-    //  isShowPage.value = false
-      pageInfoList.value = []
-  //   const resForm = await askQues({
-  //   conversationId: msgUuid.value,
-  //   modelName: '通义千问-Max',
-  //   question: buildObjPrompt(xlsxData.value,formInfo.value),
-  //   id: '699637194561691650',
-  //   // redisKey:msg.redisKey
-  //   })
-  // return console.log(resForm);
-  
- 
- } catch (error) {
-  console.log(error);
-  
- } finally {
-  //  sendLoading.value = false
-  // type.value = FunctionList.File_Operation
- }
-}
-async function handelIntelligentFillingClick() {
-  handleInput()
-  isShowPage.value = true
-  // taklToHtml.value = true
-  // const tempPageInfo = await getPageInfo()
-  // pageInfo.value = tempPageInfo
-  // pageInfoList.value = [tempPageInfo]
-  inputMessage.value = '/智能填表 '
-  type.value = FunctionList.Intelligent_Form_filling
-}
-
-function handleCurrentChange(e) {
-  msgStore.updateAIModel(e)
-  // if (AIModel.value.file === true) {
-  //   isShowPage.value = false
-  //   taklToHtml.value = false
-  //   pageInfoList.value = []
-  // }
-}
-
-async function handleCurrentData(e) {
-  drawerRef.value.drawer = false
-  isShowPage.value = false
-  if (!e) {
-    addNewDialogue()
-    return
-  }
-  messages.value = []
-  page.value = 1
-  msgUuid.value = e
-  chrome.storage.local.set({ msgUuid: msgUuid.value })
-  await msgStore.initMsg()
-  nextTick(() => {
-  if (scrollbar.value && scrollbar.value.wrapRef) {
-    scrollbar.value.setScrollTop(scrollbar.value.wrapRef.scrollHeight)
-  }
-})
-}
 let SystemMsg = null
 
 watchEffect(() => {
-  console.log(isShowPage.value);
-  
   if (!isShowPage.value) {
     summaryHtml.value = false
-   
     type.value = FunctionList.File_Operation
     SystemMsg = null
     inputMessage.value = ''
   }
 })
-const htmlIcon = ref('')
-async function readClick() {
-  if (type.value === FunctionList.Intelligent_Form_filling) {
-    pageInfoList.value = []
-    type.value = FunctionList.File_Operation
-  }
-  summaryHtml.value = true
-  isShowPage.value = true
-  taklToHtml.value = true
-  if (pageInfoList.value.length >= Number(import.meta.env.VITE_MAX_FILE_NUMBER)) {
-    ElMessage.warning(`最多添加${import.meta.env.VITE_MAX_FILE_NUMBER}个文件`)
-    return
-  }
-  const tempPageInfo = await getPageInfo()
-  htmlIcon.value = tempPageInfo.favIconUrl
-  const blob = new Blob([tempPageInfo.content.mainContent], { type: 'text/plain' })
-  const file = new File([blob], '页面' + '.txt', { type: 'text/plain' })
-  // console.log(file);
-  // 下载文件到本地
-  // downloadFile(file);
-  console.log(tempPageInfo);
-  
-  await createFileObj(file)
-  // await handleUpload(file,tempPageInfo.title + '.txt')
-}
-
-// 添加下载文件的函数
-
-function deletePageInfo(i) {
-  pageInfoList.value.splice(i, 1)
-  if (pageInfoList.value.length === 0) {
-    if (type.value === FunctionList.Intelligent_Form_filling) {
-      inputMessage.value = ''
-      SystemMsg.content = '智能填表流程中断'
-      SystemMsg.rawContent = '智能填表流程中断'
-      putChat({
-        ...SystemMsg,
-        content: '',
-      })
-    }
-    handleStopAsk()
-  }
-}
-
-function addNewDialogue() {
-  if (messages.value.length === 0) {
-    ElMessage.warning('已经是新对话')
-    return
-  }
-  summaryHtml.value = false
-  type.value = FunctionList.File_Operation
-  isShowPage.value = false
-  taklToHtml.value = false
-  messages.value = []
-  page.value = 1
-  pageInfoList.value = []
-  msgUuid.value = uuidv4()
-  hasNext.value = false
-  chrome.storage.local.set({ msgUuid: msgUuid.value })
-}
-const disabledBtn = computed(() => {
- return  !!(pageInfoList.value.find(_ => _.loading ))
-})
 function closePageInfo() {
   pageInfoList.value = []
    if (type.value === FunctionList.Intelligent_Form_filling && SystemMsg ) {
@@ -442,11 +276,9 @@ function closePageInfo() {
         content: '',
       })
     }
-    handleStopAsk()
-  
+  handleStopAsk()
 }
-async function handleAsk(value) {
-  if (sendLoading.value) return
+async function handleAsk(value) {  if (sendLoading.value) return
   const str = value ?? inputMessage.value.trim()
   inputMessage.value = ''
   if (type.value === FunctionList.Intelligent_Form_filling) {
@@ -517,132 +349,7 @@ async function createWS(msg) {
   } finally {
   }
 }
-function handlePlan(res) {
-   const obj = reactive({
-    type:  'plan',
-    rawContent: res,
-    senderId: -1,
-    receiverId: userStore.userInfo.id, //大模型
-    content: '',
-    sortKey: moment().valueOf(),
-    role: 'system',
-    conversationId: msgUuid.value,
-   })
-  messages.value.push(obj)
-}
-function handleCapture() {
-  ElMessage({
-    message: '开发中...',
-    grouping: true,
-    showClose: true
-  })
-}
-function hisRecords() {
-  drawerRef.value.drawer = true
-}
-const createFileObj = async (file) => {
-  handleUpload(file)
-}
-const handleUpload = async (file) => {
-    const obj = reactive({
-    title: summaryHtml.value ?  file.name.split('.')[0] :  file.name,
-    state: '上传中...',
-    favIconUrl: fileLogo,
-    loading: true,
-    url:'',
-    fileId: '',
-    redisKey:'',
-    content: {
-      mainContent: ''
-    }
-  })
-  if (type.value === FunctionList.Intelligent_Form_filling) {
-    pageInfoList.value = []
-  }
-  if (summaryHtml.value) obj.favIconUrl = htmlIcon.value
-  isShowPage.value = true
-  // const obj = reactive({
-  //   title: file.name,
-  //   state: '上传中...',    
-  //   favIconUrl: fileLogo,
-  //   loading: true,
-  //   url:'',
-  //   fileId: '',
-  //   redisKey:'',
-  //   content: {
-  //     mainContent: ''
-  //   }
-  // })
-  pageInfoList.value = [obj]
-  try {
-    let formData = new FormData()
-    formData.append('avatarFile', file)
-    const res = await uploadFile(formData)
-  if (type.value === FunctionList.Intelligent_Form_filling) {
-    obj.state = '解析中...'
-    obj.redisKey = res.data.redisKey
-    obj.id = res.data.file.id
-    obj.url = res.data.file.url
-    // const fileExtension = file.name.split('.').pop().toLowerCase()
-     const result = await getFormKey({
-      body: formInfo.value,
-      input_data:res.data.data
-    })
-    xlsxData.value = JSON.parse(result.data)
-    // if (fileExtension === 'xlsx') {
-    //       const readData = await getXlsxValue(file)
-    //   readData[0].forEach((header, i) => {
-    //     // if (!xlsxData.value[header]) xlsxData.value[header] = []
-    //     xlsxData.value[header] = readData[1][i]
-    //   })
-    // } else {
-    //      const result = await getFormKey({
-    //   body: formInfo.value,
-    //   input_data:res.data.data
-    // })
-    // xlsxData.value = JSON.parse(result.data)
-    //   }
-    }
- 
-   nextTick(() => {
-  if (scrollbar.value && scrollbar.value.wrapRef) {
-    scrollbar.value.setScrollTop(scrollbar.value.wrapRef.scrollHeight)
-  }
-})
-  if (type.value === FunctionList.File_Operation) {
-    obj.loading = false
-    obj.url = res.data.url
-    obj.redisKey = res.data.redisKey
-    obj.fileId = res.data.file.id
-    obj.url = res.data.file.url
-    }
-    obj.loading = false
-  console.log(SystemMsg);
-  
-  } catch (error) {
-    if (SystemMsg) {
-      SystemMsg.content = '数据上传出错,请重试'
-      SystemMsg.rawContent = '数据上传出错,请重试'
-    }
-    console.log(error);
-    ElMessage.error('上传出错')
-    pageInfoList.value = []
-    isShowPage.value = false
-  } finally {
-      SystemMsg && putChat({
-        ...SystemMsg,
-        content: '',
-      })
-    SystemMsg = null
-  }
-}
-async function getFileValue(file) {
-  let formData = new FormData()
-  formData.append('file', file)
-  const res = await getFileContent(formData)
-  return res.data
-}
-let a = null
+
 // 组件挂载时滚动到底部
 onBeforeMount(async () => {
   await msgStore.initMsg()
@@ -683,7 +390,6 @@ onMounted(async () => {
   padding: 10px 0;
   color: #909399;
   font-size: 14px;
-  
   .loading-spinner {
     width: 20px;
     height: 20px;

+ 3 - 5
src/entrypoints/sidepanel/component/ScrollToBottom.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { ref, onMounted, onUnmounted } from 'vue'
+import { ref } from 'vue'
 import { CaretBottom } from '@element-plus/icons-vue'
 
 const showButton = ref(false)
@@ -9,13 +9,11 @@ const props = defineProps({
     required: true
   }
 })
-
-
-defineExpose({
+defineExpose({  
   showButton
 })
 
-</script>
+</script> 
 
 <template>
   <el-button v-show="showButton" :icon="CaretBottom" circle

+ 6 - 8
src/entrypoints/sidepanel/component/StepsDisplay.vue

@@ -136,11 +136,11 @@ const planId = ref('')
 const currentStepIndex = ref()
 const response = ref()
 const handleExecute = async () => {
-    const res = await executorDetail(planId.value)
+    const res = await executorDetail(planId.value) as any
     response.value = res
-    response.value?.agentExecutionSequence.forEach(sequence => {
+    response.value?.agentExecutionSequence.forEach((sequence: any) => {
       if (sequence.thinkActSteps) {
-          sequence.thinkActSteps.forEach(step => {
+          sequence.thinkActSteps.forEach((step:any) => {
           // 转换actionResult
           if (step.actionResult && typeof step.actionResult === 'string') {
             step.actionResult = JSON.parse(step.actionResult);
@@ -174,7 +174,7 @@ const parsedContent = computed(() => {
   try {
     if (typeof props.content === 'string') {
       const obj = JSON.parse(props.content)
-        obj.steps = obj.steps.map(_ => ({ ..._, description: _.description.split(' ')[1] }))
+        obj.steps = obj.steps.map((_:any )=> ({ ..._, description: _.description.split(' ')[1] }))
         planTemplateId.value = obj.planId
         currentStepIndex.value = 0
         // setTimeout(() => {
@@ -199,14 +199,12 @@ const parsedContent = computed(() => {
 watch(() => parsedContent.value, (newContent) => {
   if (newContent && newContent.steps) {
     // 默认所有步骤都展开,当前步骤之外的都折叠
-    collapsedSteps.value = newContent.steps.map((_, index) => index !== activeStep.value)
+    collapsedSteps.value = newContent.steps.map((_:any, index:any) => index !== activeStep.value)
   }
 }, { immediate: true })
 
 // 切换步骤折叠状态
-const toggleCollapse = (index) => {
-    console.log(index);
-    
+const toggleCollapse = (index:any) => {
   collapsedSteps.value[index] = !collapsedSteps.value[index]
 }
 

+ 1 - 1
src/entrypoints/sidepanel/component/inputArea.vue

@@ -8,7 +8,7 @@ const taklToHtml = ref(false)
 
 const inputMessage = ref('')
 
-const emit = defineEmits(['readClick', 'uploadFile', 'handleCapture', 'addNewDialogue', 'hisRecords'])
+const emit = defineEmits(['re=adClick', 'uploadFile', 'handleCapture', 'addNewDialogue', 'hisRecords'])
 </script>
 
 <template>

+ 1 - 1
src/utils/request2.js

@@ -7,7 +7,7 @@ axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 
 // 创建axios实例
 const service = axios.create({
-  baseURL: 'http://192.168.1.140:8000',
+  baseURL: 'http://192.168.1.166:5555',
 })
 
 let cancel