fix: resolve issue with .gitignore$ being copied in recognized content

This commit is contained in:
Cunninger 2025-01-15 08:23:43 +08:00
parent 5deb60c82f
commit 4ba70a858f
2 changed files with 6 additions and 24 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
".idea/"

View File

@ -1139,7 +1139,7 @@ function getHTML() {
' <button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteHistoryItem(${i})">删除</button>',
' </div>',
' </div>',
' <div class="history-text">${record.result || \'无识别结果\'}</div>',
' <div class="history-text" data-original-text="${record.result || \'无识别结果\'}">${record.result || \'无识别结果\'}</div>',
' </div>',
' </div>',
' `;',
@ -1286,11 +1286,7 @@ function getHTML() {
' const result = recognizeData.result || \'识别失败\';',
' // 保存原始文本到属性中,确保 LaTeX 格式完整',
' const formattedResult = result',
' .replace(/\$\$(.*?)\$\$/g, (_, formula) => `$${formula}$$`)',
' .replace(/\$([^$]+)\$/g, (_, formula) => `$${formula}$`);',
' resultDiv.setAttribute(\'data-original-text\', formattedResult);',
' resultDiv.setAttribute(\'data-original-text\', result);',
' resultDiv.innerHTML = result;',
' waitForMathJax(() => {',
' try {',
@ -1511,29 +1507,14 @@ function getHTML() {
' async function copyHistoryResult(index, btn) {',
' try {',
' const history = historyManager.loadHistory(currentToken);',
' const result = history[index]?.result;',
' const historyItem = document.querySelector(`.history-item[data-index="${index}"] .history-text`);',
' const result = historyItem?.getAttribute(\'data-original-text\') || history[index]?.result;',
' if (!result) {',
' throw new Error(\'无法复制:结果为空\');',
' }',
' // 使用临时输入框来执行复制',
' const tempInput = document.createElement(\'textarea\');',
' tempInput.value = result;',
' document.body.appendChild(tempInput);',
' tempInput.select();',
' // 尝试使用 execCommand 作为后备方案',
' if (!navigator.clipboard) {',
' document.execCommand("copy");',
' tempInput.remove();',
' } else {',
' // 优先使用 clipboard API',
' await navigator.clipboard.writeText(result);',
' tempInput.remove();',
' }',
' // 更新按钮状态 - 使用传入的按钮元素',
' await navigator.clipboard.writeText(result);',
' btn.textContent = \'已复制\';',
' btn.classList.add(\'copied\');',