Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Compact headers and dialogs, two-column grids, responsive item heroes, player controls, settings tabs, login and server setup screens.
139 lines
3.5 KiB
TypeScript
139 lines
3.5 KiB
TypeScript
import {
|
|
createFileRoute,
|
|
Outlet,
|
|
useLocation,
|
|
useNavigate,
|
|
} from "@tanstack/react-router";
|
|
import React, { useCallback, useEffect } from "react";
|
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
|
|
|
import "./settings.scss";
|
|
import { IconButton, List, Typography } from "@mui/material";
|
|
import { useShallow } from "zustand/shallow";
|
|
import BackButton from "@/components/buttons/backButton";
|
|
import ListItemLink from "@/components/listItemLink";
|
|
import { useApiInContext } from "@/utils/store/api";
|
|
import { useCentralStore } from "@/utils/store/central";
|
|
|
|
export const Route = createFileRoute("/_api/settings")({
|
|
component: SettingsRoute,
|
|
});
|
|
|
|
function SettingsRoute() {
|
|
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
|
const api = useApiInContext((s) => s.api);
|
|
const user = useCentralStore((s) => s.currentUser);
|
|
useEffect(() => {
|
|
setBackdrop("");
|
|
});
|
|
const navigate = useNavigate();
|
|
const location = useLocation();
|
|
const handleNavigateHome = useCallback(() => {
|
|
navigate({ to: "/home" });
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
const active = document.querySelector(
|
|
".settings-sidebar-list [data-status='active']",
|
|
) as HTMLElement | null;
|
|
active?.scrollIntoView({ block: "nearest", inline: "center" });
|
|
}, [location.pathname]);
|
|
return (
|
|
<div className="settings-page-container" data-tauri-drag-region>
|
|
<div className="settings-sidebar">
|
|
<div className="settings-sidebar-controls">
|
|
<BackButton />
|
|
<IconButton
|
|
onClick={handleNavigateHome}
|
|
aria-label="Главная"
|
|
title="Главная"
|
|
sx={{
|
|
background: "rgba(255, 255, 255, 0.05)",
|
|
"&:hover": { background: "rgba(255, 255, 255, 0.1)" },
|
|
}}
|
|
>
|
|
<span className="material-symbols-rounded">home</span>
|
|
</IconButton>
|
|
</div>
|
|
|
|
<div className="settings-sidebar-header">
|
|
<img
|
|
className="settings-sidebar-header-image"
|
|
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
|
alt="Пользователь"
|
|
/>
|
|
<div className="flex flex-column">
|
|
<Typography
|
|
variant="h6"
|
|
sx={{
|
|
fontWeight: "bold",
|
|
}}
|
|
>
|
|
{user?.Name}
|
|
</Typography>
|
|
<Typography variant="body2" sx={{ opacity: 0.5 }}>
|
|
{user?.Policy?.IsAdministrator ? "Администратор" : "Пользователь"}
|
|
</Typography>
|
|
</div>
|
|
</div>
|
|
|
|
<List
|
|
component="nav"
|
|
aria-label="навигация по настройкам"
|
|
className="settings-sidebar-list"
|
|
sx={{
|
|
width: "100%",
|
|
padding: 0,
|
|
}}
|
|
>
|
|
<Typography
|
|
variant="overline"
|
|
sx={{
|
|
px: 2,
|
|
py: 1,
|
|
opacity: 0.5,
|
|
fontWeight: "bold",
|
|
letterSpacing: "0.1em",
|
|
}}
|
|
>
|
|
Общие
|
|
</Typography>
|
|
<ListItemLink
|
|
to="/settings/preferences"
|
|
icon="tune"
|
|
primary="Настройки"
|
|
className="settings-sidebar-list-item"
|
|
/>
|
|
<ListItemLink
|
|
to="/settings/changeServer"
|
|
icon="dns"
|
|
primary="Серверы"
|
|
className="settings-sidebar-list-item"
|
|
/>
|
|
|
|
<Typography
|
|
variant="overline"
|
|
sx={{
|
|
px: 2,
|
|
py: 1,
|
|
mt: 2,
|
|
opacity: 0.5,
|
|
fontWeight: "bold",
|
|
letterSpacing: "0.1em",
|
|
}}
|
|
>
|
|
Система
|
|
</Typography>
|
|
<ListItemLink
|
|
to="/settings/about"
|
|
icon="info"
|
|
primary="О приложении"
|
|
className="settings-sidebar-list-item"
|
|
/>
|
|
</List>
|
|
</div>
|
|
<Outlet />
|
|
</div>
|
|
);
|
|
}
|