This commit is contained in:
liubiren 2026-10-14 15:01:19 +08:00
parent 1b1e69b078
commit e0c8f984e9
1 changed files with 37 additions and 148 deletions

View File

@ -45,128 +45,24 @@ def task_history_item(
align_items="center", align_items="center",
width="100%", width="100%",
margin_bottom="8px", margin_bottom="8px",
),
width="100%",
cursor="pointer", cursor="pointer",
# 点击事件:将指定任务唯一标识设置为当前任务唯一标识 # 点击事件:将指定任务唯一标识设置为当前任务唯一标识
on_click=lambda: TaskState.set_task_id(item.id), on_click=lambda: TaskState.set_task_id(item.id),
),
# 任务历史项的更多按钮
rx.box(
rx.popover.root(
rx.popover.trigger(
rx.box(
rx.icon(
"ellipsis",
width="14px",
height="14px",
color="var(--prismui-color-2)",
),
cursor="pointer",
)
),
rx.popover.content(
rx.vstack(
rx.box(
position="absolute",
top="-6px",
left="50%",
transform="translateX(-50%) rotate(45deg)",
width="8px",
height="8px",
background_color="var(--prismui-background-color-1)",
),
rx.popover.close(
rx.box(
"删除",
# 点击事件:删除任务
on_click=lambda: TaskState.delete_task(item.id),
display="flex",
align_items="center",
justify_content="center",
width="100%",
height="24px",
border_radius="var(--prismui-border-radius-1)",
line_height="16px",
font_family="var(--prismui-font-family)",
font_size="var(--prismui-font-size-1)",
color="var(--prismui-color-1)",
style={
"_hover": {
"background_color": "var(--prismui-background-color-6)",
}, # 鼠标悬停显示背景颜色
},
cursor="pointer",
),
),
position="relative",
width="100%",
),
side="bottom",
side_offset=8,
position="relative",
align="center",
padding="4px 8px",
border_radius="var(--prismui-border-radius-1)",
box_shadow="var(--prismui-box-shadow-6)",
overflow="visible",
),
# 悬停气泡显示 / 隐藏变化事件:设置任务历史项悬停气泡显示 / 隐藏
on_open_change=lambda is_shown: TaskState.set_task_history_item_popover_shown(
item.id, is_shown
),
open_delay=0,
),
position="absolute",
top="27px",
right="16px",
transform="translateY(-50%)",
z_index="99",
min_width="14px",
cursor="pointer",
opacity=rx.cond(is_highlight, "1", "0"),
transition="opacity 0.18s ease-in-out",
pointer_events=rx.cond(is_highlight, "auto", "none"),
),
display="flex",
position="relative",
align_items="flex-start",
width="100%",
padding="16px",
margin_bottom="8px",
background=rx.cond(
is_highlight,
"var(--prismui-background-3)",
"var(--prismui-background-color-1)",
),
border_radius="var(--prismui-border-radius-3)",
box_shadow=rx.cond(is_highlight, "var(--prismui-box-shadow-7)", "none"),
cursor="pointer",
style={
"&:hover": {
"background": "var(--prismui-background-3)",
"box_shadow": "var(--prismui-box-shadow-7)",
}, # 鼠标悬停背景颜色和阴影
"&:hover > div:last-child": {
"opacity": "1",
"pointer_events": "auto",
}, # 鼠标悬停显示更多按钮
},
) )
def task_history( def task_history() -> rx.Component:
is_conversation_history_shown: bool,
) -> rx.Component:
""" """
任务历史 任务历史
:param is_conversation_history_shown: 展示 / 隐藏 :return: rx.Component
:return: Component
""" """
return rx.box( return rx.vstack(
rx.vstack( # 任务历史的标题
# 会话历史的标题
rx.hstack( rx.hstack(
rx.text( rx.text(
"会话历史", "任务历史",
margin_bottom="8px", margin_bottom="8px",
font_weight="var(--prismui-font-weight-3)", font_weight="var(--prismui-font-weight-3)",
white_space="nowrap", white_space="nowrap",
@ -177,6 +73,7 @@ def task_history(
rx.auto_scroll( rx.auto_scroll(
rx.foreach( rx.foreach(
TaskState.task_history, TaskState.task_history,
# 渲染任务历史项
task_history_item, task_history_item,
), ),
flex="1", flex="1",
@ -197,17 +94,9 @@ def task_history(
background_color="#f9f9f9cc", background_color="#f9f9f9cc",
backdrop_filter="blur(50px)", backdrop_filter="blur(50px)",
gap="12px", gap="12px",
),
width=rx.cond(is_conversation_history_shown, "25%", "0px"),
min_width=rx.cond(is_conversation_history_shown, "240px", "0px"),
max_width=rx.cond(is_conversation_history_shown, "380px", "0px"),
height="100%",
transition="all 0.18s ease-in-out",
overflow="hidden",
) )
def workflow_button(workflow_type: WorkflowType): def workflow_button(workflow_type: WorkflowType):
""" """
工作流按钮 工作流按钮