alert before clean recycle.bin

This commit is contained in:
Julian Freeman
2026-04-17 12:10:24 -04:00
parent 8764af1a56
commit 54b8701644
3 changed files with 35 additions and 5 deletions

View File

@@ -139,7 +139,11 @@ async function searchNode(provider: "google" | "perplexity") {
/>
<main class="content">
<FastCleanPage v-if="activeTab === 'clean-c-fast'" :show-alert="showAlert" />
<FastCleanPage
v-if="activeTab === 'clean-c-fast'"
:show-alert="showAlert"
:request-confirm="requestConfirm"
/>
<AdvancedCleanPage v-else-if="activeTab === 'clean-c-advanced'" :show-alert="showAlert" />
<BrowserCleanPage
v-else-if="activeTab === 'clean-browser-chrome'"

View File

@@ -1,6 +1,11 @@
import { computed, ref } from "vue";
import { startFastClean as runFastCleanCommand, startFastScan as runFastScanCommand } from "../services/tauri/cleaner";
import type { AlertOptions, CleanResult, FastScanResult } from "../types/cleaner";
import type {
AlertOptions,
CleanResult,
ConfirmOptions,
FastScanResult,
} from "../types/cleaner";
import { formatItemSize } from "../utils/format";
interface FastState {
@@ -12,7 +17,10 @@ interface FastState {
cleanResult: CleanResult | null;
}
export function useFastClean(showAlert: (options: AlertOptions) => void) {
export function useFastClean(
showAlert: (options: AlertOptions) => void,
requestConfirm: (options: ConfirmOptions) => Promise<boolean>,
) {
const state = ref<FastState>({
isScanning: false,
isCleaning: false,
@@ -82,6 +90,20 @@ export function useFastClean(showAlert: (options: AlertOptions) => void) {
return;
}
if (selectedPaths.includes("C:\\$Recycle.Bin")) {
const confirmed = await requestConfirm({
title: "确认清空回收站",
message: "当前勾选项包含回收站。\n\n清空后回收站中的文件将被永久删除通常无法直接恢复。\n\n是否继续清理",
type: "info",
confirmText: "继续清理",
cancelText: "返回检查",
});
if (!confirmed) {
return;
}
}
current.isCleaning = true;
try {
current.cleanResult = await runFastCleanCommand(selectedPaths);

View File

@@ -1,13 +1,17 @@
<script setup lang="ts">
import { useFastClean } from "../composables/useFastClean";
import type { AlertOptions } from "../types/cleaner";
import type { AlertOptions, ConfirmOptions } from "../types/cleaner";
import { splitSize, formatItemSize } from "../utils/format";
const props = defineProps<{
showAlert: (options: AlertOptions) => void;
requestConfirm: (options: ConfirmOptions) => Promise<boolean>;
}>();
const { state, selectedStats, startScan, startClean, reset } = useFastClean(props.showAlert);
const { state, selectedStats, startScan, startClean, reset } = useFastClean(
props.showAlert,
props.requestConfirm,
);
</script>
<template>