fix record
This commit is contained in:
parent
4f66ff8b1d
commit
5962e0b12d
@ -74,7 +74,7 @@ export const useTalkRecord = (uid) => {
|
|||||||
// 加载数据列表
|
// 加载数据列表
|
||||||
const load = async (params) => {
|
const load = async (params) => {
|
||||||
const request = {
|
const request = {
|
||||||
limit: 30,
|
limit:10,
|
||||||
...params,
|
...params,
|
||||||
talk_type: params.talk_type,
|
talk_type: params.talk_type,
|
||||||
receiver_id: params.receiver_id,
|
receiver_id: params.receiver_id,
|
||||||
|
@ -17,7 +17,7 @@ export const useDialogueListStore = createGlobalState(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addDialogueRecord = (newRecords, type = 'add') => {
|
const addDialogueRecord = (newRecords, type = 'add') => {
|
||||||
console.log(newRecords)
|
console.log('newRecords',newRecords)
|
||||||
|
|
||||||
const dialogue = lodash.cloneDeep(useDialogueStore())
|
const dialogue = lodash.cloneDeep(useDialogueStore())
|
||||||
if (!dialogue || typeof dialogue !== 'object') return
|
if (!dialogue || typeof dialogue !== 'object') return
|
||||||
@ -45,6 +45,21 @@ export const useDialogueListStore = createGlobalState(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 限制records数组长度为40条
|
||||||
|
const maxRecords = 40
|
||||||
|
if (dialogueList.value[existingIndex].records.length > maxRecords) {
|
||||||
|
const excessCount = dialogueList.value[existingIndex].records.length - maxRecords
|
||||||
|
// 如果是push添加,则从首部删除多余条目
|
||||||
|
if (type === 'add') {
|
||||||
|
dialogueList.value[existingIndex].records.splice(0, excessCount)
|
||||||
|
} else {
|
||||||
|
// 如果是unshift添加,则从尾部删除多余条目
|
||||||
|
dialogueList.value[existingIndex].records.splice(-excessCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('records',dialogueList.value[existingIndex].records)
|
||||||
|
|
||||||
// 更新除 records 和 index_name 外的其他属性
|
// 更新除 records 和 index_name 外的其他属性
|
||||||
const { index_name, records: _, ...updateProps } = dialogue
|
const { index_name, records: _, ...updateProps } = dialogue
|
||||||
|
Loading…
Reference in New Issue
Block a user