mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
修复了导出页面一些小问题
This commit is contained in:
@@ -2871,8 +2871,8 @@ class ChatService {
|
||||
private shouldKeepSession(username: string): boolean {
|
||||
if (!username) return false
|
||||
const lowered = username.toLowerCase()
|
||||
// placeholder_foldgroup 是折叠群入口,需要保留
|
||||
if (lowered.includes('@placeholder') && !lowered.includes('foldgroup')) return false
|
||||
// 排除所有 placeholder 会话(包括折叠群)
|
||||
if (lowered.includes('@placeholder')) return false
|
||||
if (username.startsWith('gh_')) return false
|
||||
|
||||
const excludeList = [
|
||||
|
||||
68
electron/services/cloudControlService.ts
Normal file
68
electron/services/cloudControlService.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { app } from 'electron'
|
||||
import { wcdbService } from './wcdbService'
|
||||
|
||||
interface UsageStats {
|
||||
appVersion: string
|
||||
platform: string
|
||||
deviceId: string
|
||||
timestamp: number
|
||||
online: boolean
|
||||
pages: string[]
|
||||
}
|
||||
|
||||
class CloudControlService {
|
||||
private deviceId: string = ''
|
||||
private timer: NodeJS.Timeout | null = null
|
||||
private pages: Set<string> = new Set()
|
||||
|
||||
async init() {
|
||||
this.deviceId = this.getDeviceId()
|
||||
await wcdbService.cloudInit(300)
|
||||
await this.reportOnline()
|
||||
|
||||
this.timer = setInterval(() => {
|
||||
this.reportOnline()
|
||||
}, 300000)
|
||||
}
|
||||
|
||||
private getDeviceId(): string {
|
||||
const crypto = require('crypto')
|
||||
const os = require('os')
|
||||
const machineId = os.hostname() + os.platform() + os.arch()
|
||||
return crypto.createHash('md5').update(machineId).digest('hex')
|
||||
}
|
||||
|
||||
private async reportOnline() {
|
||||
const data: UsageStats = {
|
||||
appVersion: app.getVersion(),
|
||||
platform: process.platform,
|
||||
deviceId: this.deviceId,
|
||||
timestamp: Date.now(),
|
||||
online: true,
|
||||
pages: Array.from(this.pages)
|
||||
}
|
||||
|
||||
await wcdbService.cloudReport(JSON.stringify(data))
|
||||
this.pages.clear()
|
||||
}
|
||||
|
||||
recordPage(pageName: string) {
|
||||
this.pages.add(pageName)
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
wcdbService.cloudStop()
|
||||
}
|
||||
|
||||
async getLogs() {
|
||||
return wcdbService.getLogs()
|
||||
}
|
||||
}
|
||||
|
||||
export const cloudControlService = new CloudControlService()
|
||||
|
||||
|
||||
@@ -431,20 +431,6 @@ class SnsService {
|
||||
const result = await wcdbService.getSnsTimeline(limit, offset, usernames, keyword, startTime, endTime)
|
||||
if (!result.success || !result.timeline || result.timeline.length === 0) return result
|
||||
|
||||
// 诊断:测试 execQuery 查 content 字段
|
||||
try {
|
||||
const testResult = await wcdbService.execQuery('sns', null, 'SELECT tid, CAST(content AS TEXT) as ct, typeof(content) as ctype FROM SnsTimeLine ORDER BY tid DESC LIMIT 1')
|
||||
if (testResult.success && testResult.rows?.[0]) {
|
||||
const r = testResult.rows[0]
|
||||
console.log('[SnsService] execQuery 诊断: ctype=', r.ctype, 'ct长度=', r.ct?.length, 'ct前200=', r.ct?.substring(0, 200))
|
||||
console.log('[SnsService] ct包含CommentUserList:', r.ct?.includes('CommentUserList'))
|
||||
} else {
|
||||
console.log('[SnsService] execQuery 诊断失败:', testResult.error)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[SnsService] execQuery 诊断异常:', e)
|
||||
}
|
||||
|
||||
const enrichedTimeline = result.timeline.map((post: any) => {
|
||||
const contact = this.contactCache.get(post.username)
|
||||
const isVideoPost = post.type === 15
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { join, dirname, basename } from 'path'
|
||||
import { join, dirname, basename } from 'path'
|
||||
import { appendFileSync, existsSync, mkdirSync, readdirSync, statSync, readFileSync } from 'fs'
|
||||
|
||||
// DLL 初始化错误信息,用于帮助用户诊断问题
|
||||
@@ -114,6 +114,9 @@ export class WcdbCore {
|
||||
private wcdbStartMonitorPipe: any = null
|
||||
private wcdbStopMonitorPipe: any = null
|
||||
private wcdbGetMonitorPipeName: any = null
|
||||
private wcdbCloudInit: any = null
|
||||
private wcdbCloudReport: any = null
|
||||
private wcdbCloudStop: any = null
|
||||
|
||||
private monitorPipeClient: any = null
|
||||
private monitorCallback: ((type: string, json: string) => void) | null = null
|
||||
@@ -702,6 +705,26 @@ export class WcdbCore {
|
||||
this.wcdbVerifyUser = null
|
||||
}
|
||||
|
||||
// wcdb_status wcdb_cloud_init(int32_t interval_seconds)
|
||||
try {
|
||||
this.wcdbCloudInit = this.lib.func('int32 wcdb_cloud_init(int32 intervalSeconds)')
|
||||
} catch {
|
||||
this.wcdbCloudInit = null
|
||||
}
|
||||
|
||||
// wcdb_status wcdb_cloud_report(const char* stats_json)
|
||||
try {
|
||||
this.wcdbCloudReport = this.lib.func('int32 wcdb_cloud_report(const char* statsJson)')
|
||||
} catch {
|
||||
this.wcdbCloudReport = null
|
||||
}
|
||||
|
||||
// void wcdb_cloud_stop()
|
||||
try {
|
||||
this.wcdbCloudStop = this.lib.func('void wcdb_cloud_stop()')
|
||||
} catch {
|
||||
this.wcdbCloudStop = null
|
||||
}
|
||||
|
||||
|
||||
// 初始化
|
||||
@@ -1841,8 +1864,57 @@ export class WcdbCore {
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 Windows Hello
|
||||
* 数据收集初始化
|
||||
*/
|
||||
async cloudInit(intervalSeconds: number = 600): Promise<{ success: boolean; error?: string }> {
|
||||
if (!this.initialized) {
|
||||
const initOk = await this.initialize()
|
||||
if (!initOk) return { success: false, error: 'WCDB init failed' }
|
||||
}
|
||||
if (!this.wcdbCloudInit) {
|
||||
return { success: false, error: 'Cloud init API not supported by DLL' }
|
||||
}
|
||||
try {
|
||||
const result = this.wcdbCloudInit(intervalSeconds)
|
||||
if (result !== 0) {
|
||||
return { success: false, error: `Cloud init failed: ${result}` }
|
||||
}
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: String(e) }
|
||||
}
|
||||
}
|
||||
|
||||
async cloudReport(statsJson: string): Promise<{ success: boolean; error?: string }> {
|
||||
if (!this.initialized) {
|
||||
const initOk = await this.initialize()
|
||||
if (!initOk) return { success: false, error: 'WCDB init failed' }
|
||||
}
|
||||
if (!this.wcdbCloudReport) {
|
||||
return { success: false, error: 'Cloud report API not supported by DLL' }
|
||||
}
|
||||
try {
|
||||
const result = this.wcdbCloudReport(statsJson || '')
|
||||
if (result !== 0) {
|
||||
return { success: false, error: `Cloud report failed: ${result}` }
|
||||
}
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: String(e) }
|
||||
}
|
||||
}
|
||||
|
||||
cloudStop(): { success: boolean; error?: string } {
|
||||
if (!this.wcdbCloudStop) {
|
||||
return { success: false, error: 'Cloud stop API not supported by DLL' }
|
||||
}
|
||||
try {
|
||||
this.wcdbCloudStop()
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: String(e) }
|
||||
}
|
||||
}
|
||||
async verifyUser(message: string, hwnd?: string): Promise<{ success: boolean; error?: string }> {
|
||||
if (!this.initialized) {
|
||||
const initOk = await this.initialize()
|
||||
|
||||
@@ -479,6 +479,27 @@ export class WcdbService {
|
||||
return this.callWorker('deleteMessage', { sessionId, localId, createTime, dbPathHint })
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据收集:初始化
|
||||
*/
|
||||
async cloudInit(intervalSeconds: number): Promise<{ success: boolean; error?: string }> {
|
||||
return this.callWorker('cloudInit', { intervalSeconds })
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据收集:上报数据
|
||||
*/
|
||||
async cloudReport(statsJson: string): Promise<{ success: boolean; error?: string }> {
|
||||
return this.callWorker('cloudReport', { statsJson })
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据收集:停止
|
||||
*/
|
||||
cloudStop(): Promise<{ success: boolean; error?: string }> {
|
||||
return this.callWorker('cloudStop', {})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user