alert before clean browsers

This commit is contained in:
Julian Freeman
2026-04-17 12:05:33 -04:00
parent ab1da1ff0e
commit 8764af1a56
7 changed files with 109 additions and 8 deletions

View File

@@ -3,7 +3,12 @@ import {
startBrowserClean as runBrowserCleanCommand,
startBrowserScan as runBrowserScanCommand,
} from "../services/tauri/cleaner";
import type { AlertOptions, BrowserScanResult, CleanResult } from "../types/cleaner";
import type {
AlertOptions,
BrowserScanResult,
CleanResult,
ConfirmOptions,
} from "../types/cleaner";
import { formatItemSize } from "../utils/format";
interface BrowserState {
@@ -17,6 +22,7 @@ interface BrowserState {
export function useBrowserClean(
browser: "chrome" | "edge",
showAlert: (options: AlertOptions) => void,
requestConfirm: (options: ConfirmOptions) => Promise<boolean>,
) {
const state = ref<BrowserState>({
isScanning: false,
@@ -83,6 +89,19 @@ export function useBrowserClean(
return;
}
const browserName = browser === "chrome" ? "谷歌浏览器" : "微软浏览器";
const confirmed = await requestConfirm({
title: "确认清理浏览器缓存",
message: `即将清理 ${browserName} 的缓存和临时文件。\n\n建议先关闭浏览器以避免部分文件被占用导致清理不完整。\n\n是否继续`,
type: "info",
confirmText: "继续清理",
cancelText: "暂不清理",
});
if (!confirmed) {
return;
}
current.isCleaning = true;
try {
current.cleanResult = await runBrowserCleanCommand(browser, selectedProfiles);