From 4d3ac0b86100bb1c75bd9408e8b2f45201717584 Mon Sep 17 00:00:00 2001 From: glossimute Date: Thu, 22 May 2025 04:13:13 +0900 Subject: [PATCH] copy link button --- templates/plist.html | 77 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/templates/plist.html b/templates/plist.html index 090f06c..831a15a 100644 --- a/templates/plist.html +++ b/templates/plist.html @@ -23,9 +23,23 @@ .SideNav-item .Label{color: #fff;margin-left:4px;} .d-flex{min-width:0;} .listTitle{overflow:hidden;white-space:nowrap;text-overflow: ellipsis;max-width: 100%;} + .listLabels{white-space:nowrap;display:flex;} .listLabels object{max-height:16px;max-width:24px;} +.copy-btn { + margin-left: 6px; + font-size: 12px; + background: #eee; + border: 1px solid #ccc; + border-radius: 4px; + padding: 2px 6px; + cursor: pointer; +} +.copy-btn:hover { + background: #ddd; +} + @media (max-width: 600px) { body {padding: 8px;} .avatar {width:40px;height:40px;} @@ -83,22 +97,29 @@
{{ blogBase['subTitle'] }}
+ {%- if blogBase['prevUrl']!='disabled' or blogBase['nextUrl']!='disabled' -%} {%- endif %} @@ -140,6 +160,33 @@ document.getElementById("{{ key }}").setAttribute("d",value=IconList["{{ key }}" {% for num in blogBase['singeListJson'] -%} document.getElementById("{{ blogBase['singeListJson'][num]['postTitle'] }}").setAttribute("d",value=IconList["{{ blogBase['singeListJson'][num]['labels'][0] }}"]); {%- endfor %} + + +document.querySelectorAll('.copy-btn').forEach(button => { + button.addEventListener('click', () => { + const url = button.getAttribute('data-url'); + navigator.clipboard.writeText(url).then(() => { + showToast('链接已复制!'); + }).catch(() => { + showToast('复制失败'); + }); + }); +}); + +function showToast(msg) { + const toast = document.createElement("div"); + toast.innerText = msg; + toast.style.position = "fixed"; + toast.style.bottom = "20px"; + toast.style.right = "20px"; + toast.style.background = "#222"; + toast.style.color = "#fff"; + toast.style.padding = "8px 12px"; + toast.style.borderRadius = "6px"; + toast.style.zIndex = 10000; + document.body.appendChild(toast); + setTimeout(() => toast.remove(), 2000); +} {{ blogBase['indexScript'] }} {% endblock %}