Compare commits

...

7 Commits

Author SHA1 Message Date
Julian Freeman
278a574b4f adjust ui 2026-03-03 23:05:17 -04:00
Julian Freeman
351b0b7fa0 change icons 2026-03-03 22:50:53 -04:00
Julian Freeman
e7ac620302 fix ui 2026-03-03 22:20:02 -04:00
Julian Freeman
92adfd7a2e add clean memory 2026-03-03 22:03:36 -04:00
Julian Freeman
0c77149c9e add failed count 2026-03-03 20:51:53 -04:00
Julian Freeman
91936aab19 add selection buttons 2026-03-03 20:01:50 -04:00
Julian Freeman
5cd6210dd2 add more browser paths 2026-03-03 17:46:01 -04:00
5 changed files with 657 additions and 34 deletions

121
src-tauri/Cargo.lock generated
View File

@@ -2112,6 +2112,15 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "ntapi"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "num-conv" name = "num-conv"
version = "0.2.0" version = "0.2.0"
@@ -3491,6 +3500,20 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "sysinfo"
version = "0.33.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01"
dependencies = [
"core-foundation-sys",
"libc",
"memchr",
"ntapi",
"rayon",
"windows 0.57.0",
]
[[package]] [[package]]
name = "system-deps" name = "system-deps"
version = "6.2.2" version = "6.2.2"
@@ -3538,7 +3561,7 @@ dependencies = [
"tao-macros", "tao-macros",
"unicode-segmentation", "unicode-segmentation",
"url", "url",
"windows", "windows 0.61.3",
"windows-core 0.61.2", "windows-core 0.61.2",
"windows-version", "windows-version",
"x11-dl", "x11-dl",
@@ -3609,7 +3632,7 @@ dependencies = [
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"window-vibrancy", "window-vibrancy",
"windows", "windows 0.61.3",
] ]
[[package]] [[package]]
@@ -3710,7 +3733,7 @@ dependencies = [
"tauri-plugin", "tauri-plugin",
"thiserror 2.0.18", "thiserror 2.0.18",
"url", "url",
"windows", "windows 0.61.3",
"zbus", "zbus",
] ]
@@ -3736,7 +3759,7 @@ dependencies = [
"url", "url",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows", "windows 0.61.3",
] ]
[[package]] [[package]]
@@ -3762,7 +3785,7 @@ dependencies = [
"url", "url",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows", "windows 0.61.3",
"wry", "wry",
] ]
@@ -3929,11 +3952,25 @@ dependencies = [
"bytes", "bytes",
"libc", "libc",
"mio", "mio",
"parking_lot",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry",
"socket2", "socket2",
"tokio-macros",
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "tokio-macros"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.117",
]
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.7.18" version = "0.7.18"
@@ -4527,10 +4564,10 @@ checksum = "7130243a7a5b33c54a444e54842e6a9e133de08b5ad7b5861cd8ed9a6a5bc96a"
dependencies = [ dependencies = [
"webview2-com-macros", "webview2-com-macros",
"webview2-com-sys", "webview2-com-sys",
"windows", "windows 0.61.3",
"windows-core 0.61.2", "windows-core 0.61.2",
"windows-implement", "windows-implement 0.60.2",
"windows-interface", "windows-interface 0.59.3",
] ]
[[package]] [[package]]
@@ -4551,7 +4588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c" checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c"
dependencies = [ dependencies = [
"thiserror 2.0.18", "thiserror 2.0.18",
"windows", "windows 0.61.3",
"windows-core 0.61.2", "windows-core 0.61.2",
] ]
@@ -4563,10 +4600,13 @@ dependencies = [
"jwalk", "jwalk",
"serde", "serde",
"serde_json", "serde_json",
"sysinfo",
"tauri", "tauri",
"tauri-build", "tauri-build",
"tauri-plugin-opener", "tauri-plugin-opener",
"tokio",
"walkdir", "walkdir",
"windows-sys 0.59.0",
] ]
[[package]] [[package]]
@@ -4615,6 +4655,16 @@ dependencies = [
"windows-version", "windows-version",
] ]
[[package]]
name = "windows"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
dependencies = [
"windows-core 0.57.0",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.61.3" version = "0.61.3"
@@ -4637,14 +4687,26 @@ dependencies = [
"windows-core 0.61.2", "windows-core 0.61.2",
] ]
[[package]]
name = "windows-core"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
dependencies = [
"windows-implement 0.57.0",
"windows-interface 0.57.0",
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-core" name = "windows-core"
version = "0.61.2" version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
dependencies = [ dependencies = [
"windows-implement", "windows-implement 0.60.2",
"windows-interface", "windows-interface 0.59.3",
"windows-link 0.1.3", "windows-link 0.1.3",
"windows-result 0.3.4", "windows-result 0.3.4",
"windows-strings 0.4.2", "windows-strings 0.4.2",
@@ -4656,8 +4718,8 @@ version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
dependencies = [ dependencies = [
"windows-implement", "windows-implement 0.60.2",
"windows-interface", "windows-interface 0.59.3",
"windows-link 0.2.1", "windows-link 0.2.1",
"windows-result 0.4.1", "windows-result 0.4.1",
"windows-strings 0.5.1", "windows-strings 0.5.1",
@@ -4674,6 +4736,17 @@ dependencies = [
"windows-threading", "windows-threading",
] ]
[[package]]
name = "windows-implement"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.117",
]
[[package]] [[package]]
name = "windows-implement" name = "windows-implement"
version = "0.60.2" version = "0.60.2"
@@ -4685,6 +4758,17 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "windows-interface"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.117",
]
[[package]] [[package]]
name = "windows-interface" name = "windows-interface"
version = "0.59.3" version = "0.59.3"
@@ -4718,6 +4802,15 @@ dependencies = [
"windows-link 0.1.3", "windows-link 0.1.3",
] ]
[[package]]
name = "windows-result"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-result" name = "windows-result"
version = "0.3.4" version = "0.3.4"
@@ -5155,7 +5248,7 @@ dependencies = [
"webkit2gtk", "webkit2gtk",
"webkit2gtk-sys", "webkit2gtk-sys",
"webview2-com", "webview2-com",
"windows", "windows 0.61.3",
"windows-core 0.61.2", "windows-core 0.61.2",
"windows-version", "windows-version",
"x11-dl", "x11-dl",

View File

@@ -25,4 +25,14 @@ serde_json = "1"
chrono = "0.4.44" chrono = "0.4.44"
walkdir = "2.5.0" walkdir = "2.5.0"
jwalk = "0.8.1" jwalk = "0.8.1"
sysinfo = "0.33.1"
tokio = { version = "1", features = ["full"] }
windows-sys = { version = "0.59", features = [
"Win32_System_Memory",
"Win32_Foundation",
"Win32_System_ProcessStatus",
"Win32_System_Threading",
"Win32_Security",
"Win32_System_SystemInformation"
] }

View File

@@ -368,6 +368,19 @@ fn clean_directory_contents(path: &Path, filter_days: Option<u64>) -> (u64, u32,
// --- 浏览器清理逻辑 --- // --- 浏览器清理逻辑 ---
const BROWSER_CACHE_DIRS: &[&str] = &[
"Cache",
"Code Cache",
"GPUCache",
"Media Cache",
"Service Worker/CacheStorage",
"Service Worker/ScriptCache",
"GrShaderCache",
"DawnCache",
"File System",
"blob_storage"
];
#[derive(Serialize, Clone)] #[derive(Serialize, Clone)]
pub struct BrowserProfile { pub struct BrowserProfile {
pub name: String, pub name: String,
@@ -416,9 +429,8 @@ pub async fn run_browser_scan(browser: BrowserType) -> Result<BrowserScanResult,
if profile_path.exists() { if profile_path.exists() {
let mut size = 0; let mut size = 0;
// 扫描常见的缓存目录 // 扫描配置的缓存目录
let cache_dirs = ["Cache", "Code Cache", "GPUCache", "Media Cache"]; for sub in BROWSER_CACHE_DIRS {
for sub in cache_dirs {
let target = profile_path.join(sub); let target = profile_path.join(sub);
if target.exists() { if target.exists() {
size += get_dir_size_simple(&target); size += get_dir_size_simple(&target);
@@ -461,8 +473,8 @@ pub async fn run_browser_clean(browser: BrowserType, profile_paths: Vec<String>)
for profile_dir in profile_paths { for profile_dir in profile_paths {
let profile_path = user_data_path.join(&profile_dir); let profile_path = user_data_path.join(&profile_dir);
if profile_path.exists() { if profile_path.exists() {
let cache_dirs = ["Cache", "Code Cache", "GPUCache", "Media Cache"]; // 清理配置的缓存目录
for sub in cache_dirs { for sub in BROWSER_CACHE_DIRS {
let target = profile_path.join(sub); let target = profile_path.join(sub);
if target.exists() { if target.exists() {
let (f, s, fl) = clean_directory_contents(&target, None); let (f, s, fl) = clean_directory_contents(&target, None);
@@ -480,3 +492,77 @@ pub async fn run_browser_clean(browser: BrowserType, profile_paths: Vec<String>)
fail_count, fail_count,
}) })
} }
// --- 内存清理逻辑 ---
use sysinfo::{System, ProcessesToUpdate};
#[derive(Serialize, Clone)]
pub struct MemoryStats {
pub total: u64,
pub used: u64,
pub free: u64,
pub percent: f32,
}
/// 获取当前系统内存状态
pub fn get_memory_stats() -> MemoryStats {
let mut sys = System::new_all();
sys.refresh_memory();
let total = sys.total_memory();
let used = sys.used_memory();
let free = total.saturating_sub(used);
let percent = (used as f32 / total as f32) * 100.0;
MemoryStats { total, used, free, percent }
}
/// 执行内存压缩 (Empty Working Set)
pub async fn run_memory_clean() -> Result<u64, String> {
use windows_sys::Win32::System::ProcessStatus::EmptyWorkingSet;
use windows_sys::Win32::System::Threading::{OpenProcess, PROCESS_QUERY_INFORMATION, PROCESS_SET_QUOTA};
use windows_sys::Win32::Foundation::CloseHandle;
let before = get_memory_stats().used;
let mut sys = System::new_all();
sys.refresh_processes(ProcessesToUpdate::All, true);
for (pid, _) in sys.processes() {
let pid_u32 = pid.as_u32();
unsafe {
let handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_SET_QUOTA, 0, pid_u32);
if handle != std::ptr::null_mut() {
EmptyWorkingSet(handle);
CloseHandle(handle);
}
}
}
// 给系统一点点时间反应
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
let after = get_memory_stats().used;
let freed = before.saturating_sub(after);
Ok(freed)
}
/// 深度内存清理 (Standby List / System Cache)
pub async fn run_deep_memory_clean() -> Result<u64, String> {
use windows_sys::Win32::System::Memory::SetSystemFileCacheSize;
let before = get_memory_stats().used;
unsafe {
// -1 (usize::MAX) 表示清空系统文件缓存
SetSystemFileCacheSize(usize::MAX, usize::MAX, 0);
}
// 配合普通清理一起执行
let _ = run_memory_clean().await;
let after = get_memory_stats().used;
let freed = before.saturating_sub(after);
Ok(freed)
}

View File

@@ -60,6 +60,23 @@ async fn start_browser_clean(browser: String, profiles: Vec<String>) -> Result<c
cleaner::run_browser_clean(b_type, profiles).await cleaner::run_browser_clean(b_type, profiles).await
} }
// --- 内存清理命令 ---
#[tauri::command]
async fn get_memory_stats() -> cleaner::MemoryStats {
cleaner::get_memory_stats()
}
#[tauri::command]
async fn run_memory_clean() -> Result<u64, String> {
cleaner::run_memory_clean().await
}
#[tauri::command]
async fn run_deep_memory_clean() -> Result<u64, String> {
cleaner::run_deep_memory_clean().await
}
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
tauri::Builder::default() tauri::Builder::default()
@@ -78,7 +95,10 @@ pub fn run() {
clean_thumbnails, clean_thumbnails,
disable_hibernation, disable_hibernation,
start_browser_scan, start_browser_scan,
start_browser_clean start_browser_clean,
get_memory_stats,
run_memory_clean,
run_deep_memory_clean
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");

View File

@@ -9,7 +9,7 @@ import pkg from "../package.json";
type Tab = 'clean-c-fast' | 'clean-c-advanced' | 'clean-c-deep' | 'clean-browser-chrome' | 'clean-browser-edge' | 'clean-memory'; type Tab = 'clean-c-fast' | 'clean-c-advanced' | 'clean-c-deep' | 'clean-browser-chrome' | 'clean-browser-edge' | 'clean-memory';
const activeTab = ref<Tab>('clean-c-fast'); const activeTab = ref<Tab>('clean-c-fast');
const isCMenuOpen = ref(true); const isCMenuOpen = ref(true);
const isBrowserMenuOpen = ref(false); const isBrowserMenuOpen = ref(true);
// --- 数据结构 --- // --- 数据结构 ---
interface ScanItem { name: string; path: string; size: number; count: number; enabled: boolean; } interface ScanItem { name: string; path: string; size: number; count: number; enabled: boolean; }
@@ -23,6 +23,13 @@ interface FileNode {
level: number; isOpen: boolean; isLoading: boolean; level: number; isOpen: boolean; isLoading: boolean;
} }
interface MemoryStats {
total: number;
used: number;
free: number;
percent: number;
}
// --- 状态管理 --- // --- 状态管理 ---
const fastState = ref({ const fastState = ref({
isScanning: false, isScanning: false,
@@ -33,6 +40,14 @@ const fastState = ref({
cleanResult: null as CleanResult | null, cleanResult: null as CleanResult | null,
}); });
const memoryState = ref({
stats: null as MemoryStats | null,
isCleaning: false,
cleaningType: null as 'fast' | 'deep' | null,
lastFreed: "",
isDone: false,
});
const chromeState = ref({ const chromeState = ref({
isScanning: false, isScanning: false,
isCleaning: false, isCleaning: false,
@@ -212,6 +227,20 @@ async function runAdvancedTask(task: string) {
} }
// --- 浏览器清理逻辑 --- // --- 浏览器清理逻辑 ---
function toggleAllProfiles(enabled: boolean) {
const s = activeTab.value === 'clean-browser-chrome' ? chromeState.value : edgeState.value;
if (s.scanResult) {
s.scanResult.profiles.forEach(p => p.enabled = enabled);
}
}
function invertProfiles() {
const s = activeTab.value === 'clean-browser-chrome' ? chromeState.value : edgeState.value;
if (s.scanResult) {
s.scanResult.profiles.forEach(p => p.enabled = !p.enabled);
}
}
async function startBrowserScan(browser: 'chrome' | 'edge') { async function startBrowserScan(browser: 'chrome' | 'edge') {
const s = browser === 'chrome' ? chromeState.value : edgeState.value; const s = browser === 'chrome' ? chromeState.value : edgeState.value;
s.isScanning = true; s.isScanning = true;
@@ -335,6 +364,57 @@ function splitSize(sizeStr: string | number) {
} }
return { value: str, unit: '' }; return { value: str, unit: '' };
} }
// --- 内存清理逻辑 ---
async function getMemoryStats() {
try {
const stats = await invoke<MemoryStats>("get_memory_stats");
memoryState.value.stats = stats;
} catch (err) {
console.error("Failed to fetch memory stats", err);
}
}
async function startMemoryClean(deep = false) {
if (memoryState.value.isCleaning) return;
memoryState.value.isCleaning = true;
memoryState.value.cleaningType = deep ? 'deep' : 'fast';
try {
const cmd = deep ? "run_deep_memory_clean" : "run_memory_clean";
const freedBytes = await invoke<number>(cmd);
memoryState.value.lastFreed = formatItemSize(freedBytes);
// 使用弹窗显示结果
showAlert("优化完成", `已为您释放 ${memoryState.value.lastFreed} 内存空间`, 'success');
await getMemoryStats();
} catch (err) {
showAlert("清理失败", String(err), 'error');
} finally {
memoryState.value.isCleaning = false;
memoryState.value.cleaningType = null;
}
}
// 自动刷新内存
import { onMounted, onUnmounted, watch } from "vue";
let memoryInterval: any = null;
onMounted(() => {
getMemoryStats();
memoryInterval = setInterval(() => {
if (activeTab.value === 'clean-memory') {
getMemoryStats();
}
}, 3000);
});
onUnmounted(() => {
if (memoryInterval) clearInterval(memoryInterval);
});
watch(activeTab, (newTab) => {
if (newTab === 'clean-memory') getMemoryStats();
});
</script> </script>
<template> <template>
@@ -349,7 +429,9 @@ function splitSize(sizeStr: string | number) {
<!-- 清理 C 盘组 --> <!-- 清理 C 盘组 -->
<div class="nav-group"> <div class="nav-group">
<div class="nav-item-header" @click="isCMenuOpen = !isCMenuOpen"> <div class="nav-item-header" @click="isCMenuOpen = !isCMenuOpen">
<span class="icon">💾</span> <span class="icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"/><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><line x1="6" y1="6" x2="6.01" y2="6"/><line x1="6" y1="18" x2="6.01" y2="18"/></svg>
</span>
<span class="label">清理 C </span> <span class="label">清理 C </span>
<span class="arrow" :class="{ open: isCMenuOpen }"></span> <span class="arrow" :class="{ open: isCMenuOpen }"></span>
</div> </div>
@@ -381,7 +463,9 @@ function splitSize(sizeStr: string | number) {
<!-- 清理浏览器组 --> <!-- 清理浏览器组 -->
<div class="nav-group"> <div class="nav-group">
<div class="nav-item-header" @click="isBrowserMenuOpen = !isBrowserMenuOpen"> <div class="nav-item-header" @click="isBrowserMenuOpen = !isBrowserMenuOpen">
<span class="icon">🌐</span> <span class="icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><line x1="3" y1="10" x2="21" y2="10"/><path d="M7 7h.01"/><path d="M11 7h.01"/></svg>
</span>
<span class="label">清理浏览器</span> <span class="label">清理浏览器</span>
<span class="arrow" :class="{ open: isBrowserMenuOpen }"></span> <span class="arrow" :class="{ open: isBrowserMenuOpen }"></span>
</div> </div>
@@ -409,7 +493,9 @@ function splitSize(sizeStr: string | number) {
:class="{ active: activeTab === 'clean-memory' }" :class="{ active: activeTab === 'clean-memory' }"
@click="activeTab = 'clean-memory'" @click="activeTab = 'clean-memory'"
> >
<span class="icon">🚀</span> <span class="icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/></svg>
</span>
<span class="label">清理内存</span> <span class="label">清理内存</span>
</div> </div>
</nav> </nav>
@@ -637,7 +723,7 @@ function splitSize(sizeStr: string | number) {
<!-- 扫描完成 --> <!-- 扫描完成 -->
<div class="result-card" v-else-if="chromeState.scanResult && !chromeState.isDone"> <div class="result-card" v-else-if="chromeState.scanResult && !chromeState.isDone">
<div class="result-header"> <div class="result-header">
<span class="result-icon">🌐</span> <span class="result-icon">🌍</span>
<h2>扫描完成</h2> <h2>扫描完成</h2>
</div> </div>
<div class="result-stats"> <div class="result-stats">
@@ -677,6 +763,11 @@ function splitSize(sizeStr: string | number) {
<span class="stat-value">{{ chromeState.cleanResult.success_count }}</span> <span class="stat-value">{{ chromeState.cleanResult.success_count }}</span>
<span class="stat-label">成功清理</span> <span class="stat-label">成功清理</span>
</div> </div>
<div class="stat-divider"></div>
<div class="stat-item">
<span class="stat-value highlight-gray">{{ chromeState.cleanResult.fail_count }}</span>
<span class="stat-label">跳过/失败</span>
</div>
</div> </div>
<button class="btn-secondary" @click="resetPageState">返回</button> <button class="btn-secondary" @click="resetPageState">返回</button>
</div> </div>
@@ -694,7 +785,7 @@ function splitSize(sizeStr: string | number) {
</div> </div>
<div class="result-card" v-else-if="edgeState.scanResult && !edgeState.isDone"> <div class="result-card" v-else-if="edgeState.scanResult && !edgeState.isDone">
<div class="result-header"> <div class="result-header">
<span class="result-icon">🌐</span> <span class="result-icon">🌍</span>
<h2>扫描完成</h2> <h2>扫描完成</h2>
</div> </div>
<div class="result-stats"> <div class="result-stats">
@@ -733,6 +824,11 @@ function splitSize(sizeStr: string | number) {
<span class="stat-value">{{ edgeState.cleanResult.success_count }}</span> <span class="stat-value">{{ edgeState.cleanResult.success_count }}</span>
<span class="stat-label">成功清理</span> <span class="stat-label">成功清理</span>
</div> </div>
<div class="stat-divider"></div>
<div class="stat-item">
<span class="stat-value highlight-gray">{{ edgeState.cleanResult.fail_count }}</span>
<span class="stat-label">跳过/失败</span>
</div>
</div> </div>
<button class="btn-secondary" @click="resetPageState">返回</button> <button class="btn-secondary" @click="resetPageState">返回</button>
</div> </div>
@@ -741,7 +837,14 @@ function splitSize(sizeStr: string | number) {
<!-- 详情列表 --> <!-- 详情列表 -->
<div class="detail-list" v-if="activeTab === 'clean-browser-chrome' ? (chromeState.isScanning || chromeState.scanResult) && !chromeState.isDone : (edgeState.isScanning || edgeState.scanResult) && !edgeState.isDone"> <div class="detail-list" v-if="activeTab === 'clean-browser-chrome' ? (chromeState.isScanning || chromeState.scanResult) && !chromeState.isDone : (edgeState.isScanning || edgeState.scanResult) && !edgeState.isDone">
<h3>用户资料列表</h3> <div class="list-header">
<h3>用户资料列表</h3>
<div class="list-actions">
<button class="btn-text" @click="toggleAllProfiles(true)">全选</button>
<button class="btn-text" @click="toggleAllProfiles(false)">取消</button>
<button class="btn-text" @click="invertProfiles()">反选</button>
</div>
</div>
<div <div
class="detail-item" class="detail-item"
v-for="profile in (activeTab === 'clean-browser-chrome' ? chromeState.scanResult?.profiles : edgeState.scanResult?.profiles) || []" v-for="profile in (activeTab === 'clean-browser-chrome' ? chromeState.scanResult?.profiles : edgeState.scanResult?.profiles) || []"
@@ -809,7 +912,9 @@ function splitSize(sizeStr: string | number) {
<span v-if="node.is_dir" class="node-toggle"> <span v-if="node.is_dir" class="node-toggle">
{{ node.isLoading ? '' : (node.isOpen ? '' : '') }} {{ node.isLoading ? '' : (node.isOpen ? '' : '') }}
</span> </span>
<span v-else class="node-icon">📄</span> <span v-else class="node-icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><polyline points="13 2 13 9 20 9"/></svg>
</span>
<span class="node-text">{{ node.name }}</span> <span class="node-text">{{ node.name }}</span>
</div> </div>
<div class="col-size">{{ node.size_str }}</div> <div class="col-size">{{ node.size_str }}</div>
@@ -825,7 +930,75 @@ function splitSize(sizeStr: string | number) {
</div> </div>
</section> </section>
<!-- 4. 其他占位 --> <!-- 4. 内存清理页面 -->
<section v-else-if="activeTab === 'clean-memory'" class="page-container memory-page-spread">
<div class="page-header">
<div class="header-info">
<h1>内存加速</h1>
<p>通过压缩进程工作集释放物理内存占用</p>
</div>
</div>
<div class="memory-layout-v2">
<!-- 顶部主展示区 -->
<div class="memory-main-card shadow-card">
<div class="gauge-section">
<div class="memory-gauge" :style="{ '--percent': memoryState.stats?.percent || 0 }">
<svg viewBox="0 0 100 100">
<circle class="gauge-bg" cx="50" cy="50" r="45"></circle>
<circle class="gauge-fill" cx="50" cy="50" r="45" :style="{ strokeDashoffset: 283 - (283 * (memoryState.stats?.percent || 0)) / 100 }"></circle>
</svg>
<div class="gauge-content">
<span class="gauge-value">{{ Math.round(memoryState.stats?.percent || 0) }}<small>%</small></span>
<span class="gauge-label">内存占用</span>
</div>
</div>
</div>
<div class="stats-section">
<div class="stat-box-v2">
<span class="label">已用内存</span>
<span class="value">{{ formatItemSize(memoryState.stats?.used || 0) }}</span>
</div>
<div class="stat-divider-h"></div>
<div class="stat-box-v2">
<span class="label">可用内存</span>
<span class="value">{{ formatItemSize(memoryState.stats?.free || 0) }}</span>
</div>
<div class="stat-divider-h"></div>
<div class="stat-box-v2">
<span class="label">内存总量</span>
<span class="value">{{ formatItemSize(memoryState.stats?.total || 0) }}</span>
</div>
</div>
</div>
<!-- 底部操作区 -->
<div class="memory-actions-v2">
<div class="action-card shadow-card" :class="{ cleaning: memoryState.isCleaning }">
<div class="action-info">
<h3>普通加速</h3>
<p>压缩所有进程的内存工作集释放物理内存不影响程序运行</p>
</div>
<button class="btn-primary" @click="startMemoryClean(false)" :disabled="memoryState.isCleaning">
{{ memoryState.cleaningType === 'fast' ? '清理中...' : '立即加速' }}
</button>
</div>
<div class="action-card shadow-card secondary" :class="{ cleaning: memoryState.isCleaning }">
<div class="action-info">
<h3>深度加速</h3>
<p>强制清空系统备用列表待机列表释放更多被缓存的物理空间</p>
</div>
<button class="btn-secondary" @click="startMemoryClean(true)" :disabled="memoryState.isCleaning">
{{ memoryState.cleaningType === 'deep' ? '清理中...' : '深度加速' }}
</button>
</div>
</div>
</div>
</section>
<!-- 5. 其他占位 -->
<section v-else class="placeholder-page"> <section v-else class="placeholder-page">
<div class="empty-state"> <div class="empty-state">
<span class="empty-icon">🛠</span> <span class="empty-icon">🛠</span>
@@ -843,16 +1016,22 @@ function splitSize(sizeStr: string | number) {
@click.stop @click.stop
> >
<div class="menu-item" @click="openNodeInExplorer"> <div class="menu-item" @click="openNodeInExplorer">
<span class="menu-icon">📂</span> <span class="menu-icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>
</span>
<span>在文件夹中打开</span> <span>在文件夹中打开</span>
</div> </div>
<div class="menu-divider"></div> <div class="menu-divider"></div>
<div class="menu-item" @click="searchNode('google')"> <div class="menu-item" @click="searchNode('google')">
<span class="menu-icon">🌐</span> <span class="menu-icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
</span>
<span> Google 搜索</span> <span> Google 搜索</span>
</div> </div>
<div class="menu-item" @click="searchNode('perplexity')"> <div class="menu-item" @click="searchNode('perplexity')">
<span class="menu-icon">🤖</span> <span class="menu-icon svg-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/></svg>
</span>
<span>询问 Perplexity</span> <span>询问 Perplexity</span>
</div> </div>
</div> </div>
@@ -1001,6 +1180,7 @@ body {
padding: 40px 60px; padding: 40px 60px;
overflow-y: auto; overflow-y: auto;
height: 100%; height: 100%;
scrollbar-gutter: stable;
} }
/* 当处于全屏模式(深度分析)时,内容区本身不滚动,让内部树形滚动 */ /* 当处于全屏模式(深度分析)时,内容区本身不滚动,让内部树形滚动 */
.content:has(.page-container.full-width) { .content:has(.page-container.full-width) {
@@ -1058,7 +1238,7 @@ body {
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
padding: 10px 28px; padding: 10px 28px;
border-radius: 10px; border-radius: 10px;
font-size: 14px; font-size: 15px;
font-weight: 600; font-weight: 600;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s;
@@ -1313,7 +1493,22 @@ body {
margin-top: 40px; margin-top: 40px;
border: 1px solid rgba(0,0,0,0.02); border: 1px solid rgba(0,0,0,0.02);
} }
.detail-list h3 { font-size: 18px; margin-bottom: 20px; font-weight: 700; color: var(--text-main); } .list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.list-header h3 { font-size: 18px; margin-bottom: 0; font-weight: 700; color: var(--text-main); }
.list-actions { display: flex; gap: 8px; }
.btn-text {
background: none;
border: none;
color: var(--primary-color);
font-size: 12px;
font-weight: 600;
cursor: pointer;
padding: 6px 10px;
border-radius: 8px;
transition: all 0.2s;
}
.btn-text:hover { background-color: #F0F7FF; }
.detail-item { .detail-item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@@ -1456,4 +1651,223 @@ body {
background: #F5F5F7; background: #F5F5F7;
margin: 4px 0; margin: 4px 0;
} }
/* --- 内存清理特有样式 --- */
.memory-layout-v2 {
display: flex;
flex-direction: column;
gap: 32px;
margin-top: 24px;
}
.memory-main-card {
background: white;
border-radius: 32px;
padding: 48px;
display: flex;
align-items: center;
gap: 60px;
box-shadow: var(--card-shadow);
}
.gauge-section {
flex: 0 0 auto;
}
.memory-gauge {
position: relative;
width: 240px;
height: 240px;
}
.memory-gauge svg {
transform: rotate(-90deg);
width: 100%;
height: 100%;
}
.gauge-bg {
fill: none;
stroke: #F2F2F7;
stroke-width: 8;
}
.gauge-fill {
fill: none;
stroke: var(--primary-color);
stroke-width: 8;
stroke-linecap: round;
stroke-dasharray: 283;
transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s;
}
.gauge-content {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
text-align: center;
display: flex;
flex-direction: column;
}
.gauge-value {
font-size: 64px;
font-weight: 800;
color: var(--text-main);
line-height: 1;
letter-spacing: -2px;
}
.gauge-value small {
font-size: 24px;
margin-left: 2px;
letter-spacing: 0;
}
.gauge-label {
font-size: 14px;
color: var(--text-sec);
font-weight: 600;
margin-top: 4px;
}
.stats-section {
flex: 1;
display: flex;
flex-direction: column;
gap: 20px;
}
.stat-box-v2 {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0;
}
.stat-box-v2 .label {
font-size: 15px;
color: var(--text-sec);
font-weight: 500;
}
.stat-box-v2 .value {
font-size: 20px;
font-weight: 700;
color: var(--text-main);
}
.stat-divider-h {
height: 1px;
background: #F2F2F7;
width: 100%;
}
.memory-actions-v2 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 24px;
}
.action-card {
background: white;
padding: 32px;
border-radius: 28px;
display: flex;
flex-direction: column;
gap: 24px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.action-card:hover {
transform: translateY(-4px);
box-shadow: 0 16px 40px rgba(0,0,0,0.06);
}
.action-card.secondary {
background-color: #FBFBFD;
border: 1px dashed var(--border-color);
box-shadow: none;
}
.action-info h3 {
font-size: 18px;
font-weight: 700;
margin-bottom: 8px;
color: var(--text-main);
}
.action-info p {
font-size: 13px;
color: var(--text-sec);
line-height: 1.5;
}
.action-card .btn-primary,
.action-card .btn-secondary {
width: 100%;
padding: 14px;
}
.clean-feedback {
margin-top: 40px;
text-align: center;
padding: 20px;
background-color: #E8F5E9;
color: #2E7D32;
border-radius: 20px;
font-weight: 600;
font-size: 15px;
animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.freed-amount {
font-size: 20px;
font-weight: 800;
text-decoration: underline;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.action-card.cleaning {
filter: grayscale(1);
opacity: 0.7;
pointer-events: none;
}
/* --- SVG 图标通用样式 --- */
.svg-icon {
display: inline-flex;
align-items: center;
justify-content: center;
vertical-align: middle;
}
.svg-icon svg {
width: 1.25em;
height: 1.25em;
stroke: currentColor;
stroke-width: 2;
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
}
.svg-icon.big svg {
width: 2.5em;
height: 2.5em;
}
.icon.svg-icon {
margin-right: 12px;
color: inherit;
}
.icon.svg-icon svg {
width: 18px;
height: 18px;
}
</style> </style>