mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-27 15:07:55 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51101387f7 | ||
|
|
641a3bf2ab | ||
|
|
58f22f4bb2 | ||
|
|
562eac4249 | ||
|
|
7759868664 | ||
|
|
e92df66bef | ||
|
|
354f3fd8e2 | ||
|
|
1201ea33db | ||
|
|
f8e99a34c7 | ||
|
|
d16423818d |
15
.github/workflows/release.yml
vendored
15
.github/workflows/release.yml
vendored
@@ -119,7 +119,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
npx electron-builder --publish always
|
npx electron-builder --win nsis --x64 --publish always '--config.artifactName=${productName}-${version}-x64-Setup.${ext}'
|
||||||
|
|
||||||
release-windows-arm64:
|
release-windows-arm64:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -155,7 +155,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
npx electron-builder --win nsis --arm64 --publish always '--config.artifactName=${productName}-${version}-arm64-Setup.${ext}'
|
npx electron-builder --win nsis --arm64 --publish always '--config.publish.channel=latest-arm64' '--config.artifactName=${productName}-${version}-arm64-Setup.${ext}'
|
||||||
|
|
||||||
update-release-notes:
|
update-release-notes:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -184,7 +184,10 @@ jobs:
|
|||||||
echo "$ASSETS_JSON" | jq -r --arg p "$pattern" '[.assets[].name | select(test($p))][0] // ""'
|
echo "$ASSETS_JSON" | jq -r --arg p "$pattern" '[.assets[].name | select(test($p))][0] // ""'
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOWS_ASSET="$(echo "$ASSETS_JSON" | jq -r '[.assets[].name | select(test("\\.exe$")) | select(test("arm64") | not)][0] // ""')"
|
WINDOWS_ASSET="$(echo "$ASSETS_JSON" | jq -r '[.assets[].name | select(test("x64.*\\.exe$"))][0] // ""')"
|
||||||
|
if [ -z "$WINDOWS_ASSET" ]; then
|
||||||
|
WINDOWS_ASSET="$(echo "$ASSETS_JSON" | jq -r '[.assets[].name | select(test("\\.exe$")) | select(test("arm64") | not)][0] // ""')"
|
||||||
|
fi
|
||||||
WINDOWS_ARM64_ASSET="$(echo "$ASSETS_JSON" | jq -r '[.assets[].name | select(test("arm64.*\\.exe$"))][0] // ""')"
|
WINDOWS_ARM64_ASSET="$(echo "$ASSETS_JSON" | jq -r '[.assets[].name | select(test("arm64.*\\.exe$"))][0] // ""')"
|
||||||
MAC_ASSET="$(pick_asset "\\.dmg$")"
|
MAC_ASSET="$(pick_asset "\\.dmg$")"
|
||||||
LINUX_DEB_ASSET="$(pick_asset "\\.deb$")"
|
LINUX_DEB_ASSET="$(pick_asset "\\.deb$")"
|
||||||
@@ -220,6 +223,12 @@ jobs:
|
|||||||
- Linux (.tar.gz): ${LINUX_TAR_URL:-$RELEASE_PAGE}
|
- Linux (.tar.gz): ${LINUX_TAR_URL:-$RELEASE_PAGE}
|
||||||
- linux (.AppImage): ${LINUX_APPIMAGE_URL:-$RELEASE_PAGE}
|
- linux (.AppImage): ${LINUX_APPIMAGE_URL:-$RELEASE_PAGE}
|
||||||
|
|
||||||
|
## macOS 安装提示(未知来源)
|
||||||
|
- 若打开时提示“来自未知开发者”或“无法验证开发者”,请到「系统设置 -> 隐私与安全性」中允许打开该应用。
|
||||||
|
- 如果仍被系统拦截,请在终端执行以下命令去除隔离标记:
|
||||||
|
- `xattr -dr com.apple.quarantine "/Applications/WeFlow.app"`
|
||||||
|
- 执行后重新打开 WeFlow。
|
||||||
|
|
||||||
> 如果某个平台链接暂时未生成,可进入完整发布页查看全部资源:$RELEASE_PAGE
|
> 如果某个平台链接暂时未生成,可进入完整发布页查看全部资源:$RELEASE_PAGE
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ import { messagePushService } from './services/messagePushService'
|
|||||||
autoUpdater.autoDownload = false
|
autoUpdater.autoDownload = false
|
||||||
autoUpdater.autoInstallOnAppQuit = true
|
autoUpdater.autoInstallOnAppQuit = true
|
||||||
autoUpdater.disableDifferentialDownload = true // 禁用差分更新,强制全量下载
|
autoUpdater.disableDifferentialDownload = true // 禁用差分更新,强制全量下载
|
||||||
|
// Windows x64 与 arm64 使用不同更新通道,避免 latest.yml 互相覆盖导致下错架构安装包。
|
||||||
|
if (process.platform === 'win32' && process.arch === 'arm64') {
|
||||||
|
autoUpdater.channel = 'latest-arm64'
|
||||||
|
}
|
||||||
const AUTO_UPDATE_ENABLED =
|
const AUTO_UPDATE_ENABLED =
|
||||||
process.env.AUTO_UPDATE_ENABLED === 'true' ||
|
process.env.AUTO_UPDATE_ENABLED === 'true' ||
|
||||||
process.env.AUTO_UPDATE_ENABLED === '1' ||
|
process.env.AUTO_UPDATE_ENABLED === '1' ||
|
||||||
@@ -142,33 +146,47 @@ const normalizeReleaseNotes = (rawReleaseNotes: unknown): string => {
|
|||||||
|
|
||||||
if (!merged.trim()) return ''
|
if (!merged.trim()) return ''
|
||||||
|
|
||||||
|
const shouldStripReleaseSection = (headingRaw: string): boolean => {
|
||||||
|
const heading = headingRaw.trim().toLowerCase()
|
||||||
|
if (heading === '下载' || heading === 'download') return true
|
||||||
|
|
||||||
|
const compactHeading = heading.replace(/\s+/g, '')
|
||||||
|
if (compactHeading.startsWith('macos安装提示')) return true
|
||||||
|
if (compactHeading.startsWith('mac安装提示')) return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// 兼容 electron-updater 直接返回 HTML 的场景
|
// 兼容 electron-updater 直接返回 HTML 的场景
|
||||||
const removeDownloadSectionFromHtml = (input: string): string => {
|
const removeDownloadSectionFromHtml = (input: string): string => {
|
||||||
return input.replace(
|
return input
|
||||||
/<h[1-6][^>]*>\s*(?:下载|download)\s*<\/h[1-6]>\s*[\s\S]*?(?=<h[1-6]\b|$)/gi,
|
.replace(
|
||||||
''
|
/<h[1-6][^>]*>\s*(?:下载|download)\s*<\/h[1-6]>\s*[\s\S]*?(?=<h[1-6]\b|$)/gi,
|
||||||
)
|
''
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
/<h[1-6][^>]*>\s*(?:mac\s*os|mac)\s*安装提示(?:\s*[((]\s*未知来源\s*[))])?\s*<\/h[1-6]>\s*[\s\S]*?(?=<h[1-6]\b|$)/gi,
|
||||||
|
''
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 兼容 Markdown 场景(Action 最终 release note 模板)
|
// 兼容 Markdown 场景(Action 最终 release note 模板)
|
||||||
const removeDownloadSectionFromMarkdown = (input: string): string => {
|
const removeDownloadSectionFromMarkdown = (input: string): string => {
|
||||||
const lines = input.split(/\r?\n/)
|
const lines = input.split(/\r?\n/)
|
||||||
const output: string[] = []
|
const output: string[] = []
|
||||||
let skipDownloadSection = false
|
let skipSection = false
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const headingMatch = line.match(/^\s*#{1,6}\s*(.+?)\s*$/)
|
const headingMatch = line.match(/^\s*#{1,6}\s*(.+?)\s*$/)
|
||||||
if (headingMatch) {
|
if (headingMatch) {
|
||||||
const heading = headingMatch[1].trim().toLowerCase()
|
if (shouldStripReleaseSection(headingMatch[1])) {
|
||||||
if (heading === '下载' || heading === 'download') {
|
skipSection = true
|
||||||
skipDownloadSection = true
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (skipDownloadSection) {
|
if (skipSection) {
|
||||||
skipDownloadSection = false
|
skipSection = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!skipDownloadSection) {
|
if (!skipSection) {
|
||||||
output.push(line)
|
output.push(line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5055,7 +5055,17 @@ class ChatService {
|
|||||||
|
|
||||||
const contact = await this.getContact(username)
|
const contact = await this.getContact(username)
|
||||||
const avatarResult = await wcdbService.getAvatarUrls([username])
|
const avatarResult = await wcdbService.getAvatarUrls([username])
|
||||||
const avatarUrl = avatarResult.success && avatarResult.map ? avatarResult.map[username] : undefined
|
let avatarUrl = avatarResult.success && avatarResult.map ? avatarResult.map[username] : undefined
|
||||||
|
if (!this.isValidAvatarUrl(avatarUrl)) {
|
||||||
|
avatarUrl = undefined
|
||||||
|
}
|
||||||
|
if (!avatarUrl) {
|
||||||
|
const headImageAvatars = await this.getAvatarsFromHeadImageDb([username])
|
||||||
|
const fallbackAvatarUrl = headImageAvatars[username]
|
||||||
|
if (this.isValidAvatarUrl(fallbackAvatarUrl)) {
|
||||||
|
avatarUrl = fallbackAvatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
const displayName = contact?.remark || contact?.nickName || contact?.alias || cached?.displayName || username
|
const displayName = contact?.remark || contact?.nickName || contact?.alias || cached?.displayName || username
|
||||||
const cacheEntry: ContactCacheEntry = {
|
const cacheEntry: ContactCacheEntry = {
|
||||||
avatarUrl,
|
avatarUrl,
|
||||||
@@ -5086,14 +5096,35 @@ class ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果是群聊,尝试获取群昵称
|
// 如果是群聊,尝试获取群昵称
|
||||||
let groupNicknames: Record<string, string> = {}
|
const groupNicknames = new Map<string, string>()
|
||||||
if (chatroomId.endsWith('@chatroom')) {
|
if (chatroomId.endsWith('@chatroom')) {
|
||||||
const nickResult = await wcdbService.getGroupNicknames(chatroomId)
|
const nickResult = await wcdbService.getGroupNicknames(chatroomId)
|
||||||
if (nickResult.success && nickResult.nicknames) {
|
if (nickResult.success && nickResult.nicknames) {
|
||||||
groupNicknames = nickResult.nicknames
|
const nicknameBuckets = new Map<string, Set<string>>()
|
||||||
|
for (const [memberIdRaw, nicknameRaw] of Object.entries(nickResult.nicknames)) {
|
||||||
|
const memberId = String(memberIdRaw || '').trim().toLowerCase()
|
||||||
|
const nickname = String(nicknameRaw || '').trim()
|
||||||
|
if (!memberId || !nickname) continue
|
||||||
|
const slot = nicknameBuckets.get(memberId)
|
||||||
|
if (slot) {
|
||||||
|
slot.add(nickname)
|
||||||
|
} else {
|
||||||
|
nicknameBuckets.set(memberId, new Set([nickname]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [memberId, nicknameSet] of nicknameBuckets.entries()) {
|
||||||
|
if (nicknameSet.size !== 1) continue
|
||||||
|
groupNicknames.set(memberId, Array.from(nicknameSet)[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lookupGroupNickname = (username?: string | null): string => {
|
||||||
|
const key = String(username || '').trim().toLowerCase()
|
||||||
|
if (!key) return ''
|
||||||
|
return groupNicknames.get(key) || ''
|
||||||
|
}
|
||||||
|
|
||||||
// 获取当前用户 wxid,用于识别"自己"
|
// 获取当前用户 wxid,用于识别"自己"
|
||||||
const myWxid = this.configService.get('myWxid')
|
const myWxid = this.configService.get('myWxid')
|
||||||
const cleanedMyWxid = myWxid ? this.cleanAccountDirName(myWxid) : ''
|
const cleanedMyWxid = myWxid ? this.cleanAccountDirName(myWxid) : ''
|
||||||
@@ -5103,7 +5134,7 @@ class ChatService {
|
|||||||
// 特判:如果是当前用户自己(contact 表通常不包含自己)
|
// 特判:如果是当前用户自己(contact 表通常不包含自己)
|
||||||
if (myWxid && (username === myWxid || username === cleanedMyWxid)) {
|
if (myWxid && (username === myWxid || username === cleanedMyWxid)) {
|
||||||
// 先查群昵称中是否有自己
|
// 先查群昵称中是否有自己
|
||||||
const myGroupNick = groupNicknames[username]
|
const myGroupNick = lookupGroupNickname(username) || lookupGroupNickname(myWxid)
|
||||||
if (myGroupNick) return myGroupNick
|
if (myGroupNick) return myGroupNick
|
||||||
// 尝试从缓存获取自己的昵称
|
// 尝试从缓存获取自己的昵称
|
||||||
const cached = this.avatarCache.get(username) || this.avatarCache.get(myWxid)
|
const cached = this.avatarCache.get(username) || this.avatarCache.get(myWxid)
|
||||||
@@ -5112,7 +5143,7 @@ class ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 先查群昵称
|
// 先查群昵称
|
||||||
const groupNick = groupNicknames[username]
|
const groupNick = lookupGroupNickname(username)
|
||||||
if (groupNick) return groupNick
|
if (groupNick) return groupNick
|
||||||
|
|
||||||
// 再查联系人信息
|
// 再查联系人信息
|
||||||
@@ -5523,6 +5554,13 @@ class ChatService {
|
|||||||
avatarUrl = avatarCandidate
|
avatarUrl = avatarCandidate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!avatarUrl) {
|
||||||
|
const headImageAvatars = await this.getAvatarsFromHeadImageDb([normalizedSessionId])
|
||||||
|
const fallbackAvatarUrl = headImageAvatars[normalizedSessionId]
|
||||||
|
if (this.isValidAvatarUrl(fallbackAvatarUrl)) {
|
||||||
|
avatarUrl = fallbackAvatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Number.isFinite(messageCount)) {
|
if (!Number.isFinite(messageCount)) {
|
||||||
messageCount = messageCountResult.status === 'fulfilled' &&
|
messageCount = messageCountResult.status === 'fulfilled' &&
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ interface ConfigSchema {
|
|||||||
notificationFilterList: string[]
|
notificationFilterList: string[]
|
||||||
messagePushEnabled: boolean
|
messagePushEnabled: boolean
|
||||||
windowCloseBehavior: 'ask' | 'tray' | 'quit'
|
windowCloseBehavior: 'ask' | 'tray' | 'quit'
|
||||||
|
quoteLayout: 'quote-top' | 'quote-bottom'
|
||||||
wordCloudExcludeWords: string[]
|
wordCloudExcludeWords: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@ export class ConfigService {
|
|||||||
notificationFilterList: [],
|
notificationFilterList: [],
|
||||||
messagePushEnabled: false,
|
messagePushEnabled: false,
|
||||||
windowCloseBehavior: 'ask',
|
windowCloseBehavior: 'ask',
|
||||||
|
quoteLayout: 'quote-top',
|
||||||
wordCloudExcludeWords: []
|
wordCloudExcludeWords: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1000,6 +1000,26 @@ class ExportService {
|
|||||||
return `${localType}_${this.getStableMessageKey(msg)}`
|
return `${localType}_${this.getStableMessageKey(msg)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getImageMissingRunCacheKey(
|
||||||
|
sessionId: string,
|
||||||
|
imageMd5?: unknown,
|
||||||
|
imageDatName?: unknown,
|
||||||
|
imageDeepSearchOnMiss = true
|
||||||
|
): string | null {
|
||||||
|
const normalizedSessionId = String(sessionId || '').trim()
|
||||||
|
const normalizedImageMd5 = String(imageMd5 || '').trim().toLowerCase()
|
||||||
|
const normalizedImageDatName = String(imageDatName || '').trim().toLowerCase()
|
||||||
|
if (!normalizedSessionId) return null
|
||||||
|
if (!normalizedImageMd5 && !normalizedImageDatName) return null
|
||||||
|
|
||||||
|
const primaryToken = normalizedImageMd5 || normalizedImageDatName
|
||||||
|
const secondaryToken = normalizedImageMd5 && normalizedImageDatName && normalizedImageDatName !== normalizedImageMd5
|
||||||
|
? normalizedImageDatName
|
||||||
|
: ''
|
||||||
|
const lookupMode = imageDeepSearchOnMiss ? 'deep' : 'hardlink'
|
||||||
|
return `${lookupMode}\u001f${normalizedSessionId}\u001f${primaryToken}\u001f${secondaryToken}`
|
||||||
|
}
|
||||||
|
|
||||||
private normalizeEmojiMd5(value: unknown): string | undefined {
|
private normalizeEmojiMd5(value: unknown): string | undefined {
|
||||||
const md5 = String(value || '').trim().toLowerCase()
|
const md5 = String(value || '').trim().toLowerCase()
|
||||||
if (!/^[a-f0-9]{32}$/.test(md5)) return undefined
|
if (!/^[a-f0-9]{32}$/.test(md5)) return undefined
|
||||||
@@ -1384,33 +1404,60 @@ class ExportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取群成员群昵称。优先使用 DLL,必要时回退到 `contact.chat_room.ext_buffer` 解析。
|
* 获取群成员群昵称。后端结果为唯一业务真值,前端仅做冲突净化防串号。
|
||||||
*/
|
*/
|
||||||
async getGroupNicknamesForRoom(chatroomId: string, candidates: string[] = []): Promise<Map<string, string>> {
|
async getGroupNicknamesForRoom(chatroomId: string, candidates: string[] = []): Promise<Map<string, string>> {
|
||||||
const nicknameMap = new Map<string, string>()
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dllResult = await wcdbService.getGroupNicknames(chatroomId)
|
const dllResult = await wcdbService.getGroupNicknames(chatroomId)
|
||||||
if (dllResult.success && dllResult.nicknames) {
|
if (!dllResult.success || !dllResult.nicknames) {
|
||||||
this.mergeGroupNicknameEntries(nicknameMap, Object.entries(dllResult.nicknames))
|
return new Map<string, string>()
|
||||||
}
|
}
|
||||||
|
return this.buildTrustedGroupNicknameMap(Object.entries(dllResult.nicknames), candidates)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('getGroupNicknamesForRoom dll error:', e)
|
console.error('getGroupNicknamesForRoom dll error:', e)
|
||||||
|
return new Map<string, string>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private normalizeGroupNicknameIdentity(value: string): string {
|
||||||
|
const raw = String(value || '').trim()
|
||||||
|
if (!raw) return ''
|
||||||
|
return raw.toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildTrustedGroupNicknameMap(
|
||||||
|
entries: Iterable<[string, string]>,
|
||||||
|
candidates: string[] = []
|
||||||
|
): Map<string, string> {
|
||||||
|
const candidateSet = new Set(
|
||||||
|
this.buildGroupNicknameIdCandidates(candidates)
|
||||||
|
.map((id) => this.normalizeGroupNicknameIdentity(id))
|
||||||
|
.filter(Boolean)
|
||||||
|
)
|
||||||
|
|
||||||
|
const buckets = new Map<string, Set<string>>()
|
||||||
|
for (const [memberIdRaw, nicknameRaw] of entries) {
|
||||||
|
const identity = this.normalizeGroupNicknameIdentity(memberIdRaw || '')
|
||||||
|
if (!identity) continue
|
||||||
|
if (candidateSet.size > 0 && !candidateSet.has(identity)) continue
|
||||||
|
|
||||||
|
const nickname = this.normalizeGroupNickname(nicknameRaw || '')
|
||||||
|
if (!nickname) continue
|
||||||
|
|
||||||
|
const slot = buckets.get(identity)
|
||||||
|
if (slot) {
|
||||||
|
slot.add(nickname)
|
||||||
|
} else {
|
||||||
|
buckets.set(identity, new Set([nickname]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const trusted = new Map<string, string>()
|
||||||
const result = await wcdbService.getChatRoomExtBuffer(chatroomId)
|
for (const [identity, nicknameSet] of buckets.entries()) {
|
||||||
if (!result.success || !result.extBuffer) {
|
if (nicknameSet.size !== 1) continue
|
||||||
return nicknameMap
|
trusted.set(identity, Array.from(nicknameSet)[0])
|
||||||
}
|
|
||||||
const extBuffer = this.decodeExtBuffer(result.extBuffer)
|
|
||||||
if (!extBuffer) return nicknameMap
|
|
||||||
this.mergeGroupNicknameEntries(nicknameMap, this.parseGroupNicknamesFromExtBuffer(extBuffer, candidates).entries())
|
|
||||||
return nicknameMap
|
|
||||||
} catch (e) {
|
|
||||||
console.error('getGroupNicknamesForRoom error:', e)
|
|
||||||
return nicknameMap
|
|
||||||
}
|
}
|
||||||
|
return trusted
|
||||||
}
|
}
|
||||||
|
|
||||||
private mergeGroupNicknameEntries(
|
private mergeGroupNicknameEntries(
|
||||||
@@ -1660,8 +1707,6 @@ class ExportService {
|
|||||||
const raw = String(rawValue || '').trim()
|
const raw = String(rawValue || '').trim()
|
||||||
if (!raw) continue
|
if (!raw) continue
|
||||||
set.add(raw)
|
set.add(raw)
|
||||||
const cleaned = this.cleanAccountDirName(raw)
|
|
||||||
if (cleaned && cleaned !== raw) set.add(cleaned)
|
|
||||||
}
|
}
|
||||||
return Array.from(set)
|
return Array.from(set)
|
||||||
}
|
}
|
||||||
@@ -1670,29 +1715,20 @@ class ExportService {
|
|||||||
const idCandidates = this.buildGroupNicknameIdCandidates(candidates)
|
const idCandidates = this.buildGroupNicknameIdCandidates(candidates)
|
||||||
if (idCandidates.length === 0) return ''
|
if (idCandidates.length === 0) return ''
|
||||||
|
|
||||||
|
let resolved = ''
|
||||||
for (const id of idCandidates) {
|
for (const id of idCandidates) {
|
||||||
const exact = this.normalizeGroupNickname(groupNicknamesMap.get(id) || '')
|
const normalizedId = this.normalizeGroupNicknameIdentity(id)
|
||||||
if (exact) return exact
|
if (!normalizedId) continue
|
||||||
const lower = this.normalizeGroupNickname(groupNicknamesMap.get(id.toLowerCase()) || '')
|
const candidateNickname = this.normalizeGroupNickname(groupNicknamesMap.get(normalizedId) || '')
|
||||||
if (lower) return lower
|
if (!candidateNickname) continue
|
||||||
}
|
if (!resolved) {
|
||||||
|
resolved = candidateNickname
|
||||||
for (const id of idCandidates) {
|
continue
|
||||||
const lower = id.toLowerCase()
|
|
||||||
let found = ''
|
|
||||||
let matched = 0
|
|
||||||
for (const [key, value] of groupNicknamesMap.entries()) {
|
|
||||||
if (String(key || '').toLowerCase() !== lower) continue
|
|
||||||
const normalized = this.normalizeGroupNickname(value || '')
|
|
||||||
if (!normalized) continue
|
|
||||||
found = normalized
|
|
||||||
matched += 1
|
|
||||||
if (matched > 1) return ''
|
|
||||||
}
|
}
|
||||||
if (matched === 1 && found) return found
|
if (resolved !== candidateNickname) return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return ''
|
return resolved
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -257,34 +257,60 @@ class GroupAnalyticsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从 DLL 获取群成员的群昵称
|
* 从后端获取群成员群昵称,并在前端进行唯一性净化防串号。
|
||||||
*/
|
*/
|
||||||
private async getGroupNicknamesForRoom(chatroomId: string, candidates: string[] = []): Promise<Map<string, string>> {
|
private async getGroupNicknamesForRoom(chatroomId: string, candidates: string[] = []): Promise<Map<string, string>> {
|
||||||
const nicknameMap = new Map<string, string>()
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dllResult = await wcdbService.getGroupNicknames(chatroomId)
|
const dllResult = await wcdbService.getGroupNicknames(chatroomId)
|
||||||
if (dllResult.success && dllResult.nicknames) {
|
if (!dllResult.success || !dllResult.nicknames) {
|
||||||
this.mergeGroupNicknameEntries(nicknameMap, Object.entries(dllResult.nicknames))
|
return new Map<string, string>()
|
||||||
}
|
}
|
||||||
|
return this.buildTrustedGroupNicknameMap(Object.entries(dllResult.nicknames), candidates)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('getGroupNicknamesForRoom dll error:', e)
|
console.error('getGroupNicknamesForRoom dll error:', e)
|
||||||
|
return new Map<string, string>()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
private normalizeGroupNicknameIdentity(value: string): string {
|
||||||
const result = await wcdbService.getChatRoomExtBuffer(chatroomId)
|
const raw = String(value || '').trim()
|
||||||
if (!result.success || !result.extBuffer) {
|
if (!raw) return ''
|
||||||
return nicknameMap
|
return raw.toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildTrustedGroupNicknameMap(
|
||||||
|
entries: Iterable<[string, string]>,
|
||||||
|
candidates: string[] = []
|
||||||
|
): Map<string, string> {
|
||||||
|
const candidateSet = new Set(
|
||||||
|
this.buildGroupNicknameIdCandidates(candidates)
|
||||||
|
.map((id) => this.normalizeGroupNicknameIdentity(id))
|
||||||
|
.filter(Boolean)
|
||||||
|
)
|
||||||
|
|
||||||
|
const buckets = new Map<string, Set<string>>()
|
||||||
|
for (const [memberIdRaw, nicknameRaw] of entries) {
|
||||||
|
const identity = this.normalizeGroupNicknameIdentity(memberIdRaw || '')
|
||||||
|
if (!identity) continue
|
||||||
|
if (candidateSet.size > 0 && !candidateSet.has(identity)) continue
|
||||||
|
|
||||||
|
const nickname = this.normalizeGroupNickname(nicknameRaw || '')
|
||||||
|
if (!nickname) continue
|
||||||
|
|
||||||
|
const slot = buckets.get(identity)
|
||||||
|
if (slot) {
|
||||||
|
slot.add(nickname)
|
||||||
|
} else {
|
||||||
|
buckets.set(identity, new Set([nickname]))
|
||||||
}
|
}
|
||||||
|
|
||||||
const extBuffer = this.decodeExtBuffer(result.extBuffer)
|
|
||||||
if (!extBuffer) return nicknameMap
|
|
||||||
this.mergeGroupNicknameEntries(nicknameMap, this.parseGroupNicknamesFromExtBuffer(extBuffer, candidates).entries())
|
|
||||||
return nicknameMap
|
|
||||||
} catch (e) {
|
|
||||||
console.error('getGroupNicknamesForRoom error:', e)
|
|
||||||
return nicknameMap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const trusted = new Map<string, string>()
|
||||||
|
for (const [identity, nicknameSet] of buckets.entries()) {
|
||||||
|
if (nicknameSet.size !== 1) continue
|
||||||
|
trusted.set(identity, Array.from(nicknameSet)[0])
|
||||||
|
}
|
||||||
|
return trusted
|
||||||
}
|
}
|
||||||
|
|
||||||
private mergeGroupNicknameEntries(
|
private mergeGroupNicknameEntries(
|
||||||
@@ -475,6 +501,16 @@ class GroupAnalyticsService {
|
|||||||
return Array.from(set)
|
return Array.from(set)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildGroupNicknameIdCandidates(values: Array<string | undefined | null>): string[] {
|
||||||
|
const set = new Set<string>()
|
||||||
|
for (const rawValue of values) {
|
||||||
|
const raw = String(rawValue || '').trim()
|
||||||
|
if (!raw) continue
|
||||||
|
set.add(raw)
|
||||||
|
}
|
||||||
|
return Array.from(set)
|
||||||
|
}
|
||||||
|
|
||||||
private toNonNegativeInteger(value: unknown): number {
|
private toNonNegativeInteger(value: unknown): number {
|
||||||
const parsed = Number(value)
|
const parsed = Number(value)
|
||||||
if (!Number.isFinite(parsed)) return 0
|
if (!Number.isFinite(parsed)) return 0
|
||||||
@@ -663,30 +699,23 @@ class GroupAnalyticsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private resolveGroupNicknameByCandidates(groupNicknames: Map<string, string>, candidates: string[]): string {
|
private resolveGroupNicknameByCandidates(groupNicknames: Map<string, string>, candidates: string[]): string {
|
||||||
const idCandidates = this.buildIdCandidates(candidates)
|
const idCandidates = this.buildGroupNicknameIdCandidates(candidates)
|
||||||
if (idCandidates.length === 0) return ''
|
if (idCandidates.length === 0) return ''
|
||||||
|
|
||||||
|
let resolved = ''
|
||||||
for (const id of idCandidates) {
|
for (const id of idCandidates) {
|
||||||
const exact = this.normalizeGroupNickname(groupNicknames.get(id) || '')
|
const normalizedId = this.normalizeGroupNicknameIdentity(id)
|
||||||
if (exact) return exact
|
if (!normalizedId) continue
|
||||||
}
|
const candidateNickname = this.normalizeGroupNickname(groupNicknames.get(normalizedId) || '')
|
||||||
|
if (!candidateNickname) continue
|
||||||
for (const id of idCandidates) {
|
if (!resolved) {
|
||||||
const lower = id.toLowerCase()
|
resolved = candidateNickname
|
||||||
let found = ''
|
continue
|
||||||
let matched = 0
|
|
||||||
for (const [key, value] of groupNicknames.entries()) {
|
|
||||||
if (String(key || '').toLowerCase() !== lower) continue
|
|
||||||
const normalized = this.normalizeGroupNickname(value || '')
|
|
||||||
if (!normalized) continue
|
|
||||||
found = normalized
|
|
||||||
matched += 1
|
|
||||||
if (matched > 1) return ''
|
|
||||||
}
|
}
|
||||||
if (matched === 1 && found) return found
|
if (resolved !== candidateNickname) return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return ''
|
return resolved
|
||||||
}
|
}
|
||||||
|
|
||||||
private sanitizeWorksheetName(name: string): string {
|
private sanitizeWorksheetName(name: string): string {
|
||||||
|
|||||||
@@ -1017,13 +1017,31 @@ class HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private lookupGroupNickname(groupNicknamesMap: Map<string, string>, sender: string): string {
|
private lookupGroupNickname(groupNicknamesMap: Map<string, string>, sender: string): string {
|
||||||
if (!sender) return ''
|
const key = String(sender || '').trim().toLowerCase()
|
||||||
const cleaned = this.normalizeAccountId(sender)
|
if (!key) return ''
|
||||||
return groupNicknamesMap.get(sender)
|
return groupNicknamesMap.get(key) || ''
|
||||||
|| groupNicknamesMap.get(sender.toLowerCase())
|
}
|
||||||
|| groupNicknamesMap.get(cleaned)
|
|
||||||
|| groupNicknamesMap.get(cleaned.toLowerCase())
|
private buildTrustedGroupNicknameMap(nicknames: Record<string, string>): Map<string, string> {
|
||||||
|| ''
|
const buckets = new Map<string, Set<string>>()
|
||||||
|
for (const [memberIdRaw, nicknameRaw] of Object.entries(nicknames || {})) {
|
||||||
|
const memberId = String(memberIdRaw || '').trim().toLowerCase()
|
||||||
|
const nickname = String(nicknameRaw || '').trim()
|
||||||
|
if (!memberId || !nickname) continue
|
||||||
|
const slot = buckets.get(memberId)
|
||||||
|
if (slot) {
|
||||||
|
slot.add(nickname)
|
||||||
|
} else {
|
||||||
|
buckets.set(memberId, new Set([nickname]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const trusted = new Map<string, string>()
|
||||||
|
for (const [memberId, nicknameSet] of buckets.entries()) {
|
||||||
|
if (nicknameSet.size !== 1) continue
|
||||||
|
trusted.set(memberId, Array.from(nicknameSet)[0])
|
||||||
|
}
|
||||||
|
return trusted
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveChatLabSenderInfo(
|
private resolveChatLabSenderInfo(
|
||||||
@@ -1094,21 +1112,7 @@ class HttpService {
|
|||||||
try {
|
try {
|
||||||
const result = await wcdbService.getGroupNicknames(talkerId)
|
const result = await wcdbService.getGroupNicknames(talkerId)
|
||||||
if (result.success && result.nicknames) {
|
if (result.success && result.nicknames) {
|
||||||
groupNicknamesMap = new Map()
|
groupNicknamesMap = this.buildTrustedGroupNicknameMap(result.nicknames)
|
||||||
for (const [memberIdRaw, nicknameRaw] of Object.entries(result.nicknames)) {
|
|
||||||
const memberId = String(memberIdRaw || '').trim()
|
|
||||||
const nickname = String(nicknameRaw || '').trim()
|
|
||||||
if (!memberId || !nickname) continue
|
|
||||||
|
|
||||||
groupNicknamesMap.set(memberId, nickname)
|
|
||||||
groupNicknamesMap.set(memberId.toLowerCase(), nickname)
|
|
||||||
|
|
||||||
const cleaned = this.normalizeAccountId(memberId)
|
|
||||||
if (cleaned) {
|
|
||||||
groupNicknamesMap.set(cleaned, nickname)
|
|
||||||
groupNicknamesMap.set(cleaned.toLowerCase(), nickname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[HttpService] Failed to get group nicknames:', e)
|
console.error('[HttpService] Failed to get group nicknames:', e)
|
||||||
@@ -1389,4 +1393,3 @@ class HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const httpService = new HttpService()
|
export const httpService = new HttpService()
|
||||||
|
|
||||||
|
|||||||
@@ -304,11 +304,8 @@ class MessagePushService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const groupNicknames = await this.getGroupNicknames(chatroomId)
|
const groupNicknames = await this.getGroupNicknames(chatroomId)
|
||||||
const normalizedSender = this.normalizeAccountId(senderUsername)
|
const senderKey = senderUsername.toLowerCase()
|
||||||
const nickname = groupNicknames[senderUsername]
|
const nickname = groupNicknames[senderKey]
|
||||||
|| groupNicknames[senderUsername.toLowerCase()]
|
|
||||||
|| groupNicknames[normalizedSender]
|
|
||||||
|| groupNicknames[normalizedSender.toLowerCase()]
|
|
||||||
|
|
||||||
if (nickname) {
|
if (nickname) {
|
||||||
return nickname
|
return nickname
|
||||||
@@ -328,22 +325,33 @@ class MessagePushService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await wcdbService.getGroupNicknames(cacheKey)
|
const result = await wcdbService.getGroupNicknames(cacheKey)
|
||||||
const nicknames = result.success && result.nicknames ? result.nicknames : {}
|
const nicknames = result.success && result.nicknames
|
||||||
|
? this.sanitizeGroupNicknames(result.nicknames)
|
||||||
|
: {}
|
||||||
this.groupNicknameCache.set(cacheKey, { nicknames, updatedAt: Date.now() })
|
this.groupNicknameCache.set(cacheKey, { nicknames, updatedAt: Date.now() })
|
||||||
return nicknames
|
return nicknames
|
||||||
}
|
}
|
||||||
|
|
||||||
private normalizeAccountId(value: string): string {
|
private sanitizeGroupNicknames(nicknames: Record<string, string>): Record<string, string> {
|
||||||
const trimmed = String(value || '').trim()
|
const buckets = new Map<string, Set<string>>()
|
||||||
if (!trimmed) return trimmed
|
for (const [memberIdRaw, nicknameRaw] of Object.entries(nicknames || {})) {
|
||||||
|
const memberId = String(memberIdRaw || '').trim().toLowerCase()
|
||||||
if (trimmed.toLowerCase().startsWith('wxid_')) {
|
const nickname = String(nicknameRaw || '').trim()
|
||||||
const match = trimmed.match(/^(wxid_[^_]+)/i)
|
if (!memberId || !nickname) continue
|
||||||
return match ? match[1] : trimmed
|
const slot = buckets.get(memberId)
|
||||||
|
if (slot) {
|
||||||
|
slot.add(nickname)
|
||||||
|
} else {
|
||||||
|
buckets.set(memberId, new Set([nickname]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const suffixMatch = trimmed.match(/^(.+)_([a-zA-Z0-9]{4})$/)
|
const trusted: Record<string, string> = {}
|
||||||
return suffixMatch ? suffixMatch[1] : trimmed
|
for (const [memberId, nicknameSet] of buckets.entries()) {
|
||||||
|
if (nicknameSet.size !== 1) continue
|
||||||
|
trusted[memberId] = Array.from(nicknameSet)[0]
|
||||||
|
}
|
||||||
|
return trusted
|
||||||
}
|
}
|
||||||
|
|
||||||
private isRecentMessage(messageKey: string): boolean {
|
private isRecentMessage(messageKey: string): boolean {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -625,7 +625,7 @@
|
|||||||
|
|
||||||
.bubble-content {
|
.bubble-content {
|
||||||
background: var(--primary-gradient);
|
background: var(--primary-gradient);
|
||||||
color: #fff;
|
color: var(--on-primary);
|
||||||
border-radius: 18px 18px 4px 18px;
|
border-radius: 18px 18px 4px 18px;
|
||||||
padding: 10px 14px;
|
padding: 10px 14px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -1962,7 +1962,7 @@
|
|||||||
|
|
||||||
.bubble-content {
|
.bubble-content {
|
||||||
background: var(--primary);
|
background: var(--primary);
|
||||||
color: white;
|
color: var(--on-primary);
|
||||||
border-radius: 18px 18px 4px 18px;
|
border-radius: 18px 18px 4px 18px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2420,7 +2420,6 @@
|
|||||||
background: rgba(0, 0, 0, 0.04);
|
background: rgba(0, 0, 0, 0.04);
|
||||||
border-left: 2px solid var(--primary);
|
border-left: 2px solid var(--primary);
|
||||||
padding: 6px 10px;
|
padding: 6px 10px;
|
||||||
margin-bottom: 8px;
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
||||||
@@ -2454,15 +2453,15 @@
|
|||||||
|
|
||||||
// 自己发送的消息中的引用样式
|
// 自己发送的消息中的引用样式
|
||||||
.message-bubble.sent .quoted-message {
|
.message-bubble.sent .quoted-message {
|
||||||
background: rgba(255, 255, 255, 0.15);
|
background: color-mix(in srgb, var(--on-primary) 12%, var(--primary));
|
||||||
border-left-color: rgba(255, 255, 255, 0.5);
|
border-left-color: color-mix(in srgb, var(--on-primary) 36%, var(--primary));
|
||||||
|
|
||||||
.quoted-sender {
|
.quoted-sender {
|
||||||
color: rgba(255, 255, 255, 0.9);
|
color: color-mix(in srgb, var(--on-primary) 92%, var(--primary));
|
||||||
}
|
}
|
||||||
|
|
||||||
.quoted-text {
|
.quoted-text {
|
||||||
color: rgba(255, 255, 255, 0.8);
|
color: color-mix(in srgb, var(--on-primary) 80%, var(--primary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2482,6 +2481,14 @@
|
|||||||
|
|
||||||
.bubble-content {
|
.bubble-content {
|
||||||
-webkit-app-region: no-drag;
|
-webkit-app-region: no-drag;
|
||||||
|
|
||||||
|
&.quote-layout-top .quoted-message {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.quote-layout-bottom .quoted-message {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 时间分隔
|
// 时间分隔
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ interface GlobalMsgPrefixCacheEntry {
|
|||||||
completed: boolean
|
completed: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QuoteLayout = configService.QuoteLayout
|
||||||
|
|
||||||
const GLOBAL_MSG_PER_SESSION_LIMIT = 10
|
const GLOBAL_MSG_PER_SESSION_LIMIT = 10
|
||||||
const GLOBAL_MSG_SEED_LIMIT = 120
|
const GLOBAL_MSG_SEED_LIMIT = 120
|
||||||
const GLOBAL_MSG_BACKFILL_CONCURRENCY = 3
|
const GLOBAL_MSG_BACKFILL_CONCURRENCY = 3
|
||||||
@@ -7556,6 +7558,7 @@ function MessageBubble({
|
|||||||
const [senderAvatarUrl, setSenderAvatarUrl] = useState<string | undefined>(undefined)
|
const [senderAvatarUrl, setSenderAvatarUrl] = useState<string | undefined>(undefined)
|
||||||
const [senderName, setSenderName] = useState<string | undefined>(undefined)
|
const [senderName, setSenderName] = useState<string | undefined>(undefined)
|
||||||
const [quotedSenderName, setQuotedSenderName] = useState<string | undefined>(undefined)
|
const [quotedSenderName, setQuotedSenderName] = useState<string | undefined>(undefined)
|
||||||
|
const [quoteLayout, setQuoteLayout] = useState<QuoteLayout>('quote-top')
|
||||||
const senderProfileRequestSeqRef = useRef(0)
|
const senderProfileRequestSeqRef = useRef(0)
|
||||||
const [emojiError, setEmojiError] = useState(false)
|
const [emojiError, setEmojiError] = useState(false)
|
||||||
const [emojiLoading, setEmojiLoading] = useState(false)
|
const [emojiLoading, setEmojiLoading] = useState(false)
|
||||||
@@ -8549,6 +8552,18 @@ function MessageBubble({
|
|||||||
myWxid
|
myWxid
|
||||||
])
|
])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false
|
||||||
|
void configService.getQuoteLayout().then((layout) => {
|
||||||
|
if (!cancelled) setQuoteLayout(layout)
|
||||||
|
}).catch(() => {
|
||||||
|
if (!cancelled) setQuoteLayout('quote-top')
|
||||||
|
})
|
||||||
|
return () => {
|
||||||
|
cancelled = true
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
const locationMessageMeta = useMemo(() => {
|
const locationMessageMeta = useMemo(() => {
|
||||||
if (message.localType !== 48) return null
|
if (message.localType !== 48) return null
|
||||||
const raw = message.rawContent || ''
|
const raw = message.rawContent || ''
|
||||||
@@ -8584,6 +8599,31 @@ function MessageBubble({
|
|||||||
// 是否有引用消息
|
// 是否有引用消息
|
||||||
const hasQuote = quotedContent.length > 0
|
const hasQuote = quotedContent.length > 0
|
||||||
const displayQuotedSenderName = quotedSenderName || quotedSenderFallbackName
|
const displayQuotedSenderName = quotedSenderName || quotedSenderFallbackName
|
||||||
|
const renderBubbleWithQuote = useCallback((quotedNode: React.ReactNode, messageNode: React.ReactNode) => {
|
||||||
|
const quoteFirst = quoteLayout !== 'quote-bottom'
|
||||||
|
return (
|
||||||
|
<div className={`bubble-content ${quoteFirst ? 'quote-layout-top' : 'quote-layout-bottom'}`}>
|
||||||
|
{quoteFirst ? (
|
||||||
|
<>
|
||||||
|
{quotedNode}
|
||||||
|
{messageNode}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{messageNode}
|
||||||
|
{quotedNode}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}, [quoteLayout])
|
||||||
|
|
||||||
|
const renderQuotedMessageBlock = useCallback((contentNode: React.ReactNode) => (
|
||||||
|
<div className="quoted-message">
|
||||||
|
{displayQuotedSenderName && <span className="quoted-sender">{displayQuotedSenderName}</span>}
|
||||||
|
<span className="quoted-text">{contentNode}</span>
|
||||||
|
</div>
|
||||||
|
), [displayQuotedSenderName])
|
||||||
|
|
||||||
const handlePlayVideo = useCallback(async () => {
|
const handlePlayVideo = useCallback(async () => {
|
||||||
if (!videoInfo?.videoUrl) return
|
if (!videoInfo?.videoUrl) return
|
||||||
@@ -9023,13 +9063,10 @@ function MessageBubble({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bubble-content">
|
renderBubbleWithQuote(
|
||||||
<div className="quoted-message">
|
renderQuotedMessageBlock(renderReferContent()),
|
||||||
{displayQuotedSenderName && <span className="quoted-sender">{displayQuotedSenderName}</span>}
|
|
||||||
<span className="quoted-text">{renderReferContent()}</span>
|
|
||||||
</div>
|
|
||||||
<div className="message-text">{renderTextWithEmoji(cleanMessageContent(replyText))}</div>
|
<div className="message-text">{renderTextWithEmoji(cleanMessageContent(replyText))}</div>
|
||||||
</div>
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9122,13 +9159,10 @@ function MessageBubble({
|
|||||||
const replyText = message.linkTitle || q('title') || cleanedParsedContent || ''
|
const replyText = message.linkTitle || q('title') || cleanedParsedContent || ''
|
||||||
const referContent = message.quotedContent || q('refermsg > content') || ''
|
const referContent = message.quotedContent || q('refermsg > content') || ''
|
||||||
return (
|
return (
|
||||||
<div className="bubble-content">
|
renderBubbleWithQuote(
|
||||||
<div className="quoted-message">
|
renderQuotedMessageBlock(renderTextWithEmoji(cleanMessageContent(referContent))),
|
||||||
{displayQuotedSenderName && <span className="quoted-sender">{displayQuotedSenderName}</span>}
|
|
||||||
<span className="quoted-text">{renderTextWithEmoji(cleanMessageContent(referContent))}</span>
|
|
||||||
</div>
|
|
||||||
<div className="message-text">{renderTextWithEmoji(cleanMessageContent(replyText))}</div>
|
<div className="message-text">{renderTextWithEmoji(cleanMessageContent(replyText))}</div>
|
||||||
</div>
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9338,13 +9372,10 @@ function MessageBubble({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bubble-content">
|
renderBubbleWithQuote(
|
||||||
<div className="quoted-message">
|
renderQuotedMessageBlock(renderReferContent2()),
|
||||||
{displayQuotedSenderName && <span className="quoted-sender">{displayQuotedSenderName}</span>}
|
|
||||||
<span className="quoted-text">{renderReferContent2()}</span>
|
|
||||||
</div>
|
|
||||||
<div className="message-text">{renderTextWithEmoji(cleanMessageContent(replyText))}</div>
|
<div className="message-text">{renderTextWithEmoji(cleanMessageContent(replyText))}</div>
|
||||||
</div>
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9623,14 +9654,9 @@ function MessageBubble({
|
|||||||
|
|
||||||
// 带引用的消息
|
// 带引用的消息
|
||||||
if (hasQuote) {
|
if (hasQuote) {
|
||||||
return (
|
return renderBubbleWithQuote(
|
||||||
<div className="bubble-content">
|
renderQuotedMessageBlock(renderTextWithEmoji(cleanMessageContent(quotedContent))),
|
||||||
<div className="quoted-message">
|
<div className="message-text">{renderTextWithEmoji(cleanedParsedContent)}</div>
|
||||||
{displayQuotedSenderName && <span className="quoted-sender">{displayQuotedSenderName}</span>}
|
|
||||||
<span className="quoted-text">{renderTextWithEmoji(cleanMessageContent(quotedContent))}</span>
|
|
||||||
</div>
|
|
||||||
<div className="message-text">{renderTextWithEmoji(cleanedParsedContent)}</div>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import { SnsPostItem } from '../components/Sns/SnsPostItem'
|
|||||||
import { ContactSnsTimelineDialog } from '../components/Sns/ContactSnsTimelineDialog'
|
import { ContactSnsTimelineDialog } from '../components/Sns/ContactSnsTimelineDialog'
|
||||||
import { ExportDateRangeDialog } from '../components/Export/ExportDateRangeDialog'
|
import { ExportDateRangeDialog } from '../components/Export/ExportDateRangeDialog'
|
||||||
import { ExportDefaultsSettingsForm, type ExportDefaultsSettingsPatch } from '../components/Export/ExportDefaultsSettingsForm'
|
import { ExportDefaultsSettingsForm, type ExportDefaultsSettingsPatch } from '../components/Export/ExportDefaultsSettingsForm'
|
||||||
|
import { Avatar } from '../components/Avatar'
|
||||||
import type { SnsPost } from '../types/sns'
|
import type { SnsPost } from '../types/sns'
|
||||||
import {
|
import {
|
||||||
cloneExportDateRange,
|
cloneExportDateRange,
|
||||||
@@ -538,6 +539,14 @@ const getAvatarLetter = (name: string): string => {
|
|||||||
return [...name][0] || '?'
|
return [...name][0] || '?'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizeExportAvatarUrl = (value?: string | null): string | undefined => {
|
||||||
|
const normalized = String(value || '').trim()
|
||||||
|
if (!normalized) return undefined
|
||||||
|
const lower = normalized.toLowerCase()
|
||||||
|
if (lower === 'null' || lower === 'undefined') return undefined
|
||||||
|
return normalized
|
||||||
|
}
|
||||||
|
|
||||||
const toComparableNameSet = (values: Array<string | undefined | null>): Set<string> => {
|
const toComparableNameSet = (values: Array<string | undefined | null>): Set<string> => {
|
||||||
const set = new Set<string>()
|
const set = new Set<string>()
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
@@ -1713,6 +1722,7 @@ function ExportPage() {
|
|||||||
startIndex: 0,
|
startIndex: 0,
|
||||||
endIndex: -1
|
endIndex: -1
|
||||||
})
|
})
|
||||||
|
const avatarHydrationRequestedRef = useRef<Set<string>>(new Set())
|
||||||
const sessionMutualFriendsMetricsRef = useRef<Record<string, SessionMutualFriendsMetric>>({})
|
const sessionMutualFriendsMetricsRef = useRef<Record<string, SessionMutualFriendsMetric>>({})
|
||||||
const sessionMutualFriendsDirectMetricsRef = useRef<Record<string, SessionMutualFriendsMetric>>({})
|
const sessionMutualFriendsDirectMetricsRef = useRef<Record<string, SessionMutualFriendsMetric>>({})
|
||||||
const sessionMutualFriendsQueueRef = useRef<string[]>([])
|
const sessionMutualFriendsQueueRef = useRef<string[]>([])
|
||||||
@@ -1957,6 +1967,7 @@ function ExportPage() {
|
|||||||
displayName: contact.displayName,
|
displayName: contact.displayName,
|
||||||
remark: contact.remark,
|
remark: contact.remark,
|
||||||
nickname: contact.nickname,
|
nickname: contact.nickname,
|
||||||
|
alias: contact.alias,
|
||||||
type: contact.type
|
type: contact.type
|
||||||
}))
|
}))
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
@@ -1998,6 +2009,94 @@ function ExportPage() {
|
|||||||
}
|
}
|
||||||
}, [ensureExportCacheScope, syncContactTypeCounts])
|
}, [ensureExportCacheScope, syncContactTypeCounts])
|
||||||
|
|
||||||
|
const hydrateVisibleContactAvatars = useCallback(async (usernames: string[]) => {
|
||||||
|
const targets = Array.from(new Set(
|
||||||
|
(usernames || [])
|
||||||
|
.map((username) => String(username || '').trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
)).filter((username) => {
|
||||||
|
if (avatarHydrationRequestedRef.current.has(username)) return false
|
||||||
|
const contact = contactsList.find((item) => item.username === username)
|
||||||
|
const session = sessions.find((item) => item.username === username)
|
||||||
|
const existingAvatarUrl = normalizeExportAvatarUrl(contact?.avatarUrl || session?.avatarUrl)
|
||||||
|
return !existingAvatarUrl
|
||||||
|
})
|
||||||
|
|
||||||
|
if (targets.length === 0) return
|
||||||
|
targets.forEach((username) => avatarHydrationRequestedRef.current.add(username))
|
||||||
|
|
||||||
|
const settled = await Promise.allSettled(
|
||||||
|
targets.map(async (username) => {
|
||||||
|
const profile = await window.electronAPI.chat.getContactAvatar(username)
|
||||||
|
return {
|
||||||
|
username,
|
||||||
|
avatarUrl: normalizeExportAvatarUrl(profile?.avatarUrl),
|
||||||
|
displayName: profile?.displayName ? String(profile.displayName).trim() : undefined
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const avatarPatches = new Map<string, { avatarUrl?: string; displayName?: string }>()
|
||||||
|
for (const item of settled) {
|
||||||
|
if (item.status !== 'fulfilled') continue
|
||||||
|
const { username, avatarUrl, displayName } = item.value
|
||||||
|
if (!avatarUrl && !displayName) continue
|
||||||
|
avatarPatches.set(username, { avatarUrl, displayName })
|
||||||
|
}
|
||||||
|
if (avatarPatches.size === 0) return
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
setContactsList((prev) => prev.map((contact) => {
|
||||||
|
const patch = avatarPatches.get(contact.username)
|
||||||
|
if (!patch) return contact
|
||||||
|
return {
|
||||||
|
...contact,
|
||||||
|
displayName: patch.displayName || contact.displayName,
|
||||||
|
avatarUrl: patch.avatarUrl || contact.avatarUrl
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
setSessions((prev) => prev.map((session) => {
|
||||||
|
const patch = avatarPatches.get(session.username)
|
||||||
|
if (!patch) return session
|
||||||
|
return {
|
||||||
|
...session,
|
||||||
|
displayName: patch.displayName || session.displayName,
|
||||||
|
avatarUrl: patch.avatarUrl || session.avatarUrl
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
setSessionDetail((prev) => {
|
||||||
|
if (!prev) return prev
|
||||||
|
const patch = avatarPatches.get(prev.wxid)
|
||||||
|
if (!patch) return prev
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
displayName: patch.displayName || prev.displayName,
|
||||||
|
avatarUrl: patch.avatarUrl || prev.avatarUrl
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let avatarCacheChanged = false
|
||||||
|
for (const [username, patch] of avatarPatches.entries()) {
|
||||||
|
if (!patch.avatarUrl) continue
|
||||||
|
const previous = contactsAvatarCacheRef.current[username]
|
||||||
|
if (previous?.avatarUrl === patch.avatarUrl) continue
|
||||||
|
contactsAvatarCacheRef.current[username] = {
|
||||||
|
avatarUrl: patch.avatarUrl,
|
||||||
|
updatedAt: now,
|
||||||
|
checkedAt: now
|
||||||
|
}
|
||||||
|
avatarCacheChanged = true
|
||||||
|
}
|
||||||
|
if (avatarCacheChanged) {
|
||||||
|
setAvatarCacheUpdatedAt(now)
|
||||||
|
const scopeKey = exportCacheScopeRef.current
|
||||||
|
if (scopeKey) {
|
||||||
|
void configService.setContactsAvatarCache(scopeKey, contactsAvatarCacheRef.current).catch(() => {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [contactsList, sessions])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isExportRoute) return
|
if (!isExportRoute) return
|
||||||
let cancelled = false
|
let cancelled = false
|
||||||
@@ -3824,10 +3923,12 @@ function ExportPage() {
|
|||||||
displayName: contact.displayName || contact.username,
|
displayName: contact.displayName || contact.username,
|
||||||
remark: contact.remark,
|
remark: contact.remark,
|
||||||
nickname: contact.nickname,
|
nickname: contact.nickname,
|
||||||
|
alias: contact.alias,
|
||||||
type: contact.type
|
type: contact.type
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const persistAt = Date.now()
|
const persistAt = Date.now()
|
||||||
|
setContactsList(contactsForPersist)
|
||||||
setSessions(nextSessions)
|
setSessions(nextSessions)
|
||||||
sessionsHydratedAtRef.current = persistAt
|
sessionsHydratedAtRef.current = persistAt
|
||||||
if (hasNetworkContactsSnapshot && contactsCachePayload.length > 0) {
|
if (hasNetworkContactsSnapshot && contactsCachePayload.length > 0) {
|
||||||
@@ -5380,6 +5481,11 @@ function ExportPage() {
|
|||||||
const endIndex = Number.isFinite(range?.endIndex) ? Math.max(startIndex, Math.floor(range.endIndex)) : startIndex
|
const endIndex = Number.isFinite(range?.endIndex) ? Math.max(startIndex, Math.floor(range.endIndex)) : startIndex
|
||||||
sessionMediaMetricVisibleRangeRef.current = { startIndex, endIndex }
|
sessionMediaMetricVisibleRangeRef.current = { startIndex, endIndex }
|
||||||
sessionMutualFriendsVisibleRangeRef.current = { startIndex, endIndex }
|
sessionMutualFriendsVisibleRangeRef.current = { startIndex, endIndex }
|
||||||
|
void hydrateVisibleContactAvatars(
|
||||||
|
filteredContacts
|
||||||
|
.slice(startIndex, endIndex + 1)
|
||||||
|
.map((contact) => contact.username)
|
||||||
|
)
|
||||||
const visibleTargets = collectVisibleSessionMetricTargets(filteredContacts)
|
const visibleTargets = collectVisibleSessionMetricTargets(filteredContacts)
|
||||||
if (visibleTargets.length === 0) return
|
if (visibleTargets.length === 0) return
|
||||||
enqueueSessionMediaMetricRequests(visibleTargets, { front: true })
|
enqueueSessionMediaMetricRequests(visibleTargets, { front: true })
|
||||||
@@ -5395,10 +5501,23 @@ function ExportPage() {
|
|||||||
enqueueSessionMediaMetricRequests,
|
enqueueSessionMediaMetricRequests,
|
||||||
enqueueSessionMutualFriendsRequests,
|
enqueueSessionMutualFriendsRequests,
|
||||||
filteredContacts,
|
filteredContacts,
|
||||||
|
hydrateVisibleContactAvatars,
|
||||||
scheduleSessionMediaMetricWorker,
|
scheduleSessionMediaMetricWorker,
|
||||||
scheduleSessionMutualFriendsWorker
|
scheduleSessionMutualFriendsWorker
|
||||||
])
|
])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (filteredContacts.length === 0) return
|
||||||
|
const bootstrapTargets = filteredContacts.slice(0, 24).map((contact) => contact.username)
|
||||||
|
void hydrateVisibleContactAvatars(bootstrapTargets)
|
||||||
|
}, [filteredContacts, hydrateVisibleContactAvatars])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const sessionId = String(sessionDetail?.wxid || '').trim()
|
||||||
|
if (!sessionId) return
|
||||||
|
void hydrateVisibleContactAvatars([sessionId])
|
||||||
|
}, [hydrateVisibleContactAvatars, sessionDetail?.wxid])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeTaskCount > 0) return
|
if (activeTaskCount > 0) return
|
||||||
if (filteredContacts.length === 0) return
|
if (filteredContacts.length === 0) return
|
||||||
@@ -5750,7 +5869,7 @@ function ExportPage() {
|
|||||||
displayName: mappedSession?.displayName || mappedContact?.displayName || prev?.displayName || normalizedSessionId,
|
displayName: mappedSession?.displayName || mappedContact?.displayName || prev?.displayName || normalizedSessionId,
|
||||||
remark: sameSession ? prev?.remark : mappedContact?.remark,
|
remark: sameSession ? prev?.remark : mappedContact?.remark,
|
||||||
nickName: sameSession ? prev?.nickName : mappedContact?.nickname,
|
nickName: sameSession ? prev?.nickName : mappedContact?.nickname,
|
||||||
alias: sameSession ? prev?.alias : undefined,
|
alias: sameSession ? prev?.alias : mappedContact?.alias,
|
||||||
avatarUrl: mappedSession?.avatarUrl || mappedContact?.avatarUrl || (sameSession ? prev?.avatarUrl : undefined),
|
avatarUrl: mappedSession?.avatarUrl || mappedContact?.avatarUrl || (sameSession ? prev?.avatarUrl : undefined),
|
||||||
messageCount: initialMessageCount ?? (sameSession ? prev.messageCount : Number.NaN),
|
messageCount: initialMessageCount ?? (sameSession ? prev.messageCount : Number.NaN),
|
||||||
voiceMessages: metricVoice ?? (sameSession ? prev?.voiceMessages : undefined),
|
voiceMessages: metricVoice ?? (sameSession ? prev?.voiceMessages : undefined),
|
||||||
@@ -6627,11 +6746,12 @@ function ExportPage() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="contact-avatar">
|
<div className="contact-avatar">
|
||||||
{contact.avatarUrl ? (
|
<Avatar
|
||||||
<img src={contact.avatarUrl} alt="" loading="lazy" />
|
src={normalizeExportAvatarUrl(contact.avatarUrl)}
|
||||||
) : (
|
name={contact.displayName}
|
||||||
<span>{getAvatarLetter(contact.displayName)}</span>
|
size="100%"
|
||||||
)}
|
shape="rounded"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="contact-info">
|
<div className="contact-info">
|
||||||
<div className="contact-name">{contact.displayName}</div>
|
<div className="contact-name">{contact.displayName}</div>
|
||||||
@@ -7514,11 +7634,12 @@ function ExportPage() {
|
|||||||
<div className="session-mutual-friends-header">
|
<div className="session-mutual-friends-header">
|
||||||
<div className="session-mutual-friends-header-main">
|
<div className="session-mutual-friends-header-main">
|
||||||
<div className="session-mutual-friends-avatar">
|
<div className="session-mutual-friends-avatar">
|
||||||
{sessionMutualFriendsDialogTarget.avatarUrl ? (
|
<Avatar
|
||||||
<img src={sessionMutualFriendsDialogTarget.avatarUrl} alt="" />
|
src={normalizeExportAvatarUrl(sessionMutualFriendsDialogTarget.avatarUrl)}
|
||||||
) : (
|
name={sessionMutualFriendsDialogTarget.displayName}
|
||||||
<span>{getAvatarLetter(sessionMutualFriendsDialogTarget.displayName)}</span>
|
size="100%"
|
||||||
)}
|
shape="rounded"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="session-mutual-friends-meta">
|
<div className="session-mutual-friends-meta">
|
||||||
<h4>{sessionMutualFriendsDialogTarget.displayName} 的共同好友</h4>
|
<h4>{sessionMutualFriendsDialogTarget.displayName} 的共同好友</h4>
|
||||||
@@ -7599,11 +7720,12 @@ function ExportPage() {
|
|||||||
<div className="detail-header">
|
<div className="detail-header">
|
||||||
<div className="detail-header-main">
|
<div className="detail-header-main">
|
||||||
<div className="detail-header-avatar">
|
<div className="detail-header-avatar">
|
||||||
{sessionDetail?.avatarUrl ? (
|
<Avatar
|
||||||
<img src={sessionDetail.avatarUrl} alt="" />
|
src={normalizeExportAvatarUrl(sessionDetail?.avatarUrl)}
|
||||||
) : (
|
name={sessionDetail?.displayName || sessionDetail?.wxid || ''}
|
||||||
<span>{getAvatarLetter(sessionDetail?.displayName || sessionDetail?.wxid || '')}</span>
|
size="100%"
|
||||||
)}
|
shape="rounded"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="detail-header-meta">
|
<div className="detail-header-meta">
|
||||||
<h4>{sessionDetail?.displayName || '会话详情'}</h4>
|
<h4>{sessionDetail?.displayName || '会话详情'}</h4>
|
||||||
|
|||||||
@@ -1145,6 +1145,185 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quote-layout-group {
|
||||||
|
margin-top: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-picker {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-card {
|
||||||
|
position: relative;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 14px 14px 12px;
|
||||||
|
background: color-mix(in srgb, var(--primary) 6%, var(--bg-primary));
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: color-mix(in srgb, var(--primary) 32%, var(--border-color));
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
border-color: color-mix(in srgb, var(--primary) 68%, var(--border-color));
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent);
|
||||||
|
background: color-mix(in srgb, var(--primary) 10%, var(--bg-primary));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-card-check {
|
||||||
|
position: absolute;
|
||||||
|
top: 12px;
|
||||||
|
left: 12px;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1.5px solid color-mix(in srgb, var(--primary) 46%, var(--border-color));
|
||||||
|
background: transparent;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: color-mix(in srgb, var(--primary) 78%, #6f8653);
|
||||||
|
transform: scale(0);
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
border-color: color-mix(in srgb, var(--primary) 78%, var(--border-color));
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active::after {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-shell {
|
||||||
|
padding-left: 22px;
|
||||||
|
min-height: 72px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-bubble {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
max-width: 70%;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-bubble.sent {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-bubble.sent .bubble-content {
|
||||||
|
background: var(--primary);
|
||||||
|
color: var(--on-primary);
|
||||||
|
border-radius: 18px 18px 4px 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .bubble-content {
|
||||||
|
padding: 10px 14px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6;
|
||||||
|
word-break: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-text {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .quoted-message {
|
||||||
|
background: rgba(0, 0, 0, 0.04);
|
||||||
|
border-left: 2px solid var(--primary);
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .quoted-sender {
|
||||||
|
color: var(--primary);
|
||||||
|
font-weight: 500;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .quoted-sender::after {
|
||||||
|
content: ':';
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .quoted-text {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-bubble.sent .quoted-message {
|
||||||
|
background: color-mix(in srgb, var(--on-primary) 12%, var(--primary));
|
||||||
|
border-left-color: color-mix(in srgb, var(--on-primary) 36%, var(--primary));
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-bubble.sent .quoted-sender {
|
||||||
|
color: color-mix(in srgb, var(--on-primary) 92%, var(--primary));
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .message-bubble.sent .quoted-text {
|
||||||
|
color: color-mix(in srgb, var(--on-primary) 80%, var(--primary));
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .bubble-content.quote-layout-top .quoted-message {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-preview-chat .bubble-content.quote-layout-bottom .quoted-message {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-card-footer {
|
||||||
|
margin-top: 8px;
|
||||||
|
padding-left: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-card-title-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-card-title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote-layout-card-desc {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 760px) {
|
||||||
|
.quote-layout-picker {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.theme-grid {
|
.theme-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
const [notificationFilterMode, setNotificationFilterMode] = useState<'all' | 'whitelist' | 'blacklist'>('all')
|
const [notificationFilterMode, setNotificationFilterMode] = useState<'all' | 'whitelist' | 'blacklist'>('all')
|
||||||
const [notificationFilterList, setNotificationFilterList] = useState<string[]>([])
|
const [notificationFilterList, setNotificationFilterList] = useState<string[]>([])
|
||||||
const [windowCloseBehavior, setWindowCloseBehavior] = useState<configService.WindowCloseBehavior>('ask')
|
const [windowCloseBehavior, setWindowCloseBehavior] = useState<configService.WindowCloseBehavior>('ask')
|
||||||
|
const [quoteLayout, setQuoteLayout] = useState<configService.QuoteLayout>('quote-top')
|
||||||
const [filterSearchKeyword, setFilterSearchKeyword] = useState('')
|
const [filterSearchKeyword, setFilterSearchKeyword] = useState('')
|
||||||
const [filterModeDropdownOpen, setFilterModeDropdownOpen] = useState(false)
|
const [filterModeDropdownOpen, setFilterModeDropdownOpen] = useState(false)
|
||||||
const [positionDropdownOpen, setPositionDropdownOpen] = useState(false)
|
const [positionDropdownOpen, setPositionDropdownOpen] = useState(false)
|
||||||
@@ -314,6 +315,7 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
const savedNotificationFilterList = await configService.getNotificationFilterList()
|
const savedNotificationFilterList = await configService.getNotificationFilterList()
|
||||||
const savedMessagePushEnabled = await configService.getMessagePushEnabled()
|
const savedMessagePushEnabled = await configService.getMessagePushEnabled()
|
||||||
const savedWindowCloseBehavior = await configService.getWindowCloseBehavior()
|
const savedWindowCloseBehavior = await configService.getWindowCloseBehavior()
|
||||||
|
const savedQuoteLayout = await configService.getQuoteLayout()
|
||||||
|
|
||||||
const savedAuthEnabled = await window.electronAPI.auth.verifyEnabled()
|
const savedAuthEnabled = await window.electronAPI.auth.verifyEnabled()
|
||||||
const savedAuthUseHello = await configService.getAuthUseHello()
|
const savedAuthUseHello = await configService.getAuthUseHello()
|
||||||
@@ -351,6 +353,7 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
setNotificationFilterList(savedNotificationFilterList)
|
setNotificationFilterList(savedNotificationFilterList)
|
||||||
setMessagePushEnabled(savedMessagePushEnabled)
|
setMessagePushEnabled(savedMessagePushEnabled)
|
||||||
setWindowCloseBehavior(savedWindowCloseBehavior)
|
setWindowCloseBehavior(savedWindowCloseBehavior)
|
||||||
|
setQuoteLayout(savedQuoteLayout)
|
||||||
|
|
||||||
const savedExcludeWords = await configService.getWordCloudExcludeWords()
|
const savedExcludeWords = await configService.getWordCloudExcludeWords()
|
||||||
setWordCloudExcludeWords(savedExcludeWords)
|
setWordCloudExcludeWords(savedExcludeWords)
|
||||||
@@ -1058,6 +1061,79 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group quote-layout-group">
|
||||||
|
<label>引用消息样式</label>
|
||||||
|
<span className="form-hint">选择聊天中引用消息与正文的上下顺序,下方预览会同步展示布局差异。</span>
|
||||||
|
<div className="quote-layout-picker" role="radiogroup" aria-label="引用样式选择">
|
||||||
|
{[
|
||||||
|
{
|
||||||
|
value: 'quote-top' as const,
|
||||||
|
label: '引用在上',
|
||||||
|
description: '更接近当前 WeFlow 风格',
|
||||||
|
successMessage: '已切换为引用在上样式'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'quote-bottom' as const,
|
||||||
|
label: '正文在上',
|
||||||
|
description: '更接近微信 / 密语风格',
|
||||||
|
successMessage: '已切换为正文在上样式'
|
||||||
|
}
|
||||||
|
].map(option => {
|
||||||
|
const selected = quoteLayout === option.value
|
||||||
|
const isQuoteBottom = option.value === 'quote-bottom'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={option.value}
|
||||||
|
type="button"
|
||||||
|
className={`quote-layout-card ${selected ? 'active' : ''}`}
|
||||||
|
onClick={async () => {
|
||||||
|
if (selected) return
|
||||||
|
setQuoteLayout(option.value)
|
||||||
|
await configService.setQuoteLayout(option.value)
|
||||||
|
showMessage(option.successMessage, true)
|
||||||
|
}}
|
||||||
|
role="radio"
|
||||||
|
aria-checked={selected}
|
||||||
|
>
|
||||||
|
<span className={`quote-layout-card-check ${selected ? 'active' : ''}`} aria-hidden="true" />
|
||||||
|
<div className="quote-layout-preview-shell">
|
||||||
|
<div className="quote-layout-preview-chat">
|
||||||
|
<div className="message-bubble sent">
|
||||||
|
<div className={`bubble-content ${isQuoteBottom ? 'quote-layout-bottom' : 'quote-layout-top'}`}>
|
||||||
|
{isQuoteBottom ? (
|
||||||
|
<>
|
||||||
|
<div className="message-text">拍得真不错!</div>
|
||||||
|
<div className="quoted-message">
|
||||||
|
<span className="quoted-sender">张三</span>
|
||||||
|
<span className="quoted-text">那天去爬山的照片...</span>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="quoted-message">
|
||||||
|
<span className="quoted-sender">张三</span>
|
||||||
|
<span className="quoted-text">那天去爬山的照片...</span>
|
||||||
|
</div>
|
||||||
|
<div className="message-text">拍得真不错!</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="quote-layout-card-footer">
|
||||||
|
<div className="quote-layout-card-title-group">
|
||||||
|
<span className="quote-layout-card-title">{option.label}</span>
|
||||||
|
<span className="quote-layout-card-desc">{option.description}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="divider" />
|
<div className="divider" />
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import './WelcomePage.scss'
|
|||||||
|
|
||||||
const isMac = navigator.userAgent.toLowerCase().includes('mac')
|
const isMac = navigator.userAgent.toLowerCase().includes('mac')
|
||||||
const isLinux = navigator.userAgent.toLowerCase().includes('linux')
|
const isLinux = navigator.userAgent.toLowerCase().includes('linux')
|
||||||
|
const isWindows = !isMac && !isLinux
|
||||||
|
|
||||||
const dbDirName = isMac ? '2.0b4.0.9 目录' : 'xwechat_files 目录'
|
const dbDirName = isMac ? '2.0b4.0.9 目录' : 'xwechat_files 目录'
|
||||||
const dbPathPlaceholder = isMac
|
const dbPathPlaceholder = isMac
|
||||||
@@ -46,6 +47,19 @@ const formatDbKeyFailureMessage = (error?: string, logs?: string[]): string => {
|
|||||||
return `${base};最近状态:${tailLogs.join(' | ')}`
|
return `${base};最近状态:${tailLogs.join(' | ')}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizeDbKeyStatusMessage = (message: string): string => {
|
||||||
|
if (isWindows && message.includes('Hook安装成功')) {
|
||||||
|
return '已准备就绪,现在登录微信或退出登录后重新登录微信'
|
||||||
|
}
|
||||||
|
return message
|
||||||
|
}
|
||||||
|
|
||||||
|
const isDbKeyReadyMessage = (message: string): boolean => (
|
||||||
|
message.includes('现在可以登录')
|
||||||
|
|| message.includes('Hook安装成功')
|
||||||
|
|| message.includes('已准备就绪,现在登录微信或退出登录后重新登录微信')
|
||||||
|
)
|
||||||
|
|
||||||
function WelcomePage({ standalone = false }: WelcomePageProps) {
|
function WelcomePage({ standalone = false }: WelcomePageProps) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { isDbConnected, setDbConnected, setLoading } = useAppStore()
|
const { isDbConnected, setDbConnected, setLoading } = useAppStore()
|
||||||
@@ -139,8 +153,9 @@ function WelcomePage({ standalone = false }: WelcomePageProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const removeDb = window.electronAPI.key.onDbKeyStatus((payload: { message: string; level: number }) => {
|
const removeDb = window.electronAPI.key.onDbKeyStatus((payload: { message: string; level: number }) => {
|
||||||
setDbKeyStatus(payload.message)
|
const normalizedMessage = normalizeDbKeyStatusMessage(payload.message)
|
||||||
if (payload.message.includes('现在可以登录') || payload.message.includes('Hook安装成功')) {
|
setDbKeyStatus(normalizedMessage)
|
||||||
|
if (isDbKeyReadyMessage(normalizedMessage)) {
|
||||||
window.electronAPI.notification?.show({
|
window.electronAPI.notification?.show({
|
||||||
title: 'WeFlow 准备就绪',
|
title: 'WeFlow 准备就绪',
|
||||||
content: '现在可以登录微信了',
|
content: '现在可以登录微信了',
|
||||||
@@ -761,8 +776,7 @@ function WelcomePage({ standalone = false }: WelcomePageProps) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{dbKeyStatus && <div className={`status-message ${dbKeyStatus.includes('现在可以登录') || dbKeyStatus.includes('Hook安装成功') ? 'is-success' : ''}`}>{dbKeyStatus}</div>}
|
{dbKeyStatus && <div className={`status-message ${isDbKeyReadyMessage(dbKeyStatus) ? 'is-success' : ''}`}>{dbKeyStatus}</div>}
|
||||||
<div className="field-hint">点击自动获取后微信将重启,请留意弹窗提示</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export const CONFIG_KEYS = {
|
|||||||
NOTIFICATION_FILTER_LIST: 'notificationFilterList',
|
NOTIFICATION_FILTER_LIST: 'notificationFilterList',
|
||||||
MESSAGE_PUSH_ENABLED: 'messagePushEnabled',
|
MESSAGE_PUSH_ENABLED: 'messagePushEnabled',
|
||||||
WINDOW_CLOSE_BEHAVIOR: 'windowCloseBehavior',
|
WINDOW_CLOSE_BEHAVIOR: 'windowCloseBehavior',
|
||||||
|
QUOTE_LAYOUT: 'quoteLayout',
|
||||||
|
|
||||||
// 词云
|
// 词云
|
||||||
WORD_CLOUD_EXCLUDE_WORDS: 'wordCloudExcludeWords',
|
WORD_CLOUD_EXCLUDE_WORDS: 'wordCloudExcludeWords',
|
||||||
@@ -90,6 +91,7 @@ export interface ExportDefaultMediaConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type WindowCloseBehavior = 'ask' | 'tray' | 'quit'
|
export type WindowCloseBehavior = 'ask' | 'tray' | 'quit'
|
||||||
|
export type QuoteLayout = 'quote-top' | 'quote-bottom'
|
||||||
|
|
||||||
const DEFAULT_EXPORT_MEDIA_CONFIG: ExportDefaultMediaConfig = {
|
const DEFAULT_EXPORT_MEDIA_CONFIG: ExportDefaultMediaConfig = {
|
||||||
images: true,
|
images: true,
|
||||||
@@ -660,6 +662,7 @@ export interface ContactsListCacheContact {
|
|||||||
displayName: string
|
displayName: string
|
||||||
remark?: string
|
remark?: string
|
||||||
nickname?: string
|
nickname?: string
|
||||||
|
alias?: string
|
||||||
type: 'friend' | 'group' | 'official' | 'former_friend' | 'other'
|
type: 'friend' | 'group' | 'official' | 'former_friend' | 'other'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1172,6 +1175,7 @@ export async function getContactsListCache(scopeKey: string): Promise<ContactsLi
|
|||||||
displayName,
|
displayName,
|
||||||
remark: typeof item.remark === 'string' ? item.remark : undefined,
|
remark: typeof item.remark === 'string' ? item.remark : undefined,
|
||||||
nickname: typeof item.nickname === 'string' ? item.nickname : undefined,
|
nickname: typeof item.nickname === 'string' ? item.nickname : undefined,
|
||||||
|
alias: typeof item.alias === 'string' ? item.alias : undefined,
|
||||||
type: (type === 'friend' || type === 'group' || type === 'official' || type === 'former_friend' || type === 'other')
|
type: (type === 'friend' || type === 'group' || type === 'official' || type === 'former_friend' || type === 'other')
|
||||||
? type
|
? type
|
||||||
: 'other'
|
: 'other'
|
||||||
@@ -1205,6 +1209,7 @@ export async function setContactsListCache(scopeKey: string, contacts: ContactsL
|
|||||||
displayName,
|
displayName,
|
||||||
remark: contact?.remark ? String(contact.remark) : undefined,
|
remark: contact?.remark ? String(contact.remark) : undefined,
|
||||||
nickname: contact?.nickname ? String(contact.nickname) : undefined,
|
nickname: contact?.nickname ? String(contact.nickname) : undefined,
|
||||||
|
alias: contact?.alias ? String(contact.alias) : undefined,
|
||||||
type
|
type
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1409,6 +1414,16 @@ export async function setWindowCloseBehavior(behavior: WindowCloseBehavior): Pro
|
|||||||
await config.set(CONFIG_KEYS.WINDOW_CLOSE_BEHAVIOR, behavior)
|
await config.set(CONFIG_KEYS.WINDOW_CLOSE_BEHAVIOR, behavior)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getQuoteLayout(): Promise<QuoteLayout> {
|
||||||
|
const value = await config.get(CONFIG_KEYS.QUOTE_LAYOUT)
|
||||||
|
if (value === 'quote-bottom') return value
|
||||||
|
return 'quote-top'
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setQuoteLayout(layout: QuoteLayout): Promise<void> {
|
||||||
|
await config.set(CONFIG_KEYS.QUOTE_LAYOUT, layout)
|
||||||
|
}
|
||||||
|
|
||||||
// 获取词云排除词列表
|
// 获取词云排除词列表
|
||||||
export async function getWordCloudExcludeWords(): Promise<string[]> {
|
export async function getWordCloudExcludeWords(): Promise<string[]> {
|
||||||
const value = await config.get(CONFIG_KEYS.WORD_CLOUD_EXCLUDE_WORDS)
|
const value = await config.get(CONFIG_KEYS.WORD_CLOUD_EXCLUDE_WORDS)
|
||||||
|
|||||||
Reference in New Issue
Block a user