Sfoglia il codice sorgente

refactor(env): 更新 API 地址并调整相关配置

- 更新 VITE_APP_BASE_API 和 VITE_API_WS_URL 为新的服务器地址
- 修改 VITE_CLIENT_ID 为新的客户端 ID
- 移除旧的 API 地址和客户端 ID
- 调整其他配置项以适应新环境
wzg 4 mesi fa
parent
commit
e6845c1834

+ 9 - 3
.env

@@ -1,8 +1,14 @@
 VITE_OPENAI_API_KEY_TONG=sk-e9855234f47346049809ce23ed3ebe3f
+
 VITE_MAX_FILE_NUMBER=10
-VITE_APP_BASE_API='http://192.168.1.202:13088'
+
+VITE_APP_BASE_API='http://180.76.147.97:13088'
+# VITE_APP_BASE_API='http://192.168.1.166:7777'
 
 # 接口地址 (WebSocket)
-VITE_API_WS_URL = 'ws://192.168.1.202:13088'
+VITE_API_WS_URL = 'ws://180.76.147.97:13088'
+# VITE_API_WS_URL = 'ws://192.168.1.166:7777'
 # 终端ID
-VITE_CLIENT_ID = '765be25e4e78b101b896cb3ecac39b1b'
+# VITE_CLIENT_ID = '765be25e4e78b101b896cb3ecac39b1b'
+VITE_CLIENT_ID = '153062e567553ec0bf1a02b8f1f563b1'
+

+ 2 - 1
package.json

@@ -22,6 +22,7 @@
     "dompurify": "^3.2.5",
     "element-plus": "^2.9.1",
     "eventsource-polyfill": "^0.9.6",
+    "github-markdown-css": "^5.8.1",
     "highlight.js": "^11.11.1",
     "html2canvas": "^1.4.1",
     "jsencrypt": "^3.3.2",
@@ -49,4 +50,4 @@
     "vue-tsc": "^2.1.10",
     "wxt": "^0.19.13"
   }
-}
+}

+ 2 - 1
src/entrypoints/background.js

@@ -8,6 +8,7 @@ export default defineBackground(() => {
   chrome.sidePanel
     .setPanelBehavior({ openPanelOnActionClick: true })
     .catch((error) => console.error(error))
+
   chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
     if (message.type === 'CLICK_EVENT') {
       if (token) {
@@ -109,7 +110,7 @@ export default defineBackground(() => {
     }
     // 截图
     if (message.type === 'SCREENSHOT') {
-      chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
+      chrome.tabs.query({ active: true, currentWindow: true}, (tabs) => {
         if (tabs.length === 0) return // 确保有活动标签页
         const tabId = tabs[0].id // 获取当前活动的 tabId
         chrome.tabs.sendMessage(tabId, message, (response) => {

+ 7 - 4
src/entrypoints/content.js

@@ -1,6 +1,5 @@
 // entrypoints/content.ts
 import PageAnalyzer, { cleanPage } from '../utils/page-analyzer'
-import html2canvas from 'html2canvas'
 import {
   formatDate,
   simulateCompleteUserAction,
@@ -71,10 +70,12 @@ export default defineContentScript({
       }, function (response) {
       });
     }
+
+
+
     document.addEventListener('click', handleClick)
     document.addEventListener('mouseover', handleMouseover)
-    chrome.runtime.onMessage.addListener(
-      async (message, sender, sendResponse) => {
+    chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
         if (message.type === 'GET_PAGE_INFO') {
           sendResponse({
             data: getPageInfo()
@@ -189,7 +190,7 @@ export default defineContentScript({
           }).catch(err => {
             sendResponse({ status: 'error', message: err })
           })
-          return true
+          // return true
         }
         return true
       })
@@ -298,3 +299,5 @@ export default defineContentScript({
     }
   }
 })
+
+

+ 5 - 4
src/entrypoints/sidepanel/Chat.vue

@@ -1,11 +1,11 @@
 <!-- Chat.vue -->
 <template>
-  <div class="chat-container">
+  <div class="chat-container items-center">
     <div v-if="!messages.length && !msgLoading" class="message-list">
       <pageMask />
     </div>
     <!-- 消息列表 -->
-    <div class="message-list" v-else>
+    <div class="message-list w-full" v-else>
       <el-scrollbar ref="scrollbar" @scroll="handleScroll" v-loading="msgLoading">
         <!-- 加载更多指示器 -->
         <div v-if="isLoadingMore" class="loading-more-indicator">
@@ -54,7 +54,7 @@
 
     <div class="w-full max-w-[720px] p-[0_12px_12px]">
       <!-- 输入区域 -->
-      <div class="input-area">
+      <div class="input-area w-full">
         <el-icon class="closeShow" :style="{ display: isShowPage ? 'block' : 'none' }" size="16px" color="#909399"
           @click="closePageInfo">
           <CircleClose />
@@ -577,7 +577,8 @@ function handleCapture() {
         type: 'image',
         url: response.data
       })
-      console.log(response, pageInfoList.value)
+      // console.log(response);
+      // console.log(response, pageInfoList.value)
     }
   })
 }

+ 5 - 5
src/entrypoints/sidepanel/component/tools.vue

@@ -15,10 +15,10 @@ watchEffect(() => {
 })
 const handleUpload = (e) => {
   if (!props.upload) {
-   e.stopPropagation()
+    e.stopPropagation()
     ElMessage.warning('智能填表需要先发送指令,再上传文件')
   }
-  
+
 }
 const props = defineProps({
   upload: {
@@ -43,12 +43,12 @@ const props = defineProps({
       <el-upload style="display:inline-block" :before-upload="(file: any) => emit('uploadFile', file)" :multiple="false"
         name="file" :show-file-list="false" :accept="'.xlsx,.pdf,.doc,.docx'">
         <el-tooltip effect="dark" content="文件上传" placement="top">
-          <el-button class="tools_btn" link :icon="Paperclip" @click="handleUpload"/>
+          <el-button class="tools_btn" link :icon="Paperclip" @click="handleUpload" />
         </el-tooltip>
       </el-upload>
-      <!-- <el-tooltip effect="dark" content="截屏" placement="top">
+      <el-tooltip effect="dark" content="截屏" placement="top">
         <el-button class="tools_btn" link :icon="Scissor" @click="emit('handleCapture')" />
-      </el-tooltip> -->
+      </el-tooltip>
       <el-tooltip effect="dark" content="智能填表:选择后,在输入框描述填表流程" placement="top">
         <el-button class="tools_btn" link @click="emit('handelIntelligentFillingClick')">
           <span class="iconfont icon-zhinengtianxie"></span>

+ 2 - 2
src/entrypoints/sidepanel/css/chat.scss

@@ -217,8 +217,8 @@
   color: black;
   background-color: #fff;
   border: 1px solid rgba(102, 102, 102, 0.3);
-  border-radius: 16px;
-  margin: 0 12px 12px;
+  border-radius: 8px;
+  // margin: 0 12px 12px;
   position: relative;
 
   .card_list {

+ 33 - 22
src/entrypoints/sidepanel/utils/index.js

@@ -36,23 +36,7 @@ export function getPageInfoClean() {
     )
   })
 }
-export function getPageInfoClean() {
-  return new Promise((res, rej) => {
-    chrome.runtime.sendMessage(
-      {
-        type: 'FROM_SIDE_PANEL_TO_GET_PAGE_INFO_CLEAN',
-      },
-      (response) => {
-        if (chrome.runtime.lastError) {
-          console.error('消息发送错误:', chrome.runtime.lastError, 555)
-          rej(chrome.runtime.lastError)
-        } else {
-          res(response.data)
-        }
-      }
-    )
-  })
-}
+
 export function handleInput(xlsxData, formMap) {
   chrome.runtime.sendMessage({
     type: 'FROM_SIDE_PANEL_TO_INPUT_FORM',
@@ -116,6 +100,7 @@ export function downloadFile(file) {
 }
 
 export function domToCanvas() {
+  
   return new Promise((resolve, reject) => {
     // 检查是否已经存在 Shadow Host
     const existingHost = document.querySelector('[data-shadow-host="true"]')
@@ -123,8 +108,25 @@ export function domToCanvas() {
       existingHost.remove()
     }
     const host = document.createElement('div')
+    // document.getElementsByTagName('html')[0].style.overflow = 'hidden'
     host.setAttribute('data-shadow-host', 'true') // 标记 Shadow Host
     document.body.appendChild(host)
+    
+    let scrollX = window.pageXOffset || document.documentElement.scrollLeft
+    let scrollY = window.pageYOffset || document.documentElement.scrollTop
+    // 使用requestAnimationFrame优化滚动监听
+    let ticking = false;
+    function opServe() {
+      if (!ticking) {
+        window.requestAnimationFrame(function() {
+          scrollY = window.pageYOffset || document.documentElement.scrollTop
+          scrollX = window.pageXOffset || document.documentElement.scrollLeft
+          ticking = false;
+        });
+        ticking = true;
+      }
+    }
+    window.addEventListener('scroll', opServe, { passive: true });
     const shadowRoot = host.attachShadow({ mode: 'open' })
     // 创建遮罩层
     const overlay = document.createElement('div')
@@ -136,7 +138,9 @@ export function domToCanvas() {
     overlay.style.height = '100%'
     overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'
     overlay.style.zIndex = '9999'
-    overlay.style.cursor = 'crosshair'
+    overlay.style.cursor = `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="16" cy="16" r="2" fill="red"/><line x1="16" y1="0" x2="16" y2="12" stroke="black" stroke-width="2"/><line x1="16" y1="20" x2="16" y2="32" stroke="black" stroke-width="2"/><line x1="0" y1="16" x2="12" y2="16" stroke="black" stroke-width="2"/><line x1="20" y1="16" x2="32" y2="16" stroke="black" stroke-width="2"/></svg>') 16 16, crosshair`
+    
+    // overlay.style.cursor = 'crosshair'
     shadowRoot.appendChild(overlay)
 
     // 创建选择框
@@ -148,6 +152,8 @@ export function domToCanvas() {
     selectionBox.style.pointerEvents = 'none'
     overlay.appendChild(selectionBox)
 
+
+
     let isSelecting = false
     let startX, startY, endX, endY
 
@@ -185,14 +191,17 @@ export function domToCanvas() {
         x: parseInt(selectionBox.style.left),
         y: parseInt(selectionBox.style.top),
         width: parseInt(selectionBox.style.width),
-        height: parseInt(selectionBox.style.height)
+        height: parseInt(selectionBox.style.height),
+        scrollX,
+        scrollY
       }
-      console.log(rect)
       // 移除遮罩层和选择框
       overlay.remove()
+      window.removeEventListener('scroll', opServe, { passive: true });
+      console.log(rect)
       html2canvas(document.body, {
-        x: rect.left,
-        y: rect.top,
+        x: rect.x + rect.scrollX,
+        y: rect.y + rect.scrollY,
         width: rect.width,
         height: rect.height,
         backgroundColor: null, // 背景透明
@@ -203,6 +212,8 @@ export function domToCanvas() {
         const base64Data = canvas.toDataURL('image/png', 0.9); // 可调整质量参数
         resolve(base64Data);
       }).catch((error) => {
+        console.log(error);
+        
         reject(error)
       })
     })