adjust ui
This commit is contained in:
20
src/App.vue
20
src/App.vue
@@ -43,6 +43,7 @@ const fastState = ref({
|
|||||||
const memoryState = ref({
|
const memoryState = ref({
|
||||||
stats: null as MemoryStats | null,
|
stats: null as MemoryStats | null,
|
||||||
isCleaning: false,
|
isCleaning: false,
|
||||||
|
cleaningType: null as 'fast' | 'deep' | null,
|
||||||
lastFreed: "",
|
lastFreed: "",
|
||||||
isDone: false,
|
isDone: false,
|
||||||
});
|
});
|
||||||
@@ -377,18 +378,20 @@ async function getMemoryStats() {
|
|||||||
async function startMemoryClean(deep = false) {
|
async function startMemoryClean(deep = false) {
|
||||||
if (memoryState.value.isCleaning) return;
|
if (memoryState.value.isCleaning) return;
|
||||||
memoryState.value.isCleaning = true;
|
memoryState.value.isCleaning = true;
|
||||||
memoryState.value.isDone = false;
|
memoryState.value.cleaningType = deep ? 'deep' : 'fast';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cmd = deep ? "run_deep_memory_clean" : "run_memory_clean";
|
const cmd = deep ? "run_deep_memory_clean" : "run_memory_clean";
|
||||||
const freedBytes = await invoke<number>(cmd);
|
const freedBytes = await invoke<number>(cmd);
|
||||||
memoryState.value.lastFreed = formatItemSize(freedBytes);
|
memoryState.value.lastFreed = formatItemSize(freedBytes);
|
||||||
memoryState.value.isDone = true;
|
// 使用弹窗显示结果
|
||||||
|
showAlert("优化完成", `已为您释放 ${memoryState.value.lastFreed} 内存空间`, 'success');
|
||||||
await getMemoryStats();
|
await getMemoryStats();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showAlert("清理失败", String(err), 'error');
|
showAlert("清理失败", String(err), 'error');
|
||||||
} finally {
|
} finally {
|
||||||
memoryState.value.isCleaning = false;
|
memoryState.value.isCleaning = false;
|
||||||
|
memoryState.value.cleaningType = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,7 +723,7 @@ watch(activeTab, (newTab) => {
|
|||||||
<!-- 扫描完成 -->
|
<!-- 扫描完成 -->
|
||||||
<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">
|
||||||
@@ -782,7 +785,7 @@ watch(activeTab, (newTab) => {
|
|||||||
</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">
|
||||||
@@ -978,7 +981,7 @@ watch(activeTab, (newTab) => {
|
|||||||
<p>压缩所有进程的内存工作集,释放物理内存,不影响程序运行。</p>
|
<p>压缩所有进程的内存工作集,释放物理内存,不影响程序运行。</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn-primary" @click="startMemoryClean(false)" :disabled="memoryState.isCleaning">
|
<button class="btn-primary" @click="startMemoryClean(false)" :disabled="memoryState.isCleaning">
|
||||||
{{ memoryState.isCleaning ? '清理中...' : '立即加速' }}
|
{{ memoryState.cleaningType === 'fast' ? '清理中...' : '立即加速' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -988,16 +991,11 @@ watch(activeTab, (newTab) => {
|
|||||||
<p>强制清空系统备用列表(待机列表),释放更多被缓存的物理空间。</p>
|
<p>强制清空系统备用列表(待机列表),释放更多被缓存的物理空间。</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn-secondary" @click="startMemoryClean(true)" :disabled="memoryState.isCleaning">
|
<button class="btn-secondary" @click="startMemoryClean(true)" :disabled="memoryState.isCleaning">
|
||||||
深度加速
|
{{ memoryState.cleaningType === 'deep' ? '清理中...' : '深度加速' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clean-feedback" v-if="memoryState.isDone">
|
|
||||||
<span class="success-icon">✨</span>
|
|
||||||
优化完成!已为您释放 <span class="freed-amount">{{ memoryState.lastFreed }}</span> 内存空间
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- 5. 其他占位 -->
|
<!-- 5. 其他占位 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user