Skip to content

Commit c16a1cb

Browse files
author
netphils
committed
edit grid size and edit backend size calculation
1 parent 96ca6fa commit c16a1cb

File tree

8 files changed

+36
-103
lines changed

8 files changed

+36
-103
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cefdetector-standalone",
33
"private": true,
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"type": "module",
66
"scripts": {
77
"tauri": "tauri"

screenshot.png

65.6 KB
Loading

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cefdetector-standalone"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "CEF-Detector"
55
authors = ["netphils"]
66
edition = "2021"

src-tauri/src/lib.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,33 @@ fn search_installed() -> usize {
88
apps.len()
99
}
1010

11+
#[derive(Clone, serde::Serialize)]
12+
#[serde(rename_all = "camelCase")]
13+
struct BrowserSummary {
14+
size: u64,
15+
count: usize,
16+
}
17+
1118
#[tauri::command]
12-
async fn search_browsers(app_handle: tauri::AppHandle) -> usize {
19+
async fn search_browsers(app_handle: tauri::AppHandle) -> BrowserSummary {
1320
let apps = get_installed_apps();
1421

1522
let browsers = detect_browser_apps(apps, app_handle);
1623

17-
let count = browsers
24+
let count: usize = browsers
1825
.iter()
1926
.filter(|info| info.is_browser)
2027
.count();
21-
count
28+
29+
let total_size: u64 = browsers.iter()
30+
.filter(|browser| browser.is_browser)
31+
.map(|browser| browser.size)
32+
.sum();
33+
34+
BrowserSummary {
35+
size: total_size,
36+
count: count
37+
}
2238
}
2339

2440
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/

src-tauri/tauri.conf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "cefdetector-standalone",
4-
"version": "0.1.1",
5-
"identifier": "com.cefdetector-standalone.app",
4+
"version": "0.1.2",
5+
"identifier": "info.netsh.cefdetector-standalone.myapp",
66
"build": {
77
"frontendDist": "../src"
88
},

src/main.js

Lines changed: 11 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ function createBrowserCard(browserInfo) {
8181
return card;
8282
}
8383

84-
// 格式化大小显示
8584
function formatSize(bytes) {
8685
if (bytes === 0) return '0 B';
87-
const k = 1024;
88-
const sizes = ['B', 'KB', 'MB', 'GB'];
89-
const i = Math.floor(Math.log(bytes) / Math.log(k));
90-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
86+
87+
const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
88+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
89+
const value = bytes / Math.pow(1024, i);
90+
91+
return `${value.toFixed(2)} ${units[i]}`;
9192
}
9293

9394
// 设置事件监听
@@ -199,12 +200,14 @@ async function analyzeApps() {
199200

200201
// 调用Rust函数
201202
console.log("开始分析浏览器...");
202-
const browser_count = await invoke("search_browsers");
203-
console.log(`发现 ${browser_count} 个浏览器`);
203+
const browser_summary = await invoke("search_browsers");
204+
const browser_count = browser_summary.count;
205+
const browser_size = browser_summary.size;
206+
console.log(`发现 ${browser_count} 个浏览器,总大小${formatSize(browser_size)}。(大小包含整个程序)`);
204207

205208
// 更新描述
206209
if (browser_count > 0) {
207-
description.textContent = `已发现 ${browser_count} 个浏览器详细信息:`;
210+
description.textContent = `已发现 ${browser_count} 个浏览器详细信息:`;
208211
} else {
209212
description.textContent = '未发现浏览器';
210213
}
@@ -332,92 +335,6 @@ window.addEventListener("DOMContentLoaded", () => {
332335
50% { transform: scale(1.05); }
333336
100% { transform: scale(1); }
334337
}
335-
336-
/* 浏览器网格样式 */
337-
.browsers-grid {
338-
display: grid;
339-
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
340-
gap: 20px;
341-
width: 100%;
342-
max-width: 1200px;
343-
margin-top: 20px;
344-
padding: 20px;
345-
overflow-y: auto;
346-
max-height: 500px;
347-
}
348-
349-
.browser-card {
350-
background-color: rgba(255, 255, 255, 0.9);
351-
border-radius: 12px;
352-
padding: 20px;
353-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
354-
display: flex;
355-
flex-direction: column;
356-
align-items: center;
357-
transition: all 0.3s ease;
358-
}
359-
360-
.browser-card:hover {
361-
transform: translateY(-5px);
362-
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
363-
}
364-
365-
.browser-icon {
366-
width: 64px;
367-
height: 64px;
368-
object-fit: contain;
369-
margin-bottom: 15px;
370-
border-radius: 8px;
371-
}
372-
373-
.browser-name {
374-
margin: 0 0 10px 0;
375-
font-size: 18px;
376-
font-weight: 600;
377-
color: #2c3e50;
378-
text-align: center;
379-
}
380-
381-
.browser-type, .browser-size {
382-
margin: 5px 0;
383-
font-size: 14px;
384-
color: #546e7a;
385-
text-align: center;
386-
}
387-
388-
.analysis-title {
389-
color: white;
390-
text-align: center;
391-
margin-top: 20px;
392-
margin-bottom: 10px;
393-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
394-
}
395-
396-
.grid-description {
397-
color: white;
398-
text-align: center;
399-
margin: 10px 0;
400-
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
401-
}
402-
403-
/* 深色模式适配 */
404-
@media (prefers-color-scheme: dark) {
405-
.browser-card {
406-
background-color: rgba(40, 40, 40, 0.9);
407-
}
408-
409-
.browser-name {
410-
color: #e0e0e0;
411-
}
412-
413-
.browser-type, .browser-size {
414-
color: #b0bec5;
415-
}
416-
417-
.analysis-title, .grid-description {
418-
color: #f0f0f0;
419-
}
420-
}
421338
`;
422339
document.head.appendChild(style);
423340
});

src/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ body {
360360
/* 浏览器网格样式 */
361361
.browsers-grid {
362362
display: grid;
363-
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
363+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
364364
gap: 20px;
365365
width: 100%;
366366
max-width: 1200px;

0 commit comments

Comments
 (0)