mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-11-30 16:02:58 +08:00
修复bug,第一次导出缩略图,后面有了高清图后再次导出应该覆盖
按原图、中图和缩略图对本地图片资源分级,始终优先选择高清变体。 增量导出仅复用满足清晰度要求的图片,重新探测旧缩略图并在高清图出现后替换;仅缩略图降级时显示提示。
This commit is contained in:
1 parent
7904d42442
commit
0e96c146d5
9 files changed
+185
-32
No files matched your search
@@ -3,20 +3,17 @@ import type { ExportRequest } from './export'
|
||||
export type ImageExportAttempt = {
|
||||
allowThumbnail: boolean
|
||||
preferThumbnail: boolean
|
||||
fallback: boolean
|
||||
}
|
||||
|
||||
export function getImageExportAttempts(
|
||||
request: Pick<ExportRequest, 'preferOriginal' | 'fallbackThumbnail'>
|
||||
): ImageExportAttempt[] {
|
||||
if (request.preferOriginal === false) {
|
||||
return [{ allowThumbnail: true, preferThumbnail: true, fallback: false }]
|
||||
return [{ allowThumbnail: true, preferThumbnail: true }]
|
||||
}
|
||||
const attempts: ImageExportAttempt[] = [
|
||||
{ allowThumbnail: false, preferThumbnail: false, fallback: false }
|
||||
]
|
||||
const attempts: ImageExportAttempt[] = [{ allowThumbnail: false, preferThumbnail: false }]
|
||||
if (request.fallbackThumbnail !== false) {
|
||||
attempts.push({ allowThumbnail: true, preferThumbnail: true, fallback: true })
|
||||
attempts.push({ allowThumbnail: true, preferThumbnail: true })
|
||||
}
|
||||
return attempts
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export type ExportImageQuality = 'original' | 'medium' | 'thumbnail'
|
||||
|
||||
const fileNameOf = (filePath: string): string =>
|
||||
String(filePath || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.split(/[\\/]/)
|
||||
.pop() || ''
|
||||
|
||||
export const imageFileQuality = (filePath: string): ExportImageQuality => {
|
||||
const fileName = fileNameOf(filePath)
|
||||
if (!fileName.endsWith('.dat')) return 'original'
|
||||
if (/(?:_t(?:_m)?|_thumb|\.thumb|_b|_w|_c)\.dat$/i.test(fileName)) {
|
||||
return 'thumbnail'
|
||||
}
|
||||
if (/(?:_hd|\.hd|_h_m|_h|\.h)\.dat$/i.test(fileName)) return 'original'
|
||||
return 'medium'
|
||||
}
|
||||
|
||||
export const imageQualityRank = (quality: ExportImageQuality): number => {
|
||||
if (quality === 'original') return 3
|
||||
if (quality === 'medium') return 2
|
||||
return 1
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { ExportImageQuality } from './image-quality'
|
||||
|
||||
export interface Contact {
|
||||
m_nsUsrName: string
|
||||
m_nsNickName: string
|
||||
@@ -36,6 +38,7 @@ export interface Message {
|
||||
exportMediaUrl?: string
|
||||
exportMediaType?: 'image' | 'video' | 'sticker' | 'file'
|
||||
exportMediaName?: string
|
||||
exportMediaQuality?: ExportImageQuality
|
||||
exportShowAvatar?: boolean
|
||||
exportMediaError?: string
|
||||
exportAvatarUrl?: string
|
||||
|
||||
Reference in new issue
Block a user