diff --git a/bun.lockb b/bun.lockb index 2a6200c..de5dba4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 460f159..41cb330 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "@fontsource/inter": "^5.1.0", "@heroicons/react": "^2.2.0", + "@radix-ui/react-accordion": "^1.2.2", "@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.2", diff --git a/src/components/ServerDetailOverview.tsx b/src/components/ServerDetailOverview.tsx index 5e3d0a1..d2cbd17 100644 --- a/src/components/ServerDetailOverview.tsx +++ b/src/components/ServerDetailOverview.tsx @@ -10,6 +10,8 @@ import { NezhaWebsocketResponse } from "@/types/nezha-api" import { useTranslation } from "react-i18next" import { useNavigate } from "react-router-dom" +import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "./ui/accordion" + export default function ServerDetailOverview({ server_id }: { server_id: string }) { const { t } = useTranslation() const navigate = useNavigate() @@ -228,24 +230,30 @@ export default function ServerDetailOverview({ server_id }: { server_id: string ) : null} - {server?.state.temperatures && server?.state.temperatures.length > 0 && ( -
- - -
-

{"温度"}

-
- {server?.state.temperatures.map((item, index) => ( -
-

{item.Name}

: {item.Temperature.toFixed(2)} °C -
- ))} -
-
-
-
-
- )} +
+ {server?.state.temperatures && server?.state.temperatures.length > 0 && ( +
+ + + + {t("serverDetail.temperature")} + + +
+ {server?.state.temperatures.map((item, index) => ( +
+

{item.Name}

: {item.Temperature.toFixed(2)}{" "} + °C +
+ ))} +
+
+
+
+
+ )} +
+
diff --git a/src/components/ui/accordion.tsx b/src/components/ui/accordion.tsx new file mode 100644 index 0000000..ee72507 --- /dev/null +++ b/src/components/ui/accordion.tsx @@ -0,0 +1,51 @@ +import { cn } from "@/lib/utils" +import * as AccordionPrimitive from "@radix-ui/react-accordion" +import { ChevronDown } from "lucide-react" +import * as React from "react" + +const Accordion = AccordionPrimitive.Root + +const AccordionItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AccordionItem.displayName = "AccordionItem" + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + svg]:rotate-180", + className, + )} + {...props} + > + {children} + + + +)) +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + +
{children}
+
+)) + +AccordionContent.displayName = AccordionPrimitive.Content.displayName + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index ce0a0f0..88fc294 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -61,7 +61,8 @@ "system": "System", "upload": "Upload", "download": "Download", - "lastActive": "Last active time" + "lastActive": "Last active time", + "temperature": "Temperature" }, "serverDetailChart": { "process": "Process", diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json index 49b7b98..b0df992 100644 --- a/src/locales/zh-CN/translation.json +++ b/src/locales/zh-CN/translation.json @@ -61,7 +61,8 @@ "system": "系统", "upload": "上传", "download": "下载", - "lastActive": "最后上报时间" + "lastActive": "最后上报时间", + "temperature": "温度" }, "serverDetailChart": { "process": "进程数", diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json index 8f24e4b..b9d43bb 100644 --- a/src/locales/zh-TW/translation.json +++ b/src/locales/zh-TW/translation.json @@ -61,7 +61,8 @@ "system": "系統", "upload": "上傳", "download": "下載", - "lastActive": "最後上報時間" + "lastActive": "最後上報時間", + "temperature": "溫度" }, "serverDetailChart": { "process": "進程數", diff --git a/tailwind.config.js b/tailwind.config.js index 370f977..89afbe7 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -53,6 +53,28 @@ module.exports = { 5: "hsl(var(--chart-5))", }, }, + keyframes: { + "accordion-down": { + from: { + height: "0", + }, + to: { + height: "var(--radix-accordion-content-height)", + }, + }, + "accordion-up": { + from: { + height: "var(--radix-accordion-content-height)", + }, + to: { + height: "0", + }, + }, + }, + animation: { + "accordion-down": "accordion-down 0.2s ease-out", + "accordion-up": "accordion-up 0.2s ease-out", + }, }, }, plugins: [require("tailwindcss-animate")],