mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 07:16:51 +00:00
简单优化图片解密
This commit is contained in:
@@ -1114,6 +1114,53 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.appmsg-meta-badge {
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
color: var(--primary);
|
||||
background: rgba(127, 127, 127, 0.08);
|
||||
border: 1px solid rgba(127, 127, 127, 0.18);
|
||||
border-radius: 999px;
|
||||
padding: 3px 7px;
|
||||
align-self: flex-start;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.link-desc-block {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.appmsg-url-line {
|
||||
font-size: 11px;
|
||||
color: var(--text-tertiary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&.appmsg-rich-card {
|
||||
.link-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.link-thumb.theme-adaptive,
|
||||
.miniapp-thumb.theme-adaptive {
|
||||
transition: filter 0.2s ease;
|
||||
}
|
||||
|
||||
[data-mode="dark"] {
|
||||
.link-thumb.theme-adaptive,
|
||||
.miniapp-thumb.theme-adaptive {
|
||||
filter: invert(1) hue-rotate(180deg);
|
||||
}
|
||||
}
|
||||
|
||||
// 适配发送出去的消息中的链接卡片
|
||||
@@ -2752,12 +2799,14 @@
|
||||
|
||||
.card-message,
|
||||
.chat-record-message,
|
||||
.miniapp-message {
|
||||
.miniapp-message,
|
||||
.appmsg-rich-card {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
|
||||
.card-name,
|
||||
.miniapp-title,
|
||||
.source-name {
|
||||
.source-name,
|
||||
.link-title {
|
||||
color: white;
|
||||
}
|
||||
|
||||
@@ -2765,7 +2814,9 @@
|
||||
.miniapp-label,
|
||||
.chat-record-item,
|
||||
.chat-record-meta-line,
|
||||
.chat-record-desc {
|
||||
.chat-record-desc,
|
||||
.link-desc,
|
||||
.appmsg-url-line {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
@@ -2778,6 +2829,12 @@
|
||||
.chat-record-more {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.appmsg-meta-badge {
|
||||
color: rgba(255, 255, 255, 0.92);
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.call-message {
|
||||
@@ -3235,4 +3292,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.miniapp-message-rich {
|
||||
.miniapp-thumb {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3061,7 +3061,7 @@ function MessageBubble({
|
||||
setImageLocalPath(result.localPath)
|
||||
setImageHasUpdate(false)
|
||||
if (result.liveVideoPath) setImageLiveVideoPath(result.liveVideoPath)
|
||||
return
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3072,7 +3072,7 @@ function MessageBubble({
|
||||
imageDataUrlCache.set(imageCacheKey, dataUrl)
|
||||
setImageLocalPath(dataUrl)
|
||||
setImageHasUpdate(false)
|
||||
return
|
||||
return { success: true, localPath: dataUrl } as any
|
||||
}
|
||||
if (!silent) setImageError(true)
|
||||
} catch {
|
||||
@@ -3080,6 +3080,7 @@ function MessageBubble({
|
||||
} finally {
|
||||
if (!silent) setImageLoading(false)
|
||||
}
|
||||
return { success: false } as any
|
||||
}, [isImage, imageLoading, message.imageMd5, message.imageDatName, message.localId, session.username, imageCacheKey, detectImageMimeFromBase64])
|
||||
|
||||
const triggerForceHd = useCallback(() => {
|
||||
@@ -3110,6 +3111,55 @@ function MessageBubble({
|
||||
void requestImageDecrypt()
|
||||
}, [message.imageDatName, message.imageMd5, message.localId, requestImageDecrypt, session.username])
|
||||
|
||||
const handleOpenImageViewer = useCallback(async () => {
|
||||
if (!imageLocalPath) return
|
||||
|
||||
let finalImagePath = imageLocalPath
|
||||
let finalLiveVideoPath = imageLiveVideoPath || undefined
|
||||
|
||||
// If current cache is a thumbnail, wait for a silent force-HD decrypt before opening viewer.
|
||||
if (imageHasUpdate) {
|
||||
try {
|
||||
const upgraded = await requestImageDecrypt(true, true)
|
||||
if (upgraded?.success && upgraded.localPath) {
|
||||
finalImagePath = upgraded.localPath
|
||||
finalLiveVideoPath = upgraded.liveVideoPath || finalLiveVideoPath
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
// One more resolve helps when background/batch decrypt has produced a clearer image or live video
|
||||
// but local component state hasn't caught up yet.
|
||||
if (message.imageMd5 || message.imageDatName) {
|
||||
try {
|
||||
const resolved = await window.electronAPI.image.resolveCache({
|
||||
sessionId: session.username,
|
||||
imageMd5: message.imageMd5 || undefined,
|
||||
imageDatName: message.imageDatName
|
||||
})
|
||||
if (resolved?.success && resolved.localPath) {
|
||||
finalImagePath = resolved.localPath
|
||||
finalLiveVideoPath = resolved.liveVideoPath || finalLiveVideoPath
|
||||
imageDataUrlCache.set(imageCacheKey, resolved.localPath)
|
||||
setImageLocalPath(resolved.localPath)
|
||||
if (resolved.liveVideoPath) setImageLiveVideoPath(resolved.liveVideoPath)
|
||||
setImageHasUpdate(Boolean(resolved.hasUpdate))
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
void window.electronAPI.window.openImageViewerWindow(finalImagePath, finalLiveVideoPath)
|
||||
}, [
|
||||
imageHasUpdate,
|
||||
imageLiveVideoPath,
|
||||
imageLocalPath,
|
||||
imageCacheKey,
|
||||
message.imageDatName,
|
||||
message.imageMd5,
|
||||
requestImageDecrypt,
|
||||
session.username
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (imageClickTimerRef.current) {
|
||||
@@ -3631,10 +3681,7 @@ function MessageBubble({
|
||||
src={imageLocalPath}
|
||||
alt="图片"
|
||||
className="image-message"
|
||||
onClick={() => {
|
||||
if (imageHasUpdate) void requestImageDecrypt(true, true)
|
||||
void window.electronAPI.window.openImageViewerWindow(imageLocalPath!, imageLiveVideoPath || undefined)
|
||||
}}
|
||||
onClick={() => { void handleOpenImageViewer() }}
|
||||
onLoad={() => setImageError(false)}
|
||||
onError={() => setImageError(true)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user