mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-28 07:25:53 +00:00
支持联系人签名、标签分组、地区获取;优化导出效果
This commit is contained in:
@@ -18,7 +18,7 @@ const AVATAR_ENRICH_BATCH_SIZE = 80
|
||||
const SEARCH_DEBOUNCE_MS = 120
|
||||
const VIRTUAL_ROW_HEIGHT = 76
|
||||
const VIRTUAL_OVERSCAN = 10
|
||||
const DEFAULT_CONTACTS_LOAD_TIMEOUT_MS = 3000
|
||||
const DEFAULT_CONTACTS_LOAD_TIMEOUT_MS = 10000
|
||||
const AVATAR_RECHECK_INTERVAL_MS = 24 * 60 * 60 * 1000
|
||||
|
||||
interface ContactsLoadSession {
|
||||
@@ -400,6 +400,7 @@ function ContactsPage() {
|
||||
alias: contact.alias,
|
||||
labels: contact.labels,
|
||||
detailDescription: contact.detailDescription,
|
||||
region: contact.region,
|
||||
type: contact.type
|
||||
}))
|
||||
).catch((error) => {
|
||||
@@ -1114,8 +1115,15 @@ function ContactsPage() {
|
||||
<div className="detail-row"><span className="detail-label">昵称</span><span className="detail-value">{selectedContact.nickname || selectedContact.displayName}</span></div>
|
||||
{selectedContact.remark && <div className="detail-row"><span className="detail-label">备注</span><span className="detail-value">{selectedContact.remark}</span></div>}
|
||||
{selectedContact.alias && <div className="detail-row"><span className="detail-label">微信号</span><span className="detail-value">{selectedContact.alias}</span></div>}
|
||||
{selectedContact.labels && selectedContact.labels.length > 0 && <div className="detail-row"><span className="detail-label">标签</span><span className="detail-value">{selectedContact.labels.join('、')}</span></div>}
|
||||
{selectedContact.detailDescription && <div className="detail-row"><span className="detail-label">详细描述</span><span className="detail-value">{selectedContact.detailDescription}</span></div>}
|
||||
{selectedContact.labels && selectedContact.labels.length > 0 && (
|
||||
<div className="detail-row"><span className="detail-label">标签</span><span className="detail-value">{selectedContact.labels.join('、')}</span></div>
|
||||
)}
|
||||
{selectedContact.detailDescription && (
|
||||
<div className="detail-row"><span className="detail-label">个性签名</span><span className="detail-value">{selectedContact.detailDescription}</span></div>
|
||||
)}
|
||||
{selectedContact.region && (
|
||||
<div className="detail-row"><span className="detail-label">地区</span><span className="detail-value">{selectedContact.region}</span></div>
|
||||
)}
|
||||
<div className="detail-row"><span className="detail-label">类型</span><span className="detail-value">{getContactTypeName(selectedContact.type)}</span></div>
|
||||
{selectedContactSupportsSns && (
|
||||
<div className="detail-row">
|
||||
|
||||
@@ -568,7 +568,7 @@ const createTaskId = (): string => `task-${Date.now()}-${Math.random().toString(
|
||||
const CONTACT_ENRICH_TIMEOUT_MS = 7000
|
||||
const EXPORT_SNS_STATS_CACHE_STALE_MS = 12 * 60 * 60 * 1000
|
||||
const EXPORT_AVATAR_ENRICH_BATCH_SIZE = 80
|
||||
const DEFAULT_CONTACTS_LOAD_TIMEOUT_MS = 3000
|
||||
const DEFAULT_CONTACTS_LOAD_TIMEOUT_MS = 10000
|
||||
const EXPORT_REENTER_SESSION_SOFT_REFRESH_MS = 5 * 60 * 1000
|
||||
const EXPORT_REENTER_CONTACTS_SOFT_REFRESH_MS = 5 * 60 * 1000
|
||||
const EXPORT_REENTER_SNS_SOFT_REFRESH_MS = 3 * 60 * 1000
|
||||
@@ -1928,7 +1928,7 @@ function ExportPage() {
|
||||
|
||||
setIsContactsListLoading(true)
|
||||
try {
|
||||
const contactsResult = await window.electronAPI.chat.getContacts()
|
||||
const contactsResult = await window.electronAPI.chat.getContacts({ lite: true })
|
||||
if (contactsLoadVersionRef.current !== loadVersion) return
|
||||
|
||||
if (contactsResult.success && contactsResult.contacts) {
|
||||
@@ -3782,7 +3782,7 @@ function ExportPage() {
|
||||
|
||||
if (isStale()) return
|
||||
if (detailStatsPriorityRef.current) return
|
||||
const contactsResult = await withTimeout(window.electronAPI.chat.getContacts(), CONTACT_ENRICH_TIMEOUT_MS)
|
||||
const contactsResult = await withTimeout(window.electronAPI.chat.getContacts({ lite: true }), CONTACT_ENRICH_TIMEOUT_MS)
|
||||
if (isStale()) return
|
||||
|
||||
const contactsFromNetwork: ContactInfo[] = contactsResult?.success && contactsResult.contacts ? contactsResult.contacts : []
|
||||
|
||||
@@ -665,6 +665,7 @@ export interface ContactsListCacheContact {
|
||||
alias?: string
|
||||
labels?: string[]
|
||||
detailDescription?: string
|
||||
region?: string
|
||||
type: 'friend' | 'group' | 'official' | 'former_friend' | 'other'
|
||||
}
|
||||
|
||||
@@ -1139,16 +1140,18 @@ export async function setSnsPageCache(
|
||||
export async function getContactsLoadTimeoutMs(): Promise<number> {
|
||||
const value = await config.get(CONFIG_KEYS.CONTACTS_LOAD_TIMEOUT_MS)
|
||||
if (typeof value === 'number' && Number.isFinite(value) && value >= 1000 && value <= 60000) {
|
||||
return Math.floor(value)
|
||||
const normalized = Math.floor(value)
|
||||
// 兼容历史默认值 3000ms:自动提升到新的更稳妥阈值。
|
||||
return normalized === 3000 ? 10000 : normalized
|
||||
}
|
||||
return 3000
|
||||
return 10000
|
||||
}
|
||||
|
||||
// 设置通讯录加载超时阈值(毫秒)
|
||||
export async function setContactsLoadTimeoutMs(timeoutMs: number): Promise<void> {
|
||||
const normalized = Number.isFinite(timeoutMs)
|
||||
? Math.min(60000, Math.max(1000, Math.floor(timeoutMs)))
|
||||
: 3000
|
||||
: 10000
|
||||
await config.set(CONFIG_KEYS.CONTACTS_LOAD_TIMEOUT_MS, normalized)
|
||||
}
|
||||
|
||||
@@ -1181,7 +1184,8 @@ export async function getContactsListCache(scopeKey: string): Promise<ContactsLi
|
||||
labels: Array.isArray(item.labels)
|
||||
? Array.from(new Set(item.labels.map((label) => String(label || '').trim()).filter(Boolean)))
|
||||
: undefined,
|
||||
detailDescription: typeof item.detailDescription === 'string' ? item.detailDescription : undefined,
|
||||
detailDescription: typeof item.detailDescription === 'string' ? (item.detailDescription.trim() || undefined) : undefined,
|
||||
region: typeof item.region === 'string' ? (item.region.trim() || undefined) : undefined,
|
||||
type: (type === 'friend' || type === 'group' || type === 'official' || type === 'former_friend' || type === 'other')
|
||||
? type
|
||||
: 'other'
|
||||
@@ -1219,7 +1223,8 @@ export async function setContactsListCache(scopeKey: string, contacts: ContactsL
|
||||
labels: Array.isArray(contact?.labels)
|
||||
? Array.from(new Set(contact.labels.map((label) => String(label || '').trim()).filter(Boolean)))
|
||||
: undefined,
|
||||
detailDescription: contact?.detailDescription ? String(contact.detailDescription) : undefined,
|
||||
detailDescription: contact?.detailDescription ? (String(contact.detailDescription).trim() || undefined) : undefined,
|
||||
region: contact?.region ? (String(contact.region).trim() || undefined) : undefined,
|
||||
type
|
||||
})
|
||||
}
|
||||
|
||||
2
src/types/electron.d.ts
vendored
2
src/types/electron.d.ts
vendored
@@ -219,7 +219,7 @@ export interface ElectronAPI {
|
||||
updateMessage: (sessionId: string, localId: number, createTime: number, newContent: string) => Promise<{ success: boolean; error?: string }>
|
||||
deleteMessage: (sessionId: string, localId: number, createTime: number, dbPathHint?: string) => Promise<{ success: boolean; error?: string }>
|
||||
resolveTransferDisplayNames: (chatroomId: string, payerUsername: string, receiverUsername: string) => Promise<{ payerName: string; receiverName: string }>
|
||||
getContacts: () => Promise<{
|
||||
getContacts: (options?: { lite?: boolean }) => Promise<{
|
||||
success: boolean
|
||||
contacts?: ContactInfo[]
|
||||
error?: string
|
||||
|
||||
@@ -39,6 +39,7 @@ export interface ContactInfo {
|
||||
alias?: string
|
||||
labels?: string[]
|
||||
detailDescription?: string
|
||||
region?: string
|
||||
avatarUrl?: string
|
||||
type: 'friend' | 'group' | 'official' | 'former_friend' | 'other'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user