Skip to content

Commit 328e1d8

Browse files
committed
feat: 优化全屏按钮提示及工具箱 hover 展开交互
1 parent efff2f3 commit 328e1d8

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

app/components/chat.tsx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,24 @@ export function ChatActions(props: {
620620

621621
const [showTools, setShowTools] = useState(false);
622622
const toolsRef = useRef<HTMLDivElement>(null);
623+
const toolsCloseTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(
624+
null,
625+
);
626+
627+
const handleToolsMouseEnter = () => {
628+
if (toolsCloseTimeoutRef.current) {
629+
clearTimeout(toolsCloseTimeoutRef.current);
630+
toolsCloseTimeoutRef.current = null;
631+
}
632+
setShowTools(true);
633+
};
634+
635+
const handleToolsMouseLeave = () => {
636+
toolsCloseTimeoutRef.current = setTimeout(() => {
637+
setShowTools(false);
638+
}, 150);
639+
};
640+
623641
useEffect(() => {
624642
if (!showTools) return; // 菜单没开时不监听,省一次注册
625643
const handle = (e: MouseEvent) => {
@@ -1478,6 +1496,8 @@ export function ChatActions(props: {
14781496
<div
14791497
ref={toolsRef}
14801498
className={clsx(styles["desktop-only"], styles["tool-wrapper"])}
1499+
onMouseEnter={handleToolsMouseEnter}
1500+
onMouseLeave={handleToolsMouseLeave}
14811501
>
14821502
<ChatAction
14831503
onClick={() => setShowTools((v) => !v)}
@@ -4677,8 +4697,16 @@ function ChatComponent() {
46774697
<IconButton
46784698
icon={config.tightBorder ? <MinIcon /> : <MaxIcon />}
46794699
bordered
4680-
title={Locale.Chat.Actions.FullScreen}
4681-
aria={Locale.Chat.Actions.FullScreen}
4700+
title={
4701+
config.tightBorder
4702+
? Locale.Chat.Actions.ExitFullScreen
4703+
: Locale.Chat.Actions.FullScreen
4704+
}
4705+
aria={
4706+
config.tightBorder
4707+
? Locale.Chat.Actions.ExitFullScreen
4708+
: Locale.Chat.Actions.FullScreen
4709+
}
46824710
onClick={() => {
46834711
config.update(
46844712
(config) => (config.tightBorder = !config.tightBorder),
@@ -5879,8 +5907,16 @@ function ChatComponent() {
58795907
<IconButton
58805908
icon={isExpanded ? <MinIcon /> : <MaxIcon />}
58815909
bordered
5882-
title={Locale.Chat.Actions.FullScreen}
5883-
aria={Locale.Chat.Actions.FullScreen}
5910+
title={
5911+
isExpanded
5912+
? Locale.Chat.Actions.ExitFullScreen
5913+
: Locale.Chat.Actions.FullScreen
5914+
}
5915+
aria={
5916+
isExpanded
5917+
? Locale.Chat.Actions.ExitFullScreen
5918+
: Locale.Chat.Actions.FullScreen
5919+
}
58845920
onClick={toggleExpand}
58855921
/>
58865922
<IconButton

app/locales/cn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const cn = {
5353
Save: "保存",
5454
Cancel: "取消",
5555
FullScreen: "全屏",
56+
ExitFullScreen: "退出全屏",
5657
RefreshTitle: "刷新标题",
5758
RefreshToast: "已发送刷新标题请求",
5859
FailTitleToast: "标题生成失败,检查压缩模型设置后点击🔄手动刷新标题",

app/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const en: LocaleType = {
5555
Save: "Save",
5656
Cancel: "Cancel",
5757
FullScreen: "FullScreen",
58+
ExitFullScreen: "Exit FullScreen",
5859
RefreshTitle: "Refresh Title",
5960
RefreshToast: "Title refresh request sent",
6061
FailTitleToast:

0 commit comments

Comments
 (0)