Revert "feat: auto categoried by camera & lens (#72)"

This reverts commit 21a6743c08.
This commit is contained in:
Innei
2025-08-04 00:22:54 +08:00
parent 21a6743c08
commit 001506eee4
7 changed files with 16 additions and 109 deletions

View File

@@ -318,44 +318,16 @@ export const ExifPanel: FC<{
</h4>
<div className="space-y-1 text-sm">
{formattedExifData.camera && (
<div className="flex justify-between gap-4 text-sm">
<span className="text-text-secondary shrink-0">
{t('exif.camera')}
</span>
<button
type="button"
onClick={() => {
window.open(
`/?tags=${encodeURIComponent(formattedExifData.camera!)}`,
'_blank',
'noopener,noreferrer',
)
}}
className="text-text min-w-0 cursor-pointer border-b border-dashed border-white/30 text-right hover:border-white/60"
>
{formattedExifData.camera}
</button>
</div>
<Row
label={t('exif.camera')}
value={formattedExifData.camera}
/>
)}
{formattedExifData.lens && (
<div className="flex justify-between gap-4 text-sm">
<span className="text-text-secondary shrink-0">
{t('exif.lens')}
</span>
<button
type="button"
onClick={() => {
window.open(
`/?tags=${encodeURIComponent(formattedExifData.lens!)}`,
'_blank',
'noopener,noreferrer',
)
}}
className="text-text min-w-0 cursor-pointer border-b border-dashed border-white/30 text-right hover:border-white/60"
>
{formattedExifData.lens}
</button>
</div>
<Row
label={t('exif.lens')}
value={formattedExifData.lens}
/>
)}
{formattedExifData.lensMake &&
!formattedExifData.lens?.includes(

View File

@@ -16,18 +16,11 @@ const filterAndSortPhotos = (
selectedTags: string[],
sortOrder: 'asc' | 'desc',
) => {
// 首先根据 tags 筛选(包括显示标签和设备标签)
// 首先根据 tags 筛选
let filteredPhotos = data
if (selectedTags.length > 0) {
filteredPhotos = data.filter((photo) =>
selectedTags.some((tag) => {
// 检查显示标签
if (photo.tags.includes(tag)) return true
// 检查设备标签
if (photo.equipmentTags && photo.equipmentTags.includes(tag))
return true
return false
}),
selectedTags.some((tag) => photo.tags.includes(tag)),
)
}

View File

@@ -16,7 +16,7 @@ import { Slider } from '~/components/ui/slider'
import { useMobile } from '~/hooks/useMobile'
import { clsxm } from '~/lib/cn'
const allTagsForFiltering = photoLoader.getAllTagsForFiltering()
const allTags = photoLoader.getAllTags()
const SortPanel = () => {
const { t } = useTranslation()
@@ -105,7 +105,7 @@ const TagsPanel = () => {
}
// 根据正则查询过滤标签
const filteredTags = allTagsForFiltering.filter((tag) => {
const filteredTags = allTags.filter((tag) => {
if (!searchQuery) return true
try {
@@ -149,7 +149,7 @@ const TagsPanel = () => {
</div>
</div>
{allTagsForFiltering.length === 0 ? (
{allTags.length === 0 ? (
<div className="px-3 py-8 text-center text-sm text-gray-500 dark:text-gray-400">
{t('action.tag.empty')}
</div>

View File

@@ -213,7 +213,6 @@ export async function executePhotoProcessingPipeline(
description: photoInfo.description,
dateTaken: photoInfo.dateTaken,
tags: photoInfo.tags,
equipmentTags: photoInfo.equipmentTags, // 添加设备标签
originalUrl: defaultBuilder
.getStorageManager()
.generatePublicUrl(photoKey),

View File

@@ -82,37 +82,6 @@ export function extractPhotoInfo(
log.info(`从文件名提取浏览次数:${views}`)
}
// 从 EXIF 数据中提取设备标签(相机和镜头)
const equipmentTags: string[] = []
if (exifData) {
// 相机信息标签
if (exifData.Make && exifData.Model) {
const cameraTag = `${exifData.Make} ${exifData.Model}`.trim()
equipmentTags.push(cameraTag)
log.info(`从 EXIF 提取相机标签:${cameraTag}`)
} else if (exifData.Make) {
equipmentTags.push(exifData.Make)
log.info(`从 EXIF 提取相机品牌标签:${exifData.Make}`)
} else if (exifData.Model) {
equipmentTags.push(exifData.Model)
log.info(`从 EXIF 提取相机型号标签:${exifData.Model}`)
}
// 镜头信息标签
if (exifData.LensModel) {
let lensTag = exifData.LensModel
// 如果镜头有制造商信息且与相机制造商不同,也添加制造商
if (exifData.LensMake && exifData.LensMake !== exifData.Make) {
lensTag = `${exifData.LensMake} ${exifData.LensModel}`
}
equipmentTags.push(lensTag.trim())
log.info(`从 EXIF 提取镜头标签:${lensTag}`)
} else if (exifData.LensMake) {
equipmentTags.push(exifData.LensMake)
log.info(`从 EXIF 提取镜头品牌标签:${exifData.LensMake}`)
}
}
// 从文件名中提取标题(移除日期和浏览次数)
title = fileName
.replaceAll(/\d{4}-\d{2}-\d{2}[_-]?/g, '')
@@ -125,15 +94,12 @@ export function extractPhotoInfo(
title = path.basename(key, path.extname(key))
}
log.info(
`照片信息提取完成:"${title}",路径标签:[${tags.join(', ')}],设备标签:[${equipmentTags.join(', ')}]`,
)
log.info(`照片信息提取完成:"${title}"`)
return {
title,
dateTaken,
tags, // 只包含路径等显示标签
equipmentTags, // 设备标签,仅用于筛选
tags,
description: '', // 可以从 EXIF 或其他元数据中获取
}
}

View File

@@ -31,8 +31,7 @@ export interface ToneAnalysis {
export interface PhotoInfo {
title: string
dateTaken: string
tags: string[] // 显示标签(路径标签等)
equipmentTags: string[] // 设备标签(相机、镜头,仅用于筛选)
tags: string[]
description: string
}

View File

@@ -31,27 +31,5 @@ class PhotoLoader {
})
return Array.from(tagSet).sort()
}
getAllEquipmentTags() {
const tagSet = new Set<string>()
this.photos.forEach((photo) => {
if (photo.equipmentTags) {
photo.equipmentTags.forEach((tag) => tagSet.add(tag))
}
})
return Array.from(tagSet).sort()
}
// 获取所有标签(包括显示标签和设备标签,用于筛选)
getAllTagsForFiltering() {
const tagSet = new Set<string>()
this.photos.forEach((photo) => {
photo.tags.forEach((tag) => tagSet.add(tag))
if (photo.equipmentTags) {
photo.equipmentTags.forEach((tag) => tagSet.add(tag))
}
})
return Array.from(tagSet).sort()
}
}
export const photoLoader = new PhotoLoader()