|
|
@@ -3,13 +3,18 @@
|
|
|
<LoginModal
|
|
|
:visible="showLoginModal"
|
|
|
@success="handleLoginSuccess"
|
|
|
+ @environment-change="handleEnvironmentChange"
|
|
|
@cancel="handleLoginCancel"
|
|
|
/>
|
|
|
|
|
|
- <header class="header">
|
|
|
+ <header
|
|
|
+ v-if="!showLoginModal"
|
|
|
+ class="header"
|
|
|
+ >
|
|
|
<h1 class="title">
|
|
|
{{ systemTitle }}
|
|
|
- <span class="title-meta">库位 <span class="title-meta-value">{{ availableLocationsCount }}/{{ locations.length }}</span></span>
|
|
|
+ <span class="title-meta">库位
|
|
|
+ <span class="title-meta-value">{{ availableLocationsCount }}/{{ locations.length }}</span></span>
|
|
|
<span class="title-fill-rate">
|
|
|
<span
|
|
|
class="title-meta title-fill-rate-item"
|
|
|
@@ -321,7 +326,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <main class="main-content">
|
|
|
+ <main
|
|
|
+ v-if="!showLoginModal"
|
|
|
+ class="main-content"
|
|
|
+ >
|
|
|
<div
|
|
|
v-if="loading"
|
|
|
class="loading"
|
|
|
@@ -375,7 +383,7 @@ import type { LocationAttributeCode, LocationResourceDataVO } from './types'
|
|
|
import WarehouseMap from './components/WarehouseMap.vue'
|
|
|
import LoginModal from './components/LoginModal.vue'
|
|
|
import { config } from './config'
|
|
|
-import { getApiEnvironment, isAuthenticated, removeToken } from './utils/auth'
|
|
|
+import { AUTH_INVALID_EVENT, getApiEnvironment, isAuthenticated, removeToken } from './utils/auth'
|
|
|
|
|
|
const LEVEL_STORAGE_KEY = 'warehouse-map.current-level'
|
|
|
const REFRESH_INTERVAL_STORAGE_KEY = 'warehouse-map.refresh-interval-ms'
|
|
|
@@ -791,6 +799,10 @@ const handleLoginCancel = () => {
|
|
|
// 不允许取消登录,必须登录才能使用
|
|
|
}
|
|
|
|
|
|
+const handleEnvironmentChange = (environment: 'sit' | 'prod') => {
|
|
|
+ currentEnvironment.value = environment
|
|
|
+}
|
|
|
+
|
|
|
const handleLogout = () => {
|
|
|
if (refreshTimer !== null) {
|
|
|
window.clearTimeout(refreshTimer)
|
|
|
@@ -804,11 +816,24 @@ const handleLogout = () => {
|
|
|
showLoginModal.value = true
|
|
|
}
|
|
|
|
|
|
+const handleAuthInvalid = () => {
|
|
|
+ if (refreshTimer !== null) {
|
|
|
+ window.clearTimeout(refreshTimer)
|
|
|
+ refreshTimer = null
|
|
|
+ }
|
|
|
+ locations.value = []
|
|
|
+ hasLoadedOnce.value = false
|
|
|
+ loading.value = false
|
|
|
+ refreshing.value = false
|
|
|
+ showLoginModal.value = true
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
countdownTimer = window.setInterval(() => {
|
|
|
now.value = Date.now()
|
|
|
}, 1000)
|
|
|
document.addEventListener('mousedown', handleDocumentClick)
|
|
|
+ window.addEventListener(AUTH_INVALID_EVENT, handleAuthInvalid)
|
|
|
|
|
|
if (!isAuthenticated()) {
|
|
|
showLoginModal.value = true
|
|
|
@@ -834,6 +859,7 @@ onBeforeUnmount(() => {
|
|
|
window.clearInterval(countdownTimer)
|
|
|
}
|
|
|
document.removeEventListener('mousedown', handleDocumentClick)
|
|
|
+ window.removeEventListener(AUTH_INVALID_EVENT, handleAuthInvalid)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
@@ -1270,7 +1296,6 @@ onBeforeUnmount(() => {
|
|
|
transform: translateX(16px);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
.level-select:hover,
|
|
|
.level-select:focus {
|
|
|
background: var(--input-hover-bg);
|