From aac61bafebb9725d20d949f8f42c8b157d4556a0 Mon Sep 17 00:00:00 2001 From: M1LKTEA <3494199620@qq.com> Date: Mon, 6 Jul 2026 22:29:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E4=B8=BA=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0=E5=89=94=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=AF=B9=E8=AF=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/event_bus.py | 2 ++ astrbot/core/log.py | 3 +++ astrbot/core/pipeline/respond/stage.py | 1 + .../src/components/shared/ConsoleDisplayer.vue | 17 ++++++++++++++--- .../i18n/locales/en-US/features/console.json | 4 ++++ .../i18n/locales/zh-CN/features/console.json | 4 ++++ dashboard/src/views/ConsolePage.vue | 15 ++++++++++++++- 7 files changed, 42 insertions(+), 4 deletions(-) diff --git a/astrbot/core/event_bus.py b/astrbot/core/event_bus.py index c2a96273ec..38143cf878 100644 --- a/astrbot/core/event_bus.py +++ b/astrbot/core/event_bus.py @@ -73,9 +73,11 @@ def _print_event(self, event: AstrMessageEvent, conf_name: str) -> None: if event.get_sender_name(): logger.info( f"[{conf_name}] [{event.get_platform_id()}({event.get_platform_name()})] {event.get_sender_name()}/{event.get_sender_id()}: {event.get_message_outline()}", + extra={"category": "user_chat"}, ) # 没有发送者名称: [平台名] 发送者ID: 消息概要 else: logger.info( f"[{conf_name}] [{event.get_platform_id()}({event.get_platform_name()})] {event.get_sender_id()}: {event.get_message_outline()}", + extra={"category": "user_chat"}, ) diff --git a/astrbot/core/log.py b/astrbot/core/log.py index 3dd0719b11..1d3acd1a39 100644 --- a/astrbot/core/log.py +++ b/astrbot/core/log.py @@ -32,6 +32,7 @@ def filter(self, record: logging.LogRecord) -> bool: record.source_file = _build_source_file(record.pathname) record.source_line = record.lineno record.is_trace = record.name == "astrbot.trace" + record.category = getattr(record, "category", "system") return True @@ -88,6 +89,7 @@ def _patch_record(record: "Record") -> None: extra.setdefault("source_file", _build_source_file(record["file"].path)) extra.setdefault("source_line", record["line"]) extra.setdefault("is_trace", False) + extra.setdefault("category", "system") _loguru = _raw_loguru_logger.patch(_patch_record) @@ -161,6 +163,7 @@ def emit(self, record: logging.LogRecord) -> None: "level": record.levelname, "time": time.time(), "data": log_entry, + "category": getattr(record, "category", "system"), }, ) diff --git a/astrbot/core/pipeline/respond/stage.py b/astrbot/core/pipeline/respond/stage.py index 888fb65a4b..ac50ce90a2 100644 --- a/astrbot/core/pipeline/respond/stage.py +++ b/astrbot/core/pipeline/respond/stage.py @@ -205,6 +205,7 @@ async def process( logger.info( f"Prepare to send - {event.get_sender_name()}/{event.get_sender_id()}: {event._outline_chain(result.chain)}", + extra={"category": "user_chat"}, ) if result.result_content_type == ResultContentType.STREAMING_RESULT: diff --git a/dashboard/src/components/shared/ConsoleDisplayer.vue b/dashboard/src/components/shared/ConsoleDisplayer.vue index fac250c805..0797ca1002 100644 --- a/dashboard/src/components/shared/ConsoleDisplayer.vue +++ b/dashboard/src/components/shared/ConsoleDisplayer.vue @@ -76,6 +76,10 @@ export default { showLevelBtns: { type: Boolean, default: true + }, + hideUserChat: { + type: Boolean, + default: false } }, watch: { @@ -84,6 +88,9 @@ export default { this.refreshDisplay(); }, deep: true + }, + hideUserChat() { + this.refreshDisplay(); } }, async mounted() { @@ -203,8 +210,8 @@ export default { if (!exists) { this.localLogCache.push(log); hasUpdate = true; - - if (this.isLevelSelected(log.level)) { + + if (this.isLevelSelected(log.level) && !this.isHiddenByCategory(log)) { this.printLog(log.data); } } @@ -245,6 +252,10 @@ export default { return false; }, + isHiddenByCategory(log) { + return this.hideUserChat && log && log.category === 'user_chat'; + }, + refreshDisplay() { const termElement = document.getElementById('term'); if (termElement) { @@ -252,7 +263,7 @@ export default { if (this.localLogCache && this.localLogCache.length > 0) { this.localLogCache.forEach(logItem => { - if (this.isLevelSelected(logItem.level)) { + if (this.isLevelSelected(logItem.level) && !this.isHiddenByCategory(logItem)) { this.printLog(logItem.data); } }); diff --git a/dashboard/src/i18n/locales/en-US/features/console.json b/dashboard/src/i18n/locales/en-US/features/console.json index 812a9a4a69..f0a696f380 100644 --- a/dashboard/src/i18n/locales/en-US/features/console.json +++ b/dashboard/src/i18n/locales/en-US/features/console.json @@ -4,6 +4,10 @@ "enabled": "Auto-scroll enabled", "disabled": "Auto-scroll disabled" }, + "hideUserChat": { + "enabled": "User chat hidden", + "disabled": "Hide user chat" + }, "pipInstall": { "button": "Install pip Package", "dialogTitle": "Install Pip Package", diff --git a/dashboard/src/i18n/locales/zh-CN/features/console.json b/dashboard/src/i18n/locales/zh-CN/features/console.json index f24f80ad6a..b5b15716a7 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/console.json +++ b/dashboard/src/i18n/locales/zh-CN/features/console.json @@ -4,6 +4,10 @@ "enabled": "自动滚动已开启", "disabled": "自动滚动已关闭" }, + "hideUserChat": { + "enabled": "已排除用户对话", + "disabled": "排除用户对话" + }, "pipInstall": { "button": "安装 pip 库", "dialogTitle": "安装 Pip 库", diff --git a/dashboard/src/views/ConsolePage.vue b/dashboard/src/views/ConsolePage.vue index 5ad67b77ba..076a83a1e2 100644 --- a/dashboard/src/views/ConsolePage.vue +++ b/dashboard/src/views/ConsolePage.vue @@ -17,6 +17,15 @@ const { tm } = useModuleI18n('features/console');

+
- +