2025-03-13 03:41:21 +08:00
|
|
|
|
"use client"
|
2025-03-13 03:44:48 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Card,
|
|
|
|
|
|
CardBody,
|
|
|
|
|
|
CardHeader,
|
|
|
|
|
|
CardIcon,
|
|
|
|
|
|
CardTool,
|
|
|
|
|
|
} from "@/components/window/Card"
|
2025-03-13 03:41:21 +08:00
|
|
|
|
import { ToolButton } from "@/components/window/ToolButton"
|
|
|
|
|
|
import { Chip } from "@heroui/react"
|
2025-03-13 03:44:48 +08:00
|
|
|
|
import { Refresh, SettingConfig } from "@icon-park/react"
|
2025-03-21 18:00:16 +08:00
|
|
|
|
// import { version } from "@tauri-apps/plugin-os"
|
2025-03-13 03:44:48 +08:00
|
|
|
|
import { useEffect, useState } from "react"
|
|
|
|
|
|
import { type AllSystemInfo, allSysInfo } from "tauri-plugin-system-info-api"
|
2024-09-20 23:15:42 +08:00
|
|
|
|
export default function Page() {
|
2025-03-13 03:41:21 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Card className="h-full">
|
|
|
|
|
|
<CardHeader>
|
|
|
|
|
|
<CardIcon type="menu">
|
|
|
|
|
|
<SettingConfig /> 硬件
|
|
|
|
|
|
</CardIcon>
|
|
|
|
|
|
<CardTool>
|
|
|
|
|
|
{/* <ToolButton>
|
|
|
|
|
|
<UploadOne />
|
|
|
|
|
|
云同步
|
|
|
|
|
|
</ToolButton> */}
|
|
|
|
|
|
<ToolButton>
|
|
|
|
|
|
<Refresh /> 刷新
|
|
|
|
|
|
</ToolButton>
|
|
|
|
|
|
</CardTool>
|
|
|
|
|
|
</CardHeader>
|
|
|
|
|
|
|
|
|
|
|
|
<CardBody>
|
|
|
|
|
|
<HardwareInfo />
|
|
|
|
|
|
</CardBody>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function HardwareInfo() {
|
|
|
|
|
|
const [allSysData, setAllSysData] = useState<AllSystemInfo>()
|
|
|
|
|
|
// const [memInfo, setMemInfo] = useState("")
|
|
|
|
|
|
// const [staticData, setStaticData] = useState("")
|
|
|
|
|
|
// const [cpuData, setCpuData] = useState("")
|
|
|
|
|
|
// const [batteryData, setBatteryData] = useState("")
|
2025-03-21 16:02:47 +08:00
|
|
|
|
|
2025-03-13 03:41:21 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
|
const sys = await allSysInfo()
|
|
|
|
|
|
console.log(sys)
|
|
|
|
|
|
setAllSysData(sys)
|
|
|
|
|
|
// console.log(await memoryInfo())
|
|
|
|
|
|
// console.log(await staticInfo())
|
|
|
|
|
|
// console.log(await cpuInfo())
|
|
|
|
|
|
// console.log(await batteries())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-13 03:44:48 +08:00
|
|
|
|
void fetchData()
|
2025-03-13 03:41:21 +08:00
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="flex flex-col gap-1.5">
|
|
|
|
|
|
<Chip>CPU型号: {allSysData?.cpus[0]?.brand}</Chip>
|
|
|
|
|
|
<Chip>线程数: {allSysData?.cpu_count}</Chip>
|
|
|
|
|
|
<Chip>
|
2025-03-21 18:00:16 +08:00
|
|
|
|
系统: {allSysData?.name} {allSysData?.os_version}
|
2025-03-13 03:41:21 +08:00
|
|
|
|
</Chip>
|
|
|
|
|
|
<Chip>
|
2025-03-13 03:44:48 +08:00
|
|
|
|
内存:
|
|
|
|
|
|
{allSysData?.total_memory &&
|
|
|
|
|
|
`${(allSysData.total_memory / 1024 / 1024 / 1024).toFixed(0)}GB`}
|
2025-03-13 03:41:21 +08:00
|
|
|
|
</Chip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
2024-09-20 23:15:42 +08:00
|
|
|
|
}
|