fix: resolve issue with .gitignore$ being copied in recognized content
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | ".idea/"  | ||||||
							
								
								
									
										29
									
								
								worker.js
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								worker.js
									
									
									
									
									
								
							| @@ -1139,7 +1139,7 @@ function getHTML() { | |||||||
|     '                  <button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteHistoryItem(${i})">删除</button>', |     '                  <button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteHistoryItem(${i})">删除</button>', | ||||||
|     '                </div>', |     '                </div>', | ||||||
|     '              </div>', |     '              </div>', | ||||||
|     '              <div class="history-text">${record.result || \'无识别结果\'}</div>', |     '              <div class="history-text" data-original-text="${record.result || \'无识别结果\'}">${record.result || \'无识别结果\'}</div>', | ||||||
|     '            </div>', |     '            </div>', | ||||||
|     '          </div>', |     '          </div>', | ||||||
|     '        `;', |     '        `;', | ||||||
| @@ -1286,11 +1286,7 @@ function getHTML() { | |||||||
|  |  | ||||||
|     '        const result = recognizeData.result || \'识别失败\';', |     '        const result = recognizeData.result || \'识别失败\';', | ||||||
|     '        // 保存原始文本到属性中,确保 LaTeX 格式完整', |     '        // 保存原始文本到属性中,确保 LaTeX 格式完整', | ||||||
|     '        const formattedResult = result', |     '        resultDiv.setAttribute(\'data-original-text\', result);', | ||||||
|     '          .replace(/\$\$(.*?)\$\$/g, (_, formula) => `$${formula}$$`)', |  | ||||||
|     '          .replace(/\$([^$]+)\$/g, (_, formula) => `$${formula}$`);', |  | ||||||
|  |  | ||||||
|     '        resultDiv.setAttribute(\'data-original-text\', formattedResult);', |  | ||||||
|     '        resultDiv.innerHTML = result;', |     '        resultDiv.innerHTML = result;', | ||||||
|     '        waitForMathJax(() => {', |     '        waitForMathJax(() => {', | ||||||
|     '          try {', |     '          try {', | ||||||
| @@ -1511,29 +1507,14 @@ function getHTML() { | |||||||
|     '    async function copyHistoryResult(index, btn) {', |     '    async function copyHistoryResult(index, btn) {', | ||||||
|     '      try {', |     '      try {', | ||||||
|     '        const history = historyManager.loadHistory(currentToken);', |     '        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) {', |     '        if (!result) {', | ||||||
|     '          throw new Error(\'无法复制:结果为空\');', |     '          throw new Error(\'无法复制:结果为空\');', | ||||||
|     '        }', |     '        }', | ||||||
|  |  | ||||||
|     '        // 使用临时输入框来执行复制', |     '        await navigator.clipboard.writeText(result);', | ||||||
|     '        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();', |  | ||||||
|     '        }', |  | ||||||
|  |  | ||||||
|     '        // 更新按钮状态 - 使用传入的按钮元素', |  | ||||||
|     '        btn.textContent = \'已复制\';', |     '        btn.textContent = \'已复制\';', | ||||||
|     '        btn.classList.add(\'copied\');', |     '        btn.classList.add(\'copied\');', | ||||||
|          |          | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Cunninger
					Cunninger