fix: browse序号保护防止token刷新重试导致的双刷新

This commit is contained in:
Your Name
2026-06-02 03:48:01 +08:00
parent 1d6d26d612
commit 3bc2843642
+9
View File
@@ -851,8 +851,12 @@ function openInTerminal() {
})
}
// 序号保护:防止并发/重试请求导致旧结果覆盖新结果
let _browseSeq = 0
async function browse() {
if (!selectedServer.value) return
const seq = ++_browseSeq
loading.value = true
const path = normalizeRemotePath(currentPath.value)
currentPath.value = path
@@ -861,6 +865,8 @@ async function browse() {
server_id: selectedServer.value,
path,
})
// 如果期间启动了更新的 browse(token刷新重试/快速导航),丢弃本次结果
if (seq !== _browseSeq) return
const { items, error } = parseBrowseResponse(res)
// Auto-fallback: if path doesn't exist, try parent directories automatically
@@ -886,12 +892,15 @@ async function browse() {
preloadDirectoryFiles(selectedServer.value, path, items)
}
} catch {
if (seq !== _browseSeq) return
files.value = []
snackbar('浏览目录失败', 'error')
} finally {
if (seq === _browseSeq) {
loading.value = false
syncRouteQuery()
}
}
}
/** 判断 ls 报错是否为「路径不存在」(与权限无关) */