mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-05-06 07:26:48 +00:00
修复联系人页面导出异常
This commit is contained in:
@@ -166,7 +166,15 @@ async function run() {
|
||||
|
||||
let result: any
|
||||
if (config.mode === 'contacts') {
|
||||
const { contactExportService } = await import('./services/contactExportService')
|
||||
const [{ contactExportService }, { chatService }] = await Promise.all([
|
||||
import('./services/contactExportService'),
|
||||
import('./services/chatService')
|
||||
])
|
||||
chatService.setRuntimeConfig({
|
||||
dbPath: config.dbPath,
|
||||
decryptKey: config.decryptKey,
|
||||
myWxid: config.myWxid
|
||||
})
|
||||
result = await contactExportService.exportContacts(
|
||||
String(config.outputDir || ''),
|
||||
config.options || {}
|
||||
|
||||
@@ -344,6 +344,7 @@ const FRIEND_EXCLUDE_USERNAMES = new Set(['medianote', 'floatbottle', 'qmessage'
|
||||
|
||||
class ChatService {
|
||||
private configService: ConfigService
|
||||
private runtimeConfig?: { dbPath?: string; decryptKey?: string; myWxid?: string }
|
||||
private connected = false
|
||||
private readonly dbMonitorListeners = new Set<(type: string, json: string) => void>()
|
||||
private messageCursors: Map<string, { cursor: number; fetched: number; batchSize: number; startTime?: number; endTime?: number; ascending?: boolean; bufferedMessages?: any[] }> = new Map()
|
||||
@@ -452,6 +453,10 @@ class ChatService {
|
||||
this.voiceTranscriptCache = new LRUCache(1000) // 最多缓存1000条转写记录
|
||||
}
|
||||
|
||||
setRuntimeConfig(config: { dbPath?: string; decryptKey?: string; myWxid?: string }): void {
|
||||
this.runtimeConfig = config
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理账号目录名
|
||||
*/
|
||||
@@ -537,12 +542,9 @@ class ChatService {
|
||||
*/
|
||||
async connect(): Promise<{ success: boolean; error?: string }> {
|
||||
try {
|
||||
if (this.connected && wcdbService.isReady()) {
|
||||
return { success: true }
|
||||
}
|
||||
const wxid = this.configService.get('myWxid')
|
||||
const dbPath = this.configService.get('dbPath')
|
||||
const decryptKey = this.configService.get('decryptKey')
|
||||
const wxid = String(this.runtimeConfig?.myWxid || this.configService.get('myWxid') || '').trim()
|
||||
const dbPath = String(this.runtimeConfig?.dbPath || this.configService.get('dbPath') || '').trim()
|
||||
const decryptKey = String(this.runtimeConfig?.decryptKey || this.configService.get('decryptKey') || '').trim()
|
||||
if (!wxid) {
|
||||
return { success: false, error: '请先在设置页面配置微信ID' }
|
||||
}
|
||||
@@ -553,6 +555,10 @@ class ChatService {
|
||||
return { success: false, error: '请先在设置页面配置解密密钥' }
|
||||
}
|
||||
|
||||
if (this.connected && wcdbService.isReady()) {
|
||||
return { success: true }
|
||||
}
|
||||
|
||||
// 使用 ConfigService 统一解析账号目录
|
||||
const accountDir = this.configService.getAccountDir(dbPath, wxid)
|
||||
if (!accountDir) {
|
||||
|
||||
Reference in New Issue
Block a user