|
|
@@ -139,7 +139,7 @@
|
|
|
<div ref="refreshControlRef" class="refresh-control">
|
|
|
<button
|
|
|
class="refresh-btn"
|
|
|
- :disabled="loading"
|
|
|
+ :disabled="loading || refreshing"
|
|
|
@click="handleManualRefresh"
|
|
|
@contextmenu.prevent="handleRefreshContextMenu"
|
|
|
>
|
|
|
@@ -232,6 +232,8 @@ const getInitialRefreshInterval = () => {
|
|
|
const currentLevel = ref(getInitialLevel())
|
|
|
const locations = ref<LocationResourceDataVO[]>([])
|
|
|
const loading = ref(false)
|
|
|
+const refreshing = ref(false)
|
|
|
+const hasLoadedOnce = ref(false)
|
|
|
const error = ref('')
|
|
|
const showLoginModal = ref(false)
|
|
|
const selectedCategory = ref('')
|
|
|
@@ -327,25 +329,39 @@ const refreshCountdownText = computed(() => {
|
|
|
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`
|
|
|
})
|
|
|
|
|
|
-const loadLocationData = async () => {
|
|
|
+const loadLocationData = async (options: { silent?: boolean } = {}) => {
|
|
|
+ const { silent = false } = options
|
|
|
if (!isAuthenticated()) {
|
|
|
showLoginModal.value = true
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- loading.value = true
|
|
|
- error.value = ''
|
|
|
+ const shouldUseSilentRefresh = silent && hasLoadedOnce.value
|
|
|
+ if (shouldUseSilentRefresh) {
|
|
|
+ refreshing.value = true
|
|
|
+ } else {
|
|
|
+ loading.value = true
|
|
|
+ error.value = ''
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
const data = await fetchLocationData({
|
|
|
warehouse: config.warehouse,
|
|
|
locLevel: currentLevel.value
|
|
|
})
|
|
|
locations.value = data
|
|
|
+ hasLoadedOnce.value = true
|
|
|
} catch (err: any) {
|
|
|
- error.value = err.message || '加载数据失败,请检查接口连接'
|
|
|
+ if (!shouldUseSilentRefresh) {
|
|
|
+ error.value = err.message || '加载数据失败,请检查接口连接'
|
|
|
+ }
|
|
|
console.error('Failed to load location data:', err)
|
|
|
} finally {
|
|
|
- loading.value = false
|
|
|
+ if (shouldUseSilentRefresh) {
|
|
|
+ refreshing.value = false
|
|
|
+ } else {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -355,7 +371,7 @@ const scheduleNextRefresh = () => {
|
|
|
}
|
|
|
nextRefreshAt.value = Date.now() + refreshIntervalMs.value
|
|
|
refreshTimer = window.setTimeout(async () => {
|
|
|
- await loadLocationData()
|
|
|
+ await loadLocationData({ silent: true })
|
|
|
scheduleNextRefresh()
|
|
|
}, refreshIntervalMs.value)
|
|
|
}
|
|
|
@@ -367,7 +383,7 @@ const handleLevelChange = () => {
|
|
|
}
|
|
|
|
|
|
const handleManualRefresh = () => {
|
|
|
- loadLocationData()
|
|
|
+ loadLocationData({ silent: true })
|
|
|
scheduleNextRefresh()
|
|
|
}
|
|
|
|
|
|
@@ -450,6 +466,9 @@ const handleLogout = () => {
|
|
|
}
|
|
|
removeToken()
|
|
|
locations.value = []
|
|
|
+ hasLoadedOnce.value = false
|
|
|
+ loading.value = false
|
|
|
+ refreshing.value = false
|
|
|
showLoginModal.value = true
|
|
|
}
|
|
|
|