fix: should not show vulkan options in cpu only mode (#5210)

This commit is contained in:
Louis 2025-06-07 00:55:01 +07:00 committed by GitHub
parent c444643294
commit 1fa9f4e731
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -282,13 +282,17 @@ function Hardware() {
title="Usage"
actions={
<div className="flex items-center gap-2">
<Progress
value={hardwareData.cpu?.usage}
className="h-2 w-10"
/>
<span className="text-main-view-fg/80">
{hardwareData.cpu?.usage?.toFixed(2)}%
</span>
{hardwareData.cpu?.usage > 0 && (
<>
<Progress
value={hardwareData.cpu?.usage}
className="h-2 w-10"
/>
<span className="text-main-view-fg/80">
{hardwareData.cpu?.usage?.toFixed(2)}%
</span>
</>
)}
</div>
}
/>
@ -316,49 +320,55 @@ function Hardware() {
title="Usage"
actions={
<div className="flex items-center gap-2">
<Progress
value={
((hardwareData.ram?.total -
hardwareData.ram?.available) /
hardwareData.ram?.total) *
100
}
className="h-2 w-10"
/>
<span className="text-main-view-fg/80">
{(
((hardwareData.ram?.total -
hardwareData.ram?.available) /
hardwareData.ram?.total) *
100
).toFixed(2)}
%
</span>
{hardwareData.ram?.total > 0 && (
<>
<Progress
value={
((hardwareData.ram?.total -
hardwareData.ram?.available) /
hardwareData.ram?.total) *
100
}
className="h-2 w-10"
/>
<span className="text-main-view-fg/80">
{(
((hardwareData.ram?.total -
hardwareData.ram?.available) /
hardwareData.ram?.total) *
100
).toFixed(2)}
%
</span>
</>
)}
</div>
}
/>
</Card>
{/* Vulkan Settings */}
<Card title="Vulkan">
<CardItem
title="Enable Vulkan"
description="Enable Vulkan API for GPU acceleration"
actions={
<div className="flex items-center gap-4">
<Switch
checked={vulkanEnabled}
onCheckedChange={(checked) => {
setVulkanEnabled(checked)
setTimeout(() => {
window.location.reload()
}, 500) // Reload after 500ms to apply changes
}}
/>
</div>
}
/>
</Card>
{hardwareData.gpus.length > 0 && (
<Card title="Vulkan">
<CardItem
title="Enable Vulkan"
description="Enable Vulkan API for GPU acceleration"
actions={
<div className="flex items-center gap-4">
<Switch
checked={vulkanEnabled}
onCheckedChange={(checked) => {
setVulkanEnabled(checked)
setTimeout(() => {
window.location.reload()
}, 500) // Reload after 500ms to apply changes
}}
/>
</div>
}
/>
</Card>
)}
{/* GPU Information */}
<Card title="GPUs">