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(reaction): improve reaction button and picker
Timothy Yin997e33aa5d9a
diff --git a/app/components/photo/ReactionPicker.vue b/app/components/photo/ReactionPicker.vueindex a79ffc0a..0fab426b 100644--- a/app/components/photo/ReactionPicker.vue+++ b/app/components/photo/ReactionPicker.vue@@ -10,6 +10,7 @@ interface Reaction {interface Props {isOpen: boolean+ triggerEl?: HTMLElement | nullselectedReaction?: string | nullreactionCounts?: Record<string, number>}@@ -24,11 +25,17 @@ const emit = defineEmits<{const pickerRef = ref<HTMLElement | null>(null)// 点击外部时关闭-onClickOutside(pickerRef, () => {- if (props.isOpen) {- emit('close')- }-})+onClickOutside(+ pickerRef,+ () => {+ if (props.isOpen) {+ emit('close')+ }+ },+ {+ ignore: computed(() => (props.triggerEl ? [props.triggerEl] : [])),+ },+)// 可用的表态选项const reactions = computed<Reaction[]>(() => [@@ -117,10 +124,10 @@ const handleSelect = (id: string) => {@click.stop><div- class="bg-white/90 dark:bg-neutral-800/90 backdrop-blur-xl rounded-2xl border border-neutral-200/50 dark:border-white/10 shadow-2xl shadow-black/10 dark:shadow-black/30 p-3"+ class="bg-white/95 dark:bg-neutral-800/90 backdrop-blur-xl rounded-2xl border border-neutral-300/60 dark:border-white/10 shadow-2xl shadow-black/10 dark:shadow-black/30 p-3"><!-- 表态网格 -->- <div class="grid grid-cols-4 gap-2 min-w-[220px]">+ <div class="grid grid-cols-4 gap-2 min-w-55"><motion.buttonv-for="reaction in reactions":key="reaction.id"@@ -153,7 +160,7 @@ const handleSelect = (id: string) => {},}":class="[- 'relative aspect-square w-full min-w-[48px] rounded-xl flex items-center justify-center transition-colors cursor-pointer shrink-0 group',+ 'relative aspect-square w-full min-w-12 rounded-xl flex items-center justify-center transition-colors cursor-pointer shrink-0 group/reaction','hover:bg-neutral-100/80 dark:hover:bg-white/10','active:bg-neutral-200/80 dark:active:bg-white/20',selectedReaction === reaction.id@@ -169,20 +176,27 @@ const handleSelect = (id: string) => {mode="svg"/>+ <!-- 表情 label:移动端常显,桌面端悬浮显示 -->+ <span+ class="absolute left-1/2 -bottom-1.5 -translate-x-1/2 pointer-events-none select-none whitespace-nowrap text-xs sm:text-[10px] font-medium leading-none text-neutral-600/70 md:text-neutral-500/85 dark:text-neutral-400/80 opacity-100 transition-opacity duration-200 md:opacity-0 md:group-hover/reaction:opacity-100"+ >+ {{ reaction.label }}+ </span>+<!-- 数量徽章 - 右上角 --><motion.spanv-if="reaction.count !== undefined && reaction.count > 0":initial="{ scale: 0, opacity: 0 }":animate="{ scale: 1, opacity: 1 }":class="[- 'absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1',+ 'absolute -top-1 -right-1 min-w-4.5 h-4.5 px-1','flex items-center justify-center','text-[9px] font-bold leading-none','rounded-full','shadow-sm',selectedReaction === reaction.id? 'bg-blue-500 text-white'- : 'bg-gradient-to-br from-neutral-100 to-neutral-200 dark:from-neutral-700 dark:to-neutral-600 text-neutral-700 dark:text-neutral-100',+ : 'bg-linear-to-br from-neutral-100 to-neutral-200 dark:from-neutral-700 dark:to-neutral-600 text-neutral-700 dark:text-neutral-100','border border-white/50 dark:border-neutral-800/50','group-hover:scale-110 transition-transform duration-150',]"diff --git a/app/components/photo/Viewer.vue b/app/components/photo/Viewer.vueindex ef20872c..f33b7798 100644--- a/app/components/photo/Viewer.vue+++ b/app/components/photo/Viewer.vue@@ -41,6 +41,8 @@ const showZoomLevel = ref(false)const zoomLevelTimer = ref<NodeJS.Timeout | null>(null)const showReactionPicker = ref(false)+const reactionButtonRef = ref<HTMLButtonElement | null>(null)+const shouldCloseReactionPickerOnClick = ref(false)const selectedReaction = ref<string | null>(null)const reactionCounts = ref<Record<string, number>>({})const isLoadingReaction = ref(false)@@ -484,9 +486,19 @@ const handleReactionSelect = async (reactionId: string, iconName: string) => {}const toggleReactionPicker = () => {+ if (shouldCloseReactionPickerOnClick.value) {+ showReactionPicker.value = false+ shouldCloseReactionPickerOnClick.value = false+ return+ }+showReactionPicker.value = !showReactionPicker.value}+const handleReactionButtonPointerDown = () => {+ shouldCloseReactionPickerOnClick.value = showReactionPicker.value+}+// 监听当前照片变化,加载表态数据watch(() => currentPhoto.value?.id,@@ -834,6 +846,7 @@ const swiperModules = [Navigation, Keyboard, Virtual]<!-- 表态选择器 --><ReactionPicker:is-open="showReactionPicker"+ :trigger-el="reactionButtonRef":selected-reaction="selectedReaction":reaction-counts="reactionCounts"@select="handleReactionSelect"@@ -849,6 +862,7 @@ const swiperModules = [Navigation, Keyboard, Virtual]<!-- 表态按钮 --><motion.button+ ref="reactionButtonRef"type="button":initial="{ scale: 0.8, opacity: 0 }":animate="{@@ -877,6 +891,7 @@ const swiperModules = [Navigation, Keyboard, Virtual]: 'bg-white/90 dark:bg-neutral-800/90 border-neutral-200/50 dark:border-white/10 text-neutral-700 dark:text-white/80 shadow-black/10 dark:shadow-black/30','hover:shadow-xl',]"+ @pointerdown="handleReactionButtonPointerDown"@click="toggleReactionPicker"><Icon