// 添加AI网页版分析功能
function openAIWebUI(file) {
alert("AI网页版功能正在开发中,请暂时使用「开始解析」按钮。"); return; // 临时禁用
if (!file) {
alert("请先选择文件");
return;
}
var reader = new FileReader();
reader.onload = function(e) {
try {
var arrayBuffer = e.target.result;
extractPdfText(arrayBuffer).then(function(text) {
if (!text) {
alert("无法提取PDF文本");
return;
}
// 保存文本到localStorage
localStorage.setItem('financeReportText', text.substring(0, 15000));
localStorage.setItem('financeReportFileName', file.name);
// 显示提示
showAIWebUIGuide();
// 自动打开通义千问网页版
window.open('https://tongyi.aliyun.com/', '_blank');
}).catch(function(err) {
alert("提取失败: " + err.message);
});
} catch (err) {
alert("处理失败: " + err.message);
}
};
reader.readAsArrayBuffer(file);
}
function showAIWebUIGuide() {
var guideHtml = `
🤖 使用AI网页版分析
请按照以下步骤操作:
- 新打开的页面是通义千问网页版
- 点击输入框,粘贴以下提示词和财报文本:
- 回到本页面,复制财报文本(已保存)
- 粘贴到AI的输入框中,替换[这里粘贴财报文本]
- 点击发送,等待AI返回结果
- 复制AI返回的JSON结果
- 点击下方按钮粘贴结果
`;
document.body.insertAdjacentHTML('beforeend', guideHtml);
}
function pasteAIResult() {
var result = prompt("请粘贴AI返回的JSON结果:");
if (result) {
try {
var data = JSON.parse(result);
AppState.data = data;
AppState.recognitionLog = [{
type: "success",
message: "✅ AI网页版分析完成!"
}];
AppState.view = "confirm";
render();
// 关闭弹窗
var modals = document.querySelectorAll('div[style*=position:fixed]');
modals.forEach(function(m) { m.remove(); });
} catch (err) {
alert("JSON格式错误: " + err.message);
}
}
}
function copyReportText() {
var text = localStorage.getItem('financeReportText');
if (text) {
navigator.clipboard.writeText(text.substring(0, 10000)).then(function() {
alert("财报文本已复制到剪贴板!");
});
}
}