From 202d5cf0712797cd56d34834af55bb513c554f22 Mon Sep 17 00:00:00 2001 From: shadowcz007 Date: Mon, 15 Jan 2024 14:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=B7=B3=E8=BD=AC=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/index.html | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/web/index.html b/web/index.html index 51310b5..23d05ab 100644 --- a/web/index.html +++ b/web/index.html @@ -761,19 +761,44 @@ } catch (error) { isURL = false; } + + let isAElement = undefined; + try { + let div = document.createElement('div'); + div.innerHTML = link; + let a = div.querySelector('a'); + if (a.href) { + new URL(a.href); + isAElement = div.innerHTML; + } + } catch (error) { + + } // new URL(link) - if (isURL) { + if (isURL || isAElement) { const linkBtn = document.createElement('button'); - // linkBtn.href = link; - linkBtn.innerText = 'go to' + + if (isURL) { + // linkBtn.href = link; + linkBtn.innerText = 'go to' + } else if (isAElement) { + linkBtn.innerHTML = isAElement + } + action.appendChild(linkBtn) linkBtn.style.marginLeft = '18px'; linkBtn.addEventListener('click', e => { - e.preventDefault(); - window.open(link); + + if (isURL) { + e.preventDefault(); + window.open(link); + } + // if(isURL) window.open(link); }) + } + const output_card = document.createElement("div"); output_card.className = 'output_card' container.appendChild(output_card) @@ -1826,7 +1851,7 @@ p.className = 'prompt_image' p.innerText = prompt; a.appendChild(p) - img.alt=prompt + img.alt = prompt } // imgDiv.parentElement.appendChild(a);