[feat] more mborad and memory info

This commit is contained in:
2025-11-08 16:34:37 +08:00
parent e824455577
commit 41105d3bab
8 changed files with 574 additions and 146 deletions

View File

@@ -71,9 +71,10 @@ interface GpuInfo {
}
interface MemoryInfo {
capacity?: number // 容量(字节)
manufacturer?: string
part_number?: string
speed?: number // MHz
speed?: number // MHz实际频率 ConfiguredClockSpeed
default_speed?: number // MHz,默认频率 Speed如果存在
}
interface MonitorInfo {
@@ -83,42 +84,55 @@ interface MonitorInfo {
resolution_height?: number
}
interface MotherboardInfo {
manufacturer?: string // 制造商
model?: string // 型号
version?: string
}
interface HardwareData {
allSysData: AllSystemInfo
computerInfo: ComputerInfo
gpuInfo: GpuInfo | null
memoryInfo: MemoryInfo[]
monitorInfo: MonitorInfo[]
motherboardInfo: MotherboardInfo | null
}
// 硬件信息 fetcher
const hardwareInfoFetcher = async (): Promise<HardwareData> => {
// 并行获取系统信息、PowerShell 信息、GPU 信息、内存信息显示器信息
const [sys, computerInfoData, gpuInfoData, memoryInfoData, monitorInfoData] = await Promise.all([
allSysInfo(),
invoke<ComputerInfo>("get_computer_info").catch((error) => {
console.error("获取 PowerShell 信息失败:", error)
return {} as ComputerInfo
}),
invoke<GpuInfo | null>("get_gpu_info").catch((error) => {
console.error("获取 GPU 信息失败:", error)
return null
}),
invoke<MemoryInfo[]>("get_memory_info").catch((error) => {
console.error("获取内存信息失败:", error)
return [] as MemoryInfo[]
}),
invoke<MonitorInfo[]>("get_monitor_info").catch((error) => {
console.error("获取显示器信息失败:", error)
return [] as MonitorInfo[]
}),
])
// 并行获取系统信息、PowerShell 信息、GPU 信息、内存信息显示器信息和主板信息
const [sys, computerInfoData, gpuInfoData, memoryInfoData, monitorInfoData, motherboardInfoData] =
await Promise.all([
allSysInfo(),
invoke<ComputerInfo>("get_computer_info").catch((error) => {
console.error("获取 PowerShell 信息失败:", error)
return {} as ComputerInfo
}),
invoke<GpuInfo | null>("get_gpu_info").catch((error) => {
console.error("获取 GPU 信息失败:", error)
return null
}),
invoke<MemoryInfo[]>("get_memory_info").catch((error) => {
console.error("获取内存信息失败:", error)
return [] as MemoryInfo[]
}),
invoke<MonitorInfo[]>("get_monitor_info").catch((error) => {
console.error("获取显示器信息失败:", error)
return [] as MonitorInfo[]
}),
invoke<MotherboardInfo>("get_motherboard_info").catch((error) => {
console.error("获取主板信息失败:", error)
return { manufacturer: undefined, model: undefined, version: undefined } as MotherboardInfo
}),
])
console.log("系统信息:", sys)
console.log("PowerShell 信息:", computerInfoData)
console.log("GPU 信息:", gpuInfoData)
console.log("内存信息:", memoryInfoData)
console.log("显示器信息:", monitorInfoData)
console.log("主板信息:", motherboardInfoData)
if (sys?.cpus) {
console.log("CPU数据:", sys.cpus)
@@ -134,11 +148,12 @@ const hardwareInfoFetcher = async (): Promise<HardwareData> => {
gpuInfo: gpuInfoData,
memoryInfo: memoryInfoData,
monitorInfo: monitorInfoData,
motherboardInfo: motherboardInfoData,
}
}
function HardwareInfoContent() {
const { data, isLoading } = useSWR<HardwareData>("/api/hardware-info", hardwareInfoFetcher, {
const { data, isLoading, isValidating } = useSWR<HardwareData>("/api/hardware-info", hardwareInfoFetcher, {
revalidateOnFocus: false,
revalidateOnReconnect: false,
dedupingInterval: 5 * 60 * 1000, // 5分钟内相同请求去重
@@ -149,6 +164,7 @@ function HardwareInfoContent() {
const gpuInfo = data?.gpuInfo
const memoryInfo = data?.memoryInfo || []
const monitorInfo = data?.monitorInfo || []
const motherboardInfo = data?.motherboardInfo
const formatBytes = (bytes?: number) => {
if (!bytes) return "未知"
@@ -227,8 +243,8 @@ function HardwareInfoContent() {
})()
: null
// 如果正在加载,显示 Skeleton 骨架屏
if (isLoading) {
// 如果正在加载或正在验证(包括刷新),显示 Skeleton 骨架屏
if (isLoading || isValidating) {
return (
<div className="flex flex-col gap-4">
{/* 系统信息 Skeleton */}
@@ -324,6 +340,7 @@ function HardwareInfoContent() {
{allSysData?.total_memory && (
<div className="flex flex-col gap-2">
<div className="text-sm font-medium text-foreground-600"></div>
{/* 第一行:总容量和已用内存 */}
<div className="flex flex-wrap gap-2">
<Chip>
<span className="font-medium"></span> {formatBytes(allSysData.total_memory)}
@@ -336,23 +353,34 @@ function HardwareInfoContent() {
)}
</Chip>
)}
{allSysData.total_memory !== undefined && allSysData.used_memory !== undefined && (
<Chip>
<span className="font-medium"></span>{" "}
{formatBytes(allSysData.total_memory - allSysData.used_memory)}
</Chip>
)}
{memoryInfo.length > 0 && memoryInfo[0].part_number && (
<Chip>
<span className="font-medium"></span> {memoryInfo[0].part_number}
</Chip>
)}
{memoryInfo.length > 0 && memoryInfo[0].speed && (
<Chip>
<span className="font-medium"></span> {memoryInfo[0].speed} MHz
</Chip>
)}
</div>
{/* 每个内存条的详细信息 */}
{memoryInfo.length > 0 && (
<div className="flex flex-col gap-1.5">
{memoryInfo.map((mem, index) => (
<div key={index} className="flex flex-wrap gap-2">
{mem.capacity && (
<Chip>
<span className="font-medium"></span> {formatBytes(mem.capacity)}
</Chip>
)}
{mem.manufacturer && (
<Chip>
<span className="font-medium"></span> {mem.manufacturer}
</Chip>
)}
{mem.speed && (
<Chip>
<span className="font-medium"></span> {mem.speed} MHz
{mem.default_speed && (
<span className="ml-1">({mem.default_speed} MHz)</span>
)}
</Chip>
)}
</div>
))}
</div>
)}
</div>
)}
@@ -410,13 +438,28 @@ function HardwareInfoContent() {
)}
{/* 主板信息 */}
{(computerInfo.CsManufacturer || computerInfo.BiosSMBIOSBIOSVersion) && (
{(motherboardInfo?.model ||
motherboardInfo?.manufacturer ||
motherboardInfo?.version ||
computerInfo.BiosSMBIOSBIOSVersion) && (
<div className="flex flex-col gap-2">
<div className="text-sm font-medium text-foreground-600"></div>
<div className="flex flex-wrap gap-2">
{computerInfo.CsManufacturer && (
{motherboardInfo?.model && (
<Chip>
<span className="font-medium"></span> {computerInfo.CsManufacturer}
<span className="font-medium"></span> {motherboardInfo.model}
</Chip>
)}
{motherboardInfo?.manufacturer && (
<Chip>
<span className="font-medium"></span> {motherboardInfo.manufacturer}
</Chip>
)}
</div>
<div className="flex flex-wrap gap-2">
{motherboardInfo?.version && (
<Chip>
<span className="font-medium"></span> {motherboardInfo.version}
</Chip>
)}
{computerInfo.BiosSMBIOSBIOSVersion && (

View File

@@ -151,6 +151,58 @@ export function FpsTest() {
}
}, [tool.state.autoCloseGame, batchTestProgress])
// 生成硬件信息对象的辅助函数
const getHardwareInfoObject = useCallback(() => {
if (!hardwareInfo?.systemInfo) {
return null
}
const osVersion = hardwareInfo.systemInfo.os_version || null
const osDisplayVersion = hardwareInfo.computerInfo?.OSDisplayVersion || null
let osStr = hardwareInfo.systemInfo.name || null
if (osStr) {
if (osVersion) {
osStr += ` ${osVersion}`
}
if (osDisplayVersion) {
osStr += ` ${osDisplayVersion}`
}
}
return {
cpu: hardwareInfo.systemInfo.cpus[0]?.brand || null,
cpuCount: hardwareInfo.systemInfo.cpu_count || null,
os: osStr,
memory: hardwareInfo.systemInfo.total_memory
? Math.round(hardwareInfo.systemInfo.total_memory / 1024 / 1024 / 1024)
: null,
memoryManufacturer: hardwareInfo.memoryInfo && hardwareInfo.memoryInfo.length > 0
? hardwareInfo.memoryInfo[0].manufacturer || null
: null,
memorySpeed: hardwareInfo.memoryInfo && hardwareInfo.memoryInfo.length > 0
? hardwareInfo.memoryInfo[0].speed || null
: null,
memoryDefaultSpeed: hardwareInfo.memoryInfo && hardwareInfo.memoryInfo.length > 0
? hardwareInfo.memoryInfo[0].default_speed || null
: null,
gpu: hardwareInfo.gpuInfo
? hardwareInfo.gpuInfo.model
: null,
monitor: hardwareInfo.monitorInfo && hardwareInfo.monitorInfo.length > 0
? hardwareInfo.monitorInfo[0].name || null
: null,
monitorManufacturer: hardwareInfo.monitorInfo && hardwareInfo.monitorInfo.length > 0
? hardwareInfo.monitorInfo[0].manufacturer || null
: null,
monitorModel: hardwareInfo.monitorInfo && hardwareInfo.monitorInfo.length > 0
? hardwareInfo.monitorInfo[0].model || null
: null,
motherboardModel: hardwareInfo.motherboardInfo?.model || null,
motherboardVersion: hardwareInfo.motherboardInfo?.version || null,
biosVersion: hardwareInfo.computerInfo?.BiosSMBIOSBIOSVersion || null,
}
}, [hardwareInfo])
// 读取结果函数
const readResult = useCallback(
async (silent = false): Promise<boolean> => {
@@ -285,35 +337,7 @@ export function FpsTest() {
p1,
rawResult: parsed.data,
videoSetting: currentVideoSetting,
hardwareInfo: hardwareInfo?.systemInfo
? {
cpu: hardwareInfo.systemInfo.cpus[0]?.brand || null,
cpuCount: hardwareInfo.systemInfo.cpu_count || null,
os: (() => {
const osVersion = hardwareInfo.systemInfo.os_version || null
// 使用 OSDisplayVersion 作为版本代码(如 "25H2"
const osDisplayVersion = hardwareInfo.computerInfo?.OSDisplayVersion || null
let osStr = hardwareInfo.systemInfo.name || null
if (!osStr) return null
if (osVersion) {
osStr += ` ${osVersion}`
}
if (osDisplayVersion) {
osStr += ` ${osDisplayVersion}`
}
return osStr
})(),
memory: hardwareInfo.systemInfo.total_memory
? Math.round(hardwareInfo.systemInfo.total_memory / 1024 / 1024 / 1024)
: null,
gpu: hardwareInfo.gpuInfo
? hardwareInfo.gpuInfo.model
: null,
monitor: null,
}
: null,
hardwareInfo: getHardwareInfoObject(),
note: batchNote,
})
@@ -339,35 +363,7 @@ export function FpsTest() {
p1,
rawResult: parsed.data,
videoSetting: currentVideoSetting,
hardwareInfo: hardwareInfo?.systemInfo
? {
cpu: hardwareInfo.systemInfo.cpus[0]?.brand || null,
cpuCount: hardwareInfo.systemInfo.cpu_count || null,
os: (() => {
const osVersion = hardwareInfo.systemInfo.os_version || null
// 使用 OSDisplayVersion 作为版本代码(如 "25H2"
const osDisplayVersion = hardwareInfo.computerInfo?.OSDisplayVersion || null
let osStr = hardwareInfo.systemInfo.name || null
if (!osStr) return null
if (osVersion) {
osStr += ` ${osVersion}`
}
if (osDisplayVersion) {
osStr += ` ${osDisplayVersion}`
}
return osStr
})(),
memory: hardwareInfo.systemInfo.total_memory
? Math.round(hardwareInfo.systemInfo.total_memory / 1024 / 1024 / 1024)
: null,
gpu: hardwareInfo.gpuInfo
? hardwareInfo.gpuInfo.model
: null,
monitor: null,
}
: null,
hardwareInfo: getHardwareInfoObject(),
note: singleNote, // 保存备注(包含分辨率信息)
})
}
@@ -818,23 +814,7 @@ export function FpsTest() {
1
)}\nP1低帧: ${avgP1.toFixed(1)}`,
videoSetting: tool.store.state.videoSetting,
hardwareInfo: hardwareInfo?.systemInfo
? {
cpu: hardwareInfo.systemInfo.cpus[0]?.brand || null,
cpuCount: hardwareInfo.systemInfo.cpu_count || null,
os:
hardwareInfo.systemInfo.name && hardwareInfo.systemInfo.os_version
? `${hardwareInfo.systemInfo.name} ${hardwareInfo.systemInfo.os_version}`
: null,
memory: hardwareInfo.systemInfo.total_memory
? Math.round(hardwareInfo.systemInfo.total_memory / 1024 / 1024 / 1024)
: null,
gpu: hardwareInfo.gpuInfo
? `${hardwareInfo.gpuInfo.vendor} ${hardwareInfo.gpuInfo.model}`
: null,
monitor: null,
}
: null,
hardwareInfo: getHardwareInfoObject(),
note: averageNote,
})
@@ -944,23 +924,7 @@ export function FpsTest() {
1
)}\nP1低帧: ${avgP1.toFixed(1)}`,
videoSetting: tool.store.state.videoSetting,
hardwareInfo: hardwareInfo?.systemInfo
? {
cpu: hardwareInfo.systemInfo.cpus[0]?.brand || null,
cpuCount: hardwareInfo.systemInfo.cpu_count || null,
os:
hardwareInfo.systemInfo.name && hardwareInfo.systemInfo.os_version
? `${hardwareInfo.systemInfo.name} ${hardwareInfo.systemInfo.os_version}`
: null,
memory: hardwareInfo.systemInfo.total_memory
? Math.round(hardwareInfo.systemInfo.total_memory / 1024 / 1024 / 1024)
: null,
gpu: hardwareInfo.gpuInfo
? `${hardwareInfo.gpuInfo.vendor} ${hardwareInfo.gpuInfo.model}`
: null,
monitor: null,
}
: null,
hardwareInfo: getHardwareInfoObject(),
note: averageNote,
})

View File

@@ -41,16 +41,20 @@ export function TestResultsTable({
>
<TableHeader>
<TableColumn minWidth={140}></TableColumn>
<TableColumn width={80}></TableColumn>
<TableColumn width={80}></TableColumn>
<TableColumn width={80}>P1低帧</TableColumn>
<TableColumn width={40}></TableColumn>
<TableColumn width={60}></TableColumn>
<TableColumn width={60}>P1低帧</TableColumn>
<TableColumn width={100}>CPU</TableColumn>
<TableColumn minWidth={80}></TableColumn>
<TableColumn minWidth={100}>GPU</TableColumn>
<TableColumn width={80}></TableColumn>
<TableColumn width={80}></TableColumn>
<TableColumn width={100}></TableColumn>
<TableColumn minWidth={80}></TableColumn>
<TableColumn minWidth={80}>BIOS版本</TableColumn>
<TableColumn width={120}></TableColumn>
<TableColumn minWidth={100}></TableColumn>
<TableColumn width={80} align="center">
<TableColumn minWidth={40}></TableColumn>
<TableColumn width={60} align="center">
</TableColumn>
</TableHeader>
@@ -69,10 +73,10 @@ export function TestResultsTable({
<TableCell className="text-xs">
{result.p1 !== null ? `${result.p1.toFixed(1)}` : "N/A"}
</TableCell>
<TableCell className="text-xs max-w-[175px]">
<TableCell className="text-xs max-w-[170px]">
<Tooltip
content={result.hardwareInfo?.cpu || "N/A"}
delay={500}
delay={300}
placement="top"
>
<div className="truncate cursor-help">
@@ -91,6 +95,28 @@ export function TestResultsTable({
? `${result.hardwareInfo.memory}GB`
: "N/A"}
</TableCell>
<TableCell className="text-xs whitespace-nowrap">
{result.hardwareInfo?.memorySpeed
? `${result.hardwareInfo.memorySpeed}MHz`
: "N/A"}
</TableCell>
<TableCell className="text-xs">
<Tooltip
content={result.hardwareInfo?.motherboardModel || "N/A"}
delay={500}
placement="top"
>
<div className="truncate cursor-help">
{result.hardwareInfo?.motherboardModel || "N/A"}
</div>
</Tooltip>
</TableCell>
<TableCell className="text-xs">
<div className="truncate">{result.hardwareInfo?.motherboardVersion || "N/A"}</div>
</TableCell>
<TableCell className="text-xs">
<div className="truncate">{result.hardwareInfo?.biosVersion || "N/A"}</div>
</TableCell>
<TableCell className="text-xs">
<Tooltip content={formatVideoSettingSummary(result.videoSetting)}>
<span className="truncate cursor-help">
@@ -100,7 +126,7 @@ export function TestResultsTable({
</span>
</Tooltip>
</TableCell>
<TableCell className="text-xs">
<TableCell className="text-xs min-w-fit">
<NoteCell
note={result.note || ""}
onEdit={() => onEditNote(result.id, result.note || "")}

View File

@@ -22,10 +22,35 @@ interface ComputerInfo {
ReleaseId?: string
}
interface MemoryInfo {
capacity?: number // 容量(字节)
manufacturer?: string
speed?: number // MHz实际频率 ConfiguredClockSpeed
default_speed?: number // MHz默认频率 Speed如果存在
}
interface MonitorInfo {
manufacturer?: string
model?: string
name?: string
refresh_rate?: number // Hz
resolution_width?: number
resolution_height?: number
}
interface MotherboardInfo {
manufacturer?: string // 制造商
model?: string // 型号
version?: string
}
export interface HardwareInfoWithGpu {
systemInfo: AllSystemInfo | null
gpuInfo: GpuInfo | null
computerInfo: ComputerInfo | null
memoryInfo: MemoryInfo[]
monitorInfo: MonitorInfo[]
motherboardInfo: MotherboardInfo | null
}
export function useHardwareInfo() {
@@ -34,7 +59,7 @@ export function useHardwareInfo() {
useEffect(() => {
const fetchHardwareInfo = async () => {
try {
const [sys, gpuInfo, computerInfo] = await Promise.all([
const [sys, gpuInfo, computerInfo, memoryInfo, monitorInfo, motherboardInfo] = await Promise.all([
allSysInfo(),
invoke<GpuInfo | null>("get_gpu_info").catch((error) => {
console.error("获取 GPU 信息失败:", error)
@@ -43,12 +68,27 @@ export function useHardwareInfo() {
invoke<ComputerInfo>("get_computer_info").catch((error) => {
console.error("获取 PowerShell 信息失败:", error)
return {} as ComputerInfo
}),
invoke<MemoryInfo[]>("get_memory_info").catch((error) => {
console.error("获取内存信息失败:", error)
return [] as MemoryInfo[]
}),
invoke<MonitorInfo[]>("get_monitor_info").catch((error) => {
console.error("获取显示器信息失败:", error)
return [] as MonitorInfo[]
}),
invoke<MotherboardInfo>("get_motherboard_info").catch((error) => {
console.error("获取主板信息失败:", error)
return { manufacturer: undefined, model: undefined, version: undefined } as MotherboardInfo
})
])
setHardwareInfo({
systemInfo: sys,
gpuInfo,
computerInfo
computerInfo,
memoryInfo,
monitorInfo,
motherboardInfo
})
} catch (error) {
console.error("获取硬件信息失败:", error)

View File

@@ -38,6 +38,10 @@ export async function handleExportCSV(
"系统版本",
"GPU",
"内存(GB)",
"内存频率(MHz)",
"主板型号",
"主板版本",
"BIOS版本",
"分辨率",
"视频设置",
"备注",
@@ -55,6 +59,10 @@ export async function handleExportCSV(
`"${result.hardwareInfo?.os || "N/A"}"`,
`"${result.hardwareInfo?.gpu || "N/A"}"`,
result.hardwareInfo?.memory ? result.hardwareInfo.memory.toString() : "N/A",
result.hardwareInfo?.memorySpeed ? result.hardwareInfo.memorySpeed.toString() : "N/A",
`"${result.hardwareInfo?.motherboardModel || "N/A"}"`,
`"${result.hardwareInfo?.motherboardVersion || "N/A"}"`,
`"${result.hardwareInfo?.biosVersion || "N/A"}"`,
result.videoSetting
? `${result.videoSetting.defaultres}x${result.videoSetting.defaultresheight}`
: "N/A",
@@ -118,6 +126,10 @@ export async function handleExportAverageCSV(
"系统版本",
"GPU",
"内存(GB)",
"内存频率(MHz)",
"主板型号",
"主板版本",
"BIOS版本",
"分辨率",
"视频设置",
"备注",
@@ -135,6 +147,10 @@ export async function handleExportAverageCSV(
`"${result.hardwareInfo?.os || "N/A"}"`,
`"${result.hardwareInfo?.gpu || "N/A"}"`,
result.hardwareInfo?.memory ? result.hardwareInfo.memory.toString() : "N/A",
result.hardwareInfo?.memorySpeed ? result.hardwareInfo.memorySpeed.toString() : "N/A",
`"${result.hardwareInfo?.motherboardModel || "N/A"}"`,
`"${result.hardwareInfo?.motherboardVersion || "N/A"}"`,
`"${result.hardwareInfo?.biosVersion || "N/A"}"`,
result.videoSetting
? `${result.videoSetting.defaultres}x${result.videoSetting.defaultresheight}`
: "N/A",

View File

@@ -19,8 +19,16 @@ export interface FpsTestResult {
cpuCount: number | null
os: string | null
memory: number | null // GB
memoryManufacturer: string | null
memorySpeed: number | null // MHz实际频率 ConfiguredClockSpeed
memoryDefaultSpeed: number | null // MHz默认频率 Speed如果存在
gpu: string | null
monitor: string | null
monitorManufacturer: string | null
monitorModel: string | null
motherboardModel: string | null // 合并后的制造商和型号
motherboardVersion: string | null
biosVersion: string | null
} | null // 硬件信息
note?: string // 备注(可选,用于向后兼容)
}