diff --git a/public/nzcfg.html b/public/nzcfg.html index 0dd188f..b08b2c8 100644 --- a/public/nzcfg.html +++ b/public/nzcfg.html @@ -782,7 +782,7 @@
@@ -976,20 +976,29 @@
}
}
- function copyToClipboard(elementId) {
+ function copyToClipboard(elementId, btn) {
+ const urlParams = new URLSearchParams(window.location.search);
+ const targetParam = urlParams.get('target');
+ const oldText = btn ? btn.innerHTML : null;
+
var text = document.querySelector("#" + elementId + " code").innerText
navigator.clipboard.writeText(text).then(function () {
if (window.opener) {
window.opener.postMessage(
{
type: "NZCFG_JSON",
- target: elementId === "jsonOutput" ? "public_note" : "traffic",
+ target: targetParam || (elementId === "jsonOutput" ? "public_note" : "traffic"),
payload: text,
},
"*",
)
- alert("已生成并同步至控制面板中!")
- window.close()
+ if (btn) {
+ btn.innerHTML = ' 已同步至控制面板';
+ btn.style.backgroundColor = '#2ecc71';
+ }
+ setTimeout(() => {
+ window.close();
+ }, 600);
} else {
alert("已复制到剪贴板!")
}
diff --git a/src/components/server.tsx b/src/components/server.tsx
index 018cd68..2b128f9 100644
--- a/src/components/server.tsx
+++ b/src/components/server.tsx
@@ -95,9 +95,12 @@ export const ServerCard: React.FC