feat: harden platform workflows and UI governance

This commit is contained in:
hectorzhao
2026-07-22 14:14:55 +08:00
parent ef957f7daa
commit 0f223f7f91
80 changed files with 4958 additions and 764 deletions
+9 -2
View File
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { adminApi, clientApi, type CaptchaResponse } from '@/api/adminApi';
import { writeSession, type Portal } from '@/api/session';
import { consumeSessionRecovery, readSessionRecovery, writeSession, type Portal } from '@/api/session';
import { Button, Input, Modal } from '@/components/ui';
type LoginPageProps = {
@@ -31,6 +31,7 @@ export function LoginPage({ portal }: LoginPageProps) {
const [alertMessage, setAlertMessage] = useState('');
const [loading, setLoading] = useState(false);
const isAdmin = portal === 'admin';
const recovery = readSessionRecovery(portal);
async function refreshCaptcha(options: { clearError?: boolean } = {}) {
if (options.clearError ?? true) {
@@ -56,7 +57,8 @@ export function LoginPage({ portal }: LoginPageProps) {
captchaText,
});
writeSession(session);
navigate(isAdmin ? '/admin' : '/client', { replace: true });
const target = consumeSessionRecovery(portal)?.returnUrl;
navigate(target ?? (isAdmin ? '/admin' : '/client'), { replace: true });
} catch (err) {
const message = loginErrorMessage(err);
setError(message);
@@ -78,6 +80,11 @@ export function LoginPage({ portal }: LoginPageProps) {
</div>
</div>
<div className="login-form">
{recovery ? (
<p className="login-session-notice" role="status">
{recovery.message ?? '登录会话已失效,请重新登录。'} 访
</p>
) : null}
<Input label="用户名/登录账号" onChange={(event) => setLogin(event.target.value)} placeholder="请输入用户名、邮箱或手机号" value={login} />
<Input label="密码" onChange={(event) => setPassword(event.target.value)} placeholder="请输入密码" type="password" value={password} />
<div className="login-captcha-row">