修复节点无法编辑的错误
Some checks failed
build / build (api, amd64, linux) (push) Failing after -50s
build / build (api, arm64, linux) (push) Failing after -52s
build / build (api.exe, amd64, windows) (push) Failing after -51s

This commit is contained in:
CN-JS-HuiBai
2026-04-18 10:31:31 +08:00
parent 6e75b7d7d5
commit 98379b21f4
6 changed files with 275 additions and 130 deletions

View File

@@ -404,16 +404,6 @@
state.selectedTicket = null;
render();
}
if (action === "enable-ipv6") {
handleEnableIpv6(actionEl);
return;
}
if (action === "sync-ipv6-password") {
handleSyncIpv6Password(actionEl);
return;
}
if (action === "copy-node-info") {
handleCopyNodeInfo(actionEl.getAttribute("data-node-id"));
@@ -916,39 +906,7 @@
}
}
async function handleEnableIpv6(actionEl) {
actionEl.disabled = true;
try {
var response = await fetchJson("/api/v1/user/user-add-ipv6-subscription/enable", { method: "POST" });
var payload = unwrap(response) || {};
if (payload.auth_data) {
saveIpv6Token(payload.auth_data);
state.ipv6AuthToken = getStoredIpv6Token();
}
showMessage("IPv6 订阅已开启,正在刷新...", "success");
// Try to login to IPv6 account if possible, or just refresh dashboard
// Since we don't have the password here (state doesn't keep it),
// the user might need to sync password first or we assume it was synced during creation.
await loadDashboard(true);
render();
} catch (error) {
showMessage(error.message || "开启失败", "error");
} finally {
actionEl.disabled = false;
}
}
async function handleSyncIpv6Password(actionEl) {
actionEl.disabled = true;
try {
await fetchJson("/api/v1/user/user-add-ipv6-subscription/sync-password", { method: "POST" });
showMessage("密码已同步到 IPv6 账户", "success");
} catch (error) {
showMessage(error.message || "同步失败", "error");
} finally {
actionEl.disabled = false;
}
}
async function loadUplinkMetric() {
if (state.authToken) {
@@ -1589,17 +1547,28 @@
var resetAction = isIpv6 ? "reset-ipv6-security" : "reset-security";
if (isIpv6 && !state.ipv6AuthToken) {
// If IPv6 not enabled, we still want to show the section with an "Enable" button
// But we need to make sure we don't crash on 'sub' or 'user'
// IPv6 not enabled - show guidance to submit a ticket
} else if (isIpv6 && !sub) {
return "";
}
var ipv6FooterHtml = "";
if (isIpv6 && !state.ipv6AuthToken) {
var statusText = ipv6Eligibility.status_label || "未开通";
var guidanceText = "IPv6 订阅需要通过工单由管理员开通,请提交工单申请。";
if (ipv6Eligibility.is_active) {
guidanceText = "您的 IPv6 已开通,如有问题请联系管理员。";
}
ipv6FooterHtml = '<div class="card-footer" style="margin-top:16px;border-top:1px solid var(--border-color);padding-top:16px">' +
'<div class="empty-state" style="padding:0;text-align:left">' +
'<strong>' + escapeHtml(statusText) + '</strong> — ' + escapeHtml(guidanceText) +
'</div></div>';
}
var html = [
'<article class="section-card glass-card ' + escapeHtml(extraClass) + '">',
'<div class="section-head"><div><span class="tiny-pill">' + prefix + '订阅</span><h3>连接工具</h3></div><div class="toolbar">',
'<button class="btn btn-secondary" data-action="' + copyAction + '">复制链接</button>',
isIpv6 ? '<button class="btn btn-primary" data-action="sync-ipv6-password">同步密码</button>' : '',
"</div></div>",
'<div class="kpi-row">',
!isIpv6 ? kpiBox("套餐", escapeHtml((sub && sub.plan && sub.plan.name) || "暂无套餐")) : "",
@@ -1607,20 +1576,9 @@
kpiBox("重置日", String((sub && sub.reset_day) || "-")),
!isIpv6 ? kpiBox("邮箱", '<span style="font-family:var(--font-mono)">' + escapeHtml((user && user.email) || "-") + "</span>") : "",
"</div>",
(isIpv6 && !state.ipv6AuthToken) ? '<div class="card-footer" style="margin-top:16px;border-top:1px solid var(--border-color);padding-top:16px"><button class="btn btn-primary btn-block" data-action="enable-ipv6">开启 IPv6 订阅</button></div>' : '',
ipv6FooterHtml,
"</article>"
].join("");
if (isIpv6 && !state.ipv6AuthToken) {
if (!ipv6Eligibility.allowed) {
html = html.replace(
/<div class="card-footer" style="margin-top:16px;border-top:1px solid var\(--border-color\);padding-top:16px"><button class="btn btn-primary btn-block" data-action="enable-ipv6">[\s\S]*?<\/button><\/div>/,
'<div class="card-footer" style="margin-top:16px;border-top:1px solid var(--border-color);padding-top:16px"><div class="empty-state" style="padding:0;text-align:left">' + escapeHtml(ipv6Eligibility.reason || ipv6Eligibility.status_label || "Current account is not eligible for IPv6 self-service") + '</div></div>'
);
}
if (!ipv6Eligibility.is_active) {
html = html.replace(/<button class="btn btn-primary" data-action="sync-ipv6-password">[\s\S]*?<\/button>/, "");
}
}
return html;
}