Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
feat: Add Back to Top Button and i18n (#94)
tanmantang0f0c7156c76c
diff --git a/app/components/masonry/Root.vue b/app/components/masonry/Root.vueindex 5282dde1..c054f658 100644--- a/app/components/masonry/Root.vue+++ b/app/components/masonry/Root.vue@@ -1,4 +1,5 @@<script setup lang="ts">+import { motion } from 'motion-v'interface Props {photos: Photo[]columns?: number | 'auto'@@ -81,10 +82,9 @@ const updateHeaderWidth = () => {return}- const columnElement =- masonryWrapper.value?.querySelector<HTMLElement>(- '.masonry-wall .masonry-column',- )+ const columnElement = masonryWrapper.value?.querySelector<HTMLElement>(+ '.masonry-wall .masonry-column',+ )if (columnElement) {headerColumnWidth.value = columnElement.getBoundingClientRect().width@@ -261,7 +261,9 @@ const updateDateRange = () => {} else if (uniqueCities.length <= 3) {visibleCities.value = uniqueCities.join('、')} else {- visibleCities.value = `${uniqueCities.slice(0, 2).join('、')} `+$t('ui.indexPanelCountCity',{ count: uniqueCities.length })+ visibleCities.value =+ `${uniqueCities.slice(0, 2).join('、')} ` ++ $t('ui.indexPanelCountCity', { count: uniqueCities.length })}if (visibleDates.length === 0) {@@ -298,6 +300,13 @@ const handleScroll = () => {showFloatingActions.value = scrollTop > 500}+const scrollToTop = () => {+ window.scrollTo({+ top: 0,+ behavior: 'smooth',+ })+}+onMounted(() => {window.addEventListener('scroll', handleScroll, { passive: true })window.addEventListener('resize', updateHeaderWidth)@@ -363,6 +372,28 @@ watch(currentPhotoIndex, (newIndex) => {:is-mobile="isMobile"/>+ <!-- Back to Top Button -->+ <motion.div+ v-if="showFloatingActions"+ class="fixed bottom-6 right-6 z-50"+ :initial="{ opacity: 0, scale: 0.8 }"+ :animate="{ opacity: 1, scale: 1 }"+ :exit="{ opacity: 0, scale: 0.8 }"+ :transition="{ duration: 0.2 }"+ >+ <UTooltip :text="$t('ui.action.backtotop.tooltip') || '回到顶部'">+ <UButton+ variant="soft"+ color="neutral"+ class="cursor-pointer bg-white/80 dark:bg-neutral-900/80 backdrop-blur-sm flex justify-center items-center rounded-full shadow-lg hover:bg-white dark:hover:bg-neutral-800 transition-all duration-300 border border-neutral-200/50 dark:border-neutral-700/50"+ icon="tabler:arrow-up"+ size="lg"+ :aria-label="$t('ui.action.backtotop.ariaLabel') || '回到顶部'"+ @click="scrollToTop"+ />+ </UTooltip>+ </motion.div>+<divclass="lg:px-0 lg:pb-0":class="isMobile ? 'px-1 pb-1' : 'p-1'"@@ -433,8 +464,8 @@ watch(currentPhotoIndex, (newIndex) => {padding-top: var(--masonry-header-offset, 0px);}-.masonry-wall-with-header :deep(.masonry-column:first-child .masonry-item:first-child) {+.masonry-wall-with-header+ :deep(.masonry-column:first-child .masonry-item:first-child) {margin-top: 0;}</style>-diff --git a/app/pages/albums/[albumId].vue b/app/pages/albums/[albumId].vueindex 4c2db8ee..4d09fc04 100644--- a/app/pages/albums/[albumId].vue+++ b/app/pages/albums/[albumId].vue@@ -115,10 +115,32 @@ const coverPhoto = computed(() => {return album.photos[0] || null})+const scrollToTop = () => {+ window.scrollTo({+ top: 0,+ behavior: 'smooth',+ })+}++const showFloatingActions = ref(false)++const handleScroll = () => {+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop+ showFloatingActions.value = scrollTop > 500+}+const goBackToAlbums = () => {router.push('/albums')}+onMounted(() => {+ window.addEventListener('scroll', handleScroll, { passive: true })+})++onUnmounted(() => {+ window.removeEventListener('scroll', handleScroll)+})+onBeforeMount(() => {useHead({title: albumData.value ? albumData.value.title : 'Album Not Found',@@ -328,6 +350,28 @@ onBeforeMount(() => {</UButton></div></template>++ <!-- Back to Top Button -->+ <motion.div+ v-if="showFloatingActions"+ class="fixed bottom-6 right-6 z-50"+ :initial="{ opacity: 0, scale: 0.8 }"+ :animate="{ opacity: 1, scale: 1 }"+ :exit="{ opacity: 0, scale: 0.8 }"+ :transition="{ duration: 0.2 }"+ >+ <UTooltip :text="$t('ui.action.backtotop.tooltip') || '回到顶部'">+ <UButton+ variant="soft"+ color="neutral"+ class="cursor-pointer bg-white/80 dark:bg-neutral-900/80 backdrop-blur-sm flex justify-center items-center rounded-full shadow-lg hover:bg-white dark:hover:bg-neutral-800 transition-all duration-300 border border-neutral-200/50 dark:border-neutral-700/50"+ icon="tabler:arrow-up"+ size="lg"+ :aria-label="$t('ui.action.backtotop.ariaLabel') || '回到顶部'"+ @click="scrollToTop"+ />+ </UTooltip>+ </motion.div></div></template>diff --git a/i18n/locales/en.json b/i18n/locales/en.jsonindex 4baa6266..c7ccb070 100644--- a/i18n/locales/en.json+++ b/i18n/locales/en.json@@ -101,6 +101,9 @@"text": {"prefix": "Check out this photo:"}+ },+ "backtotop": {+ "tooltip": "Back to Top"}},"stats": {diff --git a/i18n/locales/ja.json b/i18n/locales/ja.jsonindex 1dd28677..b9637ffb 100644--- a/i18n/locales/ja.json+++ b/i18n/locales/ja.json@@ -101,6 +101,9 @@"text": {"prefix": "この写真をご覧ください:"}+ },+ "backtotop": {+ "tooltip": "ページの先頭に戻る"}},"stats": {diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.jsonindex 82d7250c..726d433b 100644--- a/i18n/locales/zh-Hans.json+++ b/i18n/locales/zh-Hans.json@@ -105,6 +105,9 @@"text": {"prefix": "来看看这张照片:"}+ },+ "backtotop": {+ "tooltip": "回到顶部"}},"stats": {diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.jsonindex e1b31dea..9fa172c2 100644--- a/i18n/locales/zh-Hant-HK.json+++ b/i18n/locales/zh-Hant-HK.json@@ -105,6 +105,9 @@"text": {"prefix": "來看看這張相片:"}+ },+ "backtotop": {+ "tooltip": "回到頂部"}},"stats": {diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.jsonindex 1910c867..cd0d5f54 100644--- a/i18n/locales/zh-Hant-TW.json+++ b/i18n/locales/zh-Hant-TW.json@@ -105,6 +105,9 @@"text": {"prefix": "來看看這張相片:"}+ },+ "backToTop": {+ "tooltip": "回到頂部"}},"stats": {