粗提取链接

This commit is contained in:
2026-07-17 14:28:52 +08:00
parent f53beabdf6
commit 3abf881437
3 changed files with 157 additions and 41 deletions

View File

@@ -43,6 +43,12 @@
</view>
<scroll-view class="message-detail-content" scroll-y>
<text>{{ detailMessageContent }}</text>
<view v-if="detailLinks.length" class="detail-links-section">
<view class="detail-links-title">链接 ({{ detailLinks.length }})</view>
<view v-for="(link, i) in detailLinks" :key="i" class="detail-link-item" @click="openLink(link)">
<text class="link-text">{{ link }}</text>
</view>
</view>
</scroll-view>
</view>
</view>
@@ -671,13 +677,29 @@
// 消息详情弹窗
const showMessageModal = ref(false)
const detailMessageContent = ref('')
const detailLinks = ref([])
const extractLinks = (text) => {
const regex = /https?:\/\/[^\s<>"{}|\\^`[\]]+/gi
const matches = text.match(regex)
return matches ? [...new Set(matches)] : []
}
const showMessageDetail = (message) => {
detailMessageContent.value = message.content || ''
detailLinks.value = extractLinks(detailMessageContent.value)
showMessageModal.value = true
}
const closeMessageDetail = () => {
showMessageModal.value = false
detailMessageContent.value = ''
detailLinks.value = []
}
const openLink = (url) => {
// #ifdef APP-PLUS
plus.runtime.openURL(url)
// #endif
// #ifdef H5
window.open(url, '_blank')
// #endif
}
const sendMessage = async () => {
@@ -1396,4 +1418,31 @@
transform: scale(1.1);
}
}
/* 消息详情弹窗 — 链接提取区域 */
.detail-links-section {
margin-top: 24rpx;
padding-top: 24rpx;
border-top: 1rpx solid #eee;
}
.detail-links-title {
font-size: 30rpx;
font-weight: 600;
color: #666;
margin-bottom: 16rpx;
}
.detail-link-item {
padding: 16rpx 20rpx;
background: #f5f7fa;
border-radius: 12rpx;
margin-bottom: 12rpx;
}
.link-text {
font-size: 28rpx;
color: #007aff;
word-break: break-all;
}
</style>