feat: add computer name-based silent login (无感登录)
Implement automatic authentication based on computer name to enable passwordless login for registered computers with fallback to manual authentication. Changes: - Add SessionManager.login_by_computer_name() for silent login attempt - Add BIPUsersDAO.authenticate_by_computer_name() for computer name lookup - Update BIPUsersDAO.create_user() to support optional computer_name parameter - Update main_ui.py to try silent login before showing login dialog - Display current computer name in login dialog for user reference Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Login Dialog - Modal dialog for user authentication
|
||||
"""
|
||||
import socket
|
||||
import tkinter as tk
|
||||
from tkinter import ttk, messagebox
|
||||
from typing import Optional, Tuple
|
||||
@@ -37,7 +38,7 @@ class LoginDialog:
|
||||
"""Create the login dialog UI"""
|
||||
self.dialog = tk.Toplevel(self.parent)
|
||||
self.dialog.title("ERP 自动化工具 - 登录")
|
||||
self.dialog.geometry("400x250")
|
||||
self.dialog.geometry("400x280")
|
||||
self.dialog.resizable(False, False)
|
||||
|
||||
# Center the dialog on parent
|
||||
@@ -52,7 +53,7 @@ class LoginDialog:
|
||||
parent_height = self.parent.winfo_height()
|
||||
|
||||
dialog_width = 400
|
||||
dialog_height = 250
|
||||
dialog_height = 280
|
||||
x = parent_x + (parent_width - dialog_width) // 2
|
||||
y = parent_y + (parent_height - dialog_height) // 2
|
||||
self.dialog.geometry(f"{dialog_width}x{dialog_height}+{x}+{y}")
|
||||
@@ -78,7 +79,16 @@ class LoginDialog:
|
||||
text="请登录",
|
||||
font=('', 16, 'bold')
|
||||
)
|
||||
title_label.pack(pady=(0, 20))
|
||||
title_label.pack(pady=(0, 10))
|
||||
|
||||
# Computer name display
|
||||
computer_name_label = ttk.Label(
|
||||
main_frame,
|
||||
text=f"当前计算机: {socket.gethostname()}",
|
||||
font=('', 9),
|
||||
foreground='gray'
|
||||
)
|
||||
computer_name_label.pack(pady=(0, 15))
|
||||
|
||||
# Username field
|
||||
username_frame = ttk.Frame(main_frame)
|
||||
|
||||
Reference in New Issue
Block a user