CN-1329 fix: 修复实体主页相同搜索历史重复展示问题

This commit is contained in:
刘洪洪
2023-09-24 21:32:16 +08:00
parent a5841ea63b
commit 9ebcd6a9eb
2 changed files with 8 additions and 2 deletions

View File

@@ -98,7 +98,12 @@ export default {
const newItem = { str, date: this.dateFormatByAppearance(new Date()) }
if (!_.isEmpty(oldHistory)) {
const oldArr = JSON.parse(oldHistory)
oldArr.unshift(newItem)
const obj = oldArr.find(d => d.str === str)
if (obj) {
oldArr[0].date = this.dateFormatByAppearance(new Date())
} else {
oldArr.unshift(newItem)
}
arr = [...oldArr]
if (arr.length > 30) {
arr = arr.slice(0, 30)