|
@@ -327,8 +327,13 @@ ${this.iframeInfo}`;
|
|
|
if (type === "assistant" && !isInterrupted) {
|
|
|
const copyButton = this.createCopyButton(content);
|
|
|
actionsDiv.appendChild(copyButton);
|
|
|
- actionsDiv.appendChild(this.createFillButton());
|
|
|
+ console.log(content);
|
|
|
|
|
|
+ console.log(Object.prototype.toString.call(content));
|
|
|
+
|
|
|
+ if (Object.prototype.toString.call(content) === "[object Object]") {
|
|
|
+ actionsDiv.appendChild(this.createFillButton(paragraph));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 添加时间戳
|
|
@@ -344,14 +349,11 @@ ${this.iframeInfo}`;
|
|
|
if (typing) {
|
|
|
messageContent.classList.add("typing");
|
|
|
if (typeof content !== 'string') {
|
|
|
- console.log(content);
|
|
|
- console.log(content.controller);
|
|
|
const signal = content.controller.signal;
|
|
|
try {
|
|
|
const iterator = content.iterator();
|
|
|
for await (const chunk of iterator) {
|
|
|
if (chunk) {
|
|
|
- console.log(chunk);
|
|
|
const decodedChunk = chunk.choices[0].delta.content;
|
|
|
if (decodedChunk) {
|
|
|
paragraph.innerHTML += decodedChunk;
|
|
@@ -567,12 +569,24 @@ ${this.iframeInfo}`;
|
|
|
.replace(/^>\s+(.+)$/gm, "<blockquote>$1</blockquote>")
|
|
|
);
|
|
|
}
|
|
|
- createFillButton() {
|
|
|
+
|
|
|
+ createFillButton(paragraph) {
|
|
|
const button = document.createElement("button");
|
|
|
- button.id = 'fill-button'
|
|
|
button.className = "fill-button";
|
|
|
- button.innerHTML = `填充`;
|
|
|
-
|
|
|
+ button.innerHTML = `
|
|
|
+ <svg viewBox="0 0 24 24" fill="currentColor">
|
|
|
+ <path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
|
|
|
+ </svg>
|
|
|
+ <span>填充</span>
|
|
|
+ `;
|
|
|
+ button.addEventListener("click", () => {
|
|
|
+ window.parent.postMessage({
|
|
|
+ type: "HANDLE_FILL_INPUT", data: {
|
|
|
+ formData: JSON.parse(paragraph.innerHTML.split('json')[1].split('```')[0]) //根据不同返回修改res
|
|
|
+ }
|
|
|
+ }, "*");
|
|
|
+ });
|
|
|
+
|
|
|
return button;
|
|
|
}
|
|
|
/**
|
|
@@ -799,7 +813,7 @@ ${this.iframeInfo}`;
|
|
|
if (this.excelTypes[extension]) {
|
|
|
try {
|
|
|
this.setInputState(true);
|
|
|
- this.loadingDiv = ''
|
|
|
+ this.loadingDiv = this.createLoadingMessage();
|
|
|
|
|
|
// 读取Excel文件
|
|
|
const data = await this.readExcelFile(file);
|
|
@@ -871,7 +885,7 @@ ${this.iframeInfo}`;
|
|
|
excelData: this.excelData,
|
|
|
}
|
|
|
}, "*");
|
|
|
-
|
|
|
+
|
|
|
return `我将向你展示一个通过SheetJS库读取的Excel文件内容和一个form表单。请帮我理解这些数据:
|
|
|
|
|
|
文件名:${fileName}
|