diff --git a/.nvmdrc b/.nvmdrc
new file mode 100644
index 0000000..517a3f0
--- /dev/null
+++ b/.nvmdrc
@@ -0,0 +1 @@
+24.0.1
\ No newline at end of file
diff --git a/index.html b/index.html
index bf21ddf..03b137f 100644
--- a/index.html
+++ b/index.html
@@ -1,125 +1,291 @@
-
-
- 性能监控
-
-
-
-
-
-
-
CPU: 0%
-
内存: 0%
-
网络: 0 KB/s
-
-
-
-
-
+
+
+ 性能监控
+
+
+
+
+
+
+
+
+
+ CPU
+ 0%
+
+
+ 内存
+ 0%
+
+
+ 网络
+ 0 KB/s
+
+
+ GPU
+ 0%
+
+
+ 显存
+ 0 MB
+
+
+
+
+
-
-
\ No newline at end of file
+ // 监听窗口聚焦/失焦事件
+ const { ipcRenderer } = require('electron');
+
+ ipcRenderer.on('window-focused', () => {
+ isWindowFocused = true;
+ });
+
+ ipcRenderer.on('window-blurred', () => {
+ isWindowFocused = false;
+ });
+
+ // 监听主进程发送的GPU信息
+ ipcRenderer.on('gpu-info', (event, gpuInfo) => {
+ // 过滤掉任何剩余的虚拟GPU信息
+ const physicalGpus = gpuInfo.filter(gpu => {
+ // 检查是否为虚拟GPU
+ const isVirtual = gpu.name.includes('Oray') || gpu.name.includes('Virtual') || gpu.name.includes('Software')
+ return !isVirtual && (gpu.memoryUsed !== undefined || gpu.vram !== undefined)
+ })
+
+ if (physicalGpus && physicalGpus.length > 0) {
+ // 显示第一个物理GPU的显存使用情况
+ const gpu = physicalGpus[0]
+ // 优先使用memoryUsed和memoryTotal,如果没有则使用vram
+ if (gpu.memoryUsed !== undefined && gpu.memoryTotal !== undefined) {
+ // 转换为MB单位
+ const usedMB = Math.round(gpu.memoryUsed)
+ const totalMB = Math.round(gpu.memoryTotal)
+ gpuMemoryEl.textContent = usedMB + ' / ' + totalMB + ' MB'
+ } else if (gpu.vram !== undefined) {
+ // 如果只有vram信息,显示总显存
+ const totalMB = Math.round(gpu.vram)
+ gpuMemoryEl.textContent = '总共: ' + totalMB + ' MB'
+ } else {
+ gpuMemoryEl.textContent = 'N/A'
+ }
+ } else {
+ gpuMemoryEl.textContent = 'N/A'
+ }
+ })
+
+ // 使用requestAnimationFrame实现性能数据更新
+ let lastTime = 0;
+ const focusedUpdateInterval = 200; // 聚焦时200ms更新一次
+ const blurredUpdateInterval = 2000; // 失焦时2秒更新一次
+
+ async function updatePerformanceData(timestamp) {
+ // 根据窗口聚焦状态确定更新间隔
+ const updateInterval = isWindowFocused ? focusedUpdateInterval : blurredUpdateInterval;
+
+ if (timestamp - lastTime >= updateInterval) {
+ try {
+ // 获取CPU使用率
+ const cpuData = await si.currentLoad();
+ const cpuUsage = Math.round(cpuData.currentLoad);
+
+ // 获取内存使用率
+ const memData = await si.mem();
+ const memoryUsage = Math.round((memData.active / memData.total) * 100);
+
+ // 获取进程内存使用率
+ const pid = process.pid;
+ const pidData = await pidusage(pid);
+ const processMemory = Math.round(pidData.memory / 1024 / 1024); // 转换为MB
+
+ // 获取网络使用情况
+ const networkData = await si.networkStats();
+ const networkUsage = networkData[0] ? Math.round((networkData[0].rx_sec + networkData[0].tx_sec) / 1024) : 0; // KB/s
+
+ // 获取GPU使用率
+ const gpuData = await si.graphics();
+ let gpuUsage = 0;
+ if (gpuData.controllers && gpuData.controllers.length > 0) {
+ // 尝试获取GPU使用率,如果没有则使用默认值
+ gpuUsage = gpuData.controllers[0].utilizationMemory || gpuData.controllers[0].fanSpeed || 0;
+ }
+
+ // 更新UI
+ cpuEl.textContent = cpuUsage + '%';
+ memoryEl.textContent = memoryUsage + '%';
+ networkEl.textContent = networkUsage + ' KB/s';
+ gpuEl.textContent = gpuUsage + '%';
+ } catch (error) {
+ console.error('获取性能数据时出错:', error);
+ }
+
+ lastTime = timestamp;
+ }
+
+ requestAnimationFrame(updatePerformanceData);
+ }
+
+ // 启动动画循环
+ requestAnimationFrame(updatePerformanceData)
+
+
+