login.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>登录 - 恒达视觉智能监控平台</title>
  7. <link rel="icon" href="/logo.ico" type="image/x-icon">
  8. <style>
  9. *{margin:0;padding:0;box-sizing:border-box;border-radius:0 !important}
  10. body{font-family:system-ui,sans-serif;background:#12192e;color:#eee;height:100vh;
  11. display:flex;align-items:center;justify-content:center}
  12. .login-card{background:#141d36;border:1px solid #0f3460;padding:36px 40px;width:380px}
  13. .login-card .logo-row{display:flex;flex-direction:column;align-items:center;gap:10px;margin-bottom:26px}
  14. .login-card img{height:44px}
  15. .login-card h1{font-size:17px;color:#e94560;font-weight:bold;text-align:center}
  16. .form-group{margin-bottom:16px}
  17. .form-group label{display:block;font-size:13px;color:#aaa;margin-bottom:5px}
  18. .form-group input{width:100%;padding:10px 12px;border:1px solid #0f3460;background:#0e1426;color:#eee;font-size:14px}
  19. .form-group input:focus{outline:none;border-color:#e94560}
  20. .btn-login{width:100%;padding:11px;background:#e94560;color:#fff;border:none;font-size:15px;
  21. font-weight:bold;cursor:pointer;margin-top:6px}
  22. .btn-login:hover{background:#c0392b}
  23. .err{color:#e74c3c;font-size:12px;min-height:18px;margin-top:10px;text-align:center}
  24. .tip{text-align:center;color:#666;font-size:11px;margin-top:14px}
  25. </style>
  26. </head>
  27. <body>
  28. <div class="login-card">
  29. <div class="logo-row">
  30. <img src="/logo.png" alt="">
  31. <h1>恒达视觉智能监控平台</h1>
  32. </div>
  33. <form onsubmit="doLogin(); return false;">
  34. <div class="form-group">
  35. <label>用户名</label>
  36. <input type="text" id="username" autocomplete="username" value="admin">
  37. </div>
  38. <div class="form-group">
  39. <label>密码</label>
  40. <input type="password" id="password" autocomplete="current-password">
  41. </div>
  42. <button class="btn-login" type="submit">登 录</button>
  43. <div class="err" id="errMsg"></div>
  44. </form>
  45. <div class="tip">默认账户 admin / admin, 登录后可在系统设置中修改</div>
  46. </div>
  47. <script>
  48. async function doLogin() {
  49. const u = document.getElementById('username').value.trim();
  50. const p = document.getElementById('password').value;
  51. const err = document.getElementById('errMsg');
  52. if (!u || !p) { err.textContent = '请输入用户名和密码'; return; }
  53. try {
  54. const r = await fetch('/api/login', {
  55. method: 'POST',
  56. headers: {'Content-Type': 'application/json'},
  57. body: JSON.stringify({username: u, password: p})
  58. });
  59. const d = await r.json();
  60. if (d.ok) { location.href = '/'; return; }
  61. err.textContent = d.error || '登录失败';
  62. } catch (e) { err.textContent = '网络错误, 请重试'; }
  63. }
  64. document.getElementById('password').focus();
  65. </script>
  66. </body>
  67. </html>