fix: use reactive array instead of Set for newRecordIds
This commit is contained in:
parent
a2052b673c
commit
0ef2840f00
@ -34,7 +34,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const visible = ref(true)
|
const visible = ref(true)
|
||||||
const isPageActive = ref(true)
|
const isPageActive = ref(true)
|
||||||
const newRecordIds = ref(new Set())
|
const newRecordIds = ref([])
|
||||||
|
|
||||||
// 使用轮询 composable
|
// 使用轮询 composable
|
||||||
const { records, loading, error, start, stop, refresh } = useContributionPolling(
|
const { records, loading, error, start, stop, refresh } = useContributionPolling(
|
||||||
@ -44,7 +44,7 @@ const { records, loading, error, start, stop, refresh } = useContributionPolling
|
|||||||
|
|
||||||
// 判断记录是否为新记录(刚加入的)
|
// 判断记录是否为新记录(刚加入的)
|
||||||
function isNewRecord(id) {
|
function isNewRecord(id) {
|
||||||
return newRecordIds.value.has(id)
|
return newRecordIds.value.includes(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听 records 变化,标记新记录
|
// 监听 records 变化,标记新记录
|
||||||
@ -56,10 +56,10 @@ watch(records, (newRecords, oldRecords) => {
|
|||||||
// 找出新增的记录ID
|
// 找出新增的记录ID
|
||||||
for (const id of newIds) {
|
for (const id of newIds) {
|
||||||
if (!oldIds.includes(id)) {
|
if (!oldIds.includes(id)) {
|
||||||
newRecordIds.value.add(id)
|
newRecordIds.value.push(id)
|
||||||
// 2秒后移除新记录标记
|
// 2秒后移除新记录标记
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
newRecordIds.value.delete(id)
|
newRecordIds.value = newRecordIds.value.filter(i => i !== id)
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user