优化刷盘显示
This commit is contained in:
@@ -47,6 +47,13 @@ export async function flushIndex() {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchFlushStatus() {
|
||||||
|
const { data } = await axios.get(`${BASE}/admin/flush/status`, {
|
||||||
|
timeout: 5000,
|
||||||
|
})
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchWorkers() {
|
export async function fetchWorkers() {
|
||||||
const { data } = await axios.get(`${BASE}/admin/workers`, {
|
const { data } = await axios.get(`${BASE}/admin/workers`, {
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onUnmounted } from 'vue'
|
import { ref, onMounted, onUnmounted } from 'vue'
|
||||||
import { fetchStats, flushIndex, fetchWorkers, setWorkers, fetchBacklink, triggerBacklink, fetchPriorityStatus } from '../api.js'
|
import { fetchStats, flushIndex, fetchFlushStatus, fetchWorkers, setWorkers, fetchBacklink, triggerBacklink, fetchPriorityStatus } from '../api.js'
|
||||||
|
|
||||||
const stats = ref(null)
|
const stats = ref(null)
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
@@ -131,7 +131,13 @@ async function doFlush() {
|
|||||||
flushing.value = true
|
flushing.value = true
|
||||||
try {
|
try {
|
||||||
await flushIndex()
|
await flushIndex()
|
||||||
// 重新拉取 stats,pending 应该归零
|
// 轮询刷盘状态,直到完成
|
||||||
|
while (true) {
|
||||||
|
await new Promise(r => setTimeout(r, 500)) // 等待 500ms
|
||||||
|
const status = await fetchFlushStatus()
|
||||||
|
if (!status.flushing) break
|
||||||
|
}
|
||||||
|
// 刷盘完成,重新拉取 stats
|
||||||
stats.value = await fetchStats()
|
stats.value = await fetchStats()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error.value = '刷盘失败: ' + e.message
|
error.value = '刷盘失败: ' + e.message
|
||||||
|
|||||||
Reference in New Issue
Block a user