351 lines
9.7 KiB
HTML
351 lines
9.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="icon" type="image/svg+xml" href="logo/favicon.svg">
|
|
<title>登录 · 画个标</title>
|
|
<style>
|
|
:root {
|
|
--primary: #4f46e5;
|
|
--primary-dark: #4338ca;
|
|
--bg: #f3f4f6;
|
|
--panel: #fff;
|
|
--border: #e5e7eb;
|
|
--text: #1f2937;
|
|
--text-dim: #6b7280;
|
|
--text-faint: #9ca3af;
|
|
--danger: #dc2626;
|
|
--font: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
|
|
--mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
html, body { margin: 0; padding: 0; height: 100%; }
|
|
body {
|
|
font-family: var(--font);
|
|
color: var(--text);
|
|
background: var(--bg);
|
|
background-image:
|
|
radial-gradient(1000px 520px at 8% -10%, rgba(79,70,229,.14), transparent 60%),
|
|
radial-gradient(760px 420px at 96% 8%, rgba(14,165,233,.10), transparent 62%);
|
|
background-repeat: no-repeat;
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
a { color: inherit; text-decoration: none; }
|
|
|
|
.login {
|
|
display: grid;
|
|
grid-template-columns: 1.05fr .95fr;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
/* 左:品牌与能力 */
|
|
.brand-side {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
padding: 44px 56px;
|
|
}
|
|
|
|
.brand {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
.brand img { display: block; }
|
|
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
|
|
.brand-tag {
|
|
padding: 2px 8px; font-size: 11px; color: var(--primary);
|
|
background: #eef2ff; border-radius: 999px;
|
|
}
|
|
|
|
.pitch { max-width: 440px; }
|
|
.pitch h1 {
|
|
font-size: 32px;
|
|
line-height: 1.35;
|
|
letter-spacing: -.5px;
|
|
font-weight: 700;
|
|
}
|
|
.pitch h1 span { color: var(--primary); }
|
|
.pitch p {
|
|
margin-top: 14px;
|
|
font-size: 13.5px;
|
|
line-height: 1.85;
|
|
color: var(--text-dim);
|
|
}
|
|
.facts {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 10px;
|
|
margin-top: 26px;
|
|
}
|
|
.fact {
|
|
padding: 10px 14px;
|
|
background: rgba(255,255,255,.72);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
}
|
|
.fact b {
|
|
display: block;
|
|
font-size: 17px;
|
|
font-weight: 650;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
.fact span { font-size: 11px; color: var(--text-faint); }
|
|
|
|
.copy { font-size: 11.5px; color: var(--text-faint); }
|
|
|
|
/* 右:登录卡 */
|
|
.form-side {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 40px 32px;
|
|
}
|
|
|
|
.card {
|
|
width: 100%;
|
|
max-width: 370px;
|
|
padding: 30px 28px;
|
|
background: var(--panel);
|
|
border: 1px solid var(--border);
|
|
border-radius: 16px;
|
|
box-shadow: 0 26px 70px -34px rgba(31, 41, 55, .38);
|
|
}
|
|
|
|
.card h2 { font-size: 20px; letter-spacing: -.2px; }
|
|
.card .sub { margin-top: 7px; font-size: 12px; color: var(--text-dim); }
|
|
|
|
.field { margin-top: 18px; }
|
|
.field label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--text-dim); }
|
|
.input-wrap { position: relative; }
|
|
.field input {
|
|
width: 100%;
|
|
height: 40px;
|
|
padding: 0 12px;
|
|
font-family: inherit;
|
|
font-size: 13px;
|
|
color: var(--text);
|
|
background: #f9fafb;
|
|
border: 1px solid var(--border);
|
|
border-radius: 9px;
|
|
transition: background .15s, border-color .15s, box-shadow .15s;
|
|
}
|
|
.field input:focus {
|
|
outline: none;
|
|
background: #fff;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px rgba(79,70,229,.12);
|
|
}
|
|
.field input::placeholder { color: var(--text-faint); }
|
|
|
|
.eye {
|
|
position: absolute;
|
|
top: 50%;
|
|
right: 6px;
|
|
transform: translateY(-50%);
|
|
width: 30px;
|
|
height: 30px;
|
|
font-size: 14px;
|
|
line-height: 1;
|
|
color: var(--text-faint);
|
|
background: transparent;
|
|
border: 0;
|
|
border-radius: 7px;
|
|
cursor: pointer;
|
|
}
|
|
.eye:hover { background: #eef2ff; color: var(--primary); }
|
|
|
|
.submit {
|
|
width: 100%;
|
|
height: 40px;
|
|
margin-top: 22px;
|
|
font-family: inherit;
|
|
font-size: 13.5px;
|
|
font-weight: 600;
|
|
color: #fff;
|
|
background: linear-gradient(135deg, var(--primary), var(--primary-dark));
|
|
border: 0;
|
|
border-radius: 9px;
|
|
cursor: pointer;
|
|
box-shadow: 0 8px 20px -10px rgba(79,70,229,.8);
|
|
transition: filter .15s, transform .15s;
|
|
}
|
|
.submit:hover { filter: brightness(1.06); }
|
|
.submit:active { transform: translateY(1px); }
|
|
.submit:disabled { opacity: .7; cursor: default; transform: none; }
|
|
.submit:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
|
|
|
|
.msg {
|
|
min-height: 18px;
|
|
margin-top: 12px;
|
|
font-size: 12px;
|
|
line-height: 1.5;
|
|
}
|
|
.msg.err { color: var(--danger); }
|
|
.msg.ok { color: #047857; }
|
|
|
|
.hint {
|
|
margin-top: 20px;
|
|
padding-top: 14px;
|
|
border-top: 1px solid #f1f3f5;
|
|
font-size: 11px;
|
|
line-height: 1.7;
|
|
color: var(--text-faint);
|
|
}
|
|
|
|
@media (max-width: 920px) {
|
|
.login { grid-template-columns: 1fr; }
|
|
.brand-side {
|
|
padding: 26px 24px 0;
|
|
gap: 24px;
|
|
}
|
|
.pitch h1 { font-size: 24px; }
|
|
.pitch p, .facts, .copy { display: none; }
|
|
.form-side { padding: 26px 24px 40px; align-items: flex-start; }
|
|
.card { box-shadow: 0 14px 40px -26px rgba(31,41,55,.3); }
|
|
}
|
|
@media (prefers-reduced-motion: reduce) {
|
|
* { transition: none !important; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="login">
|
|
<aside class="brand-side">
|
|
<a class="brand" href="login.html">
|
|
<img src="logo/logo-mark.svg" alt="" width="26" height="26">
|
|
<span class="brand-name">画个标</span>
|
|
<span class="brand-tag">智能设计</span>
|
|
</a>
|
|
|
|
<div class="pitch">
|
|
<h1>让品牌设计<br>从<span>一句话</span>开始</h1>
|
|
<p>AI 驱动的设计系统:LOGO、头像、海报、动态表情四套工作台,共用同一套素材库与设计技能。</p>
|
|
<div class="facts">
|
|
<div class="fact"><b>37 万+</b><span>开源图标</span></div>
|
|
<div class="fact"><b>130</b><span>设计技能</span></div>
|
|
<div class="fact"><b>4 套</b><span>设计工作台</span></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="copy">© 2026 画个标 · 内部设计系统</div>
|
|
</aside>
|
|
|
|
<main class="form-side">
|
|
<form class="card" id="login-form" autocomplete="on">
|
|
<h2>登录</h2>
|
|
<p class="sub">使用管理员分配的帐号继续访问</p>
|
|
|
|
<div class="field">
|
|
<label for="username">帐号</label>
|
|
<input id="username" name="username" type="text" placeholder="admin" autocomplete="username" autocapitalize="off" spellcheck="false" required>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="password">密码</label>
|
|
<div class="input-wrap">
|
|
<input id="password" name="password" type="password" placeholder="请输入密码" autocomplete="current-password" required>
|
|
<button class="eye" type="button" id="btn-eye" aria-label="显示密码" title="显示密码">👁</button>
|
|
</div>
|
|
</div>
|
|
|
|
<button class="submit" type="submit" id="btn-login">登录</button>
|
|
<div class="msg" id="msg" role="status" aria-live="polite"></div>
|
|
|
|
<p class="hint">帐号由系统管理员分配。连续输错会临时限制登录,请 1 分钟后再试。</p>
|
|
</form>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
(function () {
|
|
'use strict';
|
|
|
|
var IS_LOCAL = /^(localhost|127\.0\.0\.1|\[::1\])$/.test(location.hostname);
|
|
var API_BASE = IS_LOCAL ? 'http://127.0.0.1:7891' : '';
|
|
|
|
var form = document.getElementById('login-form');
|
|
var userEl = document.getElementById('username');
|
|
var passEl = document.getElementById('password');
|
|
var msgEl = document.getElementById('msg');
|
|
var btn = document.getElementById('btn-login');
|
|
|
|
function setMsg(text, kind) {
|
|
msgEl.className = 'msg' + (kind ? ' ' + kind : '');
|
|
msgEl.textContent = text || '';
|
|
}
|
|
|
|
// 只允许站内相对路径,防开放重定向
|
|
function nextUrl() {
|
|
var n = new URLSearchParams(location.search).get('next') || '';
|
|
if (n && n[0] === '/' && n[1] !== '/') return n;
|
|
return '/home.html';
|
|
}
|
|
|
|
// 已登录则直接跳转(未登录时接口返回 loggedIn:false,不产生控制台报错)
|
|
fetch(API_BASE + '/api/v1/auth/me', { credentials: 'include' })
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (d) { if (d && d.ok && d.data && d.data.loggedIn) location.replace(nextUrl()); })
|
|
.catch(function () { /* 未登录,停留 */ });
|
|
|
|
passEl.addEventListener('input', function () { setMsg(''); });
|
|
|
|
document.getElementById('btn-eye').addEventListener('click', function () {
|
|
var show = passEl.type === 'password';
|
|
passEl.type = show ? 'text' : 'password';
|
|
this.textContent = show ? '🙈' : '👁';
|
|
this.setAttribute('aria-label', show ? '隐藏密码' : '显示密码');
|
|
});
|
|
|
|
form.addEventListener('submit', function (e) {
|
|
e.preventDefault();
|
|
var username = userEl.value.trim();
|
|
var password = passEl.value;
|
|
|
|
if (!username || !password) {
|
|
setMsg('请输入帐号与密码', 'err');
|
|
(!username ? userEl : passEl).focus();
|
|
return;
|
|
}
|
|
|
|
btn.disabled = true;
|
|
btn.textContent = '登录中…';
|
|
setMsg('');
|
|
|
|
fetch(API_BASE + '/api/v1/auth/login', {
|
|
method: 'POST',
|
|
credentials: 'include',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username: username, password: password })
|
|
})
|
|
.then(function (res) {
|
|
return res.json().catch(function () { return {}; }).then(function (data) {
|
|
if (!res.ok || !data.ok) {
|
|
var message = (data.error && data.error.message) || '登录失败';
|
|
throw new Error(message);
|
|
}
|
|
return data;
|
|
});
|
|
})
|
|
.then(function () {
|
|
setMsg('登录成功,正在进入…', 'ok');
|
|
location.replace(nextUrl());
|
|
})
|
|
.catch(function (err) {
|
|
setMsg(err.message || '登录失败,请稍后重试', 'err');
|
|
passEl.value = '';
|
|
passEl.focus();
|
|
btn.disabled = false;
|
|
btn.textContent = '登录';
|
|
});
|
|
});
|
|
|
|
// 自动聚焦
|
|
if (!userEl.value) userEl.focus();
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|