Commit da860c42 by weiw

fix:处理一下 历史记录 数据排列问题

parent 803563af
...@@ -12,8 +12,8 @@ export function processConversationData(records: Conversation[]): Conversation[] ...@@ -12,8 +12,8 @@ export function processConversationData(records: Conversation[]): Conversation[]
records.forEach((item) => { records.forEach((item) => {
const endDate = new Date(item.endTime) const endDate = new Date(item.endTime)
let timeLabel = ''
// 今天的数据
if (isToday(endDate)) { if (isToday(endDate)) {
if (!hasToday) { if (!hasToday) {
processedData.push({ processedData.push({
...@@ -24,8 +24,11 @@ export function processConversationData(records: Conversation[]): Conversation[] ...@@ -24,8 +24,11 @@ export function processConversationData(records: Conversation[]): Conversation[]
} as any) } as any)
hasToday = true hasToday = true
} }
timeLabel = '今天' processedData.push({
...item,
})
} }
// 最近一周但不是今天的数据
else if (isThisWeek(endDate, { weekStartsOn: 1 })) { else if (isThisWeek(endDate, { weekStartsOn: 1 })) {
if (!hasThisWeek) { if (!hasThisWeek) {
processedData.push({ processedData.push({
...@@ -36,8 +39,11 @@ export function processConversationData(records: Conversation[]): Conversation[] ...@@ -36,8 +39,11 @@ export function processConversationData(records: Conversation[]): Conversation[]
} as Conversation) } as Conversation)
hasThisWeek = true hasThisWeek = true
} }
timeLabel = '最近一周' processedData.push({
...item,
})
} }
// 最近30天但不是本周的数据
else if (isWithinInterval(endDate, { start: thirtyDaysAgo, end: today })) { else if (isWithinInterval(endDate, { start: thirtyDaysAgo, end: today })) {
if (!hasLast30Days) { if (!hasLast30Days) {
processedData.push({ processedData.push({
...@@ -48,16 +54,10 @@ export function processConversationData(records: Conversation[]): Conversation[] ...@@ -48,16 +54,10 @@ export function processConversationData(records: Conversation[]): Conversation[]
} as Conversation) } as Conversation)
hasLast30Days = true hasLast30Days = true
} }
// eslint-disable-next-line unused-imports/no-unused-vars processedData.push({
timeLabel = '最近30天' ...item,
})
} }
else {
return
}
processedData.push({
...item,
})
}) })
return processedData return processedData
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment