fix: 登录状态检查改为手动触发,避免自动请求不断弹出浏览器窗口
- useLoginStatus 默认 auto=false,不再挂载时自动请求 - Dashboard 登录状态卡片改为 "Click to check" 手动触发 - Login 页面初始显示 "Click Refresh to check" 提示 - Header 添加 Token 未配置警告横幅,引导用户去 Settings
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
import { useHealth } from '@/hooks/useHealth';
|
||||
import { useAuth } from '@/context/AuthContext';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export function Header() {
|
||||
const { health } = useHealth(15_000);
|
||||
const { token } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<header className="h-14 bg-dark-card border-b border-dark-border flex items-center justify-between px-6 shrink-0">
|
||||
<div />
|
||||
<div>
|
||||
{!token && (
|
||||
<button
|
||||
onClick={() => navigate('/settings')}
|
||||
className="flex items-center gap-2 px-3 py-1.5 rounded-lg bg-dark-warning/15 border border-dark-warning/30 text-dark-warning text-xs font-medium hover:bg-dark-warning/25 transition-colors"
|
||||
>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
|
||||
<line x1="12" y1="9" x2="12" y2="13" /><line x1="12" y1="17" x2="12.01" y2="17" />
|
||||
</svg>
|
||||
Token 未配置 — 点击前往 Settings
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
{health && (
|
||||
<Badge variant={health.healthy ? 'success' : 'danger'}>
|
||||
|
||||
Reference in New Issue
Block a user