update
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

This commit is contained in:
1xDed committed 2026-12-02 08:37:23 +03:00
1 parent 7fb3d6cfa4
commit cbb750a413
67 files changed
+5399 -3413

No files matched your search

+130 -207
View File
@@ -3,13 +3,12 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
import { getPersonApi } from "@jellyfin/sdk/lib/utils/api/person-api";
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
import { useQuery } from "@tanstack/react-query";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import React, { useEffect, useMemo, useState } from "react";
import { Card } from "@/components/card/card";
import CardScroller from "@/components/cardScroller/cardScroller";
import { useBackdropStore } from "@/utils/store/backdrop";
import "./search.scss";
import {
AppBar,
Box,
Chip,
Fade,
@@ -22,16 +21,11 @@ import {
Select,
type SelectChangeEvent,
Typography,
useScrollTrigger,
} from "@mui/material";
import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router";
import { useShallow } from "zustand/shallow";
import { NavigationDrawer } from "@/components/appBar/navigationDrawer";
import BackButton from "@/components/buttons/backButton";
import { UserAvatarMenu } from "@/components/userAvatarMenu";
import WindowControls from "@/components/windowControls";
import { useApiInContext } from "@/utils/store/api";
import useDebounce from "@/utils/hooks/useDebounce";
import { useApiInContext } from "@/utils/store/api";
import { useCentralStore } from "@/utils/store/central";
export const Route = createFileRoute("/_api/search/")({
@@ -46,7 +40,11 @@ const CATEGORIES = [
{ label: "Сериалы", value: "Series", kind: BaseItemKind.Series },
{ label: "Серии", value: "Episode", kind: "Episode" },
{ label: "Музыка", value: "MusicAlbum", kind: BaseItemKind.MusicAlbum },
{ label: "Исполнители", value: "MusicArtist", kind: BaseItemKind.MusicArtist },
{
label: "Исполнители",
value: "MusicArtist",
kind: BaseItemKind.MusicArtist,
},
{ label: "Люди", value: "Person", kind: "Person" },
{ label: "Книги", value: "Book", kind: BaseItemKind.Book },
];
@@ -100,7 +98,7 @@ function SearchPage() {
className={`search-page-bg ${debouncedSearchTerm ? "active" : ""}`}
/>
<SearchAppBar
<SearchToolbar
searchTerm={searchTerm}
setSearchTerm={setSearchTerm}
selectedCategories={selectedCategories}
@@ -147,7 +145,7 @@ function SearchPage() {
);
}
interface SearchAppBarProps {
interface SearchToolbarProps {
searchTerm: string;
setSearchTerm: (term: string) => void;
selectedCategories: string[];
@@ -155,216 +153,141 @@ interface SearchAppBarProps {
handleClearCategories: () => void;
}
function SearchAppBar({
function SearchToolbar({
searchTerm,
setSearchTerm,
selectedCategories,
handleCategoryChange,
handleClearCategories,
}: SearchAppBarProps) {
const scrollTrigger = useScrollTrigger({
disableHysteresis: true,
threshold: 20,
});
const appBarStyling = useMemo(
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
[],
);
const navigate = useNavigate();
const handleNavigateToHome = useCallback(() => navigate({ to: "/home" }), []);
const handleNavigateToFavorite = useCallback(() => {
navigate({ to: "/favorite" });
}, []);
const [showDrawer, setShowDrawer] = useState(false);
}: SearchToolbarProps) {
return (
<>
<AppBar
className={
scrollTrigger
? "appBar search-header scrolling flex flex-row"
: "appBar search-header flex flex-row"
}
style={appBarStyling}
elevation={0}
color="transparent"
>
<div className="flex flex-row" style={{ gap: "0.6em" }}>
<IconButton
onClick={() => setShowDrawer(true)}
aria-label="Открыть меню"
title="Открыть меню"
>
<div className="material-symbols-rounded">menu</div>
</IconButton>
<BackButton />
<IconButton
onClick={handleNavigateToHome}
aria-label="Главная"
title="Главная"
>
<div
className={
location.pathname === "/home"
? "material-symbols-rounded fill"
: "material-symbols-rounded"
}
>
home
</div>
</IconButton>
</div>
<div
className="flex flex-row library-header-center"
style={{ gap: "0.6em" }}
>
<Box className="search-input-container">
<span className="material-symbols-rounded search-icon">search</span>
<InputBase
className="search-input"
placeholder="Поиск в библиотеке..."
fullWidth
autoFocus
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
endAdornment={
searchTerm && (
<IconButton
size="small"
onClick={() => setSearchTerm("")}
sx={{ color: "white" }}
>
<span
className="material-symbols-rounded"
style={{ fontSize: "1.2rem" }}
>
close
</span>
</IconButton>
)
}
size="small"
/>
<FormControl size="small" className="search-category-select">
<Select
multiple
displayEmpty
value={selectedCategories}
onChange={handleCategoryChange}
input={
<OutlinedInput
endAdornment={
selectedCategories.length > 0 && (
<IconButton
size="small"
onMouseDown={(e) => {
e.stopPropagation();
}}
onClick={(e) => {
e.stopPropagation();
handleClearCategories();
}}
sx={{ p: 0.5 }}
>
<span
className="material-symbols-rounded"
style={{ fontSize: "1rem" }}
>
close
</span>
</IconButton>
)
}
/>
}
IconComponent={(props) => (
<div className="search-toolbar">
<Box className="search-input-container">
<span className="material-symbols-rounded search-icon">search</span>
<InputBase
className="search-input"
placeholder="Поиск в библиотеке..."
fullWidth
autoFocus
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
endAdornment={
searchTerm && (
<IconButton
size="small"
onClick={() => setSearchTerm("")}
sx={{ color: "white" }}
>
<span
{...props}
className={`material-symbols-rounded ${props.className}`}
className="material-symbols-rounded"
style={{ fontSize: "1.2rem" }}
>
expand_more
close
</span>
)}
renderValue={(selected) => {
if (selected.length === 0)
return (
<Typography
variant="body2"
color="textSecondary"
sx={{ opacity: 0.7 }}
</IconButton>
)
}
size="small"
/>
<FormControl size="small" className="search-category-select">
<Select
multiple
displayEmpty
value={selectedCategories}
onChange={handleCategoryChange}
input={
<OutlinedInput
endAdornment={
selectedCategories.length > 0 && (
<IconButton
size="small"
onMouseDown={(e) => {
e.stopPropagation();
}}
onClick={(e) => {
e.stopPropagation();
handleClearCategories();
}}
sx={{ p: 0.5 }}
>
Типы
</Typography>
);
<span
className="material-symbols-rounded"
style={{ fontSize: "1rem" }}
>
close
</span>
</IconButton>
)
}
/>
}
IconComponent={(props) => (
<span
{...props}
className={`material-symbols-rounded ${props.className}`}
>
expand_more
</span>
)}
renderValue={(selected) => {
if (selected.length === 0)
return (
<Box
sx={{
display: "flex",
flexWrap: "nowrap",
gap: 0.5,
overflow: "hidden",
maxWidth: "100%",
maskImage:
"linear-gradient(to right, black 85%, transparent 100%)",
}}
<Typography
variant="body2"
color="textSecondary"
sx={{ opacity: 0.7 }}
>
{selected.map((value) => {
const label =
CATEGORIES.find((c) => c.value === value)?.label ||
value;
return (
<Chip
key={value}
label={label}
size="small"
sx={{ height: 24 }}
/>
);
})}
</Box>
Типы
</Typography>
);
}}
MenuProps={{
slotProps: { paper: { className: "glass-menu-paper" } },
disableScrollLock: true,
}}
size="small"
>
<MenuItem disabled value="">
<Typography variant="overline" color="textSecondary">
Фильтр по типу
</Typography>
return (
<Box
sx={{
display: "flex",
flexWrap: "nowrap",
gap: 0.5,
overflow: "hidden",
maxWidth: "100%",
maskImage:
"linear-gradient(to right, black 85%, transparent 100%)",
}}
>
{selected.map((value) => {
const label =
CATEGORIES.find((c) => c.value === value)?.label || value;
return (
<Chip
key={value}
label={label}
size="small"
sx={{ height: 24 }}
/>
);
})}
</Box>
);
}}
MenuProps={{
slotProps: { paper: { className: "glass-menu-paper" } },
disableScrollLock: true,
}}
size="small"
>
<MenuItem disabled value="">
<Typography variant="overline" color="textSecondary">
Фильтр по типу
</Typography>
</MenuItem>
{CATEGORIES.map((cat) => (
<MenuItem key={cat.value} value={cat.value}>
{cat.label}
</MenuItem>
{CATEGORIES.map((cat) => (
<MenuItem key={cat.value} value={cat.value}>
{cat.label}
</MenuItem>
))}
</Select>
</FormControl>
</Box>
</div>
<div className="flex flex-row" style={{ gap: "0.6em" }}>
<IconButton
onClick={handleNavigateToFavorite}
aria-label="Избранное"
title="Избранное"
>
<div className="material-symbols-rounded">favorite</div>
</IconButton>
<UserAvatarMenu />
<WindowControls />
</div>
</AppBar>
<NavigationDrawer
open={showDrawer}
onClose={() => setShowDrawer(false)}
/>
</>
))}
</Select>
</FormControl>
</Box>
</div>
);
}