mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-06 21:22:36 +00:00
chore: update frontend folder
This commit is contained in:
41
frontend/web/src/App.tsx
Normal file
41
frontend/web/src/App.tsx
Normal file
@ -0,0 +1,41 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import DemoBanner from "./components/DemoBanner";
|
||||
import { globalService } from "./services";
|
||||
import useUserStore from "./stores/v1/user";
|
||||
|
||||
function App() {
|
||||
const userStore = useUserStore();
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const initialState = async () => {
|
||||
try {
|
||||
await globalService.initialState();
|
||||
} catch (error) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
try {
|
||||
await userStore.fetchCurrentUser();
|
||||
} catch (error) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
initialState();
|
||||
}, []);
|
||||
|
||||
return !loading ? (
|
||||
<>
|
||||
<DemoBanner />
|
||||
<Outlet />
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
Reference in New Issue
Block a user