diff --git a/app/api/os/route.ts b/app/api/os/route.ts index e9ac107..97075e7 100644 --- a/app/api/os/route.ts +++ b/app/api/os/route.ts @@ -65,7 +65,12 @@ export function SOCKET( memory: { total: mem.total, usage: (mem.used / mem.total) * 100, - amount: memLayout.length + amount: memLayout.length, + mems: memLayout.map((item) => ({ + size: item.size, + type: item.type, + formFactor: item.formFactor + })) }, gpu: graphics.controllers.map((gpu) => ({ model: gpu.model, diff --git a/components/dashboard/memory-widget.tsx b/components/dashboard/memory-widget.tsx index 505f9c9..8a10a22 100644 --- a/components/dashboard/memory-widget.tsx +++ b/components/dashboard/memory-widget.tsx @@ -2,9 +2,10 @@ import type { PropsWithCN } from "@/types"; import React, { useState } from "react"; import { Progress } from "@nextui-org/progress"; +import { Chip } from "@nextui-org/chip"; +import { ScrollShadow } from "@nextui-org/scroll-shadow"; import DashboardWidget from "./dashboard-widget"; -import Info from "./info"; import { type MemoryInfo, useOS } from "@/hooks/useOS"; import { formatSize } from "@/lib/utils"; @@ -18,13 +19,23 @@ const MemoryWidget: React.FC = (props) => { return ( - - + insideClassName="relative"> + + { + memoryInfo?.mems.map((mem, index) => ( +
+ 内存条 {index + 1} + {formatSize(mem.size)} + {mem.type} + {mem.formFactor} +
+ )) + } +
-
+
{memoryInfo?.usage ? `${memoryInfo?.usage.toFixed(2)}%` : "--%"}
diff --git a/hooks/useOS.ts b/hooks/useOS.ts index 9907dc7..e87fd8b 100644 --- a/hooks/useOS.ts +++ b/hooks/useOS.ts @@ -17,6 +17,11 @@ export interface MemoryInfo { total: number usage: number amount: number + mems: { + size: number + type: string + formFactor: string + }[] } export interface GPUInfo {