|
@@ -8,7 +8,11 @@ class ChatUI {
|
|
|
this.promptPanel = document.getElementById("prompt-panel");
|
|
|
this.uploadButton = document.getElementById("upload-button");
|
|
|
this.fileInput = document.getElementById("file-input");
|
|
|
-
|
|
|
+ this.inputs = document.querySelectorAll('input')
|
|
|
+ this.ContentInputs = []
|
|
|
+ console.log(this.inputs);
|
|
|
+
|
|
|
+ this.excelData = [];
|
|
|
// 确保AI服务已经初始化
|
|
|
if (!window.aiService) {
|
|
|
throw new Error("AI Service not initialized");
|
|
@@ -307,6 +311,8 @@ ${message}`;
|
|
|
if (type === "assistant" && !isInterrupted) {
|
|
|
const copyButton = this.createCopyButton(content);
|
|
|
actionsDiv.appendChild(copyButton);
|
|
|
+ actionsDiv.appendChild(this.createFillButton());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 添加时间戳
|
|
@@ -519,7 +525,22 @@ ${message}`;
|
|
|
.replace(/^>\s+(.+)$/gm, "<blockquote>$1</blockquote>")
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+ createFillButton() {
|
|
|
+ const button = document.createElement("button");
|
|
|
+ button.className = "fill-button";
|
|
|
+ button.innerHTML = `填充`;
|
|
|
+ button.addEventListener("click", () => {
|
|
|
+ window.parent.postMessage(
|
|
|
+ {
|
|
|
+ type: "FILL_INPUT",
|
|
|
+ data: this.excelData,
|
|
|
+ },
|
|
|
+ "*"
|
|
|
+ );
|
|
|
+ //从夫窗口获取信息
|
|
|
+ });
|
|
|
+ return button;
|
|
|
+ }
|
|
|
/**
|
|
|
* 创建复制按钮
|
|
|
* @param {string} content 要复制的内容
|
|
@@ -634,6 +655,7 @@ ${message}`;
|
|
|
window.addEventListener("message", (event) => {
|
|
|
if (event.data.type === "PAGE_INFO") {
|
|
|
const pageInfo = event.data.pageInfo;
|
|
|
+ this.ContentInputs = pageInfo.inputs
|
|
|
|
|
|
// 更新卡片内容
|
|
|
const favicon = document.querySelector(".page-favicon");
|
|
@@ -795,7 +817,8 @@ ${message}`;
|
|
|
const headers = data[0];
|
|
|
const rows = data.slice(1);
|
|
|
const sampleRows = rows.slice(0, 2);
|
|
|
-
|
|
|
+ console.log(data);
|
|
|
+ this.excelData = data
|
|
|
return `我将向你展示一个通过SheetJS库读取的Excel文件内容。请帮我理解这些数据:
|
|
|
|
|
|
文件名:${fileName}
|
|
@@ -865,6 +888,8 @@ ${sampleRows
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
try {
|
|
|
const chatUI = new ChatUI();
|
|
|
+
|
|
|
+
|
|
|
} catch (error) {
|
|
|
console.error("Failed to initialize ChatUI:", error);
|
|
|
}
|