chore: seperate function onclick

This commit is contained in:
Faisal Amir 2025-05-21 12:47:06 +07:00
parent 2812a8978a
commit afab839733

View File

@ -163,14 +163,7 @@ function Hardware() {
return () => clearInterval(intervalId)
}, [setHardwareData, updateCPUUsage, updateRAMAvailable])
return (
<div className="flex flex-col h-full">
<HeaderPage>
<div className="flex items-center gap-2 justify-between w-full pr-3">
<h1 className="font-medium">{t('common.settings')}</h1>
<div
className="flex items-center gap-1 hover:bg-main-view-fg/8 px-1.5 py-0.5 rounded relative z-10 cursor-pointer"
onClick={async () => {
const handleClickSystemMonitor = async () => {
try {
// Check if system monitor window already exists
const existingWindow = await WebviewWindow.getByLabel(
@ -183,17 +176,14 @@ function Hardware() {
console.log('Focused existing system monitor window')
} else {
// Create a new system monitor window
const monitorWindow = new WebviewWindow(
'system-monitor-window',
{
const monitorWindow = new WebviewWindow('system-monitor-window', {
url: route.systemMonitor,
title: 'System Monitor - Jan',
width: 900,
height: 600,
resizable: true,
center: true,
}
)
})
// Listen for window creation
monitorWindow.once('tauri://created', () => {
@ -208,7 +198,16 @@ function Hardware() {
} catch (error) {
console.error('Failed to open system monitor window:', error)
}
}}
}
return (
<div className="flex flex-col h-full">
<HeaderPage>
<div className="flex items-center gap-2 justify-between w-full pr-3">
<h1 className="font-medium">{t('common.settings')}</h1>
<div
className="flex items-center gap-1 hover:bg-main-view-fg/8 px-1.5 py-0.5 rounded relative z-10 cursor-pointer"
onClick={handleClickSystemMonitor}
>
<IconDeviceDesktopAnalytics className="text-main-view-fg/50 size-5" />
<p>System monitor</p>