From 4a33f07d012eaf4ddf64f2137c202ad3280b8875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Wed, 11 Feb 2026 11:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=86=E9=A2=91=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/plugins/video/detail/detail.vue | 51 ++++++++++++++++++--------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/pages/plugins/video/detail/detail.vue b/pages/plugins/video/detail/detail.vue index f56f922f..90a2f11c 100644 --- a/pages/plugins/video/detail/detail.vue +++ b/pages/plugins/video/detail/detail.vue @@ -357,23 +357,42 @@ if (data.code == 0) { const new_data = data.data; // 第一次的数据 - const data_list = JSON.parse(JSON.stringify(this.video_data_list)); - if (is_last == 1 && is_next == 1) { - // 上一批数据 - if (new_data.last.length > 0) { - data_list.unshift(...new_data.last); - } - // 下一批数据 - if (new_data.next.length > 0) { - data_list.push(...new_data.next); - } - } else if (is_last == 1 && new_data.last.length > 0) { // 上一页数据 - data_list.unshift(...new_data.last); - } else if (is_next == 1 && new_data.next.length > 0) { // 下一页数据 - data_list.push(...new_data.next); - } - console.log(data_list); + let data_list = JSON.parse(JSON.stringify(this.video_data_list)); + // 创建现有数据的ID映射表,用于快速去重 + const existing_ids = new Map(); + data_list.forEach(item => { + existing_ids.set(item.id, true); + }); + + if (is_last == 1 && is_next == 1) { + // 上一批数据 - 去重处理 + if (new_data.last.length > 0) { + const unique_last = new_data.last.filter(item => !existing_ids.has(item.id)); + if (unique_last.length > 0) { + data_list.unshift(...unique_last); + // 更新ID映射表 + unique_last.forEach(item => existing_ids.set(item.id, true)); + } + } + // 下一批数据 - 去重处理 + if (new_data.next.length > 0) { + const unique_next = new_data.next.filter(item => !existing_ids.has(item.id)); + if (unique_next.length > 0) { + data_list.push(...unique_next); + } + } + } else if (is_last == 1 && new_data.last.length > 0) { // 上一页数据 - 去重处理 + const unique_last = new_data.last.filter(item => !existing_ids.has(item.id)); + if (unique_last.length > 0) { + data_list.unshift(...unique_last); + } + } else if (is_next == 1 && new_data.next.length > 0) { // 下一页数据 - 去重处理 + const unique_next = new_data.next.filter(item => !existing_ids.has(item.id)); + if (unique_next.length > 0) { + data_list.push(...unique_next); + } + } const new_index = data_list.findIndex(item => item.id == this.params.id); this.setData({ video_data_list: data_list,