feat(auth): replace browser Basic Auth popup with custom Shadcn SSO AuthGateModal and .hl-input system

Browse Source
This commit is contained in:
Yin Kou committed 2026-11-07 00:33:10 +08:00
1 parent ba3cf726b4
commit cbc47336d6
13 files changed
+804 -208

No files matched your search

+26 -2
View File
@@ -1,10 +1,11 @@
import React, { useEffect, useMemo } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { usePortalStore } from './store/usePortalStore'; import { usePortalStore } from './store/usePortalStore';
import { TopRibbon } from './components/TopRibbon'; import { TopRibbon } from './components/TopRibbon';
import { ServiceCard } from './components/ServiceCard'; import { ServiceCard } from './components/ServiceCard';
import { SshShelf } from './components/SshShelf'; import { SshShelf } from './components/SshShelf';
import { CommandPalette } from './components/CommandPalette'; import { CommandPalette } from './components/CommandPalette';
import { AgyTerminalModal } from './components/AgyTerminalModal'; import { AgyTerminalModal } from './components/AgyTerminalModal';
import { AuthGateCard } from './components/AuthGateModal';
import { StorybookWorkbench } from './components/StorybookWorkbench'; import { StorybookWorkbench } from './components/StorybookWorkbench';
import { LAYOUT_PRESETS } from './design-system/tokens'; import { LAYOUT_PRESETS } from './design-system/tokens';
import type { ServiceGroup } from './types/telemetry'; import type { ServiceGroup } from './types/telemetry';
@@ -21,6 +22,12 @@ export const App: React.FC = () => {
routeMode, routeMode,
} = usePortalStore(); } = usePortalStore();
const [authRedirect, setAuthRedirect] = useState<string | null>(() => {
if (typeof window === 'undefined') return null;
const params = new URLSearchParams(window.location.search);
return params.get('auth_redirect');
});
useEffect(() => { useEffect(() => {
fetchTelemetry(); fetchTelemetry();
const timer = setInterval(fetchTelemetry, 3000); const timer = setInterval(fetchTelemetry, 3000);
@@ -45,7 +52,8 @@ export const App: React.FC = () => {
return '443 免端口 HTTPS 直达 (*.961504.xyz)'; return '443 免端口 HTTPS 直达 (*.961504.xyz)';
}, [getEffectiveMode, routeMode]); }, [getEffectiveMode, routeMode]);
const gridClass = LAYOUT_PRESETS[layoutPreset]?.gridClass || LAYOUT_PRESETS['homepage-3col'].gridClass; const gridClass =
LAYOUT_PRESETS[layoutPreset]?.gridClass || LAYOUT_PRESETS['homepage-3col'].gridClass;
const serviceGroups = useMemo<ServiceGroup[]>(() => { const serviceGroups = useMemo<ServiceGroup[]>(() => {
const t = telemetry; const t = telemetry;
@@ -235,6 +243,22 @@ export const App: React.FC = () => {
{/* 5. Embedded AGY Cloud Terminal Modal */} {/* 5. Embedded AGY Cloud Terminal Modal */}
<AgyTerminalModal /> <AgyTerminalModal />
{/* 6. Custom SSO Auth Gate Modal (Replaces Browser Native Basic Auth Popup!) */}
{authRedirect && (
<div className="fixed inset-0 z-50 bg-black/75 backdrop-blur-sm flex items-center justify-center p-4">
<AuthGateCard
targetUrl={authRedirect}
onSuccess={() => {
window.location.href = authRedirect;
}}
onCancel={() => {
setAuthRedirect(null);
window.history.replaceState({}, '', '/');
}}
/>
</div>
)}
</div> </div>
); );
}; };