Skip to content

Commit 83a9839

Browse files
committed
🚸 自动化上色面板从右侧弹出后,可以通过Esc键关闭了
1 parent 7542e43 commit 83a9839

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/src/components/panel.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,20 @@ export namespace Panel {
5656
function Component({ title, closable, buttons, children, widthRate }: Props) {
5757
const [show, setShow] = React.useState(false);
5858

59+
const closeFunction = (e: KeyboardEvent) => {
60+
if (e.key === "Escape") {
61+
setShow(false);
62+
}
63+
};
5964
React.useEffect(() => {
6065
setTimeout(() => {
6166
setShow(true);
6267
}, 50);
68+
69+
window.addEventListener("keydown", closeFunction);
70+
return () => {
71+
window.removeEventListener("keydown", closeFunction);
72+
};
6373
}, []);
6474

6575
return (

0 commit comments

Comments
 (0)