mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
perf: remove unused deps
This commit is contained in:
parent
2959850238
commit
81ea88443e
@ -1,43 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { verifySSEConnection } from "@/lib/sseFetch";
|
|
||||||
|
|
||||||
export default function LiveTag() {
|
|
||||||
const [connected, setConnected] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// Store the promise in a variable
|
|
||||||
const ssePromise = verifySSEConnection(
|
|
||||||
"https://home.buycoffee.tech/v2/VerifySSEConnect",
|
|
||||||
);
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.promise(ssePromise, {
|
|
||||||
loading: "Connecting to SSE...",
|
|
||||||
success: "HomeDash SSE Connected",
|
|
||||||
error: "Error connecting to SSE",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// Handle promise resolution separately
|
|
||||||
ssePromise
|
|
||||||
.then(() => {
|
|
||||||
setConnected(true);
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
setConnected(false);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return connected ? (
|
|
||||||
<Badge className={"flex items-center justify-center gap-1 px-2"}>
|
|
||||||
Synced
|
|
||||||
<span className="h-2 w-2 rounded-full bg-green-500"></span>
|
|
||||||
</Badge>
|
|
||||||
) : (
|
|
||||||
<Badge className={"flex items-center justify-center gap-1 px-2"}>
|
|
||||||
Static<span className="h-2 w-2 rounded-full bg-red-500"></span>
|
|
||||||
</Badge>
|
|
||||||
);
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ import { Inter as FontSans } from "next/font/google";
|
|||||||
import { ThemeProvider } from "next-themes";
|
import { ThemeProvider } from "next-themes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import NextThemeToaster from "@/components/client/NextToast";
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
const fontSans = FontSans({
|
const fontSans = FontSans({
|
||||||
@ -43,7 +42,6 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
enableSystem
|
enableSystem
|
||||||
disableTransitionOnChange
|
disableTransitionOnChange
|
||||||
>
|
>
|
||||||
<NextThemeToaster />
|
|
||||||
{children}
|
{children}
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { useTheme } from "next-themes";
|
|
||||||
import React from "react";
|
|
||||||
import { Toaster } from "sonner";
|
|
||||||
|
|
||||||
type ThemeType = "light" | "dark" | "system"; // 声明 theme 的类型
|
|
||||||
export default function NextThemeToaster() {
|
|
||||||
const { theme } = useTheme();
|
|
||||||
const themeMap: Record<ThemeType, string> = {
|
|
||||||
light: "light",
|
|
||||||
dark: "dark",
|
|
||||||
system: "system",
|
|
||||||
};
|
|
||||||
|
|
||||||
// 使用类型断言确保theme是一个ThemeType
|
|
||||||
const selectedTheme = theme ? themeMap[theme as ThemeType] : "system";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Toaster
|
|
||||||
theme={selectedTheme as ThemeType}
|
|
||||||
richColors={true}
|
|
||||||
duration={2000}
|
|
||||||
position="top-center"
|
|
||||||
className={"mb-16 sm:mb-14"}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useEffect } from "react";
|
|
||||||
|
|
||||||
type ClientSideRefreshProps = {
|
|
||||||
timeMs: number;
|
|
||||||
};
|
|
||||||
export default function ClientSideRefresh({ timeMs }: ClientSideRefreshProps) {
|
|
||||||
const router = useRouter();
|
|
||||||
useEffect(() => {
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
router.refresh();
|
|
||||||
}, timeMs);
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
return null;
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { Moon, Sun } from "lucide-react";
|
|
||||||
import { useTheme } from "next-themes";
|
|
||||||
import * as React from "react";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu";
|
|
||||||
|
|
||||||
export function ModeToggle() {
|
|
||||||
const { setTheme } = useTheme();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" size="sm" className="rounded-full p-2">
|
|
||||||
<Sun className="h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
|
|
||||||
<Moon className="absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
|
|
||||||
<span className="sr-only">Toggle theme</span>
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuItem onClick={() => setTheme("light")}>
|
|
||||||
Light
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => setTheme("dark")}>
|
|
||||||
Dark
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => setTheme("system")}>
|
|
||||||
System
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
);
|
|
||||||
}
|
|
@ -33,17 +33,15 @@
|
|||||||
"react-intersection-observer": "^9.8.2",
|
"react-intersection-observer": "^9.8.2",
|
||||||
"react-wrap-balancer": "^1.1.0",
|
"react-wrap-balancer": "^1.1.0",
|
||||||
"sharp": "^0.33.3",
|
"sharp": "^0.33.3",
|
||||||
"sonner": "^1.4.41",
|
|
||||||
"swr": "^2.2.6-beta.4",
|
"swr": "^2.2.6-beta.4",
|
||||||
"tailwind-merge": "^2.2.2",
|
"tailwind-merge": "^2.2.2",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7"
|
||||||
"zod": "^3.22.4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint-plugin-turbo": "^2.0.3",
|
"eslint-plugin-turbo": "^2.0.3",
|
||||||
"eslint-plugin-unused-imports": "^4.0.0",
|
"eslint-plugin-unused-imports": "^4.0.0",
|
||||||
"@next/bundle-analyzer": "^14.1.4",
|
"@next/bundle-analyzer": "^14.1.4",
|
||||||
"@types/node": "^20.12.4",
|
"@types/node": "^22.0.0",
|
||||||
"@types/react": "^18.2.74",
|
"@types/react": "^18.2.74",
|
||||||
"@types/react-dom": "^18.2.24",
|
"@types/react-dom": "^18.2.24",
|
||||||
"autoprefixer": "^10.4.19",
|
"autoprefixer": "^10.4.19",
|
||||||
|
Loading…
Reference in New Issue
Block a user