Files
Gset/static/js/Login.js
T
treeandClaude Opus 5.5 f8d1ccc526 初始提交:5G 基站退服时长智能分析与故障闭环管控系统
Flask + SQLite 后端,免构建 React + ECharts 前端,含合成样例数据。
测试参考数据(FOR-TEST-ONLY)与运行时数据库不入库。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 14:01:48 +08:00

39 lines
1.6 KiB
JavaScript

import {GlassButton, GlassSurface, html, TextField, useState} from 'vendor';
import {api} from './api.js';
/** 登录页。系统不开放自助注册,账号由管理员在「用户管理」中分配。 */
export function Login({onLogin}) {
const [error, setError] = useState('');
const [busy, setBusy] = useState(false);
const submit = async e => {
e.preventDefault();
setBusy(true);
setError('');
try {
await api('/login', {json: Object.fromEntries(new FormData(e.currentTarget))});
history.replaceState(null, '', '/');
onLogin();
} catch (err) {
setError(err.message);
setBusy(false);
}
};
return html`
<div className="center-screen">
<${GlassSurface} size="large" radius=${28} className="login-card">
<img className="logo lg" src="/static/icon.svg" alt=""/>
<h1>5G 基站退服智能分析</h1>
<p className="hint">故障闭环管控系统 · 南宁城区</p>
<form onSubmit=${submit} className="login-form">
<${TextField} name="username" label="用户名" autoComplete="username" required controlSize="large" autoFocus/>
<${TextField} name="password" label="密码" type="password" autoComplete="current-password" required
controlSize="large" error=${error || undefined}/>
<${GlassButton} type="submit" variant="glassProminent" controlSize="large" loading=${busy}>登录</${GlassButton}>
</form>
<p className="hint small">默认账号 admin / admin123(管理员)· user / user123(普通用户)</p>
</${GlassSurface}>
</div>`;
}