Merge pull request #1434 from A-Dawn/main

fix:修改webui默认端口暴露值
pull/1438/head
tcmofashi 2025-12-14 16:48:48 +08:00 committed by GitHub
commit 48639bba70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -59,12 +59,12 @@ class MainSystem:
if webui_mode == "development":
logger.info("📝 WebUI 开发模式已启用")
logger.info("🌐 后端 API 将运行在 http://0.0.0.0:8001")
logger.info("🌐 后端 API 将运行在配置的地址(默认 http://127.0.0.1:8001")
logger.info("💡 请手动启动前端开发服务器: cd MaiBot-Dashboard && bun dev")
logger.info("💡 前端将运行在 http://localhost:7999")
else:
logger.info("✅ WebUI 生产模式已启用")
logger.info("🌐 WebUI 将运行在 http://0.0.0.0:8001")
logger.info("🌐 WebUI 将运行在配置的地址(默认 http://127.0.0.1:8001")
logger.info("💡 请确保已构建前端: cd MaiBot-Dashboard && bun run build")
except Exception as e:

View File

@ -1,4 +1,4 @@
"""独立的 WebUI 服务器 - 运行在 0.0.0.0:8001"""
"""独立的 WebUI 服务器 - 默认运行在 127.0.0.1:8001"""
import os
import asyncio
@ -16,7 +16,7 @@ logger = get_logger("webui_server")
class WebUIServer:
"""独立的 WebUI 服务器"""
def __init__(self, host: str = "0.0.0.0", port: int = 8001):
def __init__(self, host: str = "127.0.0.1", port: int = 8001):
self.host = host
self.port = port
self.app = FastAPI(title="MaiBot WebUI")
@ -178,7 +178,7 @@ def get_webui_server() -> WebUIServer:
global _webui_server
if _webui_server is None:
# 从环境变量读取配置
host = os.getenv("WEBUI_HOST", "0.0.0.0")
host = os.getenv("WEBUI_HOST", "127.0.0.1")
port = int(os.getenv("WEBUI_PORT", "8001"))
_webui_server = WebUIServer(host=host, port=port)
return _webui_server

View File

@ -5,5 +5,5 @@ PORT=8000
# WebUI 独立服务器配置
WEBUI_ENABLED=true
WEBUI_MODE=production # 模式: development(开发) 或 production(生产)
WEBUI_HOST=0.0.0.0 # WebUI 服务器监听地址
WEBUI_HOST=127.0.0.1 # WebUI 服务器监听地址默认仅本地访问设置为0.0.0.0可允许外部访问)
WEBUI_PORT=8001 # WebUI 服务器端口