diff --git a/src/components/article/indexNewsInfo.vue b/src/components/article/indexNewsInfo.vue index 598834c..fc9d2af 100644 --- a/src/components/article/indexNewsInfo.vue +++ b/src/components/article/indexNewsInfo.vue @@ -234,8 +234,13 @@ function getFirstTextNode(node: any): any { const content = computed(() => { const content = props.data.content; + // 未发布文章直接返回 status = 2 已发布 + if(!content || props.data.status !== 2) { + return content; + } + + // 插入文案 const insertText = `中证参考海外资讯${dayjs(props.data.publishTime).format('MM月DD日')}援引${props.data.source}`; - if (!content) return; const dom = new DOMParser().parseFromString(content, "text/html"); const body = dom.querySelector("body"); const p = body?.childNodes; @@ -246,7 +251,7 @@ const content = computed(() => { textNode.textContent = insertText + textNode.textContent; break; } - } + } return body?.innerHTML; });