容器处理
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""
|
||||
UI 组件模块
|
||||
包含所有可复用的 Streamlit 组件
|
||||
"""
|
||||
"""
|
||||
|
||||
|
||||
@@ -6,18 +6,25 @@ AI Agent 前端主入口
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 添加项目根目录到 Python 路径,支持绝对导入
|
||||
# 现在的结构: frontend/src/frontend_main.py,所以要获取 frontend/ 目录作为根
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
# 添加当前目录到路径,确保智能导入能工作
|
||||
src_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, src_dir)
|
||||
|
||||
import streamlit as st
|
||||
|
||||
# 使用相对导入
|
||||
from .config import config
|
||||
from .state import AppState
|
||||
from .components.sidebar import render_sidebar
|
||||
from .components.chat_area import render_chat_area
|
||||
from .components.info_panel import render_info_panel
|
||||
# 智能导入:作为 __main__ 被 Streamlit 运行时用绝对导入,否则用相对导入
|
||||
if __name__ == '__main__':
|
||||
from config import config
|
||||
from state import AppState
|
||||
from components.sidebar import render_sidebar
|
||||
from components.chat_area import render_chat_area
|
||||
from components.info_panel import render_info_panel
|
||||
else:
|
||||
from .config import config
|
||||
from .state import AppState
|
||||
from .components.sidebar import render_sidebar
|
||||
from .components.chat_area import render_chat_area
|
||||
from .components.info_panel import render_info_panel
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user