flat: 演示版

This commit is contained in:
Apcallover
2025-12-09 11:13:32 +08:00
parent f24d95cedf
commit 67f5dbbfb0
12 changed files with 161 additions and 36 deletions

View File

@@ -70,8 +70,29 @@ watch(
() => props.list,
(newList) => {
if (!Array.isArray(newList)) return;
let shouldReset = false;
if (dataSource.value.length > newList.length) {
shouldReset = true;
} else if (dataSource.value.length > 0 && newList.length > 0) {
// 注意:这里沿用你代码中使用的 item.id 作为唯一标识
const oldId = dataSource.value[0].id;
const newId = newList[0].id;
if (oldId !== newId) {
shouldReset = true;
}
}
if (shouldReset) {
dataSource.value = [];
processedIds.clear();
}
const newItems = newList.filter((item) => !processedIds.has(item.id));
if (newItems.length === 0) return;
newItems.forEach((item) => processedIds.add(item.id));
const delay = 50;
newItems.forEach((item, index) => {
@@ -80,7 +101,7 @@ watch(
}, index * delay);
});
},
{ immediate: true }
{ immediate: true, deep: true }
);
function nextDetail(company) {