From 556000c0025f5296211347e975eddc1278ff9a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sat, 19 Apr 2025 19:59:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E9=9B=85=E7=9A=84=E5=9B=9E?= =?UTF-8?q?=E8=BD=A6=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- napcat.webui/src/pages/web_login.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/napcat.webui/src/pages/web_login.tsx b/napcat.webui/src/pages/web_login.tsx index 3f9a53eb..c171bc75 100644 --- a/napcat.webui/src/pages/web_login.tsx +++ b/napcat.webui/src/pages/web_login.tsx @@ -47,6 +47,22 @@ export default function WebLoginPage() { } } + // 处理全局键盘事件 + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Enter' && !isLoading) { + onSubmit() + } + } + + useEffect(() => { + document.addEventListener('keydown', handleKeyDown) + + // 清理函数 + return () => { + document.removeEventListener('keydown', handleKeyDown) + } + }, [tokenValue, isLoading]) // 依赖项包含用于登录的状态 + useEffect(() => { if (token) { onSubmit()