支持本机删除群消息和打开群链接
This commit is contained in:
1 parent
5ec9c81f90
commit
fef421bd4b
7 files changed
+134
-40
No files matched your search
@@ -13,6 +13,7 @@ import type { Attachment } from '../chat/attachments'
|
||||
import VoiceRecorder from '../chat/VoiceRecorder.vue'
|
||||
import VoiceMessage from '../chat/VoiceMessage.vue'
|
||||
import MediaPreview from '../chat/MediaPreview.vue'
|
||||
import MessageText from '../chat/MessageText.vue'
|
||||
|
||||
const session = useSession()
|
||||
const route = useRoute()
|
||||
@@ -54,31 +55,6 @@ const lines = computed(() => {
|
||||
(!favoritesOnly.value || line.favorite) &&
|
||||
(!query || [line.text, line.attachment?.name, line.quote].some((part) => part?.toLowerCase().includes(query))))
|
||||
})
|
||||
const internalBrowser = window.xhchat?.openBrowser
|
||||
|
||||
function messageParts(text: string) {
|
||||
const parts: { text: string; url?: string }[] = []
|
||||
let offset = 0
|
||||
for (const match of text.matchAll(/https?:\/\/[^\s<>"']+/giu)) {
|
||||
const label = match[0].replace(/[.,!?;:,。!?;:、))\]】]+$/u, '')
|
||||
try {
|
||||
const url = new URL(label)
|
||||
if (url.username || url.password || label.length > 4096 ||
|
||||
(url.protocol !== 'https:' && !['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname))) continue
|
||||
if (match.index > offset) parts.push({ text: text.slice(offset, match.index) })
|
||||
parts.push({ text: label, url: url.href })
|
||||
offset = match.index + label.length
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if (offset < text.length) parts.push({ text: text.slice(offset) })
|
||||
return parts
|
||||
}
|
||||
|
||||
function openLink(url: string) {
|
||||
if (internalBrowser) void execute(() => internalBrowser(url))
|
||||
}
|
||||
let timer: ReturnType<typeof setInterval>
|
||||
let receiptTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
@@ -365,9 +341,7 @@ onBeforeUnmount(() => {
|
||||
<button type="button" class="plain" :disabled="busy"
|
||||
@click="saveAttachment(line.attachment)">下载 {{ line.attachment.name }}</button>
|
||||
</template>
|
||||
<span v-else><template v-for="(part, index) in messageParts(line.text)" :key="index"><button v-if="part.url && internalBrowser"
|
||||
type="button" class="chat-link" @click="openLink(part.url)">{{ part.text }}</button><a v-else-if="part.url"
|
||||
class="chat-link" :href="part.url" target="_blank" rel="noopener noreferrer">{{ part.text }}</a><template v-else>{{ part.text }}</template></template></span>
|
||||
<MessageText v-else :text="line.text" @error="error = $event" />
|
||||
<small v-if="view?.unsent.includes(line.id)">待发送</small>
|
||||
<small v-else-if="line.own && line.read && !line.recalled">已读</small>
|
||||
<small v-if="line.edited && !line.recalled">已编辑</small>
|
||||
|
||||
Reference in new issue
Block a user