show scan progress
This commit is contained in:
31
src/App.vue
31
src/App.vue
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { ref, onUnmounted } from "vue";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import pkg from "../package.json";
|
||||
|
||||
@@ -25,6 +26,7 @@ const isCleaning = ref(false);
|
||||
const isCleanDone = ref(false);
|
||||
const isFullScanning = ref(false);
|
||||
const scanProgress = ref(0);
|
||||
const fullScanProgress = ref({ fileCount: 0, currentPath: "" });
|
||||
const fastScanResult = ref<FastScanResult | null>(null);
|
||||
const cleanResult = ref<CleanResult | null>(null);
|
||||
const treeData = ref<FileNode[]>([]);
|
||||
@@ -174,6 +176,14 @@ async function runAdvancedTask(task: string) {
|
||||
async function startFullDiskScan() {
|
||||
isFullScanning.value = true;
|
||||
treeData.value = [];
|
||||
fullScanProgress.value = { fileCount: 0, currentPath: "" };
|
||||
|
||||
// 监听进度
|
||||
const unlisten = await listen<{file_count: number, current_path: string}>("scan-progress", (event) => {
|
||||
fullScanProgress.value.fileCount = event.payload.file_count;
|
||||
fullScanProgress.value.currentPath = event.payload.current_path;
|
||||
});
|
||||
|
||||
try {
|
||||
await invoke("start_full_disk_scan");
|
||||
const rootChildren = await invoke<FileNode[]>("get_tree_children", { path: "C:\\" });
|
||||
@@ -182,6 +192,7 @@ async function startFullDiskScan() {
|
||||
alert("扫描失败,请确保以管理员身份运行。");
|
||||
} finally {
|
||||
isFullScanning.value = false;
|
||||
unlisten();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +513,7 @@ function splitSize(sizeStr: string | number) {
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<button class="btn-primary btn-sm" @click="startFullDiskScan" :disabled="isFullScanning">
|
||||
{{ isFullScanning ? '正在扫描...' : '开始深度分析' }}
|
||||
{{ isFullScanning ? '正在扫描...' : '开始扫描' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -510,7 +521,15 @@ function splitSize(sizeStr: string | number) {
|
||||
<div class="tree-table-container shadow-card" v-if="treeData.length > 0 || isFullScanning">
|
||||
<div v-if="isFullScanning" class="scanning-overlay">
|
||||
<div class="spinner"></div>
|
||||
<p>正在分析数百万个文件,请稍候...</p>
|
||||
<div class="scanning-status">
|
||||
<p class="scanning-main-text">正在扫描全盘文件...</p>
|
||||
<div class="scanning-stats-row">
|
||||
<span class="stat-badge">已扫描:{{ fullScanProgress.fileCount.toLocaleString() }} 个文件</span>
|
||||
</div>
|
||||
<p class="scanning-current-path" v-if="fullScanProgress.currentPath">
|
||||
当前:{{ fullScanProgress.currentPath }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="tree-content-wrapper">
|
||||
@@ -1013,6 +1032,12 @@ body {
|
||||
|
||||
/* --- 通用状态 --- */
|
||||
.scanning-loader, .scanning-overlay { padding: 100px 40px; text-align: center; color: var(--text-sec); }
|
||||
.scanning-status { margin-top: 16px; }
|
||||
.scanning-main-text { font-size: 16px; font-weight: 600; color: var(--text-main); margin-bottom: 12px; }
|
||||
.scanning-stats-row { margin-bottom: 16px; }
|
||||
.stat-badge { background: #EBF4FF; color: var(--primary-color); padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 700; }
|
||||
.scanning-current-path { font-size: 12px; color: var(--text-sec); max-width: 500px; margin: 0 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; opacity: 0.8; }
|
||||
|
||||
.spinner {
|
||||
width: 44px; height: 44px;
|
||||
border: 3px solid #F2F2F7;
|
||||
|
||||
Reference in New Issue
Block a user