diff --git a/src/router/index.ts b/src/router/index.ts index 1fc6435..da44c1c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -120,6 +120,12 @@ const router = createRouter({ component: () => import('@/views/system/ForbiddenView.vue'), meta: { title: '无权访问', noindex: true }, }, + { + path: '/401', + name: 'auth-required', + component: () => import('@/views/system/AuthRequiredView.vue'), + meta: { title: '需要登录', noindex: true }, + }, { path: '/:pathMatch(.*)*', name: 'not-found', @@ -136,7 +142,12 @@ router.beforeEach((to, _from, next) => { const authStore = useAuthStore() if (to.meta.requiresAuth && !authStore.isLoggedIn) { - next({ name: 'login', query: { redirect: to.fullPath } }) + next({ + name: 'auth-required', + query: { + redirect: to.fullPath, + }, + }) } else if (to.meta.requiresAdmin && !authStore.isAdmin) { next({ name: 'forbidden' }) } else if ((to.name === 'login' || to.name === 'register') && authStore.isLoggedIn) { diff --git a/src/views/map/MapView.vue b/src/views/map/MapView.vue index 5ed6484..2461b70 100644 --- a/src/views/map/MapView.vue +++ b/src/views/map/MapView.vue @@ -5,6 +5,7 @@ import MiniLocationMap from '@/components/cloud/MiniLocationMap.vue' import QuickUploadModal from '@/components/cloud/QuickUploadModal.vue' import { supabase } from '@/lib/supabase' import { loadAMap } from '@/lib/amap' +import { useAuthStore } from '@/stores/auth' import { NIcon } from 'naive-ui' import { Adjustments, Calendar, CloudUpload, Refresh, Map, Satellite, X } from '@vicons/tabler' @@ -24,6 +25,7 @@ interface CloudMarkerData { } const mapEl = ref() +const authStore = useAuthStore() const previewCloud = ref(null) const satelliteOn = ref(false) const statusText = ref('加载中...') @@ -70,7 +72,6 @@ const archiveTitle = computed(() => { if (mapMode.value === 'realtime') return '实时' return archiveKind.value === 'day' ? archiveDay.value : archiveMonth.value }) - function getMinuteOfDay(date: Date) { return date.getHours() * 60 + date.getMinutes() } @@ -344,6 +345,7 @@ function toggleSat() { } function openQuickUpload() { + if (authStore.loading || !authStore.isLoggedIn) return quickUploadOpen.value = true } @@ -446,9 +448,11 @@ onUnmounted(() => {