Simplify WebUI logs and adjust hook reconnect

Translate and consolidate verbose WebUI log messages to shorter English variants (dev mode, initial credentials, forced password change, password update, port fallback, and listening message). Remove a startup log emitted in core index.ts. In HookManager, preserve an existing state.method when detecting an already-injected PID (only set to 'reconnect' if not present) and remove a redundant injection success log to reduce noise.
This commit is contained in:
手瓜一十雪
2026-05-09 16:36:03 +08:00
parent 144e0fdd59
commit 2af273b9e2
3 changed files with 9 additions and 19 deletions
+1 -2
View File
@@ -165,13 +165,12 @@ export class HookManager {
const livePipes = await QqHookClient.listLivePipes();
if (livePipes.has(pid)) {
state.injected = true;
state.method = 'reconnect';
state.method = state.method || 'reconnect';
log.info('PID=%d already has SnowLuma pipe; will reconnect via watcher', pid);
} else {
state.injectResult = injectHookProcess(pid);
state.injected = true;
state.method = state.injectResult.method;
log.info('SnowLuma loaded into PID=%d via %s', pid, state.method);
}
}
state.status = state.connected
-1
View File
@@ -25,7 +25,6 @@ async function main() {
process.env.SNOWLUMA_DEV_WEBUI === '1'
) {
try {
log.info('WebUI is enabled, starting...');
const { initWebUI } = await import('./webui/server');
await initWebUI(runtimeConfig.webuiPort || 5099, oneBotManager, hookManager);
} catch (err) {
+8 -16
View File
@@ -78,21 +78,13 @@ export async function initWebUI(
const auth = WebuiAuth.load();
const initialPassword = auth.takeInitialPassword();
if (auth.isDevMode()) {
log.warn('=========================================');
log.warn('WebUI 已进入开发模式 (SNOWLUMA_DEV_MODE=1)');
log.warn('固定密码: %s', WebuiAuth.devPassword);
log.warn('config/webui.json 不会被读写,强制改密流程已跳过');
log.warn('请勿在生产环境启用此模式');
log.warn('=========================================');
log.warn('dev mode enabled: password=%s', WebuiAuth.devPassword);
log.warn('dev mode skips config/webui.json and password rotation');
} else if (initialPassword) {
log.info('=========================================');
log.info('WebUI 安全认证(首次启动,已生成临时密码)');
log.info('默认用户: admin');
log.info('临时密码: %s', initialPassword);
log.info('请使用该密码登录后立即设置强密码(≥10 位、含大小写、特殊符号、不含空格)');
log.info('=========================================');
log.info('initial credentials: user=admin password=%s', initialPassword);
log.info('password change required after first login');
} else if (auth.mustChangePassword()) {
log.warn('WebUI 仍未完成强制改密,登录后须立即修改密码。');
log.warn('password change is still required');
}
const app = new Hono();
@@ -216,7 +208,7 @@ export async function initWebUI(
sessionTokens.delete(tok);
}
}
log.info('WebUI 密码已更新(强制改密流程完成)');
log.info('password updated');
return c.json({ success: true });
});
@@ -458,12 +450,12 @@ export async function initWebUI(
const finalPort = await findAvailablePort(desiredPort);
if (finalPort !== desiredPort) {
log.warn('端口 %d 已被占用,已自动改用 %d', desiredPort, finalPort);
log.warn('port %d is in use, using %d instead', desiredPort, finalPort);
}
await new Promise<void>((resolve) => {
serve({ fetch: app.fetch, port: finalPort }, (info) => {
log.info(`WebUI 服务监听 http://localhost:${info.port}`);
log.info(`listening http://localhost:${info.port}`);
resolve();
});
});