Files
itsc/pages/_app.js
2022-03-31 12:25:54 +08:00

64 lines
1.4 KiB
JavaScript

import Head from "next/head";
import Link from "next/link";
import { useState } from "react";
import {
Button,
Stack,
Box,
CssBaseline,
AppBar,
Toolbar,
Typography,
} from "@mui/material";
import "../styles/globals.css";
function MyApp({ Component, pageProps }) {
const [username, setUsername] = useState("");
pageProps = { ...pageProps, username, setUsername };
return (
<>
<Head>
<title>ITSC Tool</title>
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
/>
<CssBaseline />
</Head>
<AppBar
position="static"
sx={{
mb: 3,
}}
>
<Toolbar
sx={{
flex: 1,
justifyContent: "space-between",
alignItems: "center",
}}
>
<Typography variant="h5">
<Link href="/"> </Link>
</Typography>
{username && (
<Button
variant="contained"
color="secondary"
onClick={() => {
//localStorage.removeItem("username");
setUsername("");
}}
>
{username} (点击登出)
</Button>
)}
</Toolbar>
</AppBar>
<Component {...pageProps} />
</>
);
}
export default MyApp;