diff --git a/src/components/ServiceTracker.tsx b/src/components/ServiceTracker.tsx
index 6784c89..16ccc42 100644
--- a/src/components/ServiceTracker.tsx
+++ b/src/components/ServiceTracker.tsx
@@ -26,14 +26,10 @@ export const ServiceTracker: React.FC = () => {
}))
const totalUp = serviceData.up.reduce((a, b) => a + b, 0)
- const totalChecks =
- serviceData.up.reduce((a, b) => a + b, 0) + serviceData.down.reduce((a, b) => a + b, 0)
+ const totalChecks = serviceData.up.reduce((a, b) => a + b, 0) + serviceData.down.reduce((a, b) => a + b, 0)
const uptime = (totalUp / totalChecks) * 100
- const avgDelay =
- serviceData.delay.length > 0
- ? serviceData.delay.reduce((a, b) => a + b, 0) / serviceData.delay.length
- : 0
+ const avgDelay = serviceData.delay.length > 0 ? serviceData.delay.reduce((a, b) => a + b, 0) / serviceData.delay.length : 0
return { days, uptime, avgDelay }
}
@@ -67,15 +63,7 @@ export const ServiceTracker: React.FC = () => {
{Object.entries(serviceData.data.services).map(([name, data]) => {
const { days, uptime, avgDelay } = processServiceData(data)
- return (
-
- )
+ return
})}
)}
diff --git a/src/components/ServiceTrackerClient.tsx b/src/components/ServiceTrackerClient.tsx
index 47ef5e5..44eb1d9 100644
--- a/src/components/ServiceTrackerClient.tsx
+++ b/src/components/ServiceTrackerClient.tsx
@@ -15,16 +15,10 @@ interface ServiceTrackerProps {
avgDelay?: number
}
-export const ServiceTrackerClient: React.FC = ({
- days,
- className,
- title,
- uptime = 100,
- avgDelay = 0,
-}) => {
+export const ServiceTrackerClient: React.FC = ({ days, className, title, uptime = 100, avgDelay = 0 }) => {
const { t } = useTranslation()
const customBackgroundImage =
- // @ts-expect-error ShowNetTransfer is a global variable
+ // @ts-expect-error CustomBackgroundImage is a global variable
(window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
return (
= ({
{title}
-
- {avgDelay.toFixed(0)}ms
-
+
{avgDelay.toFixed(0)}ms
{uptime.toFixed(1)}% {t("serviceTracker.uptime")}
@@ -58,10 +50,7 @@ export const ServiceTrackerClient: React.FC = ({
{days.map((day, index) => (
))}
diff --git a/src/components/TabSwitch.tsx b/src/components/TabSwitch.tsx
index 1438413..8308e33 100644
--- a/src/components/TabSwitch.tsx
+++ b/src/components/TabSwitch.tsx
@@ -2,28 +2,17 @@ import { cn } from "@/lib/utils"
import { m } from "framer-motion"
import { useTranslation } from "react-i18next"
-export default function TabSwitch({
- tabs,
- currentTab,
- setCurrentTab,
-}: {
- tabs: string[]
- currentTab: string
- setCurrentTab: (tab: string) => void
-}) {
+export default function TabSwitch({ tabs, currentTab, setCurrentTab }: { tabs: string[]; currentTab: string; setCurrentTab: (tab: string) => void }) {
const { t } = useTranslation()
const customBackgroundImage =
- // @ts-expect-error ShowNetTransfer is a global variable
+ // @ts-expect-error CustomBackgroundImage is a global variable
(window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
return (
{tabs.map((tab: string) => (
setCurrentTab(tab)}
className={cn(
"relative cursor-pointer rounded-3xl px-2.5 py-[8px] text-[13px] font-[600] transition-all duration-500",
- currentTab === tab
- ? "text-black dark:text-white"
- : "text-stone-400 dark:text-stone-500",
+ currentTab === tab ? "text-black dark:text-white" : "text-stone-400 dark:text-stone-500",
)}
>
{currentTab === tab && (
diff --git a/src/components/ThemeProvider.tsx b/src/components/ThemeProvider.tsx
index 44b1c70..000d8f6 100644
--- a/src/components/ThemeProvider.tsx
+++ b/src/components/ThemeProvider.tsx
@@ -21,9 +21,7 @@ const initialState: ThemeProviderState = {
const ThemeProviderContext = createContext
(initialState)
export function ThemeProvider({ children, storageKey = "vite-ui-theme" }: ThemeProviderProps) {
- const [theme, setTheme] = useState(
- () => (localStorage.getItem(storageKey) as Theme) || "system",
- )
+ const [theme, setTheme] = useState(() => (localStorage.getItem(storageKey) as Theme) || "system")
useEffect(() => {
const root = window.document.documentElement
@@ -31,9 +29,7 @@ export function ThemeProvider({ children, storageKey = "vite-ui-theme" }: ThemeP
root.classList.remove("light", "dark")
if (theme === "system") {
- const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
- ? "dark"
- : "light"
+ const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
root.classList.add(systemTheme)
const themeColor = systemTheme === "dark" ? "hsl(30 15% 8%)" : "hsl(0 0% 98%)"
diff --git a/src/components/ThemeSwitcher.tsx b/src/components/ThemeSwitcher.tsx
index 14e7fd6..76c32e2 100644
--- a/src/components/ThemeSwitcher.tsx
+++ b/src/components/ThemeSwitcher.tsx
@@ -1,11 +1,6 @@
import { Theme } from "@/components/ThemeProvider"
import { Button } from "@/components/ui/button"
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu"
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { cn } from "@/lib/utils"
import { CheckCircleIcon } from "@heroicons/react/20/solid"
import { Moon, Sun } from "lucide-react"
@@ -18,7 +13,7 @@ export function ModeToggle() {
const { setTheme, theme } = useTheme()
const customBackgroundImage =
- // @ts-expect-error ShowNetTransfer is a global variable
+ // @ts-expect-error CustomBackgroundImage is a global variable
(window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
const handleSelect = (e: Event, newTheme: Theme) => {
@@ -42,24 +37,15 @@ export function ModeToggle() {
- handleSelect(e, "light")}
- >
+ handleSelect(e, "light")}>
{t("theme.light")}
{theme === "light" && }
- handleSelect(e, "dark")}
- >
+ handleSelect(e, "dark")}>
{t("theme.dark")}
{theme === "dark" && }
- handleSelect(e, "system")}
- >
+ handleSelect(e, "system")}>
{t("theme.system")}
{theme === "system" && }
diff --git a/src/components/billingInfo.tsx b/src/components/billingInfo.tsx
index 9a0affa..7836cba 100644
--- a/src/components/billingInfo.tsx
+++ b/src/components/billingInfo.tsx
@@ -24,12 +24,8 @@ export default function BillingInfo({ parsedData }: { parsedData: PublicNoteData
return daysLeftObject.days >= 0 ? (
<>
-
- 剩余时间: {isNeverExpire ? "永久" : daysLeftObject.days + "天"}
-
- {parsedData.billingDataMod.amount &&
- parsedData.billingDataMod.amount !== "0" &&
- parsedData.billingDataMod.amount !== "-1" ? (
+ 剩余时间: {isNeverExpire ? "永久" : daysLeftObject.days + "天"}
+ {parsedData.billingDataMod.amount && parsedData.billingDataMod.amount !== "0" && parsedData.billingDataMod.amount !== "-1" ? (
价格: {parsedData.billingDataMod.amount}/{parsedData.billingDataMod.cycle}
@@ -42,12 +38,8 @@ export default function BillingInfo({ parsedData }: { parsedData: PublicNoteData
>
) : (
<>
-
- 已过期: {daysLeftObject.days * -1} 天
-
- {parsedData.billingDataMod.amount &&
- parsedData.billingDataMod.amount !== "0" &&
- parsedData.billingDataMod.amount !== "-1" ? (
+ 已过期: {daysLeftObject.days * -1} 天
+ {parsedData.billingDataMod.amount && parsedData.billingDataMod.amount !== "0" && parsedData.billingDataMod.amount !== "-1" ? (
价格: {parsedData.billingDataMod.amount}/{parsedData.billingDataMod.cycle}
diff --git a/src/components/ui/accordion.tsx b/src/components/ui/accordion.tsx
index ee72507..df64af7 100644
--- a/src/components/ui/accordion.tsx
+++ b/src/components/ui/accordion.tsx
@@ -8,9 +8,7 @@ const Accordion = AccordionPrimitive.Root
const AccordionItem = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
-))
+>(({ className, ...props }, ref) => )
AccordionItem.displayName = "AccordionItem"
const AccordionTrigger = React.forwardRef<
diff --git a/src/components/ui/animated-circular-progress-bar.tsx b/src/components/ui/animated-circular-progress-bar.tsx
index a98f992..0df5380 100644
--- a/src/components/ui/animated-circular-progress-bar.tsx
+++ b/src/components/ui/animated-circular-progress-bar.tsx
@@ -8,13 +8,7 @@ interface Props {
primaryColor?: string
}
-export default function AnimatedCircularProgressBar({
- max = 100,
- min = 0,
- value = 0,
- primaryColor,
- className,
-}: Props) {
+export default function AnimatedCircularProgressBar({ max = 100, min = 0, value = 0, primaryColor, className }: Props) {
const circumference = 2 * Math.PI * 45
const percentPx = circumference / 100
const currentPercent = ((value - min) / (max - min)) * 100
@@ -52,10 +46,8 @@ export default function AnimatedCircularProgressBar({
{
"--stroke-percent": 90 - currentPercent,
"--offset-factor-secondary": "calc(1 - var(--offset-factor))",
- strokeDasharray:
- "calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)",
- transform:
- "rotate(calc(1turn - 90deg - (var(--gap-percent) * var(--percent-to-deg) * var(--offset-factor-secondary)))) scaleY(-1)",
+ strokeDasharray: "calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)",
+ transform: "rotate(calc(1turn - 90deg - (var(--gap-percent) * var(--percent-to-deg) * var(--offset-factor-secondary)))) scaleY(-1)",
transition: "all var(--transition-length) ease var(--delay)",
transformOrigin: "calc(var(--circle-size) / 2) calc(var(--circle-size) / 2)",
} as React.CSSProperties
@@ -77,13 +69,10 @@ export default function AnimatedCircularProgressBar({
{
"--stroke-primary-color": primaryColor,
"--stroke-percent": currentPercent,
- strokeDasharray:
- "calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)",
- transition:
- "var(--transition-length) ease var(--delay),stroke var(--transition-length) ease var(--delay)",
+ strokeDasharray: "calc(var(--stroke-percent) * var(--percent-to-px)) var(--circumference)",
+ transition: "var(--transition-length) ease var(--delay),stroke var(--transition-length) ease var(--delay)",
transitionProperty: "stroke-dasharray,transform",
- transform:
- "rotate(calc(-90deg + var(--gap-percent) * var(--offset-factor) * var(--percent-to-deg)))",
+ transform: "rotate(calc(-90deg + var(--gap-percent) * var(--offset-factor) * var(--percent-to-deg)))",
transformOrigin: "calc(var(--circle-size) / 2) calc(var(--circle-size) / 2)",
} as React.CSSProperties
}
diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx
index 020ed14..cf62176 100644
--- a/src/components/ui/badge.tsx
+++ b/src/components/ui/badge.tsx
@@ -8,10 +8,8 @@ const badgeVariants = cva(
variants: {
variant: {
default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
- secondary:
- "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
- destructive:
- "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
+ secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
outline: "text-foreground",
},
},
@@ -21,9 +19,7 @@ const badgeVariants = cva(
},
)
-export interface BadgeProps
- extends React.HTMLAttributes,
- VariantProps {}
+export interface BadgeProps extends React.HTMLAttributes, VariantProps {}
function Badge({ className, variant, ...props }: BadgeProps) {
return
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
index 94c642a..17248c8 100644
--- a/src/components/ui/button.tsx
+++ b/src/components/ui/button.tsx
@@ -29,20 +29,14 @@ const buttonVariants = cva(
},
)
-export interface ButtonProps
- extends React.ButtonHTMLAttributes,
- VariantProps {
+export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps {
asChild?: boolean
}
-const Button = React.forwardRef(
- ({ className, variant, size, asChild = false, ...props }, ref) => {
- const Comp = asChild ? Slot : "button"
- return (
-
- )
- },
-)
+const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : "button"
+ return
+})
Button.displayName = "Button"
export { Button, buttonVariants }
diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx
index cda8e0a..1baf02f 100644
--- a/src/components/ui/card.tsx
+++ b/src/components/ui/card.tsx
@@ -1,58 +1,38 @@
import { cn } from "@/lib/utils"
import * as React from "react"
-const Card = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const Card = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
Card.displayName = "Card"
-const CardHeader = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const CardHeader = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
CardHeader.displayName = "CardHeader"
-const CardTitle = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const CardTitle = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
CardTitle.displayName = "CardTitle"
-const CardDescription = React.forwardRef<
- HTMLParagraphElement,
- React.HTMLAttributes
->(({ className, ...props }, ref) => (
+const CardDescription = React.forwardRef>(({ className, ...props }, ref) => (
))
CardDescription.displayName = "CardDescription"
-const CardContent = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const CardContent = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
CardContent.displayName = "CardContent"
-const CardFooter = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const CardFooter = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
CardFooter.displayName = "CardFooter"
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx
index 787b312..17c44ab 100644
--- a/src/components/ui/chart.tsx
+++ b/src/components/ui/chart.tsx
@@ -9,10 +9,7 @@ export type ChartConfig = {
[k in string]: {
label?: React.ReactNode
icon?: React.ComponentType
- } & (
- | { color?: string; theme?: never }
- | { color?: never; theme: Record }
- )
+ } & ({ color?: string; theme?: never } | { color?: never; theme: Record })
}
type ChartContextProps = {
@@ -130,15 +127,10 @@ const ChartTooltipContent = React.forwardRef<
const [item] = payload
const key = `${labelKey || item.dataKey || item.name || "value"}`
const itemConfig = getPayloadConfigFromPayload(config, item, key)
- const value =
- !labelKey && typeof label === "string"
- ? config[label as keyof typeof config]?.label || label
- : itemConfig?.label
+ const value = !labelKey && typeof label === "string" ? config[label as keyof typeof config]?.label || label : itemConfig?.label
if (labelFormatter) {
- return (
- {labelFormatter(value, payload)}
- )
+ return {labelFormatter(value, payload)}
}
if (!value) {
@@ -186,16 +178,12 @@ const ChartTooltipContent = React.forwardRef<
) : (
!hideIndicator && (
)
)}
-
+
{nestLabel ? tooltipLabel : null}
-
- {itemConfig?.label || item.name}
-
+ {itemConfig?.label || item.name}
- {item.value && (
-
- {item.value.toLocaleString()}
-
- )}
+ {item.value &&
{item.value.toLocaleString()}}
>
)}
@@ -252,25 +229,13 @@ const ChartLegendContent = React.forwardRef<
}
return (
-
+
{payload.map((item) => {
const key = `${nameKey || item.dataKey || "value"}`
const itemConfig = getPayloadConfigFromPayload(config, item, key)
return (
-
svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",
- )}
- >
+
svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}>
{itemConfig?.icon && !hideIcon ? (
) : (
@@ -296,31 +261,17 @@ function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key:
return undefined
}
- const payloadPayload =
- "payload" in payload && typeof payload.payload === "object" && payload.payload !== null
- ? payload.payload
- : undefined
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : undefined
let configLabelKey: string = key
if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
configLabelKey = payload[key as keyof typeof payload] as string
- } else if (
- payloadPayload &&
- key in payloadPayload &&
- typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
- ) {
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key as keyof typeof payloadPayload] === "string") {
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string
}
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config]
}
-export {
- ChartContainer,
- ChartTooltip,
- ChartTooltipContent,
- ChartLegend,
- ChartLegendContent,
- ChartStyle,
-}
+export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle }
diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx
index 1d3fd05..3fd5900 100644
--- a/src/components/ui/checkbox.tsx
+++ b/src/components/ui/checkbox.tsx
@@ -3,23 +3,22 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { Check } from "lucide-react"
import * as React from "react"
-const Checkbox = React.forwardRef<
- React.ElementRef
,
- React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
-
-
-
-
-))
+const Checkbox = React.forwardRef, React.ComponentPropsWithoutRef>(
+ ({ className, ...props }, ref) => (
+
+
+
+
+
+ ),
+)
Checkbox.displayName = CheckboxPrimitive.Root.displayName
export { Checkbox }
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx
index 7887930..a9739fe 100644
--- a/src/components/ui/dialog.tsx
+++ b/src/components/ui/dialog.tsx
@@ -56,46 +56,21 @@ const DialogHeader = ({ className, ...props }: React.HTMLAttributes) => (
-
+
)
DialogFooter.displayName = "DialogFooter"
-const DialogTitle = React.forwardRef<
- React.ElementRef,
- React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
-))
+const DialogTitle = React.forwardRef, React.ComponentPropsWithoutRef>(
+ ({ className, ...props }, ref) => (
+
+ ),
+)
DialogTitle.displayName = DialogPrimitive.Title.displayName
const DialogDescription = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
-))
+>(({ className, ...props }, ref) => )
DialogDescription.displayName = DialogPrimitive.Description.displayName
-export {
- Dialog,
- DialogPortal,
- DialogOverlay,
- DialogClose,
- DialogTrigger,
- DialogContent,
- DialogHeader,
- DialogFooter,
- DialogTitle,
- DialogDescription,
-}
+export { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription }
diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx
index be700fb..6dd57f0 100644
--- a/src/components/ui/dropdown-menu.tsx
+++ b/src/components/ui/dropdown-menu.tsx
@@ -138,24 +138,14 @@ const DropdownMenuLabel = React.forwardRef<
inset?: boolean
}
>(({ className, inset, ...props }, ref) => (
-
+
))
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
const DropdownMenuSeparator = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
-))
+>(({ className, ...props }, ref) => )
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes) => {
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx
index 8609d3e..7149a26 100644
--- a/src/components/ui/input.tsx
+++ b/src/components/ui/input.tsx
@@ -3,21 +3,19 @@ import * as React from "react"
export interface InputProps extends React.InputHTMLAttributes {}
-const Input = React.forwardRef(
- ({ className, type, ...props }, ref) => {
- return (
-
- )
- },
-)
+const Input = React.forwardRef(({ className, type, ...props }, ref) => {
+ return (
+
+ )
+})
Input.displayName = "Input"
export { Input }
diff --git a/src/components/ui/label.tsx b/src/components/ui/label.tsx
index ed46b19..f3f0208 100644
--- a/src/components/ui/label.tsx
+++ b/src/components/ui/label.tsx
@@ -3,16 +3,12 @@ import * as LabelPrimitive from "@radix-ui/react-label"
import { type VariantProps, cva } from "class-variance-authority"
import * as React from "react"
-const labelVariants = cva(
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
-)
+const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70")
const Label = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef & VariantProps
->(({ className, ...props }, ref) => (
-
-))
+>(({ className, ...props }, ref) => )
Label.displayName = LabelPrimitive.Root.displayName
export { Label }
diff --git a/src/components/ui/progress.tsx b/src/components/ui/progress.tsx
index db6f7e6..c37320f 100644
--- a/src/components/ui/progress.tsx
+++ b/src/components/ui/progress.tsx
@@ -8,11 +8,7 @@ const Progress = React.forwardRef<
indicatorClassName?: string
}
>(({ className, value, indicatorClassName, ...props }, ref) => (
-
+
,
- React.ComponentPropsWithoutRef
->(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
-
-))
+const Separator = React.forwardRef, React.ComponentPropsWithoutRef>(
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
+
+ ),
+)
Separator.displayName = SeparatorPrimitive.Root.displayName
export { Separator }
diff --git a/src/components/ui/switch.tsx b/src/components/ui/switch.tsx
index 1920d2e..7a59c05 100644
--- a/src/components/ui/switch.tsx
+++ b/src/components/ui/switch.tsx
@@ -2,25 +2,24 @@ import { cn } from "@/lib/utils"
import * as SwitchPrimitives from "@radix-ui/react-switch"
import * as React from "react"
-const Switch = React.forwardRef<
- React.ElementRef,
- React.ComponentPropsWithoutRef
->(({ className, ...props }, ref) => (
-
- , React.ComponentPropsWithoutRef>(
+ ({ className, ...props }, ref) => (
+
-
-))
+ {...props}
+ ref={ref}
+ >
+
+
+ ),
+)
Switch.displayName = SwitchPrimitives.Root.displayName
export { Switch }
diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx
index ac5fd8b..68a695d 100644
--- a/src/components/ui/table.tsx
+++ b/src/components/ui/table.tsx
@@ -1,88 +1,48 @@
import { cn } from "@/lib/utils"
import * as React from "react"
-const Table = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const Table = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
Table.displayName = "Table"
-const TableHeader = React.forwardRef<
- HTMLTableSectionElement,
- React.HTMLAttributes
->(({ className, ...props }, ref) => (
+const TableHeader = React.forwardRef>(({ className, ...props }, ref) => (
))
TableHeader.displayName = "TableHeader"
-const TableBody = React.forwardRef<
- HTMLTableSectionElement,
- React.HTMLAttributes
->(({ className, ...props }, ref) => (
+const TableBody = React.forwardRef>(({ className, ...props }, ref) => (
))
TableBody.displayName = "TableBody"
-const TableFooter = React.forwardRef<
- HTMLTableSectionElement,
- React.HTMLAttributes
->(({ className, ...props }, ref) => (
- tr]:last:border-b-0", className)}
- {...props}
- />
+const TableFooter = React.forwardRef>(({ className, ...props }, ref) => (
+ tr]:last:border-b-0", className)} {...props} />
))
TableFooter.displayName = "TableFooter"
-const TableRow = React.forwardRef>(
- ({ className, ...props }, ref) => (
-
- ),
-)
+const TableRow = React.forwardRef>(({ className, ...props }, ref) => (
+
+))
TableRow.displayName = "TableRow"
-const TableHead = React.forwardRef<
- HTMLTableCellElement,
- React.ThHTMLAttributes
->(({ className, ...props }, ref) => (
+const TableHead = React.forwardRef>(({ className, ...props }, ref) => (
|
))
TableHead.displayName = "TableHead"
-const TableCell = React.forwardRef<
- HTMLTableCellElement,
- React.TdHTMLAttributes
->(({ className, ...props }, ref) => (
- |
+const TableCell = React.forwardRef>(({ className, ...props }, ref) => (
+ |
))
TableCell.displayName = "TableCell"
-const TableCaption = React.forwardRef<
- HTMLTableCaptionElement,
- React.HTMLAttributes
->(({ className, ...props }, ref) => (
+const TableCaption = React.forwardRef>(({ className, ...props }, ref) => (
))
TableCaption.displayName = "TableCaption"
diff --git a/src/context/sort-context.ts b/src/context/sort-context.ts
index 2891400..62796f8 100644
--- a/src/context/sort-context.ts
+++ b/src/context/sort-context.ts
@@ -1,31 +1,8 @@
import { createContext } from "react"
-export type SortType =
- | "default"
- | "name"
- | "uptime"
- | "system"
- | "cpu"
- | "mem"
- | "stg"
- | "up"
- | "down"
- | "up total"
- | "down total"
+export type SortType = "default" | "name" | "uptime" | "system" | "cpu" | "mem" | "stg" | "up" | "down" | "up total" | "down total"
-export const SORT_TYPES: SortType[] = [
- "default",
- "name",
- "uptime",
- "system",
- "cpu",
- "mem",
- "stg",
- "up",
- "down",
- "up total",
- "down total",
-]
+export const SORT_TYPES: SortType[] = ["default", "name", "uptime", "system", "cpu", "mem", "stg", "up", "down", "up total", "down total"]
export type SortOrder = "asc" | "desc"
diff --git a/src/context/sort-provider.tsx b/src/context/sort-provider.tsx
index a250fec..804f9a6 100644
--- a/src/context/sort-provider.tsx
+++ b/src/context/sort-provider.tsx
@@ -6,9 +6,5 @@ export function SortProvider({ children }: { children: ReactNode }) {
const [sortType, setSortType] = useState("default")
const [sortOrder, setSortOrder] = useState("desc")
- return (
-
- {children}
-
- )
+ return {children}
}
diff --git a/src/context/tooltip-provider.tsx b/src/context/tooltip-provider.tsx
index 0790246..7e8b6c0 100644
--- a/src/context/tooltip-provider.tsx
+++ b/src/context/tooltip-provider.tsx
@@ -5,9 +5,5 @@ import { TooltipContext, TooltipData } from "./tooltip-context"
export function TooltipProvider({ children }: { children: ReactNode }) {
const [tooltipData, setTooltipData] = useState(null)
- return (
-
- {children}
-
- )
+ return {children}
}
diff --git a/src/lib/nezha-api.ts b/src/lib/nezha-api.ts
index 3c4f504..0570d21 100644
--- a/src/lib/nezha-api.ts
+++ b/src/lib/nezha-api.ts
@@ -1,10 +1,4 @@
-import {
- LoginUserResponse,
- MonitorResponse,
- ServerGroupResponse,
- ServiceResponse,
- SettingResponse,
-} from "@/types/nezha-api"
+import { LoginUserResponse, MonitorResponse, ServerGroupResponse, ServiceResponse, SettingResponse } from "@/types/nezha-api"
export const fetchServerGroup = async (): Promise => {
const response = await fetch("/api/v1/server-group")
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 05206dc..16bff0c 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -8,9 +8,7 @@ export function cn(...inputs: ClassValue[]) {
}
export function formatNezhaInfo(now: number, serverInfo: NezhaServer) {
- const lastActiveTime = serverInfo.last_active.startsWith("000")
- ? 0
- : parseISOTimestamp(serverInfo.last_active)
+ const lastActiveTime = serverInfo.last_active.startsWith("000") ? 0 : parseISOTimestamp(serverInfo.last_active)
return {
...serverInfo,
cpu: serverInfo.state.cpu || 0,
@@ -47,12 +45,11 @@ export function formatNezhaInfo(now: number, serverInfo: NezhaServer) {
}
}
-export function getDaysBetweenDatesWithAutoRenewal({
- autoRenewal,
- cycle,
- startDate,
- endDate,
-}: BillingData): { days: number; cycleLabel: string; remainingPercentage: number } {
+export function getDaysBetweenDatesWithAutoRenewal({ autoRenewal, cycle, startDate, endDate }: BillingData): {
+ days: number
+ cycleLabel: string
+ remainingPercentage: number
+} {
let months = 1
// 套餐资费
let cycleLabel = cycle
@@ -100,12 +97,9 @@ export function getDaysBetweenDatesWithAutoRenewal({
days: getDaysBetweenDates(endDate, new Date(nowTime).toISOString()),
cycleLabel: cycleLabel,
remainingPercentage:
- getDaysBetweenDates(endDate, new Date(nowTime).toISOString()) /
- dayjs(endDate).diff(startDate, "day") >
- 1
+ getDaysBetweenDates(endDate, new Date(nowTime).toISOString()) / dayjs(endDate).diff(startDate, "day") > 1
? 1
- : getDaysBetweenDates(endDate, new Date(nowTime).toISOString()) /
- dayjs(endDate).diff(startDate, "day"),
+ : getDaysBetweenDates(endDate, new Date(nowTime).toISOString()) / dayjs(endDate).diff(startDate, "day"),
}
}
diff --git a/src/main.tsx b/src/main.tsx
index ba8f264..f584633 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -30,8 +30,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
duration={1000}
toastOptions={{
classNames: {
- default:
- "w-fit rounded-full px-2.5 py-1.5 bg-neutral-100 border border-neutral-200 backdrop-blur-xl shadow-none",
+ default: "w-fit rounded-full px-2.5 py-1.5 bg-neutral-100 border border-neutral-200 backdrop-blur-xl shadow-none",
},
}}
position="top-center"
diff --git a/src/pages/Server.tsx b/src/pages/Server.tsx
index bf10cc9..5f1053f 100644
--- a/src/pages/Server.tsx
+++ b/src/pages/Server.tsx
@@ -15,14 +15,7 @@ import { fetchServerGroup } from "@/lib/nezha-api"
import { cn, formatNezhaInfo } from "@/lib/utils"
import { NezhaWebsocketResponse } from "@/types/nezha-api"
import { ServerGroup } from "@/types/nezha-api"
-import {
- ArrowDownIcon,
- ArrowUpIcon,
- ArrowsUpDownIcon,
- ChartBarSquareIcon,
- MapIcon,
- ViewColumnsIcon,
-} from "@heroicons/react/20/solid"
+import { ArrowDownIcon, ArrowUpIcon, ArrowsUpDownIcon, ChartBarSquareIcon, MapIcon, ViewColumnsIcon } from "@heroicons/react/20/solid"
import { useQuery } from "@tanstack/react-query"
import { useEffect, useState } from "react"
import { useTranslation } from "react-i18next"
@@ -44,7 +37,7 @@ export default function Servers() {
const [currentGroup, setCurrentGroup] = useState("All")
const customBackgroundImage =
- // @ts-expect-error ShowNetTransfer is a global variable
+ // @ts-expect-error CustomBackgroundImage is a global variable
(window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined
useEffect(() => {
@@ -96,60 +89,40 @@ export default function Servers() {
nezhaWsData?.servers?.filter((server) => {
if (currentGroup === "All") return true
const group = groupData?.data?.find(
- (g: ServerGroup) =>
- g.group.name === currentGroup &&
- Array.isArray(g.servers) &&
- g.servers.includes(server.id),
+ (g: ServerGroup) => g.group.name === currentGroup && Array.isArray(g.servers) && g.servers.includes(server.id),
)
return !!group
}) || []
const totalServers = filteredServers.length || 0
- const onlineServers =
- filteredServers.filter((server) => formatNezhaInfo(nezhaWsData.now, server).online)?.length || 0
- const offlineServers =
- filteredServers.filter((server) => !formatNezhaInfo(nezhaWsData.now, server).online)?.length ||
- 0
+ const onlineServers = filteredServers.filter((server) => formatNezhaInfo(nezhaWsData.now, server).online)?.length || 0
+ const offlineServers = filteredServers.filter((server) => !formatNezhaInfo(nezhaWsData.now, server).online)?.length || 0
const up =
filteredServers.reduce(
- (total, server) =>
- formatNezhaInfo(nezhaWsData.now, server).online
- ? total + (server.state?.net_out_transfer ?? 0)
- : total,
+ (total, server) => (formatNezhaInfo(nezhaWsData.now, server).online ? total + (server.state?.net_out_transfer ?? 0) : total),
0,
) || 0
const down =
filteredServers.reduce(
- (total, server) =>
- formatNezhaInfo(nezhaWsData.now, server).online
- ? total + (server.state?.net_in_transfer ?? 0)
- : total,
+ (total, server) => (formatNezhaInfo(nezhaWsData.now, server).online ? total + (server.state?.net_in_transfer ?? 0) : total),
0,
) || 0
const upSpeed =
filteredServers.reduce(
- (total, server) =>
- formatNezhaInfo(nezhaWsData.now, server).online
- ? total + (server.state?.net_out_speed ?? 0)
- : total,
+ (total, server) => (formatNezhaInfo(nezhaWsData.now, server).online ? total + (server.state?.net_out_speed ?? 0) : total),
0,
) || 0
const downSpeed =
filteredServers.reduce(
- (total, server) =>
- formatNezhaInfo(nezhaWsData.now, server).online
- ? total + (server.state?.net_in_speed ?? 0)
- : total,
+ (total, server) => (formatNezhaInfo(nezhaWsData.now, server).online ? total + (server.state?.net_in_speed ?? 0) : total),
0,
) || 0
filteredServers =
status === "all"
? filteredServers
- : filteredServers.filter((server) =>
- [status].includes(formatNezhaInfo(nezhaWsData.now, server).online ? "online" : "offline"),
- )
+ : filteredServers.filter((server) => [status].includes(formatNezhaInfo(nezhaWsData.now, server).online ? "online" : "offline"))
filteredServers = filteredServers.sort((a, b) => {
const serverAInfo = formatNezhaInfo(nezhaWsData.now, a)
@@ -277,17 +250,14 @@ export default function Servers() {
className={cn(
"rounded-[50px] flex items-center gap-1 dark:text-white border dark:border-none text-black cursor-pointer dark:[text-shadow:_0_1px_0_rgb(0_0_0_/_20%)] dark:bg-stone-800 bg-stone-100 p-[10px] transition-all shadow-[inset_0_1px_0_rgba(255,255,255,0.2)] ",
{
- "shadow-[inset_0_1px_0_rgba(0,0,0,0.2)] dark:bg-stone-700 bg-stone-200":
- settingsOpen,
+ "shadow-[inset_0_1px_0_rgba(0,0,0,0.2)] dark:bg-stone-700 bg-stone-200": settingsOpen,
},
{
"dark:bg-stone-800/50 bg-stone-100/50 ": customBackgroundImage,
},
)}
>
-
- {sortType === "default" ? "Sort" : sortType.toUpperCase()}
-
+ {sortType === "default" ? "Sort" : sortType.toUpperCase()}
{sortOrder === "asc" && sortType !== "default" ? (
) : sortOrder === "desc" && sortType !== "default" ? (
@@ -309,8 +279,7 @@ export default function Servers() {
className={cn(
"rounded-[5px] text-[11px] w-fit px-1 py-0.5 cursor-pointer bg-transparent border transition-all dark:shadow-none ",
{
- "bg-black text-white dark:bg-white dark:text-black shadow-[inset_0_1px_0_rgba(255,255,255,0.2)]":
- sortType === type,
+ "bg-black text-white dark:bg-white dark:text-black shadow-[inset_0_1px_0_rgba(255,255,255,0.2)]": sortType === type,
},
)}
>
@@ -330,8 +299,7 @@ export default function Servers() {
className={cn(
"rounded-[5px] text-[11px] w-fit px-1 py-0.5 cursor-pointer bg-transparent border transition-all shadow-[inset_0_1px_0_rgba(255,255,255,0.2)] dark:shadow-none",
{
- "bg-black text-white dark:bg-white dark:text-black":
- sortOrder === order && sortType !== "default",
+ "bg-black text-white dark:bg-white dark:text-black": sortOrder === order && sortType !== "default",
},
)}
>
@@ -344,9 +312,7 @@ export default function Servers() {
- {showMap === "1" && (
-
- )}
+ {showMap === "1" && }
{showServices === "1" && }
{inline === "1" && (