From 8286d20beaaaf8f52a84d7b385495f626cb59d13 Mon Sep 17 00:00:00 2001 From: lipenghui Date: Mon, 29 Jan 2024 13:50:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:1.=20=E4=BC=9A=E8=AF=9D=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E8=BF=9E=E6=8E=A5=E6=94=B9=E4=B8=BA=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E6=A0=87=E7=AD=BE=E9=A1=B5=EF=BC=9B2.=20?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F=E5=A2=9E=E5=8A=A0=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=EF=BC=9B3.=20=E4=BF=AE=E6=94=B9=E7=BA=BF=E4=B8=8A=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=B8=BA=E5=9F=9F=E5=90=8D=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 2 +- src/components/AppMessage/index.vue | 31 ++++++++++++++++++++++++++++- src/layout/AppMenu/index.vue | 31 ++++++++++++++++++++--------- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/.env.production b/.env.production index 40563ef..5bf9372 100644 --- a/.env.production +++ b/.env.production @@ -1,7 +1,7 @@ # 正式环境 # 公共地址 -VITE_GLOB_BASE_URL = "http://223.99.228.207:19872" +VITE_GLOB_BASE_URL = "https://ai.sinenux.com:19876" # 本地MQTT地址 VITE_GLOB_MQTT_HOST = "223.99.228.240" diff --git a/src/components/AppMessage/index.vue b/src/components/AppMessage/index.vue index 7a069c8..882e6f0 100644 --- a/src/components/AppMessage/index.vue +++ b/src/components/AppMessage/index.vue @@ -3,6 +3,7 @@ import { computed, nextTick, onMounted, ref, watch } from 'vue' import { Image } from 'ant-design-vue' import { MdPreview } from 'md-editor-v3' import 'md-editor-v3/lib/style.css' +import { throttle } from 'lodash-es' import type { MessageItem } from './index.d' import { SvgIcon } from '@/components/SvgIcon' import { MessageStatusEnum, MessageTypeEnum } from '@/enums/messageEnum' @@ -46,6 +47,7 @@ const conversationData = computed(() => messageStore.getConversationData) watch( () => props.list[props.list.length - 1], () => { + throttle(setHrefTarget, 500) if (isAutoScroll.value) { scrollToBottom() } @@ -53,6 +55,19 @@ watch( { immediate: true }, ) +watch( + () => messageStore.messageStatus, + () => { + setHrefTarget() + }, +) +watch( + () => props.list.length, + () => { + setHrefTarget() + }, +) + /** * @description: 滚动到底部 */ @@ -111,8 +126,22 @@ function reloadMessage() { emit('reloadMessage') } +/** + * @description: 给链接添加target="_blank" + */ +async function setHrefTarget() { + if (messageRef.value && props.list.length) { + await nextTick() + const links = messageRef.value.querySelectorAll('a') + links.forEach((item: { target: string }) => { + item.target = '_blank' + }) + } +} + onMounted(async () => { scrollToBottom() + setHrefTarget() }) @@ -123,7 +152,7 @@ onMounted(async () => {
diff --git a/src/layout/AppMenu/index.vue b/src/layout/AppMenu/index.vue index 5aa8bd4..5737d12 100644 --- a/src/layout/AppMenu/index.vue +++ b/src/layout/AppMenu/index.vue @@ -104,8 +104,8 @@ function showConfirm() {