alert before clean browsers
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user