feat:注册功能
This commit is contained in:
@@ -1,9 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { ChatMessage } from '@/types/customer-service'
|
||||
import fileIcon from '@/static/icons/PDF.png'
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
message: ChatMessage
|
||||
}>()
|
||||
|
||||
const messageType = computed(() => props.message.type || 'text')
|
||||
|
||||
function handlePreviewImage() {
|
||||
if (!props.message.imageUrl)
|
||||
return
|
||||
|
||||
uni.previewImage({
|
||||
urls: [props.message.imageUrl],
|
||||
current: props.message.imageUrl,
|
||||
})
|
||||
}
|
||||
|
||||
function handleOpenFile() {
|
||||
if (!props.message.filePath) {
|
||||
uni.showToast({ title: props.message.fileName || '文件', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
uni.openDocument({
|
||||
filePath: props.message.filePath,
|
||||
showMenu: true,
|
||||
fail: () => {
|
||||
uni.showToast({ title: `已发送${props.message.fileName || '文件'}`, icon: 'none' })
|
||||
},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,7 +50,37 @@ defineProps<{
|
||||
<text class="chat-message__nickname">
|
||||
{{ message.nickname }}
|
||||
</text>
|
||||
|
||||
<view
|
||||
v-if="messageType === 'image' && message.imageUrl"
|
||||
class="chat-message__image-wrap"
|
||||
@tap="handlePreviewImage"
|
||||
>
|
||||
<image
|
||||
class="chat-message__image"
|
||||
:src="message.imageUrl"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-else-if="messageType === 'file'"
|
||||
class="chat-message__bubble chat-message__bubble--file"
|
||||
:class="`chat-message__bubble--${message.role}`"
|
||||
@tap="handleOpenFile"
|
||||
>
|
||||
<image
|
||||
class="chat-message__file-icon"
|
||||
:src="fileIcon"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="chat-message__file-name">
|
||||
{{ message.fileName || message.content }}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-else
|
||||
class="chat-message__bubble"
|
||||
:class="`chat-message__bubble--${message.role}`"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user