💄 Optimized UX

This commit is contained in:
LittleSheep 2024-02-26 19:26:04 +08:00
parent 518b2f2503
commit 14e87d96ce
5 changed files with 32 additions and 27 deletions

View File

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.3", "@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5.15.10", "@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10", "@mui/material": "^5.15.10",
"@unocss/reset": "^0.58.5", "@unocss/reset": "^0.58.5",

View File

@ -1,7 +1,8 @@
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft"; import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
import ChevronRightIcon from "@mui/icons-material/ChevronRight"; import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import { import {
Box, Collapse, Box,
Collapse,
Divider, Divider,
Drawer, Drawer,
IconButton, IconButton,
@ -14,15 +15,13 @@ import {
} from "@mui/material"; } from "@mui/material";
import { theme } from "@/theme"; import { theme } from "@/theme";
import { Fragment, ReactNode, useState } from "react"; import { Fragment, ReactNode, useState } from "react";
import HomeIcon from "@mui/icons-material/Home"; import HowToRegIcon from "@mui/icons-material/HowToReg";
import ArticleIcon from "@mui/icons-material/Article"; import LoginIcon from "@mui/icons-material/Login";
import FeedIcon from "@mui/icons-material/RssFeed"; import FaceIcon from "@mui/icons-material/Face";
import InfoIcon from "@mui/icons-material/Info"; import LogoutIcon from "@mui/icons-material/Logout";
import GavelIcon from "@mui/icons-material/Gavel";
import PolicyIcon from "@mui/icons-material/Policy";
import SupervisedUserCircleIcon from "@mui/icons-material/SupervisedUserCircle";
import ExpandLess from "@mui/icons-material/ExpandLess"; import ExpandLess from "@mui/icons-material/ExpandLess";
import ExpandMore from "@mui/icons-material/ExpandMore"; import ExpandMore from "@mui/icons-material/ExpandMore";
import { useUserinfo } from "@/stores/userinfo.tsx";
export interface NavigationItem { export interface NavigationItem {
icon?: ReactNode; icon?: ReactNode;
@ -33,19 +32,6 @@ export interface NavigationItem {
} }
export const DRAWER_WIDTH = 320; export const DRAWER_WIDTH = 320;
export const NAVIGATION_ITEMS: NavigationItem[] = [
{ icon: <HomeIcon />, title: "首页", link: "/" },
{ icon: <ArticleIcon />, title: "博客", link: "/posts" },
{
icon: <InfoIcon />, title: "信息中心", children: [
{ icon: <GavelIcon />, title: "用户协议", link: "/i/user-agreement" },
{ icon: <PolicyIcon />, title: "隐私协议", link: "/i/privacy-policy" },
{ icon: <SupervisedUserCircleIcon />, title: "社区准则", link: "/i/community-guidelines" }
]
},
{ divider: true },
{ icon: <FeedIcon />, title: "订阅源", link: "/feed" }
];
export const AppNavigationHeader = styled("div")(({ theme }) => ({ export const AppNavigationHeader = styled("div")(({ theme }) => ({
display: "flex", display: "flex",
@ -91,6 +77,23 @@ export function AppNavigationSection({ items, depth }: { items: NavigationItem[]
} }
export function AppNavigation({ showClose, onClose }: { showClose?: boolean; onClose: () => void }) { export function AppNavigation({ showClose, onClose }: { showClose?: boolean; onClose: () => void }) {
const { checkLoggedIn } = useUserinfo();
const nav: NavigationItem[] = [
...(
checkLoggedIn() ?
[
{ icon: <FaceIcon />, title: "Account", link: "/users" },
{ divider: true },
{ icon: <LogoutIcon />, title: "Sign out", link: "/auth/sign-out" }
] :
[
{ icon: <HowToRegIcon />, title: "Sign up", link: "/auth/sign-up" },
{ icon: <LoginIcon />, title: "Sign in", link: "/auth/sign-in" }
]
)
];
return ( return (
<> <>
<AppNavigationHeader> <AppNavigationHeader>
@ -102,7 +105,7 @@ export function AppNavigation({ showClose, onClose }: { showClose?: boolean; onC
</AppNavigationHeader> </AppNavigationHeader>
<Divider /> <Divider />
<List> <List>
<AppNavigationSection items={NAVIGATION_ITEMS} /> <AppNavigationSection items={nav} />
</List> </List>
</> </>
); );

View File

@ -8,6 +8,7 @@ import "virtual:uno.css";
import "./index.css"; import "./index.css";
import "@unocss/reset/tailwind.css"; import "@unocss/reset/tailwind.css";
import "@fontsource/roboto/latin.css";
import AppShell from "@/components/AppShell.tsx"; import AppShell from "@/components/AppShell.tsx";
import LandingPage from "@/pages/landing.tsx"; import LandingPage from "@/pages/landing.tsx";

View File

@ -171,7 +171,7 @@ export default function SignInPage() {
disabled={loading} disabled={loading}
sx={{ mt: 3, mb: 2 }} sx={{ mt: 3, mb: 2 }}
> >
{loading ? "Signing Now..." : "Sign In"} {loading ? "Processing..." : "Next"}
</Button> </Button>
</Box> </Box>
</> </>
@ -217,7 +217,7 @@ export default function SignInPage() {
disabled={loading} disabled={loading}
sx={{ mt: 3, mb: 2 }} sx={{ mt: 3, mb: 2 }}
> >
{loading ? "Signing Now..." : "Sign In"} {loading ? "Processing..." : "Next"}
</Button> </Button>
</Box> </Box>
</> </>
@ -251,7 +251,7 @@ export default function SignInPage() {
disabled={loading} disabled={loading}
sx={{ mt: 3, mb: 2 }} sx={{ mt: 3, mb: 2 }}
> >
{loading ? "Signing Now..." : "Sign In"} {loading ? "Processing..." : "Next"}
</Button> </Button>
</Box> </Box>
</> </>
@ -279,7 +279,7 @@ export default function SignInPage() {
return ( return (
<Box sx={{ height: "100vh", display: "flex", alignItems: "center", justifyContent: "center" }}> <Box sx={{ height: "100vh", display: "flex", alignItems: "center", justifyContent: "center" }}>
<Box style={{ width: "100vw", maxWidth: "450px" }}> <Box style={{ width: "100vw", maxWidth: "450px" }}>
{error && <Alert severity="error" sx={{ mb: 2 }}>{error}</Alert>} {error && <Alert severity="error" className="capitalize" sx={{ mb: 2 }}>{error}</Alert>}
<Card variant="outlined"> <Card variant="outlined">
<Collapse in={loading}> <Collapse in={loading}>

View File

@ -168,7 +168,7 @@ export default function SignUpPage() {
return ( return (
<Box sx={{ height: "100vh", display: "flex", alignItems: "center", justifyContent: "center" }}> <Box sx={{ height: "100vh", display: "flex", alignItems: "center", justifyContent: "center" }}>
<Box style={{ width: "100vw", maxWidth: "450px" }}> <Box style={{ width: "100vw", maxWidth: "450px" }}>
{error && <Alert severity="error" sx={{ mb: 2 }}>{error}</Alert>} {error && <Alert severity="error" className="capitalize" sx={{ mb: 2 }}>{error}</Alert>}
<Card variant="outlined"> <Card variant="outlined">
<Collapse in={loading}> <Collapse in={loading}>