|
@@ -108,6 +108,7 @@ import { useMsg } from '@/entrypoints/sidepanel/hook/useMsg.ts';
|
|
import Tools from "@/entrypoints/sidepanel/component/tools.vue";
|
|
import Tools from "@/entrypoints/sidepanel/component/tools.vue";
|
|
import { useSummary } from '@/entrypoints/sidepanel/hook/useSummary.ts'
|
|
import { useSummary } from '@/entrypoints/sidepanel/hook/useSummary.ts'
|
|
import { mockData } from "@/entrypoints/sidepanel/mock"
|
|
import { mockData } from "@/entrypoints/sidepanel/mock"
|
|
|
|
+import {upload} from '@/utils/ai-service'
|
|
|
|
|
|
// 滚动条引用
|
|
// 滚动条引用
|
|
const scrollbar = ref(null);
|
|
const scrollbar = ref(null);
|
|
@@ -129,14 +130,6 @@ const {
|
|
} = useMsg(scrollbar, type, xlsxData, fetchDataAndProcess);
|
|
} = useMsg(scrollbar, type, xlsxData, fetchDataAndProcess);
|
|
const { handleCardButtonClick } = useSummary(addMessage, sendRequese);
|
|
const { handleCardButtonClick } = useSummary(addMessage, sendRequese);
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// const pageInfo = ref({})
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// 输入框内容
|
|
|
|
-// const inputMessage = ref('')
|
|
|
|
-
|
|
|
|
// 计算标题是否需要滚动
|
|
// 计算标题是否需要滚动
|
|
const titleScroll = computed(() => {
|
|
const titleScroll = computed(() => {
|
|
return pageInfo.value?.title?.length > 20 // 当标题超过20个字符时触发滚动
|
|
return pageInfo.value?.title?.length > 20 // 当标题超过20个字符时触发滚动
|
|
@@ -147,48 +140,60 @@ let formInfo = []
|
|
const flag = ref(false) //true调用算法接口
|
|
const flag = ref(false) //true调用算法接口
|
|
|
|
|
|
const handleUpload = (file) => {
|
|
const handleUpload = (file) => {
|
|
|
|
+ console.log(upload);
|
|
|
|
+
|
|
chrome.runtime.sendMessage({
|
|
chrome.runtime.sendMessage({
|
|
type: 'FROM_SIDE_PANEL_TO_GET_PAGE_FORM',
|
|
type: 'FROM_SIDE_PANEL_TO_GET_PAGE_FORM',
|
|
}, async (response) => {
|
|
}, async (response) => {
|
|
if (chrome.runtime.lastError) {
|
|
if (chrome.runtime.lastError) {
|
|
-
|
|
|
|
console.error("消息发送错误:", chrome.runtime.lastError);
|
|
console.error("消息发送错误:", chrome.runtime.lastError);
|
|
} else {
|
|
} else {
|
|
|
|
+ console.log(file);
|
|
addMessage(`已上传文件:${file.name}`, false)
|
|
addMessage(`已上传文件:${file.name}`, false)
|
|
-
|
|
|
|
- formInfo = response.data
|
|
|
|
- const reader = new FileReader();
|
|
|
|
- reader.readAsArrayBuffer(file);
|
|
|
|
- reader.onload = async (e) => {
|
|
|
|
- const data = new Uint8Array(e.target.result);
|
|
|
|
- const workbook = XLSX.read(data, {
|
|
|
|
- type: "array",
|
|
|
|
- cellDates: false,
|
|
|
|
- cellNF: true,
|
|
|
|
- cellText: true,
|
|
|
|
- dateNF: 'yyyy-mm-dd'
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 修复日期处理
|
|
|
|
- const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
|
|
|
-
|
|
|
|
- // 转换为JSON数据
|
|
|
|
- const readData = XLSX.utils.sheet_to_json(firstSheet, {
|
|
|
|
- header: 1,
|
|
|
|
- raw: false,
|
|
|
|
- defval: "",
|
|
|
|
- dateNF: 'yyyy-mm-dd'
|
|
|
|
- });
|
|
|
|
- console.log(readData, 58);
|
|
|
|
-
|
|
|
|
- readData[0].forEach((header, i) => {
|
|
|
|
- if (!xlsxData.value[header]) xlsxData.value[header] = []
|
|
|
|
- xlsxData.value[header].push(readData[1][i])
|
|
|
|
- })
|
|
|
|
- if (type.value === '2') {
|
|
|
|
- await streamRes(buildExcelUnderstandingPrompt(readData, file?.name, response), false)
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ const fileExtension = file.name.split('.').pop().toLowerCase();
|
|
|
|
+ console.log('文件后缀:', fileExtension);
|
|
|
|
+ if (fileExtension === 'xlsx') {
|
|
|
|
+
|
|
|
|
+ formInfo = response.data
|
|
|
|
+ const reader = new FileReader();
|
|
|
|
+ reader.readAsArrayBuffer(file);
|
|
|
|
+ reader.onload = async (e) => {
|
|
|
|
+ const data = new Uint8Array(e.target.result);
|
|
|
|
+ const workbook = XLSX.read(data, {
|
|
|
|
+ type: "array",
|
|
|
|
+ cellDates: false,
|
|
|
|
+ cellNF: true,
|
|
|
|
+ cellText: true,
|
|
|
|
+ dateNF: 'yyyy-mm-dd'
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 修复日期处理
|
|
|
|
+ const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
|
|
|
+
|
|
|
|
+ // 转换为JSON数据
|
|
|
|
+ const readData = XLSX.utils.sheet_to_json(firstSheet, {
|
|
|
|
+ header: 1,
|
|
|
|
+ raw: false,
|
|
|
|
+ defval: "",
|
|
|
|
+ dateNF: 'yyyy-mm-dd'
|
|
|
|
+ });
|
|
|
|
+ console.log(readData, 58);
|
|
|
|
+
|
|
|
|
+ readData[0].forEach((header, i) => {
|
|
|
|
+ if (!xlsxData.value[header]) xlsxData.value[header] = []
|
|
|
|
+ xlsxData.value[header].push(readData[1][i])
|
|
|
|
+ })
|
|
|
|
+ if (type.value === '2') {
|
|
|
|
+ await streamRes(buildExcelUnderstandingPrompt(readData, file?.name, response), false)
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ let formData = new FormData();
|
|
|
|
+ formData.append("file", file);
|
|
|
|
+ const res = await upload(formData)
|
|
|
|
+ console.log(res);
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
});
|
|
});
|
|
@@ -216,7 +221,7 @@ async function fetchDataAndProcess(input, obj) {
|
|
|
|
|
|
|
|
|
|
async function handleClick(res, msgObj) {
|
|
async function handleClick(res, msgObj) {
|
|
- await new Promise(resolve => setTimeout(resolve, 1000))
|
|
|
|
|
|
+ await new Promise(resolve => setTimeout(resolve, 2000))
|
|
if (res.action === 'click') {
|
|
if (res.action === 'click') {
|
|
msgObj.content = `点击${res.tag}元素`
|
|
msgObj.content = `点击${res.tag}元素`
|
|
chrome.runtime.sendMessage({
|
|
chrome.runtime.sendMessage({
|