This commit is contained in:
liubiren 2026-07-10 02:01:25 +08:00
parent bfd281f17e
commit 9bd365a44e
3 changed files with 47 additions and 42 deletions

View File

@ -282,43 +282,62 @@ def render_conversation_box() -> rx.Component:
runs = ConversationState.get_runs runs = ConversationState.get_runs
# 若运行字典为空则渲染品牌图标和名称、预设用户提示词,否则遍历渲染运行项 # 若运行字典为空则渲染品牌图标和名称、预设用户提示词,否则遍历渲染运行项
return rx.auto_scroll( return rx.vstack(
rx.cond( rx.cond(
ConversationState.is_runs_empty, runs.length() == 0,
# 渲染空运行字典组件 rx.vstack(
rx.center( # 智能体图标和名称
rx.vstack( rx.hstack(
rx.spacer(), rx.image(
# 智能体图标和名称 src="/logo.png",
rx.hstack( width="64px",
rx.icon("info", size=18), height="64px",
rx.text("智能体"), object_fit="contain", # 等比缩放
), ),
# 预设用户提示词
rx.box( rx.box(
rx.vstack( "Gluballu",
# 标题 font_size="32px",
rx.text("猜你想问"), font_weight="700",
rx.hstack( letter_spacing="1px",
rx.button("你可以帮我做什么"),
),
)
), ),
spacing="4", display="flex",
width="min(100%, 40em)", margin_bottom="12px",
padding_y="40px", align_items="center",
gap="8px",
), ),
border="none", rx.box(
"Gluballu 可辅助产品检索业务资料、开展产品设计与撰写产品方案等。",
line_height="1.5",
),
# 预设用户提示词
rx.box(
rx.vstack(
# 标题
rx.text("猜你想问"),
rx.hstack(
rx.button("你可以帮我做什么"),
),
)
),
color="var(--devui-text)",
), ),
# 遍历渲染运行组件 # 遍历渲染运行项
rx.foreach( rx.auto_scroll(
runs, rx.foreach(
lambda i, _: render_run_component(i[0], i[1]), runs,
lambda i, _: render_run_component(i[0], i[1]),
),
), ),
), ),
display="flex",
flex="1", flex="1",
padding="8px", flex_direction="column",
overflow_y="auto", width="100%",
max_height="1200px",
padding="0 12px",
justify_content="flex-start",
gap="24px",
overflow="auto",
style={ style={
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": {
"display": "none", "display": "none",

View File

@ -72,14 +72,12 @@ def render_sidebar() -> rx.Component:
rx.vstack( rx.vstack(
# 渲染品牌 LOGO 和名称 # 渲染品牌 LOGO 和名称
rx.vstack( rx.vstack(
# 渲染品牌 Logo
rx.image( rx.image(
src="/logo.png", src="/logo.png",
width="34px", width="34px",
height="34px", height="34px",
object_fit="contain", # 等比缩放 object_fit="contain", # 等比缩放
), ),
# 渲染品牌名称
rx.text( rx.text(
"Gluballu", "Gluballu",
line_height="20px", # 行高 line_height="20px", # 行高

View File

@ -143,18 +143,6 @@ class ConversationState(rx.State):
conversation = self.conversations.get(self.conversation_id) conversation = self.conversations.get(self.conversation_id)
return conversation.description if conversation else "新对话" return conversation.description if conversation else "新对话"
@rx.var
def is_runs_empty(self) -> bool:
"""
运行字典是否为空
:return: 运行字典是否为空
"""
# 当前对话
conversation = self.conversations.get(self.conversation_id)
if not conversation:
return True
return not conversation.runs
@rx.var @rx.var
def get_runs(self) -> Dict[str, Run]: def get_runs(self) -> Dict[str, Run]:
""" """