From 84f1a1659838d6a071e595567498965410a6a75f Mon Sep 17 00:00:00 2001 From: limingCai <1902058478@qq.com> Date: Thu, 3 Sep 2026 16:05:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=88=B7=E5=8D=A1=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JinYuan.Helper/ScanerHook.cs | 6 ++++-- LargeSquareOne/FrmMain.cs | 33 ++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/JinYuan.Helper/ScanerHook.cs b/JinYuan.Helper/ScanerHook.cs index a7cc54c..d0bc6c4 100644 --- a/JinYuan.Helper/ScanerHook.cs +++ b/JinYuan.Helper/ScanerHook.cs @@ -82,14 +82,16 @@ namespace JinYuan.Helper } private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam) { - - EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg)); codes.Add(msg); if (ScanerEvent != null && msg.message == 13 && msg.paramH > 0 && !string.IsNullOrEmpty(codes.Result)) { ScanerEvent(codes); + + // 返回一个非零值,阻断键盘消息继续向下传递 + return 1; } + return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); } public class ScanerCodes diff --git a/LargeSquareOne/FrmMain.cs b/LargeSquareOne/FrmMain.cs index a2b7420..64e1fb4 100644 --- a/LargeSquareOne/FrmMain.cs +++ b/LargeSquareOne/FrmMain.cs @@ -207,6 +207,11 @@ namespace LargeSquareOne idleTimer.Interval = 1000; idleTimer.Tick += (s, e) => { + if (CommonMethods.LoginOut) + { + return; + } + if ((DateTime.Now - lastActivityTime).TotalMinutes >= 1) { idleTimer.Stop(); @@ -220,10 +225,15 @@ namespace LargeSquareOne private void btn_logOut_Click(object sender, EventArgs e) { - idleTimer.Stop(); + //idleTimer.Stop(); // 处理用户超时 - this.BeginInvoke(new Action(() => LoginLocalOut())); + this.BeginInvoke(new Action(() => { + LoginLocalOut(); + + // 为了取消当前按钮的焦点 + avMesicon.Focus(); + })); } private async void FrmNewMain_Load(object sender, EventArgs e) @@ -533,11 +543,14 @@ namespace LargeSquareOne } CommonMethods.IsLoginOk = true; + CommonMethods.LoginOut = false; //存储用户对象 CommonMethods.currentAdmin = sysAdmin; + //1.设置登录用户 this.lbl_LoginLevel.Text = CommonMethods.currentAdmin?.LoginLevel; this.lbl_LoginName.Text = CommonMethods.currentAdmin?.LoginName; + this.lbl_LoginName.Visible = true; //登录日志 CommonMethods.AddOPLog(false, "登录成功,登录用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName}," + "权限".Translated() + $":{CommonMethods.currentAdmin?.LoginLevel}"); @@ -678,13 +691,13 @@ namespace LargeSquareOne } // 登录状态:只在状态变化时更新 - bool isSwipeCardMode = CommonMethods.sysConfig.SwipeCardMode && !CommonMethods.IsLoginOk; - if (lbl_LoginName.Visible == isSwipeCardMode) - { - lbl_LoginName.Visible = !isSwipeCardMode; - if (isSwipeCardMode) - lbl_LoginLevel.Text = "未登录"; - } + //bool isSwipeCardMode = CommonMethods.sysConfig.SwipeCardMode && !CommonMethods.IsLoginOk; + //if (lbl_LoginName.Visible == isSwipeCardMode) + //{ + // lbl_LoginName.Visible = !isSwipeCardMode; + // if (isSwipeCardMode) + // lbl_LoginLevel.Text = "未登录"; + //} } System.Diagnostics.Debug.Print("ShowButtonEven_Run end at " + DateTime.Now.ToString("HH:mm:ss.fff")); @@ -1311,6 +1324,8 @@ namespace LargeSquareOne LogHelper.Instance.WriteLog("用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName} - " + "退出".Translated()); CommonMethods.LoginOut = true; CommonMethods.IsLoginOk = false; + this.lbl_LoginName.Visible = false; + lbl_LoginLevel.Text = "未登录"; } ///