From f6643c044b76b0b3832fc630361aba2e4a73c4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Fri, 11 Oct 2024 17:15:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=89=E9=A1=B9=E5=8D=A1?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/model-article-list/index.vue | 17 ++++++++------ src/components/model-goods-list/index.vue | 25 ++++++++++++--------- src/config/const/header-nav.ts | 4 ++-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/components/model-article-list/index.vue b/src/components/model-article-list/index.vue index 902551bf..1e96014c 100644 --- a/src/components/model-article-list/index.vue +++ b/src/components/model-article-list/index.vue @@ -177,14 +177,17 @@ const data_list_computer = computed(() => { }); watch( () => data_list_computer.value, - (new_value) => { - if (new_value.data_type == '1') { - get_auto_data_list(); - } else { - if (!isEmpty(new_content.value.data_list)) { - data_list.value = cloneDeep(new_content.value.data_list); + (new_value, old_value) => { + // 使用JSON.stringify()进行判断 新值和旧值是否一样 不一样就重新获取数据 + if (JSON.stringify(new_value) !== JSON.stringify(old_value)) { + if (new_value.data_type == '1') { + get_auto_data_list(); } else { - data_list.value = Array(4).fill(default_data_list); + if (!isEmpty(new_content.value.data_list)) { + data_list.value = cloneDeep(new_content.value.data_list); + } else { + data_list.value = Array(4).fill(default_data_list); + } } } }, diff --git a/src/components/model-goods-list/index.vue b/src/components/model-goods-list/index.vue index 919ce529..3b5ac937 100644 --- a/src/components/model-goods-list/index.vue +++ b/src/components/model-goods-list/index.vue @@ -269,19 +269,22 @@ const watch_data = computed(() => { return { category_ids: category_ids, brand: brand, number: number, order_by_type: order_by_type, order_by_rule: order_by_rule, data_type: data_type, data_list: data_list }; }) // 初始化的时候不执行, 监听数据变化 -watch(() => watch_data.value, (val) => { - if (val.data_type == '0') { - if (!isEmpty(val.data_list)) { - list.value = cloneDeep(val.data_list).map((item: any) => ({ - ...item.data, - title: !isEmpty(item.new_title) ? item.new_title : item.data.title, - new_cover: item.new_cover, - })); +watch(() => watch_data.value, (val, oldVal) => { + // 使用JSON.stringify()进行判断 新值和旧值是否一样 不一样就重新获取数据 + if (JSON.stringify(val) !== JSON.stringify(oldVal)) { + if (val.data_type == '0') { + if (!isEmpty(val.data_list)) { + list.value = cloneDeep(val.data_list).map((item: any) => ({ + ...item.data, + title: !isEmpty(item.new_title) ? item.new_title : item.data.title, + new_cover: item.new_cover, + })); + } else { + list.value = Array(4).fill(default_list); + } } else { - list.value = Array(4).fill(default_list); + get_products(); } - } else { - get_products(); } }, { deep: true }); //#endregion diff --git a/src/config/const/header-nav.ts b/src/config/const/header-nav.ts index 37c88405..50c2ba8a 100644 --- a/src/config/const/header-nav.ts +++ b/src/config/const/header-nav.ts @@ -18,7 +18,7 @@ interface DefaultFooterNav { is_arrows_show: string; is_center: string; is_icon_show: string; - icon_src: string; + icon_src: object; icon_img: uploadList[]; icon_class: string; search_botton_img: uploadList[]; @@ -76,7 +76,7 @@ const defaultFooterNav: DefaultFooterNav = { is_arrows_show: '1', is_center: '0', is_icon_show: '1', - icon_src: '', + icon_src: {}, icon_img: [], icon_class: '', search_botton_img: [],