From 4b2f63f2f8023f39b9dd7666e0e53906122e8d8b Mon Sep 17 00:00:00 2001 From: sws <1141121512@qq.com> Date: Mon, 2 Sep 2024 14:24:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96=20sws=20?= =?UTF-8?q?2024-09-02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/model-article-list/index.vue | 19 ++++++++++++++----- .../model-article-list-content.vue | 9 +++------ .../model-article-tabs-content.vue | 9 +++------ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/components/model-article-list/index.vue b/src/components/model-article-list/index.vue index 0d9dc759..4e61f905 100644 --- a/src/components/model-article-list/index.vue +++ b/src/components/model-article-list/index.vue @@ -14,8 +14,8 @@
{{ !isEmpty(item.new_title) ? item.new_title : item.data.title }}
{{ field_show.includes('0') ? (!is_obj_empty(item.data) ? item.data.add_time : '2020-06-05 15:20') : '' }}
-
- +
+
{{ item.data.access_count ? item.data.access_count : '16' }}
@@ -116,21 +116,30 @@ const get_auto_data_list = async (new_content: any) => { data_list.value = Array(4).fill(default_data_list); } }; +const data_type_is_change = ref(0); +watch( + () => data_type_is_change.value, + (newVal, oldValue) => { + if (newVal !== oldValue && String(newVal) === '1') { + get_auto_data_list(props.value?.content); + } + }, + { deep: true } +); watch( props.value, (newVal, oldValue) => { const new_content = newVal?.content; const new_style = newVal?.style; // 内容 - if (new_content.data_type === '0') { + data_type_is_change.value = new_content.data_type; + if (String(new_content.data_type) === '0') { if (!isEmpty(new_content.data_list)) { data_list.value = new_content.data_list; data_list.value = cloneDeep(new_content.data_list); } else { data_list.value = Array(4).fill(default_data_list); } - } else { - get_auto_data_list(new_content); } article_theme.value = new_content.theme; diff --git a/src/components/model-article-list/model-article-list-content.vue b/src/components/model-article-list/model-article-list-content.vue index c52820d9..12448f1c 100644 --- a/src/components/model-article-list/model-article-list-content.vue +++ b/src/components/model-article-list/model-article-list-content.vue @@ -119,12 +119,9 @@ const base_list = reactive({ onMounted(() => { nextTick(() => { // 定时获取common_store.common.article_category的数据,直到拿到值或者关闭页面为止 - const interval = setInterval(() => { - if (common_store.common.article_category.length > 0) { - base_list.article_category_list = common_store.common.article_category; - clearInterval(interval); - } - }, 1000); + if (common_store.common.article_category.length > 0) { + base_list.article_category_list = common_store.common.article_category; + } }); }); const theme_change = (val: any) => { diff --git a/src/components/model-article-tabs/model-article-tabs-content.vue b/src/components/model-article-tabs/model-article-tabs-content.vue index b8df360b..2c3a993f 100644 --- a/src/components/model-article-tabs/model-article-tabs-content.vue +++ b/src/components/model-article-tabs/model-article-tabs-content.vue @@ -145,12 +145,9 @@ const base_list = reactive({ onMounted(() => { nextTick(() => { // 定时获取common_store.common.article_category的数据,直到拿到值或者关闭页面为止 - const interval = setInterval(() => { - if (common_store.common.article_category.length > 0) { - base_list.article_category_list = common_store.common.article_category; - clearInterval(interval); - } - }, 1000); + if (common_store.common.article_category.length > 0) { + base_list.article_category_list = common_store.common.article_category; + } }); }); const article_theme_change = (val: any) => {