Revert "优化登录功能` (#1386)"

This reverts commit 795f2965cc.
This commit is contained in:
ForgQi committed 2025-09-18 00:13:13 +08:00
1 parent 0f1a3c758d
commit 7dfc81a6d8
4 files changed
+3 -21

No files matched your search

+1 -2
View File
@@ -39,10 +39,9 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const checkAuthRequired = async () => {
try {
const auth = localStorage.getItem('auth');
const response = await fetch('/api/basic', {
headers: {
'Authorization': `Basic ${auth}` // 使用测试凭据
'Authorization': 'Basic dGVzdDp0ZXN0' // 使用测试凭据
}
});
// 如果返回401,说明需要认证
+1 -2
View File
@@ -14,10 +14,9 @@ export function AuthGuard({ children }: { children: React.ReactNode }) {
// 如果用户未认证,则检查是否需要认证
if (!isAuthenticated) {
// 检查是否需要认证
const auth = localStorage.getItem('auth');
fetch('/api/basic', {
headers: {
'Authorization': `Basic ${auth}` // 使用测试凭据
'Authorization': 'Basic dGVzdDp0ZXN0' // 使用测试凭据
}
}).then(response => {
if (response.status !== 401) {
-12
View File
@@ -279,18 +279,6 @@ export default function ProtectedLayout({ children }: { children: React.ReactNod
</Nav.Header>
<Nav.Footer collapseButton={false}>
<ThemeButton mode={mode} setMode={setMode} systemTheme={systemTheme} />
{typeof window !== 'undefined' && localStorage.getItem('auth') && (
<Button
onClick={() => {
localStorage.removeItem('auth');
window.location.href = '/login';
}}
type="danger"
style={{ marginTop: '10px', width: '100%' }}
>
退出登录
</Button>
)}
</Nav.Footer>
</Nav>
</Sider>
+1 -5
View File
@@ -13,10 +13,9 @@ export default function LoginPage() {
useEffect(() => {
// 检查是否需要认证
const auth = localStorage.getItem('auth');
fetch('/api/basic', {
headers: {
'Authorization': `Basic ${auth}` // 使用测试凭据
'Authorization': 'Basic dGVzdDp0ZXN0' // 使用测试凭据
}
}).then(response => {
if (response.status !== 401) {
@@ -54,9 +53,6 @@ export default function LoginPage() {
height: '100vh',
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
backgroundSize: 'cover',
['--semi-color-text-0' as any]: 'rgba(0, 0, 0, 1)',
['--semi-color-text-1' as any]: 'rgba(0, 0, 0, 0.3)',
['--semi-color-text-2' as any]: 'rgba(0, 0, 0, 0.3)',
}}>
<Card
shadows='always'