Add files via upload

This commit is contained in:
公明
2026-05-04 13:07:37 +08:00
committed by GitHub
parent 9b4c6dedc8
commit b27e443d37
5 changed files with 100 additions and 0 deletions
+7
View File
@@ -789,6 +789,7 @@
"nav": {
"basic": "Basic",
"knowledge": "Knowledge base",
"c2": "C2",
"robots": "Bots",
"terminal": "Terminal",
"security": "Security",
@@ -800,6 +801,12 @@
"knowledge": {
"title": "Knowledge base"
},
"c2": {
"title": "C2",
"sectionTitle": "Built-in C2",
"enableLabel": "Enable built-in C2 (listeners, sessions, payloads, MCP tools)",
"enableHint": "When off, listeners are not started and C2 MCP tools are not registered; the C2 sidebar is hidden—useful for local-only chat/knowledge deployments. Click Apply to save."
},
"robots": {
"title": "Bot settings",
"description": "Configure WeCom, DingTalk and Lark bots so you can chat with CyberStrikeAI on your phone without opening the web UI.",
+7
View File
@@ -778,6 +778,7 @@
"nav": {
"basic": "基本设置",
"knowledge": "知识库",
"c2": "C2",
"robots": "机器人设置",
"terminal": "终端",
"security": "安全设置",
@@ -789,6 +790,12 @@
"knowledge": {
"title": "知识库设置"
},
"c2": {
"title": "C2 设置",
"sectionTitle": "内置 C2",
"enableLabel": "启用内置 C2(监听器、会话、Payload、MCP 工具等)",
"enableHint": "关闭后不再启动监听器、不注册 C2 相关 MCP 工具,侧栏 C2 入口将隐藏;仅本机使用对话与知识库时可关闭以节省资源。修改后请点击「应用配置」。"
},
"robots": {
"title": "机器人设置",
"description": "配置企业微信、钉钉、飞书等机器人,在手机端直接与 CyberStrikeAI 对话,无需在服务器上打开网页。",
+3
View File
@@ -65,6 +65,9 @@ function initRouter() {
// 切换页面
function switchPage(pageId) {
if (typeof window.syncC2NavOnceFromServer === 'function') {
void window.syncC2NavOnceFromServer();
}
// 隐藏所有页面
document.querySelectorAll('.page').forEach(page => {
page.classList.remove('active');
+57
View File
@@ -29,6 +29,42 @@ let toolsPagination = {
totalPages: 0
};
let c2NavSyncedOnce = false;
/** 首次进入仪表盘等页面前拉一次配置,隐藏侧栏 C2(避免禁用后仍显示) */
window.syncC2NavOnceFromServer = async function syncC2NavOnceFromServer() {
if (c2NavSyncedOnce || typeof apiFetch === 'undefined') {
return;
}
c2NavSyncedOnce = true;
try {
const r = await apiFetch('/api/config');
if (r.ok) {
const cfg = await r.json();
syncC2NavFromConfig(cfg);
}
} catch (_) {
/* ignore */
}
};
// 根据 C2 是否启用显示主导航 C2 入口与仪表盘 C2 区块(与 /api/config 的 c2.enabled 一致)
function syncC2NavFromConfig(cfg) {
const on = cfg && cfg.c2 && cfg.c2.enabled !== false;
const nav = document.getElementById('nav-c2');
if (nav) {
nav.style.display = on ? '' : 'none';
}
const dash = document.getElementById('dashboard-section-c2');
if (dash) {
if (!on) {
dash.hidden = true;
} else {
dash.removeAttribute('hidden');
}
}
}
// 切换设置分类
function switchSettingsSection(section) {
// 更新导航项状态
@@ -274,6 +310,12 @@ async function loadConfig(loadTools = true) {
}
}
const c2EnabledCb = document.getElementById('c2-enabled');
if (c2EnabledCb) {
c2EnabledCb.checked = currentConfig.c2?.enabled !== false;
}
syncC2NavFromConfig(currentConfig);
// 填充机器人配置
const robots = currentConfig.robots || {};
const wecom = robots.wecom || {};
@@ -975,6 +1017,9 @@ async function applySettings() {
const knowledgeEnabled = knowledgeEnabledCheckbox ? knowledgeEnabledCheckbox.checked : true;
// 收集知识库配置
const c2EnabledCheckbox = document.getElementById('c2-enabled');
const c2Enabled = c2EnabledCheckbox ? c2EnabledCheckbox.checked : true;
const knowledgeConfig = {
enabled: knowledgeEnabled,
base_path: document.getElementById('knowledge-base-path')?.value.trim() || 'knowledge_base',
@@ -1048,6 +1093,9 @@ async function applySettings() {
};
})(),
knowledge: knowledgeConfig,
c2: {
enabled: c2Enabled
},
robots: {
wecom: {
enabled: document.getElementById('robot-wecom-enabled')?.checked === true,
@@ -1174,6 +1222,15 @@ async function applySettings() {
? window.t('settings.apply.applySuccess')
: '配置已成功应用!';
alert(successMsg);
try {
const cfgResp = await apiFetch('/api/config');
if (cfgResp.ok) {
const fresh = await cfgResp.json();
syncC2NavFromConfig(fresh);
}
} catch (e) {
console.warn('refresh C2 nav after apply', e);
}
try {
if (typeof initChatAgentModeFromConfig === 'function') {
await initChatAgentModeFromConfig();
+26
View File
@@ -1937,6 +1937,9 @@
<div class="settings-nav-item" data-section="knowledge" onclick="switchSettingsSection('knowledge')">
<span data-i18n="settings.nav.knowledge">知识库</span>
</div>
<div class="settings-nav-item" data-section="c2" onclick="switchSettingsSection('c2')">
<span data-i18n="settings.nav.c2">C2</span>
</div>
<div class="settings-nav-item" data-section="robots" onclick="switchSettingsSection('robots')">
<span data-i18n="settings.nav.robots">机器人设置</span>
</div>
@@ -2222,6 +2225,29 @@
</div>
</div>
<!-- C2 总开关 -->
<div id="settings-section-c2" class="settings-section-content">
<div class="settings-section-header">
<h3 data-i18n="settings.c2.title">C2 设置</h3>
</div>
<div class="settings-subsection">
<h4 data-i18n="settings.c2.sectionTitle">内置 C2</h4>
<div class="settings-form">
<div class="form-group">
<label class="checkbox-label">
<input type="checkbox" id="c2-enabled" class="modern-checkbox" />
<span class="checkbox-custom"></span>
<span class="checkbox-text" data-i18n="settings.c2.enableLabel">启用内置 C2(监听器、会话、Payload、MCP 工具等)</span>
</label>
<small class="form-hint" data-i18n="settings.c2.enableHint">关闭后不再启动监听器、不注册 C2 相关 MCP 工具,侧栏 C2 入口将隐藏;仅本机使用对话与知识库时可关闭以节省资源。</small>
</div>
</div>
</div>
<div class="settings-actions">
<button class="btn-primary" onclick="applySettings()" data-i18n="settings.apply.button">应用配置</button>
</div>
</div>
<!-- 机器人设置 -->
<div id="settings-section-robots" class="settings-section-content">
<div class="settings-section-header">