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(minimap): 根据拍摄时间动态调整小地图光照预设
Timothy Yin7812a9912395
diff --git a/app/components/photo/InfoPanel.vue b/app/components/photo/InfoPanel.vueindex cee636fe..d5a07ef8 100644--- a/app/components/photo/InfoPanel.vue+++ b/app/components/photo/InfoPanel.vue@@ -59,37 +59,40 @@ const formatExposureTime = (const formatGPSCoordinates = (latitude: number, longitude: number): string => {const latDirection = latitude >= 0 ? 'N' : 'S'const lngDirection = longitude >= 0 ? 'E' : 'W'-+const latDegrees = Math.abs(latitude)const lngDegrees = Math.abs(longitude)-+const latDeg = Math.floor(latDegrees)const latMin = Math.floor((latDegrees - latDeg) * 60)const latSec = ((latDegrees - latDeg) * 60 - latMin) * 60-+const lngDeg = Math.floor(lngDegrees)const lngMin = Math.floor((lngDegrees - lngDeg) * 60)const lngSec = ((lngDegrees - lngDeg) * 60 - lngMin) * 60-+return `${latDeg}°${latMin}'${latSec.toFixed(2)}"${latDirection}, ${lngDeg}°${lngMin}'${lngSec.toFixed(2)}"${lngDirection}`}// 格式化GPS坐标为两行显示-const formatGPSCoordinatesMultiLine = (latitude: number, longitude: number): string => {+const formatGPSCoordinatesMultiLine = (+ latitude: number,+ longitude: number,+): string => {const latDirection = latitude >= 0 ? 'N' : 'S'const lngDirection = longitude >= 0 ? 'E' : 'W'-+const latDegrees = Math.abs(latitude)const lngDegrees = Math.abs(longitude)-+const latDeg = Math.floor(latDegrees)const latMin = Math.floor((latDegrees - latDeg) * 60)const latSec = ((latDegrees - latDeg) * 60 - latMin) * 60-+const lngDeg = Math.floor(lngDegrees)const lngMin = Math.floor((lngDegrees - lngDeg) * 60)const lngSec = ((lngDegrees - lngDeg) * 60 - lngMin) * 60-+return `${latDeg}°${latMin}'${latSec.toFixed(2)}"${latDirection}\n${lngDeg}°${lngMin}'${lngSec.toFixed(2)}"${lngDirection}`}@@ -101,7 +104,7 @@ const gpsCoordinates = computed(() => {longitude: props.currentPhoto.longitude,}}-+// 如果数据库中没有,尝试从EXIF数据中获取if (!props.exifData) return nullconst { GPSLatitude, GPSLongitude } = props.exifData@@ -204,7 +207,10 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {props.currentPhoto.latitude && props.currentPhoto.longitude? {label: '坐标',- value: formatGPSCoordinatesMultiLine(props.currentPhoto.latitude, props.currentPhoto.longitude),+ value: formatGPSCoordinatesMultiLine(+ props.currentPhoto.latitude,+ props.currentPhoto.longitude,+ ),icon: 'tabler:gps',}: null,@@ -257,14 +263,20 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {props.exifData?.Make && props.exifData?.Model? {label: '相机',- value: formatCameraInfo(props.exifData.Make, props.exifData.Model),+ value: formatCameraInfo(+ props.exifData.Make,+ props.exifData.Model,+ ),icon: 'tabler:camera',}: null,props.exifData?.LensModel? {label: '镜头',- value: formatLensInfo(props.exifData.LensMake, props.exifData.LensModel),+ value: formatLensInfo(+ props.exifData.LensMake,+ props.exifData.LensModel,+ ),icon: 'tabler:focus',}: null,@@ -475,7 +487,7 @@ const isMobile = useMediaQuery('(max-width: 768px)')<PhotoMiniMapv-if="gpsCoordinates"- :photo-id="currentPhoto.id"+ :photo="currentPhoto":latitude="gpsCoordinates?.latitude":longitude="gpsCoordinates?.longitude"/>diff --git a/app/components/photo/MiniMap.vue b/app/components/photo/MiniMap.vueindex a7644c36..eebffb20 100644--- a/app/components/photo/MiniMap.vue+++ b/app/components/photo/MiniMap.vue@@ -2,11 +2,13 @@import { motion } from 'motion-v'const props = defineProps<{- photoId: string+ photo: Photolatitude: numberlongitude: number}>()+const MAPID = 'minimap-info-panel'+const loaded = ref(false)const isAnimating = ref(false)const mapInstance = ref<any>(null)@@ -48,6 +50,31 @@ const moveMapTo = (newLat: number, newLng: number) => {watch([() => props.latitude, () => props.longitude], ([newLat, newLng]) => {moveMapTo(newLat, newLng)+ if (mapInstance.value) {+ // 根据拍摄时间决定四种 lightPreset: dawn / day / dusk / night+ const photoDate = new Date(props.photo.dateTaken || 0)+ const hours = photoDate.getHours()+ if (hours >= 5 && hours < 7) {+ mapInstance.value.setConfigProperty('basemap', 'lightPreset', 'dawn')+ } else if (hours >= 7 && hours < 17) {+ mapInstance.value.setConfigProperty('basemap', 'lightPreset', 'day')+ } else if (hours >= 17 && hours < 21) {+ mapInstance.value.setConfigProperty('basemap', 'lightPreset', 'dusk')+ } else {+ mapInstance.value.setConfigProperty('basemap', 'lightPreset', 'night')+ }+ }+})++onUnmounted(() => {+ if (animationTimer) {+ clearTimeout(animationTimer)+ animationTimer = null+ }+ if (mapInstance.value) {+ mapInstance.value.remove()+ mapInstance.value = null+ }})</script>@@ -55,13 +82,20 @@ watch([() => props.latitude, () => props.longitude], ([newLat, newLng]) => {<divclass="relative w-full h-44 overflow-hidden rounded-lg border border-white/10 dark:border-white/10">+ <!-- mapbox://styles/hoshinosuzumi/cmev0eujf01dw01pje3g9cmlg --><MapboxMapclass="w-full h-full relative overflow-hidden"- :map-id="`minimap-info-panel`"+ :map-id="MAPID":options="{- style: 'mapbox://styles/hoshinosuzumi/cmev0eujf01dw01pje3g9cmlg',+ style: 'mapbox://styles/mapbox/standard',zoom: 12,+ config: {+ basemap: {+ colorThemes: 'faded'+ }+ },interactive: false,+ language: 'zh-Hans'}"@load="onMapLoad">