mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 15:25:50 +00:00
fix: 修复了虚拟机上无法索引到wxkey的问题;修复图片密钥扫描的问题;修复年度报告错误;修复了年度报告和数据分析中的发送者错误问题;修复了部分页面偶发的未渲染名称问题;修复了头像偶发渲染失败的问题;修复了部分图片无法解密的问题
79 lines
1.9 KiB
TypeScript
79 lines
1.9 KiB
TypeScript
import { create } from 'zustand'
|
|
import { persist } from 'zustand/middleware'
|
|
|
|
interface ChatStatistics {
|
|
totalMessages: number
|
|
textMessages: number
|
|
imageMessages: number
|
|
voiceMessages: number
|
|
videoMessages: number
|
|
emojiMessages: number
|
|
otherMessages: number
|
|
sentMessages: number
|
|
receivedMessages: number
|
|
firstMessageTime: number | null
|
|
lastMessageTime: number | null
|
|
activeDays: number
|
|
messageTypeCounts: Record<number, number>
|
|
}
|
|
|
|
interface ContactRanking {
|
|
username: string
|
|
displayName: string
|
|
avatarUrl?: string
|
|
messageCount: number
|
|
sentCount: number
|
|
receivedCount: number
|
|
lastMessageTime: number | null
|
|
}
|
|
|
|
interface TimeDistribution {
|
|
hourlyDistribution: Record<number, number>
|
|
monthlyDistribution: Record<string, number>
|
|
}
|
|
|
|
interface AnalyticsState {
|
|
// 数据
|
|
statistics: ChatStatistics | null
|
|
rankings: ContactRanking[]
|
|
timeDistribution: TimeDistribution | null
|
|
|
|
// 状态
|
|
isLoaded: boolean
|
|
lastLoadTime: number | null
|
|
|
|
// Actions
|
|
setStatistics: (data: ChatStatistics) => void
|
|
setRankings: (data: ContactRanking[]) => void
|
|
setTimeDistribution: (data: TimeDistribution) => void
|
|
markLoaded: () => void
|
|
clearCache: () => void
|
|
}
|
|
|
|
export const useAnalyticsStore = create<AnalyticsState>()(
|
|
persist(
|
|
(set) => ({
|
|
statistics: null,
|
|
rankings: [],
|
|
timeDistribution: null,
|
|
isLoaded: false,
|
|
lastLoadTime: null,
|
|
|
|
setStatistics: (data) => set({ statistics: data }),
|
|
setRankings: (data) => set({ rankings: data }),
|
|
setTimeDistribution: (data) => set({ timeDistribution: data }),
|
|
markLoaded: () => set({ isLoaded: true, lastLoadTime: Date.now() }),
|
|
clearCache: () => set({
|
|
statistics: null,
|
|
rankings: [],
|
|
timeDistribution: null,
|
|
isLoaded: false,
|
|
lastLoadTime: null
|
|
}),
|
|
}),
|
|
{
|
|
name: 'analytics-storage',
|
|
}
|
|
)
|
|
)
|