Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat: 优化仪表盘移动端的样式和交互

Timothy Yinbbd56ccac696
diff --git a/app/layouts/dashboard.vue b/app/layouts/dashboard.vue
index 9f4da5be..25d6354a 100644
--- a/app/layouts/dashboard.vue
+++ b/app/layouts/dashboard.vue
@@ -1,5 +1,6 @@
<script lang="ts" setup>
import type { NavigationMenuItem } from '@nuxt/ui'
+import { motion } from 'motion-v'
const items = ref<NavigationMenuItem[]>([
{
@@ -19,56 +20,154 @@ const items = ref<NavigationMenuItem[]>([
},
])
+const isMobileMenuOpen = ref(false)
+
useHead({
title: "Dashboard",
titleTemplate: (title) => `${title} - TimoYin's mems`,
})
+const route = useRoute()
const { loggedIn, user } = useUserSession()
+const isRouteActive = (itemPath: string) => {
+ if (itemPath === '/dashboard') {
+ return route.path === '/dashboard'
+ }
+ return route.path.startsWith(itemPath)
+}
+
const handleLogin = () => {
window.location.href = '/api/auth/github'
}
+
+const toggleMobileMenu = () => {
+ isMobileMenuOpen.value = !isMobileMenuOpen.value
+}
+
+const closeMobileMenu = () => {
+ isMobileMenuOpen.value = false
+}
</script>
<template>
<header
v-if="loggedIn"
- class="w-full px-4 border-b border-default flex items-center gap-4"
+ class="w-full px-4 border-b border-default"
>
- <div class="flex items-center gap-2">
- <Icon
- name="tabler:photo-circle"
- class="size-6 text-primary"
+ <!-- 桌面端导航 -->
+ <div class="hidden md:flex items-center gap-4">
+ <div class="flex items-center gap-2">
+ <Icon
+ name="tabler:photo-circle"
+ class="size-6 text-primary"
+ />
+ <NuxtLink
+ to="/"
+ class="text-lg font-medium text-nowrap"
+ >
+ TimoYin's mems
+ </NuxtLink>
+ </div>
+ <UNavigationMenu
+ variant="pill"
+ :items="items"
+ :ui="{
+ viewportWrapper: 'max-w-5xl',
+ }"
+ class="w-full"
/>
- <NuxtLink
- to="/"
- class="text-lg font-medium text-nowrap"
+ </div>
+
+ <!-- 移动端导航 -->
+ <div class="md:hidden">
+ <!-- 移动端顶部栏 -->
+ <div class="flex items-center justify-between py-3">
+ <div class="flex items-center gap-2">
+ <Icon
+ name="tabler:photo-circle"
+ class="size-6 text-primary"
+ />
+ <NuxtLink
+ to="/"
+ class="text-lg font-medium"
+ >
+ TimoYin's mems
+ </NuxtLink>
+ </div>
+ <UButton
+ variant="ghost"
+ size="sm"
+ :icon="isMobileMenuOpen ? 'tabler:x' : 'tabler:menu-2'"
+ @click="toggleMobileMenu"
+ />
+ </div>
+
+ <!-- 移动端下拉菜单 -->
+ <AnimatePresence>
+ <motion.div
+ v-if="isMobileMenuOpen"
+ :initial="{ opacity: 0, y: -10, height: 0 }"
+ :animate="{ opacity: 1, y: 0, height: 'auto' }"
+ :exit="{ opacity: 0, y: -10, height: 0 }"
+ :transition="{
+ duration: 0.3,
+ ease: 'easeOut',
+ height: { duration: 0.2 }
+ }"
+ class="border-t border-default bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 overflow-hidden"
>
- TimoYin's mems
- </NuxtLink>
+ <nav class="py-2">
+ <motion.div
+ v-for="(item, index) in items"
+ :key="index"
+ :initial="{ opacity: 0, x: -20 }"
+ :animate="{ opacity: 1, x: 0 }"
+ :transition="{
+ duration: 0.2,
+ delay: index * 0.06,
+ ease: 'easeOut'
+ }"
+ >
+ <NuxtLink
+ :to="item.to"
+ :class="[
+ 'flex items-center gap-3 px-4 py-3 text-sm font-medium transition-colors',
+ isRouteActive(item.to as string)
+ ? 'bg-primary/10 text-primary border-r-2 border-primary'
+ : 'hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300'
+ ]"
+ @click="closeMobileMenu"
+ >
+ <Icon
+ :name="item.icon!"
+ :class="[
+ 'size-5',
+ isRouteActive(item.to as string)
+ ? 'text-primary'
+ : 'text-gray-500'
+ ]"
+ />
+ <span>{{ item.label }}</span>
+ </NuxtLink>
+ </motion.div>
+ </nav>
+ </motion.div>
+ </AnimatePresence>
</div>
- <UNavigationMenu
- variant="pill"
- :items="items"
- :ui="{
- viewportWrapper: 'max-w-5xl',
- }"
- class="w-full"
- />
</header>
<main v-if="loggedIn && user?.isAdmin">
<NuxtPage />
</main>
<div
v-else
- class="h-svh flex flex-col gap-4 items-center justify-center"
+ class="h-svh flex flex-col gap-4 items-center justify-center px-4"
>
<Icon
name="tabler:alert-triangle"
class="size-12 text-primary"
/>
- <p class="text-gray-500">
+ <p class="text-gray-500 text-center">
{{
!user?.isAdmin
? 'Please login to view dashboard'
diff --git a/app/pages/dashboard/location.vue b/app/pages/dashboard/location.vue
index 7b02901a..0eae95b1 100644
--- a/app/pages/dashboard/location.vue
+++ b/app/pages/dashboard/location.vue
@@ -222,6 +222,7 @@ const formatPercentage = (value: string) => {
<div class="flex gap-3">
<UButton
+ size="sm"
icon="i-tabler-refresh"
:loading="isReindexing"
:disabled="
@@ -229,10 +230,11 @@ const formatPercentage = (value: string) => {
"
@click="startReindex(false)"
>
- 重新索引缺失的位置信息
+ 索引缺少的城市信息
</UButton>
<UButton
+ size="sm"
icon="i-tabler-reload"
variant="outline"
:loading="isReindexing"
@@ -241,7 +243,7 @@ const formatPercentage = (value: string) => {
"
@click="startReindex(true)"
>
- 强制重新索引所有
+ 重建位置信息
</UButton>
</div>
</div>