mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 15:25:50 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b7b94f507 | ||
|
|
28e38f73f8 | ||
|
|
d43c0ef209 | ||
|
|
6394384be0 | ||
|
|
4f0af3d0cb | ||
|
|
2a6f833718 | ||
|
|
c8835f4d4c |
@@ -11,6 +11,7 @@ interface WorkerConfig {
|
|||||||
resourcesPath?: string
|
resourcesPath?: string
|
||||||
userDataPath?: string
|
userDataPath?: string
|
||||||
logEnabled?: boolean
|
logEnabled?: boolean
|
||||||
|
excludeWords?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = workerData as WorkerConfig
|
const config = workerData as WorkerConfig
|
||||||
@@ -29,6 +30,7 @@ async function run() {
|
|||||||
dbPath: config.dbPath,
|
dbPath: config.dbPath,
|
||||||
decryptKey: config.decryptKey,
|
decryptKey: config.decryptKey,
|
||||||
wxid: config.myWxid,
|
wxid: config.myWxid,
|
||||||
|
excludeWords: config.excludeWords,
|
||||||
onProgress: (status: string, progress: number) => {
|
onProgress: (status: string, progress: number) => {
|
||||||
parentPort?.postMessage({
|
parentPort?.postMessage({
|
||||||
type: 'dualReport:progress',
|
type: 'dualReport:progress',
|
||||||
|
|||||||
@@ -903,6 +903,9 @@ function registerIpcHandlers() {
|
|||||||
ipcMain.handle('chat:getAllVoiceMessages', async (_, sessionId: string) => {
|
ipcMain.handle('chat:getAllVoiceMessages', async (_, sessionId: string) => {
|
||||||
return chatService.getAllVoiceMessages(sessionId)
|
return chatService.getAllVoiceMessages(sessionId)
|
||||||
})
|
})
|
||||||
|
ipcMain.handle('chat:getMessageDates', async (_, sessionId: string) => {
|
||||||
|
return chatService.getMessageDates(sessionId)
|
||||||
|
})
|
||||||
ipcMain.handle('chat:resolveVoiceCache', async (_, sessionId: string, msgId: string) => {
|
ipcMain.handle('chat:resolveVoiceCache', async (_, sessionId: string, msgId: string) => {
|
||||||
return chatService.resolveVoiceCache(sessionId, msgId)
|
return chatService.resolveVoiceCache(sessionId, msgId)
|
||||||
})
|
})
|
||||||
@@ -1192,6 +1195,7 @@ function registerIpcHandlers() {
|
|||||||
const logEnabled = cfg.get('logEnabled')
|
const logEnabled = cfg.get('logEnabled')
|
||||||
const friendUsername = payload?.friendUsername
|
const friendUsername = payload?.friendUsername
|
||||||
const year = payload?.year ?? 0
|
const year = payload?.year ?? 0
|
||||||
|
const excludeWords = cfg.get('wordCloudExcludeWords') || []
|
||||||
|
|
||||||
if (!friendUsername) {
|
if (!friendUsername) {
|
||||||
return { success: false, error: '缺少好友用户名' }
|
return { success: false, error: '缺少好友用户名' }
|
||||||
@@ -1206,7 +1210,7 @@ function registerIpcHandlers() {
|
|||||||
|
|
||||||
return await new Promise((resolve) => {
|
return await new Promise((resolve) => {
|
||||||
const worker = new Worker(workerPath, {
|
const worker = new Worker(workerPath, {
|
||||||
workerData: { year, friendUsername, dbPath, decryptKey, myWxid: wxid, resourcesPath, userDataPath, logEnabled }
|
workerData: { year, friendUsername, dbPath, decryptKey, myWxid: wxid, resourcesPath, userDataPath, logEnabled, excludeWords }
|
||||||
})
|
})
|
||||||
|
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
getVoiceData: (sessionId: string, msgId: string, createTime?: number, serverId?: string | number) =>
|
getVoiceData: (sessionId: string, msgId: string, createTime?: number, serverId?: string | number) =>
|
||||||
ipcRenderer.invoke('chat:getVoiceData', sessionId, msgId, createTime, serverId),
|
ipcRenderer.invoke('chat:getVoiceData', sessionId, msgId, createTime, serverId),
|
||||||
getAllVoiceMessages: (sessionId: string) => ipcRenderer.invoke('chat:getAllVoiceMessages', sessionId),
|
getAllVoiceMessages: (sessionId: string) => ipcRenderer.invoke('chat:getAllVoiceMessages', sessionId),
|
||||||
|
getMessageDates: (sessionId: string) => ipcRenderer.invoke('chat:getMessageDates', sessionId),
|
||||||
resolveVoiceCache: (sessionId: string, msgId: string) => ipcRenderer.invoke('chat:resolveVoiceCache', sessionId, msgId),
|
resolveVoiceCache: (sessionId: string, msgId: string) => ipcRenderer.invoke('chat:resolveVoiceCache', sessionId, msgId),
|
||||||
getVoiceTranscript: (sessionId: string, msgId: string, createTime?: number) => ipcRenderer.invoke('chat:getVoiceTranscript', sessionId, msgId, createTime),
|
getVoiceTranscript: (sessionId: string, msgId: string, createTime?: number) => ipcRenderer.invoke('chat:getVoiceTranscript', sessionId, msgId, createTime),
|
||||||
onVoiceTranscriptPartial: (callback: (payload: { msgId: string; text: string }) => void) => {
|
onVoiceTranscriptPartial: (callback: (payload: { msgId: string; text: string }) => void) => {
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class AnnualReportService {
|
|||||||
}
|
}
|
||||||
const suffixMatch = trimmed.match(/^(.+)_([a-zA-Z0-9]{4})$/)
|
const suffixMatch = trimmed.match(/^(.+)_([a-zA-Z0-9]{4})$/)
|
||||||
const cleaned = suffixMatch ? suffixMatch[1] : trimmed
|
const cleaned = suffixMatch ? suffixMatch[1] : trimmed
|
||||||
|
|
||||||
return cleaned
|
return cleaned
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,7 +499,7 @@ class AnnualReportService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reportProgress('加载扩展统计... (初始化)', 30, onProgress)
|
this.reportProgress('加载扩展统计...', 30, onProgress)
|
||||||
const extras = await wcdbService.getAnnualReportExtras(sessionIds, actualStartTime, actualEndTime, peakDayBegin, peakDayEnd)
|
const extras = await wcdbService.getAnnualReportExtras(sessionIds, actualStartTime, actualEndTime, peakDayBegin, peakDayEnd)
|
||||||
if (extras.success && extras.data) {
|
if (extras.success && extras.data) {
|
||||||
this.reportProgress('加载扩展统计... (解析热力图)', 32, onProgress)
|
this.reportProgress('加载扩展统计... (解析热力图)', 32, onProgress)
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ export interface Message {
|
|||||||
// 名片消息
|
// 名片消息
|
||||||
cardUsername?: string // 名片的微信ID
|
cardUsername?: string // 名片的微信ID
|
||||||
cardNickname?: string // 名片的昵称
|
cardNickname?: string // 名片的昵称
|
||||||
|
// 转账消息
|
||||||
|
transferPayerUsername?: string // 转账付款人
|
||||||
|
transferReceiverUsername?: string // 转账收款人
|
||||||
// 聊天记录
|
// 聊天记录
|
||||||
chatRecordTitle?: string // 聊天记录标题
|
chatRecordTitle?: string // 聊天记录标题
|
||||||
chatRecordList?: Array<{
|
chatRecordList?: Array<{
|
||||||
@@ -723,7 +726,7 @@ class ChatService {
|
|||||||
// 1. 没有游标状态
|
// 1. 没有游标状态
|
||||||
// 2. offset 为 0 (重新加载会话)
|
// 2. offset 为 0 (重新加载会话)
|
||||||
// 3. batchSize 改变
|
// 3. batchSize 改变
|
||||||
// 4. startTime 改变
|
// 4. startTime/endTime 改变(视为全新查询)
|
||||||
// 5. ascending 改变
|
// 5. ascending 改变
|
||||||
const needNewCursor = !state ||
|
const needNewCursor = !state ||
|
||||||
offset === 0 ||
|
offset === 0 ||
|
||||||
@@ -756,27 +759,35 @@ class ChatService {
|
|||||||
this.messageCursors.set(sessionId, state)
|
this.messageCursors.set(sessionId, state)
|
||||||
|
|
||||||
// 如果需要跳过消息(offset > 0),逐批获取但不返回
|
// 如果需要跳过消息(offset > 0),逐批获取但不返回
|
||||||
|
// 注意:仅在 offset === 0 时重建游标最安全;
|
||||||
|
// 当 startTime/endTime 变化导致重建时,offset 应由前端重置为 0
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
|
console.warn(`[ChatService] 新游标需跳过 ${offset} 条消息(startTime=${startTime}, endTime=${endTime})`)
|
||||||
let skipped = 0
|
let skipped = 0
|
||||||
while (skipped < offset) {
|
const maxSkipAttempts = Math.ceil(offset / batchSize) + 5 // 防止无限循环
|
||||||
|
let attempts = 0
|
||||||
|
while (skipped < offset && attempts < maxSkipAttempts) {
|
||||||
|
attempts++
|
||||||
const skipBatch = await wcdbService.fetchMessageBatch(state.cursor)
|
const skipBatch = await wcdbService.fetchMessageBatch(state.cursor)
|
||||||
if (!skipBatch.success) {
|
if (!skipBatch.success) {
|
||||||
console.error('[ChatService] 跳过消息批次失败:', skipBatch.error)
|
console.error('[ChatService] 跳过消息批次失败:', skipBatch.error)
|
||||||
return { success: false, error: skipBatch.error || '跳过消息失败' }
|
return { success: false, error: skipBatch.error || '跳过消息失败' }
|
||||||
}
|
}
|
||||||
if (!skipBatch.rows || skipBatch.rows.length === 0) {
|
if (!skipBatch.rows || skipBatch.rows.length === 0) {
|
||||||
|
console.warn(`[ChatService] 跳过时数据耗尽: skipped=${skipped}/${offset}`)
|
||||||
return { success: true, messages: [], hasMore: false }
|
return { success: true, messages: [], hasMore: false }
|
||||||
}
|
}
|
||||||
skipped += skipBatch.rows.length
|
skipped += skipBatch.rows.length
|
||||||
state.fetched += skipBatch.rows.length
|
state.fetched += skipBatch.rows.length
|
||||||
if (!skipBatch.hasMore) {
|
if (!skipBatch.hasMore) {
|
||||||
|
console.warn(`[ChatService] 跳过后无更多数据: skipped=${skipped}/${offset}`)
|
||||||
return { success: true, messages: [], hasMore: false }
|
return { success: true, messages: [], hasMore: false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (attempts >= maxSkipAttempts) {
|
||||||
|
console.error(`[ChatService] 跳过消息超过最大尝试次数: attempts=${attempts}`)
|
||||||
|
}
|
||||||
|
console.log(`[ChatService] 跳过完成: skipped=${skipped}, fetched=${state.fetched}`)
|
||||||
}
|
}
|
||||||
} else if (state && offset !== state.fetched) {
|
} else if (state && offset !== state.fetched) {
|
||||||
// offset 与 fetched 不匹配,说明状态不一致
|
// offset 与 fetched 不匹配,说明状态不一致
|
||||||
@@ -3776,6 +3787,32 @@ class ChatService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某会话中有消息的日期列表
|
||||||
|
* 返回 YYYY-MM-DD 格式的日期字符串数组
|
||||||
|
*/
|
||||||
|
async getMessageDates(sessionId: string): Promise<{ success: boolean; dates?: string[]; error?: string }> {
|
||||||
|
try {
|
||||||
|
const connectResult = await this.ensureConnected()
|
||||||
|
if (!connectResult.success) {
|
||||||
|
return { success: false, error: connectResult.error || '数据库未连接' }
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await wcdbService.getMessageDates(sessionId)
|
||||||
|
if (!result.success) {
|
||||||
|
throw new Error(result.error || '查询失败')
|
||||||
|
}
|
||||||
|
|
||||||
|
const dates = result.dates || []
|
||||||
|
|
||||||
|
console.log(`[ChatService] 会话 ${sessionId} 共有 ${dates.length} 个有消息的日期`)
|
||||||
|
return { success: true, dates }
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[ChatService] 获取消息日期失败:', e)
|
||||||
|
return { success: false, error: String(e) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getMessageById(sessionId: string, localId: number): Promise<{ success: boolean; message?: Message; error?: string }> {
|
async getMessageById(sessionId: string, localId: number): Promise<{ success: boolean; message?: Message; error?: string }> {
|
||||||
try {
|
try {
|
||||||
// 1. 尝试从缓存获取会话表信息
|
// 1. 尝试从缓存获取会话表信息
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ interface ConfigSchema {
|
|||||||
notificationPosition: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
|
notificationPosition: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
|
||||||
notificationFilterMode: 'all' | 'whitelist' | 'blacklist'
|
notificationFilterMode: 'all' | 'whitelist' | 'blacklist'
|
||||||
notificationFilterList: string[]
|
notificationFilterList: string[]
|
||||||
|
wordCloudExcludeWords: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ConfigService {
|
export class ConfigService {
|
||||||
@@ -94,7 +95,8 @@ export class ConfigService {
|
|||||||
notificationEnabled: true,
|
notificationEnabled: true,
|
||||||
notificationPosition: 'top-right',
|
notificationPosition: 'top-right',
|
||||||
notificationFilterMode: 'all',
|
notificationFilterMode: 'all',
|
||||||
notificationFilterList: []
|
notificationFilterList: [],
|
||||||
|
wordCloudExcludeWords: []
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { parentPort } from 'worker_threads'
|
import { parentPort } from 'worker_threads'
|
||||||
import { wcdbService } from './wcdbService'
|
import { wcdbService } from './wcdbService'
|
||||||
|
|
||||||
|
|
||||||
export interface DualReportMessage {
|
export interface DualReportMessage {
|
||||||
content: string
|
content: string
|
||||||
isSentByMe: boolean
|
isSentByMe: boolean
|
||||||
@@ -58,6 +59,8 @@ export interface DualReportData {
|
|||||||
} | null
|
} | null
|
||||||
stats: DualReportStats
|
stats: DualReportStats
|
||||||
topPhrases: Array<{ phrase: string; count: number }>
|
topPhrases: Array<{ phrase: string; count: number }>
|
||||||
|
myExclusivePhrases: Array<{ phrase: string; count: number }>
|
||||||
|
friendExclusivePhrases: Array<{ phrase: string; count: number }>
|
||||||
heatmap?: number[][]
|
heatmap?: number[][]
|
||||||
initiative?: { initiated: number; received: number }
|
initiative?: { initiated: number; received: number }
|
||||||
response?: { avg: number; fastest: number; count: number }
|
response?: { avg: number; fastest: number; count: number }
|
||||||
@@ -499,10 +502,11 @@ class DualReportService {
|
|||||||
dbPath: string
|
dbPath: string
|
||||||
decryptKey: string
|
decryptKey: string
|
||||||
wxid: string
|
wxid: string
|
||||||
|
excludeWords?: string[]
|
||||||
onProgress?: (status: string, progress: number) => void
|
onProgress?: (status: string, progress: number) => void
|
||||||
}): Promise<{ success: boolean; data?: DualReportData; error?: string }> {
|
}): Promise<{ success: boolean; data?: DualReportData; error?: string }> {
|
||||||
try {
|
try {
|
||||||
const { year, friendUsername, dbPath, decryptKey, wxid, onProgress } = params
|
const { year, friendUsername, dbPath, decryptKey, wxid, excludeWords, onProgress } = params
|
||||||
this.reportProgress('正在连接数据库...', 5, onProgress)
|
this.reportProgress('正在连接数据库...', 5, onProgress)
|
||||||
const conn = await this.ensureConnectedWithConfig(dbPath, decryptKey, wxid)
|
const conn = await this.ensureConnectedWithConfig(dbPath, decryptKey, wxid)
|
||||||
if (!conn.success || !conn.cleanedWxid || !conn.rawWxid) return { success: false, error: conn.error }
|
if (!conn.success || !conn.cleanedWxid || !conn.rawWxid) return { success: false, error: conn.error }
|
||||||
@@ -714,11 +718,58 @@ class DualReportService {
|
|||||||
if (myTopCount >= 0) stats.myTopEmojiCount = myTopCount
|
if (myTopCount >= 0) stats.myTopEmojiCount = myTopCount
|
||||||
if (friendTopCount >= 0) stats.friendTopEmojiCount = friendTopCount
|
if (friendTopCount >= 0) stats.friendTopEmojiCount = friendTopCount
|
||||||
|
|
||||||
const topPhrases = (cppData.phrases || []).map((p: any) => ({
|
if (friendTopCount >= 0) stats.friendTopEmojiCount = friendTopCount
|
||||||
|
|
||||||
|
const excludeSet = new Set(excludeWords || [])
|
||||||
|
|
||||||
|
const filterPhrases = (list: any[]) => {
|
||||||
|
return (list || []).filter((p: any) => !excludeSet.has(p.phrase))
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanPhrases = filterPhrases(cppData.phrases)
|
||||||
|
const cleanMyPhrases = filterPhrases(cppData.myPhrases)
|
||||||
|
const cleanFriendPhrases = filterPhrases(cppData.friendPhrases)
|
||||||
|
|
||||||
|
const topPhrases = cleanPhrases.map((p: any) => ({
|
||||||
phrase: p.phrase,
|
phrase: p.phrase,
|
||||||
count: p.count
|
count: p.count
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// 计算专属词汇:一方频繁使用而另一方很少使用的词
|
||||||
|
const myPhraseMap = new Map<string, number>()
|
||||||
|
const friendPhraseMap = new Map<string, number>()
|
||||||
|
for (const p of cleanMyPhrases) {
|
||||||
|
myPhraseMap.set(p.phrase, p.count)
|
||||||
|
}
|
||||||
|
for (const p of cleanFriendPhrases) {
|
||||||
|
friendPhraseMap.set(p.phrase, p.count)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 专属词汇:该方使用占比 >= 75% 且至少出现 2 次
|
||||||
|
const myExclusivePhrases: Array<{ phrase: string; count: number }> = []
|
||||||
|
const friendExclusivePhrases: Array<{ phrase: string; count: number }> = []
|
||||||
|
|
||||||
|
for (const [phrase, myCount] of myPhraseMap) {
|
||||||
|
const friendCount = friendPhraseMap.get(phrase) || 0
|
||||||
|
const total = myCount + friendCount
|
||||||
|
if (myCount >= 2 && total > 0 && myCount / total >= 0.75) {
|
||||||
|
myExclusivePhrases.push({ phrase, count: myCount })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [phrase, friendCount] of friendPhraseMap) {
|
||||||
|
const myCount = myPhraseMap.get(phrase) || 0
|
||||||
|
const total = myCount + friendCount
|
||||||
|
if (friendCount >= 2 && total > 0 && friendCount / total >= 0.75) {
|
||||||
|
friendExclusivePhrases.push({ phrase, count: friendCount })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按频率排序,取前 20
|
||||||
|
myExclusivePhrases.sort((a, b) => b.count - a.count)
|
||||||
|
friendExclusivePhrases.sort((a, b) => b.count - a.count)
|
||||||
|
if (myExclusivePhrases.length > 20) myExclusivePhrases.length = 20
|
||||||
|
if (friendExclusivePhrases.length > 20) friendExclusivePhrases.length = 20
|
||||||
|
|
||||||
const reportData: DualReportData = {
|
const reportData: DualReportData = {
|
||||||
year: reportYear,
|
year: reportYear,
|
||||||
selfName: myName,
|
selfName: myName,
|
||||||
@@ -731,6 +782,8 @@ class DualReportService {
|
|||||||
yearFirstChat,
|
yearFirstChat,
|
||||||
stats,
|
stats,
|
||||||
topPhrases,
|
topPhrases,
|
||||||
|
myExclusivePhrases,
|
||||||
|
friendExclusivePhrases,
|
||||||
heatmap: cppData.heatmap,
|
heatmap: cppData.heatmap,
|
||||||
initiative: cppData.initiative,
|
initiative: cppData.initiative,
|
||||||
response: cppData.response,
|
response: cppData.response,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export class WcdbCore {
|
|||||||
private wcdbGetAnnualReportExtras: any = null
|
private wcdbGetAnnualReportExtras: any = null
|
||||||
private wcdbGetDualReportStats: any = null
|
private wcdbGetDualReportStats: any = null
|
||||||
private wcdbGetGroupStats: any = null
|
private wcdbGetGroupStats: any = null
|
||||||
|
private wcdbGetMessageDates: any = null
|
||||||
private wcdbOpenMessageCursor: any = null
|
private wcdbOpenMessageCursor: any = null
|
||||||
private wcdbOpenMessageCursorLite: any = null
|
private wcdbOpenMessageCursorLite: any = null
|
||||||
private wcdbFetchMessageBatch: any = null
|
private wcdbFetchMessageBatch: any = null
|
||||||
@@ -299,9 +300,6 @@ export class WcdbCore {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关键修复:显式预加载依赖库 WCDB.dll 和 SDL2.dll
|
|
||||||
// Windows 加载器默认不会查找子目录中的依赖,必须先将其加载到内存
|
|
||||||
// 这可以解决部分用户因为 VC++ 运行时或 DLL 依赖问题导致的闪退
|
|
||||||
const dllDir = dirname(dllPath)
|
const dllDir = dirname(dllPath)
|
||||||
const wcdbCorePath = join(dllDir, 'WCDB.dll')
|
const wcdbCorePath = join(dllDir, 'WCDB.dll')
|
||||||
if (existsSync(wcdbCorePath)) {
|
if (existsSync(wcdbCorePath)) {
|
||||||
@@ -478,6 +476,13 @@ export class WcdbCore {
|
|||||||
this.wcdbGetGroupStats = null
|
this.wcdbGetGroupStats = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wcdb_status wcdb_get_message_dates(wcdb_handle handle, const char* session_id, char** out_json)
|
||||||
|
try {
|
||||||
|
this.wcdbGetMessageDates = this.lib.func('int32 wcdb_get_message_dates(int64 handle, const char* sessionId, _Out_ void** outJson)')
|
||||||
|
} catch {
|
||||||
|
this.wcdbGetMessageDates = null
|
||||||
|
}
|
||||||
|
|
||||||
// wcdb_status wcdb_open_message_cursor(wcdb_handle handle, const char* session_id, int32_t batch_size, int32_t ascending, int32_t begin_timestamp, int32_t end_timestamp, wcdb_cursor* out_cursor)
|
// wcdb_status wcdb_open_message_cursor(wcdb_handle handle, const char* session_id, int32_t batch_size, int32_t ascending, int32_t begin_timestamp, int32_t end_timestamp, wcdb_cursor* out_cursor)
|
||||||
this.wcdbOpenMessageCursor = this.lib.func('int32 wcdb_open_message_cursor(int64 handle, const char* sessionId, int32 batchSize, int32 ascending, int32 beginTimestamp, int32 endTimestamp, _Out_ int64* outCursor)')
|
this.wcdbOpenMessageCursor = this.lib.func('int32 wcdb_open_message_cursor(int64 handle, const char* sessionId, int32 batchSize, int32 ascending, int32 beginTimestamp, int32 endTimestamp, _Out_ int64* outCursor)')
|
||||||
|
|
||||||
@@ -1194,6 +1199,29 @@ export class WcdbCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getMessageDates(sessionId: string): Promise<{ success: boolean; dates?: string[]; error?: string }> {
|
||||||
|
if (!this.ensureReady()) {
|
||||||
|
return { success: false, error: 'WCDB 未连接' }
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (!this.wcdbGetMessageDates) {
|
||||||
|
return { success: false, error: 'DLL 不支持 getMessageDates' }
|
||||||
|
}
|
||||||
|
const outPtr = [null as any]
|
||||||
|
const result = this.wcdbGetMessageDates(this.handle, sessionId, outPtr)
|
||||||
|
if (result !== 0 || !outPtr[0]) {
|
||||||
|
// 空结果也可能是正常的(无消息)
|
||||||
|
return { success: true, dates: [] }
|
||||||
|
}
|
||||||
|
const jsonStr = this.decodeJsonPtr(outPtr[0])
|
||||||
|
if (!jsonStr) return { success: false, error: '解析日期列表失败' }
|
||||||
|
const dates = JSON.parse(jsonStr)
|
||||||
|
return { success: true, dates }
|
||||||
|
} catch (e) {
|
||||||
|
return { success: false, error: String(e) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getMessageTableStats(sessionId: string): Promise<{ success: boolean; tables?: any[]; error?: string }> {
|
async getMessageTableStats(sessionId: string): Promise<{ success: boolean; tables?: any[]; error?: string }> {
|
||||||
if (!this.ensureReady()) {
|
if (!this.ensureReady()) {
|
||||||
return { success: false, error: 'WCDB 未连接' }
|
return { success: false, error: 'WCDB 未连接' }
|
||||||
|
|||||||
@@ -273,6 +273,10 @@ export class WcdbService {
|
|||||||
return this.callWorker('getMessageTableStats', { sessionId })
|
return this.callWorker('getMessageTableStats', { sessionId })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getMessageDates(sessionId: string): Promise<{ success: boolean; dates?: string[]; error?: string }> {
|
||||||
|
return this.callWorker('getMessageDates', { sessionId })
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取消息元数据
|
* 获取消息元数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ if (parentPort) {
|
|||||||
case 'getMessageTableStats':
|
case 'getMessageTableStats':
|
||||||
result = await core.getMessageTableStats(payload.sessionId)
|
result = await core.getMessageTableStats(payload.sessionId)
|
||||||
break
|
break
|
||||||
|
case 'getMessageDates':
|
||||||
|
result = await core.getMessageDates(payload.sessionId)
|
||||||
|
break
|
||||||
case 'getMessageMeta':
|
case 'getMessageMeta':
|
||||||
result = await core.getMessageMeta(payload.dbPath, payload.tableName, payload.limit, payload.offset)
|
result = await core.getMessageMeta(payload.dbPath, payload.tableName, payload.limit, payload.offset)
|
||||||
break
|
break
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -11428,12 +11428,6 @@
|
|||||||
"sherpa-onnx-win-x64": "^1.12.23"
|
"sherpa-onnx-win-x64": "^1.12.23"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-darwin-x64": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"node_modules/sherpa-onnx-node/node_modules/sherpa-onnx-linux-arm64": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"node_modules/sherpa-onnx-win-ia32": {
|
"node_modules/sherpa-onnx-win-ia32": {
|
||||||
"version": "1.12.23",
|
"version": "1.12.23",
|
||||||
"resolved": "https://registry.npmmirror.com/sherpa-onnx-win-ia32/-/sherpa-onnx-win-ia32-1.12.23.tgz",
|
"resolved": "https://registry.npmmirror.com/sherpa-onnx-win-ia32/-/sherpa-onnx-win-ia32-1.12.23.tgz",
|
||||||
@@ -13032,4 +13026,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -70,6 +70,7 @@
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-8px);
|
transform: translateY(-8px);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
@@ -144,6 +145,7 @@
|
|||||||
.calendar-grid {
|
.calendar-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
|
grid-template-rows: auto repeat(6, 32px);
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +158,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.calendar-day {
|
.calendar-day {
|
||||||
aspect-ratio: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -211,4 +212,4 @@
|
|||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ function DateRangePicker({ startDate, endDate, onStartDateChange, onEndDateChang
|
|||||||
|
|
||||||
const handleDateClick = (day: number) => {
|
const handleDateClick = (day: number) => {
|
||||||
const dateStr = `${currentMonth.getFullYear()}-${String(currentMonth.getMonth() + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
const dateStr = `${currentMonth.getFullYear()}-${String(currentMonth.getMonth() + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
||||||
|
|
||||||
if (selectingStart) {
|
if (selectingStart) {
|
||||||
onStartDateChange(dateStr)
|
onStartDateChange(dateStr)
|
||||||
if (endDate && dateStr > endDate) {
|
if (endDate && dateStr > endDate) {
|
||||||
@@ -125,8 +125,8 @@ function DateRangePicker({ startDate, endDate, onStartDateChange, onEndDateChang
|
|||||||
const isToday = (day: number) => {
|
const isToday = (day: number) => {
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
return currentMonth.getFullYear() === today.getFullYear() &&
|
return currentMonth.getFullYear() === today.getFullYear() &&
|
||||||
currentMonth.getMonth() === today.getMonth() &&
|
currentMonth.getMonth() === today.getMonth() &&
|
||||||
day === today.getDate()
|
day === today.getDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderCalendar = () => {
|
const renderCalendar = () => {
|
||||||
|
|||||||
@@ -100,6 +100,33 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.calendar-grid {
|
.calendar-grid {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&.loading {
|
||||||
|
|
||||||
|
.weekdays,
|
||||||
|
.days {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-loading {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
.spin {
|
||||||
|
color: var(--primary);
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.weekdays {
|
.weekdays {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
@@ -117,10 +144,10 @@
|
|||||||
.days {
|
.days {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
|
grid-template-rows: repeat(6, 36px);
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
|
|
||||||
.day-cell {
|
.day-cell {
|
||||||
aspect-ratio: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -129,12 +156,13 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
&.empty {
|
&.empty {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.empty):hover {
|
&:not(.empty):not(.no-message):hover {
|
||||||
background: var(--bg-hover);
|
background: var(--bg-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,10 +177,43 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
background: var(--primary-light);
|
background: var(--primary-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 无消息的日期 - 灰显且不可点击
|
||||||
|
&.no-message {
|
||||||
|
opacity: 0.3;
|
||||||
|
cursor: default;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 有消息的日期指示器小圆点
|
||||||
|
.message-dot {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 3px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 4px;
|
||||||
|
height: 4px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.selected .message-dot {
|
||||||
|
background: rgba(255, 255, 255, 0.7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.quick-options {
|
.quick-options {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState, useMemo } from 'react'
|
||||||
import { X, ChevronLeft, ChevronRight, Calendar as CalendarIcon } from 'lucide-react'
|
import { X, ChevronLeft, ChevronRight, Calendar as CalendarIcon, Loader2 } from 'lucide-react'
|
||||||
import './JumpToDateDialog.scss'
|
import './JumpToDateDialog.scss'
|
||||||
|
|
||||||
interface JumpToDateDialogProps {
|
interface JumpToDateDialogProps {
|
||||||
@@ -7,15 +7,22 @@ interface JumpToDateDialogProps {
|
|||||||
onClose: () => void
|
onClose: () => void
|
||||||
onSelect: (date: Date) => void
|
onSelect: (date: Date) => void
|
||||||
currentDate?: Date
|
currentDate?: Date
|
||||||
|
/** 有消息的日期集合,格式为 YYYY-MM-DD */
|
||||||
|
messageDates?: Set<string>
|
||||||
|
/** 是否正在加载消息日期 */
|
||||||
|
loadingDates?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const JumpToDateDialog: React.FC<JumpToDateDialogProps> = ({
|
const JumpToDateDialog: React.FC<JumpToDateDialogProps> = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
onSelect,
|
onSelect,
|
||||||
currentDate = new Date()
|
currentDate = new Date(),
|
||||||
|
messageDates,
|
||||||
|
loadingDates = false
|
||||||
}) => {
|
}) => {
|
||||||
const [calendarDate, setCalendarDate] = useState(new Date(currentDate))
|
const isValidDate = (d: any) => d instanceof Date && !isNaN(d.getTime())
|
||||||
|
const [calendarDate, setCalendarDate] = useState(isValidDate(currentDate) ? new Date(currentDate) : new Date())
|
||||||
const [selectedDate, setSelectedDate] = useState(new Date(currentDate))
|
const [selectedDate, setSelectedDate] = useState(new Date(currentDate))
|
||||||
|
|
||||||
if (!isOpen) return null
|
if (!isOpen) return null
|
||||||
@@ -48,7 +55,20 @@ const JumpToDateDialog: React.FC<JumpToDateDialogProps> = ({
|
|||||||
return days
|
return days
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断某天是否有消息
|
||||||
|
*/
|
||||||
|
const hasMessage = (day: number): boolean => {
|
||||||
|
if (!messageDates || messageDates.size === 0) return true // 未加载时默认全部可点击
|
||||||
|
const year = calendarDate.getFullYear()
|
||||||
|
const month = calendarDate.getMonth() + 1
|
||||||
|
const dateStr = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
||||||
|
return messageDates.has(dateStr)
|
||||||
|
}
|
||||||
|
|
||||||
const handleDateClick = (day: number) => {
|
const handleDateClick = (day: number) => {
|
||||||
|
// 如果已加载日期数据且该日期无消息,则不可点击
|
||||||
|
if (messageDates && messageDates.size > 0 && !hasMessage(day)) return
|
||||||
const newDate = new Date(calendarDate.getFullYear(), calendarDate.getMonth(), day)
|
const newDate = new Date(calendarDate.getFullYear(), calendarDate.getMonth(), day)
|
||||||
setSelectedDate(newDate)
|
setSelectedDate(newDate)
|
||||||
}
|
}
|
||||||
@@ -71,6 +91,28 @@ const JumpToDateDialog: React.FC<JumpToDateDialogProps> = ({
|
|||||||
calendarDate.getFullYear() === selectedDate.getFullYear()
|
calendarDate.getFullYear() === selectedDate.getFullYear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某天的 CSS 类名
|
||||||
|
*/
|
||||||
|
const getDayClassName = (day: number | null): string => {
|
||||||
|
if (day === null) return 'day-cell empty'
|
||||||
|
|
||||||
|
const classes = ['day-cell']
|
||||||
|
if (isSelected(day)) classes.push('selected')
|
||||||
|
if (isToday(day)) classes.push('today')
|
||||||
|
|
||||||
|
// 仅在已加载消息日期数据时区分有/无消息
|
||||||
|
if (messageDates && messageDates.size > 0) {
|
||||||
|
if (hasMessage(day)) {
|
||||||
|
classes.push('has-message')
|
||||||
|
} else {
|
||||||
|
classes.push('no-message')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
const weekdays = ['日', '一', '二', '三', '四', '五', '六']
|
const weekdays = ['日', '一', '二', '三', '四', '五', '六']
|
||||||
const days = generateCalendar()
|
const days = generateCalendar()
|
||||||
|
|
||||||
@@ -106,18 +148,28 @@ const JumpToDateDialog: React.FC<JumpToDateDialogProps> = ({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="calendar-grid">
|
<div className={`calendar-grid ${loadingDates ? 'loading' : ''}`}>
|
||||||
<div className="weekdays">
|
{loadingDates && (
|
||||||
|
<div className="calendar-loading">
|
||||||
|
<Loader2 size={20} className="spin" />
|
||||||
|
<span>正在加载...</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="weekdays" style={{ visibility: loadingDates ? 'hidden' : 'visible' }}>
|
||||||
{weekdays.map(d => <div key={d} className="weekday">{d}</div>)}
|
{weekdays.map(d => <div key={d} className="weekday">{d}</div>)}
|
||||||
</div>
|
</div>
|
||||||
<div className="days">
|
<div className="days" style={{ visibility: loadingDates ? 'hidden' : 'visible' }}>
|
||||||
{days.map((day, i) => (
|
{days.map((day, i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
className={`day-cell ${day === null ? 'empty' : ''} ${day !== null && isSelected(day) ? 'selected' : ''} ${day !== null && isToday(day) ? 'today' : ''}`}
|
className={getDayClassName(day)}
|
||||||
|
style={{ visibility: loadingDates ? 'hidden' : 'visible' }}
|
||||||
onClick={() => day !== null && handleDateClick(day)}
|
onClick={() => day !== null && handleDateClick(day)}
|
||||||
>
|
>
|
||||||
{day}
|
{day}
|
||||||
|
{day !== null && messageDates && messageDates.size > 0 && hasMessage(day) && (
|
||||||
|
<span className="message-dot" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -87,8 +87,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
inset: -6%;
|
inset: -6%;
|
||||||
background:
|
background:
|
||||||
radial-gradient(circle at 35% 45%, color-mix(in srgb, var(--primary, #07C160) 12%, transparent), transparent 55%),
|
radial-gradient(circle at 35% 45%, rgba(var(--ar-primary-rgb, 7, 193, 96), 0.12), transparent 55%),
|
||||||
radial-gradient(circle at 65% 50%, color-mix(in srgb, var(--accent, #F2AA00) 10%, transparent), transparent 58%),
|
radial-gradient(circle at 65% 50%, rgba(var(--ar-accent-rgb, 242, 170, 0), 0.10), transparent 58%),
|
||||||
radial-gradient(circle at 50% 65%, var(--bg-tertiary, rgba(0, 0, 0, 0.04)), transparent 60%);
|
radial-gradient(circle at 50% 65%, var(--bg-tertiary, rgba(0, 0, 0, 0.04)), transparent 60%);
|
||||||
filter: blur(18px);
|
filter: blur(18px);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
.annual-report-window {
|
.annual-report-window {
|
||||||
// 使用全局主题变量,带回退值
|
// 使用全局主题变量,带回退值
|
||||||
--ar-primary: var(--primary, #07C160);
|
--ar-primary: var(--primary, #07C160);
|
||||||
|
--ar-primary-rgb: var(--primary-rgb, 7, 193, 96);
|
||||||
--ar-accent: var(--accent, #F2AA00);
|
--ar-accent: var(--accent, #F2AA00);
|
||||||
|
--ar-accent-rgb: 242, 170, 0;
|
||||||
--ar-text-main: var(--text-primary, #222222);
|
--ar-text-main: var(--text-primary, #222222);
|
||||||
--ar-text-sub: var(--text-secondary, #555555);
|
--ar-text-sub: var(--text-secondary, #555555);
|
||||||
--ar-bg-color: var(--bg-primary, #F9F8F6);
|
--ar-bg-color: var(--bg-primary, #F9F8F6);
|
||||||
@@ -53,7 +55,7 @@
|
|||||||
.deco-circle {
|
.deco-circle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: color-mix(in srgb, var(--primary) 3%, transparent);
|
background: rgba(var(--ar-primary-rgb), 0.03);
|
||||||
backdrop-filter: blur(40px);
|
backdrop-filter: blur(40px);
|
||||||
-webkit-backdrop-filter: blur(40px);
|
-webkit-backdrop-filter: blur(40px);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
@@ -254,6 +256,11 @@
|
|||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deco-circle {
|
||||||
|
background: transparent !important;
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
|
|||||||
@@ -164,6 +164,9 @@ function ChatPage(_props: ChatPageProps) {
|
|||||||
const [jumpStartTime, setJumpStartTime] = useState(0)
|
const [jumpStartTime, setJumpStartTime] = useState(0)
|
||||||
const [jumpEndTime, setJumpEndTime] = useState(0)
|
const [jumpEndTime, setJumpEndTime] = useState(0)
|
||||||
const [showJumpDialog, setShowJumpDialog] = useState(false)
|
const [showJumpDialog, setShowJumpDialog] = useState(false)
|
||||||
|
const [messageDates, setMessageDates] = useState<Set<string>>(new Set())
|
||||||
|
const [loadingDates, setLoadingDates] = useState(false)
|
||||||
|
const messageDatesCache = useRef<Map<string, Set<string>>>(new Map())
|
||||||
const [myAvatarUrl, setMyAvatarUrl] = useState<string | undefined>(undefined)
|
const [myAvatarUrl, setMyAvatarUrl] = useState<string | undefined>(undefined)
|
||||||
const [myWxid, setMyWxid] = useState<string | undefined>(undefined)
|
const [myWxid, setMyWxid] = useState<string | undefined>(undefined)
|
||||||
const [showScrollToBottom, setShowScrollToBottom] = useState(false)
|
const [showScrollToBottom, setShowScrollToBottom] = useState(false)
|
||||||
@@ -680,12 +683,32 @@ function ChatPage(_props: ChatPageProps) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 动态游标批量大小控制
|
||||||
|
const currentBatchSizeRef = useRef(50)
|
||||||
|
|
||||||
// 加载消息
|
// 加载消息
|
||||||
const loadMessages = async (sessionId: string, offset = 0, startTime = 0, endTime = 0) => {
|
const loadMessages = async (sessionId: string, offset = 0, startTime = 0, endTime = 0) => {
|
||||||
const listEl = messageListRef.current
|
const listEl = messageListRef.current
|
||||||
const session = sessionMapRef.current.get(sessionId)
|
const session = sessionMapRef.current.get(sessionId)
|
||||||
const unreadCount = session?.unreadCount ?? 0
|
const unreadCount = session?.unreadCount ?? 0
|
||||||
const messageLimit = offset === 0 && unreadCount > 99 ? 30 : 50
|
|
||||||
|
let messageLimit = 50
|
||||||
|
|
||||||
|
if (offset === 0) {
|
||||||
|
// 初始加载:重置批量大小
|
||||||
|
currentBatchSizeRef.current = 50
|
||||||
|
// 首屏优化:消息过多时限制数量
|
||||||
|
messageLimit = unreadCount > 99 ? 30 : 50
|
||||||
|
} else {
|
||||||
|
// 滚动加载:动态递增 (50 -> 100 -> 200)
|
||||||
|
if (currentBatchSizeRef.current < 100) {
|
||||||
|
currentBatchSizeRef.current = 100
|
||||||
|
} else {
|
||||||
|
currentBatchSizeRef.current = 200
|
||||||
|
}
|
||||||
|
messageLimit = currentBatchSizeRef.current
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (offset === 0) {
|
if (offset === 0) {
|
||||||
setLoadingMessages(true)
|
setLoadingMessages(true)
|
||||||
@@ -1523,7 +1546,31 @@ function ChatPage(_props: ChatPageProps) {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="icon-btn jump-to-time-btn"
|
className="icon-btn jump-to-time-btn"
|
||||||
onClick={() => setShowJumpDialog(true)}
|
onClick={async () => {
|
||||||
|
setShowJumpDialog(true)
|
||||||
|
if (!currentSessionId) return
|
||||||
|
// 检查缓存
|
||||||
|
const cached = messageDatesCache.current.get(currentSessionId)
|
||||||
|
if (cached) {
|
||||||
|
setMessageDates(cached)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 获取消息日期
|
||||||
|
setMessageDates(new Set()) // 清除旧数据
|
||||||
|
setLoadingDates(true)
|
||||||
|
try {
|
||||||
|
const result = await (window as any).electronAPI.chat.getMessageDates(currentSessionId)
|
||||||
|
if (result?.success && result.dates) {
|
||||||
|
const dateSet = new Set<string>(result.dates)
|
||||||
|
setMessageDates(dateSet)
|
||||||
|
messageDatesCache.current.set(currentSessionId, dateSet)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('获取消息日期失败:', e)
|
||||||
|
} finally {
|
||||||
|
setLoadingDates(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
title="跳转到指定时间"
|
title="跳转到指定时间"
|
||||||
>
|
>
|
||||||
<Calendar size={18} />
|
<Calendar size={18} />
|
||||||
@@ -1539,6 +1586,8 @@ function ChatPage(_props: ChatPageProps) {
|
|||||||
setJumpEndTime(end)
|
setJumpEndTime(end)
|
||||||
loadMessages(currentSessionId, 0, 0, end)
|
loadMessages(currentSessionId, 0, 0, end)
|
||||||
}}
|
}}
|
||||||
|
messageDates={messageDates}
|
||||||
|
loadingDates={loadingDates}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
className="icon-btn refresh-messages-btn"
|
className="icon-btn refresh-messages-btn"
|
||||||
|
|||||||
@@ -906,4 +906,79 @@
|
|||||||
min-width: 56px;
|
min-width: 56px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Word Cloud Tabs
|
||||||
|
.word-cloud-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.word-cloud-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
padding: 4px;
|
||||||
|
border-radius: 12px;
|
||||||
|
margin: 0 auto 32px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-item {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--ar-text-sub);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--ar-text-main);
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background: var(--ar-card-bg);
|
||||||
|
color: var(--ar-primary);
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.word-cloud-container {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&.fade-in {
|
||||||
|
animation: fadeIn 0.4s ease-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 40px 0;
|
||||||
|
color: var(--ar-text-sub);
|
||||||
|
opacity: 0.6;
|
||||||
|
font-size: 14px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px dashed rgba(255, 255, 255, 0.1);
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,8 @@ interface DualReportData {
|
|||||||
friendTopEmojiCount?: number
|
friendTopEmojiCount?: number
|
||||||
}
|
}
|
||||||
topPhrases: Array<{ phrase: string; count: number }>
|
topPhrases: Array<{ phrase: string; count: number }>
|
||||||
|
myExclusivePhrases: Array<{ phrase: string; count: number }>
|
||||||
|
friendExclusivePhrases: Array<{ phrase: string; count: number }>
|
||||||
heatmap?: number[][]
|
heatmap?: number[][]
|
||||||
initiative?: { initiated: number; received: number }
|
initiative?: { initiated: number; received: number }
|
||||||
response?: { avg: number; fastest: number; slowest: number; count: number }
|
response?: { avg: number; fastest: number; slowest: number; count: number }
|
||||||
@@ -72,6 +74,7 @@ function DualReportWindow() {
|
|||||||
const [loadingProgress, setLoadingProgress] = useState(0)
|
const [loadingProgress, setLoadingProgress] = useState(0)
|
||||||
const [myEmojiUrl, setMyEmojiUrl] = useState<string | null>(null)
|
const [myEmojiUrl, setMyEmojiUrl] = useState<string | null>(null)
|
||||||
const [friendEmojiUrl, setFriendEmojiUrl] = useState<string | null>(null)
|
const [friendEmojiUrl, setFriendEmojiUrl] = useState<string | null>(null)
|
||||||
|
const [activeWordCloudTab, setActiveWordCloudTab] = useState<'shared' | 'my' | 'friend'>('shared')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const params = new URLSearchParams(window.location.hash.split('?')[1] || '')
|
const params = new URLSearchParams(window.location.hash.split('?')[1] || '')
|
||||||
@@ -584,10 +587,48 @@ function DualReportWindow() {
|
|||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<section className="section">
|
<section className="section word-cloud-section">
|
||||||
<div className="label-text">常用语</div>
|
<div className="label-text">常用语</div>
|
||||||
<h2 className="hero-title">{yearTitle}常用语</h2>
|
<h2 className="hero-title">{yearTitle}常用语</h2>
|
||||||
<ReportWordCloud words={reportData.topPhrases} />
|
|
||||||
|
<div className="word-cloud-tabs">
|
||||||
|
<button
|
||||||
|
className={`tab-item ${activeWordCloudTab === 'shared' ? 'active' : ''}`}
|
||||||
|
onClick={() => setActiveWordCloudTab('shared')}
|
||||||
|
>
|
||||||
|
共用词汇
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={`tab-item ${activeWordCloudTab === 'my' ? 'active' : ''}`}
|
||||||
|
onClick={() => setActiveWordCloudTab('my')}
|
||||||
|
>
|
||||||
|
我的专属
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={`tab-item ${activeWordCloudTab === 'friend' ? 'active' : ''}`}
|
||||||
|
onClick={() => setActiveWordCloudTab('friend')}
|
||||||
|
>
|
||||||
|
TA的专属
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={`word-cloud-container fade-in ${activeWordCloudTab}`}>
|
||||||
|
{activeWordCloudTab === 'shared' && <ReportWordCloud words={reportData.topPhrases} />}
|
||||||
|
{activeWordCloudTab === 'my' && (
|
||||||
|
reportData.myExclusivePhrases && reportData.myExclusivePhrases.length > 0 ? (
|
||||||
|
<ReportWordCloud words={reportData.myExclusivePhrases} />
|
||||||
|
) : (
|
||||||
|
<div className="empty-state">暂无专属词汇</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
{activeWordCloudTab === 'friend' && (
|
||||||
|
reportData.friendExclusivePhrases && reportData.friendExclusivePhrases.length > 0 ? (
|
||||||
|
<ReportWordCloud words={reportData.friendExclusivePhrases} />
|
||||||
|
) : (
|
||||||
|
<div className="empty-state">暂无专属词汇</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="section">
|
<section className="section">
|
||||||
|
|||||||
@@ -830,8 +830,7 @@
|
|||||||
padding: 28px 32px;
|
padding: 28px 32px;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
|
||||||
min-width: 420px;
|
width: 420px;
|
||||||
max-width: 500px;
|
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
@@ -977,10 +976,10 @@
|
|||||||
.calendar-days {
|
.calendar-days {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
|
grid-template-rows: repeat(6, 40px);
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
|
|
||||||
.calendar-day {
|
.calendar-day {
|
||||||
aspect-ratio: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -1084,7 +1084,7 @@ function ExportPage() {
|
|||||||
>
|
>
|
||||||
<span className="date-label">开始日期</span>
|
<span className="date-label">开始日期</span>
|
||||||
<span className="date-value">
|
<span className="date-value">
|
||||||
{options.dateRange?.start.toLocaleDateString('zh-CN', {
|
{options.dateRange?.start?.toLocaleDateString('zh-CN', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
day: '2-digit'
|
day: '2-digit'
|
||||||
@@ -1098,7 +1098,7 @@ function ExportPage() {
|
|||||||
>
|
>
|
||||||
<span className="date-label">结束日期</span>
|
<span className="date-label">结束日期</span>
|
||||||
<span className="date-value">
|
<span className="date-value">
|
||||||
{options.dateRange?.end.toLocaleDateString('zh-CN', {
|
{options.dateRange?.end?.toLocaleDateString('zh-CN', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: '2-digit',
|
month: '2-digit',
|
||||||
day: '2-digit'
|
day: '2-digit'
|
||||||
@@ -1136,9 +1136,9 @@ function ExportPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const currentDate = new Date(calendarDate.getFullYear(), calendarDate.getMonth(), day)
|
const currentDate = new Date(calendarDate.getFullYear(), calendarDate.getMonth(), day)
|
||||||
const isStart = options.dateRange?.start.toDateString() === currentDate.toDateString()
|
const isStart = options.dateRange?.start?.toDateString() === currentDate.toDateString()
|
||||||
const isEnd = options.dateRange?.end.toDateString() === currentDate.toDateString()
|
const isEnd = options.dateRange?.end?.toDateString() === currentDate.toDateString()
|
||||||
const isInRange = options.dateRange && currentDate >= options.dateRange.start && currentDate <= options.dateRange.end
|
const isInRange = options.dateRange?.start && options.dateRange?.end && currentDate >= options.dateRange.start && currentDate <= options.dateRange.end
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
today.setHours(0, 0, 0, 0)
|
today.setHours(0, 0, 0, 0)
|
||||||
const isFuture = currentDate > today
|
const isFuture = currentDate > today
|
||||||
|
|||||||
@@ -1279,6 +1279,7 @@
|
|||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
@@ -1289,6 +1290,7 @@
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(10px);
|
transform: translateY(10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
@@ -2097,9 +2099,77 @@
|
|||||||
.btn-sm {
|
.btn-sm {
|
||||||
padding: 4px 10px !important;
|
padding: 4px 10px !important;
|
||||||
font-size: 12px !important;
|
font-size: 12px !important;
|
||||||
|
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
height: 14px;
|
height: 14px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Analysis Settings Styling
|
||||||
|
.settings-section {
|
||||||
|
h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin: 0 0 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-item {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
|
||||||
|
span:first-child {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-desc {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-control {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
// textarea specific
|
||||||
|
textarea.form-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 12px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
resize: vertical;
|
||||||
|
transition: all 0.2s;
|
||||||
|
outline: none;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
&::placeholder {
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,12 +9,12 @@ import {
|
|||||||
Eye, EyeOff, FolderSearch, FolderOpen, Search, Copy,
|
Eye, EyeOff, FolderSearch, FolderOpen, Search, Copy,
|
||||||
RotateCcw, Trash2, Plug, Check, Sun, Moon,
|
RotateCcw, Trash2, Plug, Check, Sun, Moon,
|
||||||
Palette, Database, Download, HardDrive, Info, RefreshCw, ChevronDown, Mic,
|
Palette, Database, Download, HardDrive, Info, RefreshCw, ChevronDown, Mic,
|
||||||
ShieldCheck, Fingerprint, Lock, KeyRound, Bell, Globe
|
ShieldCheck, Fingerprint, Lock, KeyRound, Bell, Globe, BarChart2
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { Avatar } from '../components/Avatar'
|
import { Avatar } from '../components/Avatar'
|
||||||
import './SettingsPage.scss'
|
import './SettingsPage.scss'
|
||||||
|
|
||||||
type SettingsTab = 'appearance' | 'notification' | 'database' | 'models' | 'export' | 'cache' | 'api' | 'security' | 'about'
|
type SettingsTab = 'appearance' | 'notification' | 'database' | 'models' | 'export' | 'cache' | 'api' | 'security' | 'about' | 'analytics'
|
||||||
|
|
||||||
const tabs: { id: SettingsTab; label: string; icon: React.ElementType }[] = [
|
const tabs: { id: SettingsTab; label: string; icon: React.ElementType }[] = [
|
||||||
{ id: 'appearance', label: '外观', icon: Palette },
|
{ id: 'appearance', label: '外观', icon: Palette },
|
||||||
@@ -24,6 +24,8 @@ const tabs: { id: SettingsTab; label: string; icon: React.ElementType }[] = [
|
|||||||
{ id: 'export', label: '导出', icon: Download },
|
{ id: 'export', label: '导出', icon: Download },
|
||||||
{ id: 'cache', label: '缓存', icon: HardDrive },
|
{ id: 'cache', label: '缓存', icon: HardDrive },
|
||||||
{ id: 'api', label: 'API 服务', icon: Globe },
|
{ id: 'api', label: 'API 服务', icon: Globe },
|
||||||
|
|
||||||
|
{ id: 'analytics', label: '分析', icon: BarChart2 },
|
||||||
{ id: 'security', label: '安全', icon: ShieldCheck },
|
{ id: 'security', label: '安全', icon: ShieldCheck },
|
||||||
{ id: 'about', label: '关于', icon: Info }
|
{ id: 'about', label: '关于', icon: Info }
|
||||||
]
|
]
|
||||||
@@ -109,6 +111,9 @@ function SettingsPage() {
|
|||||||
const [filterModeDropdownOpen, setFilterModeDropdownOpen] = useState(false)
|
const [filterModeDropdownOpen, setFilterModeDropdownOpen] = useState(false)
|
||||||
const [positionDropdownOpen, setPositionDropdownOpen] = useState(false)
|
const [positionDropdownOpen, setPositionDropdownOpen] = useState(false)
|
||||||
|
|
||||||
|
const [wordCloudExcludeWords, setWordCloudExcludeWords] = useState<string[]>([])
|
||||||
|
const [excludeWordsInput, setExcludeWordsInput] = useState('')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -302,6 +307,10 @@ function SettingsPage() {
|
|||||||
setNotificationFilterMode(savedNotificationFilterMode)
|
setNotificationFilterMode(savedNotificationFilterMode)
|
||||||
setNotificationFilterList(savedNotificationFilterList)
|
setNotificationFilterList(savedNotificationFilterList)
|
||||||
|
|
||||||
|
const savedExcludeWords = await configService.getWordCloudExcludeWords()
|
||||||
|
setWordCloudExcludeWords(savedExcludeWords)
|
||||||
|
setExcludeWordsInput(savedExcludeWords.join('\n'))
|
||||||
|
|
||||||
// 如果语言列表为空,保存默认值
|
// 如果语言列表为空,保存默认值
|
||||||
if (!savedTranscribeLanguages || savedTranscribeLanguages.length === 0) {
|
if (!savedTranscribeLanguages || savedTranscribeLanguages.length === 0) {
|
||||||
const defaultLanguages = ['zh']
|
const defaultLanguages = ['zh']
|
||||||
@@ -1863,13 +1872,13 @@ function SettingsPage() {
|
|||||||
// HTTP API 服务控制
|
// HTTP API 服务控制
|
||||||
const handleToggleApi = async () => {
|
const handleToggleApi = async () => {
|
||||||
if (isTogglingApi) return
|
if (isTogglingApi) return
|
||||||
|
|
||||||
// 启动时显示警告弹窗
|
// 启动时显示警告弹窗
|
||||||
if (!httpApiRunning) {
|
if (!httpApiRunning) {
|
||||||
setShowApiWarning(true)
|
setShowApiWarning(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsTogglingApi(true)
|
setIsTogglingApi(true)
|
||||||
try {
|
try {
|
||||||
await window.electronAPI.http.stop()
|
await window.electronAPI.http.stop()
|
||||||
@@ -2053,6 +2062,56 @@ function SettingsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderAnalyticsTab = () => (
|
||||||
|
<div className="tab-content">
|
||||||
|
<div className="settings-section">
|
||||||
|
<h2>分析设置</h2>
|
||||||
|
<div className="setting-item">
|
||||||
|
<div className="setting-label">
|
||||||
|
<span>词云排除词</span>
|
||||||
|
<span className="setting-desc">输入不需要在词云和常用语中显示的词语,用换行分隔</span>
|
||||||
|
</div>
|
||||||
|
<div className="setting-control" style={{ flexDirection: 'column', alignItems: 'flex-start', gap: '8px' }}>
|
||||||
|
<textarea
|
||||||
|
className="form-input"
|
||||||
|
style={{ width: '100%', height: '200px', fontFamily: 'monospace' }}
|
||||||
|
value={excludeWordsInput}
|
||||||
|
onChange={(e) => setExcludeWordsInput(e.target.value)}
|
||||||
|
placeholder="例如:
|
||||||
|
第一个词
|
||||||
|
第二个词
|
||||||
|
第三个词"
|
||||||
|
/>
|
||||||
|
<div className="button-group">
|
||||||
|
<button
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={async () => {
|
||||||
|
const words = excludeWordsInput.split('\n').map(w => w.trim()).filter(w => w.length > 0)
|
||||||
|
// 去重
|
||||||
|
const uniqueWords = Array.from(new Set(words))
|
||||||
|
await configService.setWordCloudExcludeWords(uniqueWords)
|
||||||
|
setWordCloudExcludeWords(uniqueWords)
|
||||||
|
setExcludeWordsInput(uniqueWords.join('\n'))
|
||||||
|
// Show success toast or feedback if needed (optional)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
保存排除列表
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-secondary"
|
||||||
|
onClick={() => {
|
||||||
|
setExcludeWordsInput(wordCloudExcludeWords.join('\n'))
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
const renderSecurityTab = () => (
|
const renderSecurityTab = () => (
|
||||||
<div className="tab-content">
|
<div className="tab-content">
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
@@ -2242,6 +2301,7 @@ function SettingsPage() {
|
|||||||
{activeTab === 'export' && renderExportTab()}
|
{activeTab === 'export' && renderExportTab()}
|
||||||
{activeTab === 'cache' && renderCacheTab()}
|
{activeTab === 'cache' && renderCacheTab()}
|
||||||
{activeTab === 'api' && renderApiTab()}
|
{activeTab === 'api' && renderApiTab()}
|
||||||
|
{activeTab === 'analytics' && renderAnalyticsTab()}
|
||||||
{activeTab === 'security' && renderSecurityTab()}
|
{activeTab === 'security' && renderSecurityTab()}
|
||||||
{activeTab === 'about' && renderAboutTab()}
|
{activeTab === 'about' && renderAboutTab()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ export const CONFIG_KEYS = {
|
|||||||
NOTIFICATION_ENABLED: 'notificationEnabled',
|
NOTIFICATION_ENABLED: 'notificationEnabled',
|
||||||
NOTIFICATION_POSITION: 'notificationPosition',
|
NOTIFICATION_POSITION: 'notificationPosition',
|
||||||
NOTIFICATION_FILTER_MODE: 'notificationFilterMode',
|
NOTIFICATION_FILTER_MODE: 'notificationFilterMode',
|
||||||
NOTIFICATION_FILTER_LIST: 'notificationFilterList'
|
NOTIFICATION_FILTER_LIST: 'notificationFilterList',
|
||||||
|
|
||||||
|
// 词云
|
||||||
|
WORD_CLOUD_EXCLUDE_WORDS: 'wordCloudExcludeWords'
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export interface WxidConfig {
|
export interface WxidConfig {
|
||||||
@@ -465,3 +468,14 @@ export async function getNotificationFilterList(): Promise<string[]> {
|
|||||||
export async function setNotificationFilterList(list: string[]): Promise<void> {
|
export async function setNotificationFilterList(list: string[]): Promise<void> {
|
||||||
await config.set(CONFIG_KEYS.NOTIFICATION_FILTER_LIST, list)
|
await config.set(CONFIG_KEYS.NOTIFICATION_FILTER_LIST, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取词云排除词列表
|
||||||
|
export async function getWordCloudExcludeWords(): Promise<string[]> {
|
||||||
|
const value = await config.get(CONFIG_KEYS.WORD_CLOUD_EXCLUDE_WORDS)
|
||||||
|
return Array.isArray(value) ? value : []
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置词云排除词列表
|
||||||
|
export async function setWordCloudExcludeWords(words: string[]): Promise<void> {
|
||||||
|
await config.set(CONFIG_KEYS.WORD_CLOUD_EXCLUDE_WORDS, words)
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
[data-theme="cloud-dancer"][data-mode="light"],
|
[data-theme="cloud-dancer"][data-mode="light"],
|
||||||
[data-theme="cloud-dancer"]:not([data-mode]) {
|
[data-theme="cloud-dancer"]:not([data-mode]) {
|
||||||
--primary: #8B7355;
|
--primary: #8B7355;
|
||||||
|
--primary-rgb: 139, 115, 85;
|
||||||
--primary-hover: #7A6548;
|
--primary-hover: #7A6548;
|
||||||
--primary-light: rgba(139, 115, 85, 0.1);
|
--primary-light: rgba(139, 115, 85, 0.1);
|
||||||
--bg-primary: #F0EEE9;
|
--bg-primary: #F0EEE9;
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
[data-theme="corundum-blue"][data-mode="light"],
|
[data-theme="corundum-blue"][data-mode="light"],
|
||||||
[data-theme="corundum-blue"]:not([data-mode]) {
|
[data-theme="corundum-blue"]:not([data-mode]) {
|
||||||
--primary: #4A6670;
|
--primary: #4A6670;
|
||||||
|
--primary-rgb: 74, 102, 112;
|
||||||
--primary-hover: #3D565E;
|
--primary-hover: #3D565E;
|
||||||
--primary-light: rgba(74, 102, 112, 0.1);
|
--primary-light: rgba(74, 102, 112, 0.1);
|
||||||
--bg-primary: #E8EEF0;
|
--bg-primary: #E8EEF0;
|
||||||
@@ -83,6 +85,7 @@
|
|||||||
[data-theme="kiwi-green"][data-mode="light"],
|
[data-theme="kiwi-green"][data-mode="light"],
|
||||||
[data-theme="kiwi-green"]:not([data-mode]) {
|
[data-theme="kiwi-green"]:not([data-mode]) {
|
||||||
--primary: #7A9A5C;
|
--primary: #7A9A5C;
|
||||||
|
--primary-rgb: 122, 154, 92;
|
||||||
--primary-hover: #6A8A4C;
|
--primary-hover: #6A8A4C;
|
||||||
--primary-light: rgba(122, 154, 92, 0.1);
|
--primary-light: rgba(122, 154, 92, 0.1);
|
||||||
--bg-primary: #E8F0E4;
|
--bg-primary: #E8F0E4;
|
||||||
@@ -102,6 +105,7 @@
|
|||||||
[data-theme="spicy-red"][data-mode="light"],
|
[data-theme="spicy-red"][data-mode="light"],
|
||||||
[data-theme="spicy-red"]:not([data-mode]) {
|
[data-theme="spicy-red"]:not([data-mode]) {
|
||||||
--primary: #8B4049;
|
--primary: #8B4049;
|
||||||
|
--primary-rgb: 139, 64, 73;
|
||||||
--primary-hover: #7A3540;
|
--primary-hover: #7A3540;
|
||||||
--primary-light: rgba(139, 64, 73, 0.1);
|
--primary-light: rgba(139, 64, 73, 0.1);
|
||||||
--bg-primary: #F0E8E8;
|
--bg-primary: #F0E8E8;
|
||||||
@@ -121,6 +125,7 @@
|
|||||||
[data-theme="teal-water"][data-mode="light"],
|
[data-theme="teal-water"][data-mode="light"],
|
||||||
[data-theme="teal-water"]:not([data-mode]) {
|
[data-theme="teal-water"]:not([data-mode]) {
|
||||||
--primary: #5A8A8A;
|
--primary: #5A8A8A;
|
||||||
|
--primary-rgb: 90, 138, 138;
|
||||||
--primary-hover: #4A7A7A;
|
--primary-hover: #4A7A7A;
|
||||||
--primary-light: rgba(90, 138, 138, 0.1);
|
--primary-light: rgba(90, 138, 138, 0.1);
|
||||||
--bg-primary: #E4F0F0;
|
--bg-primary: #E4F0F0;
|
||||||
@@ -141,6 +146,7 @@
|
|||||||
// 云上舞白 - 深色
|
// 云上舞白 - 深色
|
||||||
[data-theme="cloud-dancer"][data-mode="dark"] {
|
[data-theme="cloud-dancer"][data-mode="dark"] {
|
||||||
--primary: #C9A86C;
|
--primary: #C9A86C;
|
||||||
|
--primary-rgb: 201, 168, 108;
|
||||||
--primary-hover: #D9B87C;
|
--primary-hover: #D9B87C;
|
||||||
--primary-light: rgba(201, 168, 108, 0.15);
|
--primary-light: rgba(201, 168, 108, 0.15);
|
||||||
--bg-primary: #1a1816;
|
--bg-primary: #1a1816;
|
||||||
@@ -159,6 +165,7 @@
|
|||||||
// 刚玉蓝 - 深色
|
// 刚玉蓝 - 深色
|
||||||
[data-theme="corundum-blue"][data-mode="dark"] {
|
[data-theme="corundum-blue"][data-mode="dark"] {
|
||||||
--primary: #6A9AAA;
|
--primary: #6A9AAA;
|
||||||
|
--primary-rgb: 106, 154, 170;
|
||||||
--primary-hover: #7AAABA;
|
--primary-hover: #7AAABA;
|
||||||
--primary-light: rgba(106, 154, 170, 0.15);
|
--primary-light: rgba(106, 154, 170, 0.15);
|
||||||
--bg-primary: #141a1c;
|
--bg-primary: #141a1c;
|
||||||
@@ -177,6 +184,7 @@
|
|||||||
// 冰猕猴桃汁绿 - 深色
|
// 冰猕猴桃汁绿 - 深色
|
||||||
[data-theme="kiwi-green"][data-mode="dark"] {
|
[data-theme="kiwi-green"][data-mode="dark"] {
|
||||||
--primary: #9ABA7C;
|
--primary: #9ABA7C;
|
||||||
|
--primary-rgb: 154, 186, 124;
|
||||||
--primary-hover: #AACA8C;
|
--primary-hover: #AACA8C;
|
||||||
--primary-light: rgba(154, 186, 124, 0.15);
|
--primary-light: rgba(154, 186, 124, 0.15);
|
||||||
--bg-primary: #161a14;
|
--bg-primary: #161a14;
|
||||||
@@ -195,6 +203,7 @@
|
|||||||
// 辛辣红 - 深色
|
// 辛辣红 - 深色
|
||||||
[data-theme="spicy-red"][data-mode="dark"] {
|
[data-theme="spicy-red"][data-mode="dark"] {
|
||||||
--primary: #C06068;
|
--primary: #C06068;
|
||||||
|
--primary-rgb: 192, 96, 104;
|
||||||
--primary-hover: #D07078;
|
--primary-hover: #D07078;
|
||||||
--primary-light: rgba(192, 96, 104, 0.15);
|
--primary-light: rgba(192, 96, 104, 0.15);
|
||||||
--bg-primary: #1a1416;
|
--bg-primary: #1a1416;
|
||||||
@@ -213,6 +222,7 @@
|
|||||||
// 明水鸭色 - 深色
|
// 明水鸭色 - 深色
|
||||||
[data-theme="teal-water"][data-mode="dark"] {
|
[data-theme="teal-water"][data-mode="dark"] {
|
||||||
--primary: #7ABAAA;
|
--primary: #7ABAAA;
|
||||||
|
--primary-rgb: 122, 186, 170;
|
||||||
--primary-hover: #8ACABA;
|
--primary-hover: #8ACABA;
|
||||||
--primary-light: rgba(122, 186, 170, 0.15);
|
--primary-light: rgba(122, 186, 170, 0.15);
|
||||||
--bg-primary: #121a1a;
|
--bg-primary: #121a1a;
|
||||||
|
|||||||
17
src/types/electron.d.ts
vendored
17
src/types/electron.d.ts
vendored
@@ -397,16 +397,15 @@ export interface ElectronAPI {
|
|||||||
myTopEmojiMd5?: string
|
myTopEmojiMd5?: string
|
||||||
friendTopEmojiMd5?: string
|
friendTopEmojiMd5?: string
|
||||||
myTopEmojiUrl?: string
|
myTopEmojiUrl?: string
|
||||||
friendTopEmojiUrl?: string
|
topPhrases: Array<{ phrase: string; count: number }>
|
||||||
myTopEmojiCount?: number
|
myExclusivePhrases: Array<{ phrase: string; count: number }>
|
||||||
friendTopEmojiCount?: number
|
friendExclusivePhrases: Array<{ phrase: string; count: number }>
|
||||||
|
heatmap?: number[][]
|
||||||
|
initiative?: { initiated: number; received: number }
|
||||||
|
response?: { avg: number; fastest: number; count: number }
|
||||||
|
monthly?: Record<string, number>
|
||||||
|
streak?: { days: number; startDate: string; endDate: string }
|
||||||
}
|
}
|
||||||
topPhrases: Array<{ phrase: string; count: number }>
|
|
||||||
heatmap?: number[][]
|
|
||||||
initiative?: { initiated: number; received: number }
|
|
||||||
response?: { avg: number; fastest: number; count: number }
|
|
||||||
monthly?: Record<string, number>
|
|
||||||
streak?: { days: number; startDate: string; endDate: string }
|
|
||||||
}
|
}
|
||||||
error?: string
|
error?: string
|
||||||
}>
|
}>
|
||||||
|
|||||||
Reference in New Issue
Block a user