Add files via upload

This commit is contained in:
公明
2026-07-13 18:56:52 +08:00
committed by GitHub
parent 597712a7b9
commit 68e3ead4d7
7 changed files with 365 additions and 0 deletions
+6
View File
@@ -711,6 +711,9 @@ async function openRobotAccountBinding() {
function closeRobotAccountBinding() {
closeAppModal('robot-account-binding-modal');
if (typeof window.loadVulnerabilityAlertSubscription === 'function') {
window.loadVulnerabilityAlertSubscription();
}
}
async function generateRobotBindingCode() {
@@ -859,6 +862,9 @@ async function loadRobotAccountBindings() {
</div>
<button type="button" class="btn-secondary btn-small robot-binding-unbind-btn" onclick="deleteRobotAccountBinding('${escapeHtml(binding.id || '')}')">解除绑定</button>
</div>`).join('');
if (typeof window.loadVulnerabilityAlertSubscription === 'function') {
window.loadVulnerabilityAlertSubscription();
}
}
function formatRobotBindingTime(value) {
+3
View File
@@ -585,6 +585,9 @@ function switchSettingsSection(section) {
activeContent.classList.add('active');
initSettingsCustomSelects(activeContent);
}
if (section === 'robots' && typeof window.loadVulnerabilityAlertSubscription === 'function') {
window.loadVulnerabilityAlertSubscription();
}
if (section === 'terminal' && typeof initTerminal === 'function') {
setTimeout(initTerminal, 0);
}
+75
View File
@@ -1856,6 +1856,79 @@ function refreshVulnerabilities() {
loadVulnerabilities();
}
async function loadVulnerabilityAlertSubscription() {
const enabledEl = document.getElementById('vulnerability-alert-enabled');
const severityEl = document.getElementById('vulnerability-alert-min-severity');
if (!enabledEl || !severityEl || typeof apiFetch === 'undefined') return;
try {
const response = await apiFetch('/api/vulnerability-alerts/subscription');
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
const sub = data.subscription || {};
enabledEl.checked = !!sub.enabled;
severityEl.value = sub.min_severity || 'high';
severityEl.disabled = false;
if (typeof window.refreshSettingsCustomSelects === 'function') {
window.refreshSettingsCustomSelects();
}
const hint = document.getElementById('vulnerability-alert-binding-hint');
const bindButton = document.getElementById('vulnerability-alert-bind-button');
if (hint && !data.delivery_ready) {
const supportedTypes = [
{ type: 'wecom', label: vulnT('settings.robots.wecom.title') },
{ type: 'lark', label: vulnT('settings.robots.lark.title') },
{ type: 'telegram', label: 'Telegram' },
{ type: 'slack', label: 'Slack' },
{ type: 'discord', label: 'Discord' }
];
const enabledPlatforms = supportedTypes.filter(function (item) {
if (typeof getRobotStatus !== 'function') return false;
const status = getRobotStatus(item.type);
return status && status.state === 'enabled';
}).map(function (item) { return item.label; });
hint.textContent = enabledPlatforms.length
? vulnT('vulnerabilityPage.alertConfiguredNotBound', { platforms: enabledPlatforms.join('、') })
: vulnT('vulnerabilityPage.alertNoBinding');
hint.classList.add('is-warning');
if (bindButton) bindButton.hidden = false;
} else if (hint) {
hint.textContent = vulnT('vulnerabilityPage.alertHint');
hint.classList.remove('is-warning');
if (bindButton) bindButton.hidden = true;
}
} catch (error) {
console.warn('加载漏洞提醒设置失败', error);
}
}
async function saveVulnerabilityAlertSubscription() {
const enabledEl = document.getElementById('vulnerability-alert-enabled');
const severityEl = document.getElementById('vulnerability-alert-min-severity');
if (!enabledEl || !severityEl) return;
enabledEl.disabled = true;
severityEl.disabled = true;
if (typeof window.refreshSettingsCustomSelects === 'function') {
window.refreshSettingsCustomSelects();
}
try {
const response = await apiFetch('/api/vulnerability-alerts/subscription', {
method: 'PUT', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ enabled: enabledEl.checked, min_severity: severityEl.value })
});
if (!response.ok) throw new Error(await response.text());
if (typeof showNotification === 'function') showNotification(vulnT('vulnerabilityPage.alertSaved'), 'success');
} catch (error) {
if (typeof showNotification === 'function') showNotification(vulnT('vulnerabilityPage.alertSaveFailed'), 'error');
await loadVulnerabilityAlertSubscription();
} finally {
enabledEl.disabled = false;
severityEl.disabled = false;
if (typeof window.refreshSettingsCustomSelects === 'function') {
window.refreshSettingsCustomSelects();
}
}
}
// 切换漏洞详情展开/折叠
function toggleVulnerabilityDetails(id) {
const content = document.getElementById(`content-${id}`);
@@ -2415,3 +2488,5 @@ window.bindVulnerabilityProject = bindVulnerabilityProject;
window.buildVulnerabilityProjectOptionsHtml = buildVulnerabilityProjectOptionsHtml;
window.changeVulnerabilityStatus = changeVulnerabilityStatus;
window.openVulnerabilityConversation = openVulnerabilityConversation;
window.loadVulnerabilityAlertSubscription = loadVulnerabilityAlertSubscription;
window.saveVulnerabilityAlertSubscription = saveVulnerabilityAlertSubscription;