Flask + SQLite 后端,免构建 React + ECharts 前端,含合成样例数据。 测试参考数据(FOR-TEST-ONLY)与运行时数据库不入库。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.6 KiB
JavaScript
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>`;
|
|
}
|