File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -335,7 +335,10 @@ class OnlineModeManager {
335335 </div>
336336 <div class="form-group">
337337 <label>密码:</label>
338- <input type="password" id="loginPassword" class="login-input" placeholder="请输入密码" required>
338+ <div class="password-wrapper">
339+ <input type="password" id="loginPassword" class="login-input" placeholder="请输入密码" required>
340+ <button type="button" id="togglePassword" class="toggle-password"></button>
341+ </div>
339342 </div>
340343 <button type="submit" class="btn login-btn">登录</button>
341344 </form>
@@ -367,6 +370,22 @@ class OnlineModeManager {
367370 } ) ;
368371 }
369372
373+ // 新增:密码显示/隐藏切换功能
374+ const togglePassword = document . getElementById ( 'togglePassword' ) ;
375+ const passwordInput = document . getElementById ( 'loginPassword' ) ;
376+
377+ const eyeIconSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/><path d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/></svg>` ;
378+ const eyeSlashIconSVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="m10.79 12.912-1.614-1.615a3.5 3.5 0 0 1-4.474-4.474l-2.06-2.06C.938 6.278 0 8 0 8s3 5.5 8 5.5a7.029 7.029 0 0 0 2.79-.588zM5.21 3.088A7.028 7.028 0 0 1 8 2.5c5 0 8 5.5 8 5.5s-.939 1.721-2.641 3.238l-2.062-2.062a3.5 3.5 0 0 0-4.474-4.474L5.21 3.089z"/><path d="M5.525 7.646a2.5 2.5-0 0 0 2.829 2.829l-2.83-2.829zm4.95.708-2.829-2.83a2.5 2.5 0 0 1 2.829 2.829zm3.171 6-12-12 .708-.708 12 12-.708.708z"/></svg>` ;
379+
380+ if ( togglePassword && passwordInput ) {
381+ togglePassword . innerHTML = eyeIconSVG ; // 默认显示睁眼
382+ togglePassword . addEventListener ( 'click' , ( ) => {
383+ const type = passwordInput . getAttribute ( 'type' ) === 'password' ? 'text' : 'password' ;
384+ passwordInput . setAttribute ( 'type' , type ) ;
385+ togglePassword . innerHTML = type === 'password' ? eyeIconSVG : eyeSlashIconSVG ;
386+ } ) ;
387+ }
388+
370389 document . getElementById ( 'loginForm' ) . addEventListener ( 'submit' , ( e ) => {
371390 e . preventDefault ( ) ;
372391 this . handleLogin ( ) ;
Original file line number Diff line number Diff line change @@ -2861,4 +2861,42 @@ body.dark-mode .leaflet-tile {
28612861 vertical-align : middle;
28622862}
28632863
2864+ /* 密码输入框 “小眼睛” 样式 */
2865+ .password-wrapper {
2866+ position : relative;
2867+ display : flex;
2868+ align-items : center;
2869+ }
2870+
2871+ .password-wrapper .login-input {
2872+ /* Make space for the icon */
2873+ padding-right : 40px !important ;
2874+ }
2875+
2876+ .toggle-password {
2877+ position : absolute;
2878+ right : 8px ;
2879+ top : 50% ;
2880+ transform : translateY (-50% );
2881+ cursor : pointer;
2882+ user-select : none; /* Prevent text selection */
2883+ background : transparent;
2884+ border : none;
2885+ padding : 5px ;
2886+ display : flex;
2887+ align-items : center;
2888+ justify-content : center;
2889+ color : var (--text-secondary );
2890+ }
2891+
2892+ .toggle-password : hover {
2893+ color : var (--text-primary );
2894+ }
2895+
2896+ .toggle-password svg {
2897+ width : 18px ;
2898+ height : 18px ;
2899+ fill : currentColor;
2900+ }
2901+
28642902
You can’t perform that action at this time.
0 commit comments