Enhance file upload process in devlop.py with progress tracking and remote file validation. Add aiType field to weChatGroup and ContractData interfaces for AI type differentiation. Update ChatWindow component to handle AI configuration changes and ensure proper database updates for contact and message management. Implement database versioning to include aiType in chatSessions and contactsUnified tables, with migration logic for existing data. Improve error handling and user feedback during configuration updates.
This commit is contained in:
@@ -41,6 +41,7 @@ export interface ChatSession {
|
||||
avatar: string; // 头像
|
||||
content: string; // 最新消息内容
|
||||
lastUpdateTime: string; // 最后更新时间
|
||||
aiType?: number; // AI类型(0=普通,1=AI辅助)
|
||||
config: {
|
||||
unreadCount: number; // 未读数量
|
||||
top: number; // 是否置顶(1=置顶,0=非置顶)
|
||||
@@ -72,6 +73,7 @@ export interface Contact {
|
||||
conRemark?: string; // 备注名
|
||||
avatar: string; // 头像
|
||||
lastUpdateTime: string; // 最后更新时间
|
||||
aiType?: number; // AI类型(0=普通,1=AI辅助)
|
||||
config?: any; // 配置信息
|
||||
sortKey: string; // 预计算排序键
|
||||
searchKey: string; // 预计算搜索键
|
||||
@@ -142,6 +144,47 @@ class CunkebaoDatabase extends Dexie {
|
||||
userLoginRecords:
|
||||
"serverId, userId, lastLoginTime, loginCount, createTime, lastActiveTime",
|
||||
});
|
||||
|
||||
// 版本2:添加 aiType 字段
|
||||
this.version(2)
|
||||
.stores({
|
||||
// 会话表索引:添加 aiType 索引
|
||||
chatSessions:
|
||||
"serverId, userId, id, type, wechatAccountId, [userId+type], [userId+wechatAccountId], [userId+lastUpdateTime], [userId+aiType], sortKey, nickname, conRemark, avatar, content, lastUpdateTime, aiType",
|
||||
|
||||
// 联系人表索引:添加 aiType 索引
|
||||
contactsUnified:
|
||||
"serverId, userId, id, type, wechatAccountId, [userId+type], [userId+wechatAccountId], [userId+aiType], sortKey, searchKey, nickname, conRemark, avatar, lastUpdateTime, groupId, aiType",
|
||||
|
||||
// 联系人标签映射表索引:保持不变
|
||||
contactLabelMap:
|
||||
"serverId, userId, labelId, contactId, contactType, [userId+labelId], [userId+contactId], [userId+labelId+sortKey], sortKey, searchKey, avatar, nickname, conRemark, unreadCount, lastUpdateTime",
|
||||
|
||||
// 用户登录记录表索引:保持不变
|
||||
userLoginRecords:
|
||||
"serverId, userId, lastLoginTime, loginCount, createTime, lastActiveTime",
|
||||
})
|
||||
.upgrade(tx => {
|
||||
// 数据迁移:为现有数据添加 aiType 默认值
|
||||
return tx
|
||||
.table("chatSessions")
|
||||
.toCollection()
|
||||
.modify(session => {
|
||||
if (session.aiType === undefined) {
|
||||
session.aiType = 0; // 默认为普通类型
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
return tx
|
||||
.table("contactsUnified")
|
||||
.toCollection()
|
||||
.modify(contact => {
|
||||
if (contact.aiType === undefined) {
|
||||
contact.aiType = 0; // 默认为普通类型
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user