chore: seperate function onclick
This commit is contained in:
parent
2812a8978a
commit
afab839733
@ -163,14 +163,7 @@ function Hardware() {
|
|||||||
return () => clearInterval(intervalId)
|
return () => clearInterval(intervalId)
|
||||||
}, [setHardwareData, updateCPUUsage, updateRAMAvailable])
|
}, [setHardwareData, updateCPUUsage, updateRAMAvailable])
|
||||||
|
|
||||||
return (
|
const handleClickSystemMonitor = async () => {
|
||||||
<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 () => {
|
|
||||||
try {
|
try {
|
||||||
// Check if system monitor window already exists
|
// Check if system monitor window already exists
|
||||||
const existingWindow = await WebviewWindow.getByLabel(
|
const existingWindow = await WebviewWindow.getByLabel(
|
||||||
@ -183,17 +176,14 @@ function Hardware() {
|
|||||||
console.log('Focused existing system monitor window')
|
console.log('Focused existing system monitor window')
|
||||||
} else {
|
} else {
|
||||||
// Create a new system monitor window
|
// Create a new system monitor window
|
||||||
const monitorWindow = new WebviewWindow(
|
const monitorWindow = new WebviewWindow('system-monitor-window', {
|
||||||
'system-monitor-window',
|
|
||||||
{
|
|
||||||
url: route.systemMonitor,
|
url: route.systemMonitor,
|
||||||
title: 'System Monitor - Jan',
|
title: 'System Monitor - Jan',
|
||||||
width: 900,
|
width: 900,
|
||||||
height: 600,
|
height: 600,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
center: true,
|
center: true,
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
// Listen for window creation
|
// Listen for window creation
|
||||||
monitorWindow.once('tauri://created', () => {
|
monitorWindow.once('tauri://created', () => {
|
||||||
@ -208,7 +198,16 @@ function Hardware() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to open system monitor window:', 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" />
|
<IconDeviceDesktopAnalytics className="text-main-view-fg/50 size-5" />
|
||||||
<p>System monitor</p>
|
<p>System monitor</p>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user