layout grid
This commit is contained in:
+24
-78
@@ -20,36 +20,37 @@ const App = ({ options = { type: 'api', contextPath: '/' } }) => {
|
||||
|
||||
const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
const { isAuthenticated, setIsAuthenticated } = useAPI();
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const checkAuth = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/account', {
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.status !== 200) {
|
||||
setShowLogin(true);
|
||||
setIsAuthenticated(false);
|
||||
return;
|
||||
}
|
||||
const checkAuth = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/account', {});
|
||||
|
||||
const data = await response.json();
|
||||
setIsAuthenticated(!!data.authorities);
|
||||
if (!data.authorities) {
|
||||
setShowLogin(true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Auth check failed:', error);
|
||||
if (response.status !== 200) {
|
||||
setShowLogin(true);
|
||||
setIsAuthenticated(false);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
checkAuth();
|
||||
}, [setIsAuthenticated]);
|
||||
const data = await response.json();
|
||||
setIsAuthenticated(!!data.authorities);
|
||||
if (!data.authorities) {
|
||||
setShowLogin(true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Auth check failed:', error);
|
||||
setShowLogin(true);
|
||||
setIsAuthenticated(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!isInitialized) {
|
||||
setIsInitialized(true);
|
||||
checkAuth();
|
||||
}
|
||||
}, [isInitialized]);
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <LoginDialog open={showLogin} onOpenChange={setShowLogin} />;
|
||||
@@ -68,59 +69,4 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// const App = ({ options = { type: 'api', contextPath: '/' } }) => {
|
||||
//
|
||||
// const [isAuthenticated, setIsAuthenticated] = useState(false);
|
||||
// const [showLogin, setShowLogin] = useState(false);
|
||||
//
|
||||
// useEffect(() => {
|
||||
// // Check authentication status
|
||||
// const checkAuth = async () => {
|
||||
// try {
|
||||
// const response = await fetch('/api/accouont', {
|
||||
// headers: {
|
||||
// 'X-Requested-With': 'XMLHttpRequest'
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// if (response.status !== 200) {
|
||||
// setShowLogin(true);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const data = await response.json();
|
||||
// console.log(data);
|
||||
// setIsAuthenticated(data.authorities);
|
||||
// if (!data.authorities) {
|
||||
// setShowLogin(true);
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error('Auth check failed:', error);
|
||||
// setShowLogin(true);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// checkAuth();
|
||||
// }, []);
|
||||
//
|
||||
// if (!isAuthenticated) {
|
||||
// return <LoginDialog open={showLogin} onOpenChange={setShowLogin} />;
|
||||
// }
|
||||
//
|
||||
// return (
|
||||
// <APIProvider contextPath={options.contextPath}>
|
||||
// <LoadTestProvider contextPath={options.contextPath}>
|
||||
// <div className="flex flex-col h-screen bg-background">
|
||||
// {options.type === 'api' ? (
|
||||
// <APITester />
|
||||
// ) : (
|
||||
// <LoadTestManager />
|
||||
// )}
|
||||
// </div>
|
||||
// </LoadTestProvider>
|
||||
// </APIProvider>
|
||||
// );
|
||||
// };
|
||||
|
||||
export default App
|
||||
|
||||
Reference in New Issue
Block a user