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
perf(gps): 优化 GPS 坐标渲染格式
Timothy Yin9c4fb570fc54
diff --git a/app/components/photo/InfoPanel.vue b/app/components/photo/InfoPanel.vueindex 327c2126..cee636fe 100644--- a/app/components/photo/InfoPanel.vue+++ b/app/components/photo/InfoPanel.vue@@ -55,6 +55,44 @@ const formatExposureTime = (}}+// 格式化GPS坐标为标准的N/E格式+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 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}`+}+const gpsCoordinates = computed(() => {// 优先使用数据库中存储的坐标if (props.currentPhoto.latitude && props.currentPhoto.longitude) {@@ -112,25 +150,20 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {icon: 'tabler:grid-dots',}: null,- props.currentPhoto.country- ? {- label: '国家',- value: props.currentPhoto.country,- icon: 'tabler:map-pin',- }- : null,- props.currentPhoto.city+ props.exifData?.DateTimeOriginal? {- label: '城市',- value: props.currentPhoto.city,- icon: 'tabler:building',+ label: '拍摄时间',+ value: dayjs(props.exifData.DateTimeOriginal).format(+ 'YYYY-MM-DD HH:mm:ss',+ ),+ icon: 'tabler:calendar',}: null,- props.currentPhoto.latitude && props.currentPhoto.longitude+ props.exifData?.ColorSpace? {- label: 'GPS坐标',- value: `${props.currentPhoto.latitude.toFixed(6)}, ${props.currentPhoto.longitude.toFixed(6)}`,- icon: 'tabler:gps',+ label: '色彩空间',+ value: props.exifData.ColorSpace,+ icon: 'tabler:palette',}: null,props.exifData?.Artist@@ -154,20 +187,25 @@ const formatedExifData = computed<Record<string, KVData[]>>(() => {icon: 'tabler:world',}: null,- props.exifData?.DateTimeOriginal+ props.currentPhoto.country? {- label: '拍摄时间',- value: dayjs(props.exifData.DateTimeOriginal).format(- 'YYYY-MM-DD HH:mm:ss',- ),- icon: 'tabler:calendar',+ label: '国家',+ value: props.currentPhoto.country,+ icon: 'tabler:map-pin',}: null,- props.exifData?.ColorSpace+ props.currentPhoto.city? {- label: '色彩空间',- value: props.exifData.ColorSpace,- icon: 'tabler:palette',+ label: '城市',+ value: props.currentPhoto.city,+ icon: 'tabler:building',+ }+ : null,+ props.currentPhoto.latitude && props.currentPhoto.longitude+ ? {+ label: '坐标',+ value: formatGPSCoordinatesMultiLine(props.currentPhoto.latitude, props.currentPhoto.longitude),+ icon: 'tabler:gps',}: null,],diff --git a/app/components/photo/KVRenderer.vue b/app/components/photo/KVRenderer.vueindex ca8ac1ff..fcae8cd9 100644--- a/app/components/photo/KVRenderer.vue+++ b/app/components/photo/KVRenderer.vue@@ -45,7 +45,7 @@ defineProps<{class="flex-1 min-w-0 flex gap-6 items-start justify-between font-medium"><div class="text-white/80 text-nowrap">{{ item!.label }}</div>- <div class="text-white text-wrap tracking-tight wrap-anywhere text-end">+ <div class="text-white text-wrap tracking-tight wrap-anywhere text-end whitespace-pre-line">{{ item!.value }}</div></div>