diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 13e9739..e5a63d7 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -11,6 +11,14 @@ body { height: 100%; width: 100%; } +.van-button--primary{ + background-color: #3662FE !important; +} +.van-floating-bubble{ + background: transparent !important; + width: 140px !important; + height: 140px !important; +} ::-webkit-scrollbar { width: 7px; diff --git a/src/icons/svg/生活助手.svg b/src/icons/svg/生活助手.svg new file mode 100644 index 0000000..002359c --- /dev/null +++ b/src/icons/svg/生活助手.svg @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/src/views/chat/components/ai-assistant-float.vue b/src/views/chat/components/ai-assistant-float.vue new file mode 100644 index 0000000..18b809e --- /dev/null +++ b/src/views/chat/components/ai-assistant-float.vue @@ -0,0 +1,79 @@ + + + diff --git a/src/views/chat/components/ai-assistant.vue b/src/views/chat/components/ai-assistant.vue index 200819f..89b9b50 100644 --- a/src/views/chat/components/ai-assistant.vue +++ b/src/views/chat/components/ai-assistant.vue @@ -1,28 +1,16 @@ @@ -100,8 +89,6 @@ import { ref, computed, nextTick } from 'vue' import http from '@/io/request' import { v4 as uuidv4 } from 'uuid' import { useAiChat } from '@/stores/aichat' -import VueDraggableResizable from 'vue-draggable-resizable/src/components/vue-draggable-resizable.vue' -import 'vue-draggable-resizable/dist/VueDraggableResizable.css' const props = defineProps({ top: { type: String, @@ -183,7 +170,7 @@ const changeOption = (index) => { autoMessage() } const currentOption = computed(() => { - if(optionIndex.value === null) return null + if (optionIndex.value === null) return null return options[optionIndex.value] ?? null }) @@ -193,11 +180,13 @@ const dataSources = computed(() => { const prompt = ref('') -const autoMessage = async ()=>{ - - const message = replacePlaceholder(currentOption.value.value, truncateRichText(props.content, 4000)) +const autoMessage = async () => { + const message = replacePlaceholder( + currentOption.value.value, + truncateRichText(props.content, 4000) + ) - if(loading.value) return + if (loading.value) return contentLoading.value = true loading.value = true try { @@ -233,26 +222,24 @@ const autoMessage = async ()=>{ } const errorMessage = error?.errmsg ?? '好像出错了,请稍后再试。' contenText.value = errorMessage - }finally{ + } finally { contentLoading.value = false loading.value = false } } - - function truncateRichText(richText, maxLength) { // 去除标签 - const plainText = richText.replace(/<[^>]+>/g, ''); + const plainText = richText.replace(/<[^>]+>/g, '') // 截取最多 maxLength 个字符 - const truncatedText = plainText.substring(0, maxLength); + const truncatedText = plainText.substring(0, maxLength) - return truncatedText; + return truncatedText } function replacePlaceholder(originalText, replacement) { - return originalText.replace('{0}', replacement); + return originalText.replace('{0}', replacement) } const sendMessage = async () => { @@ -290,8 +277,6 @@ const sendMessage = async () => { const { responseText } = xhr if (xhr.status == 200) { const arr = parseEventMessages(responseText) - const { conversation_id, message_id } = arr[0] - const msg = arr.reduce((acc, item) => { return acc + item.text }, '') @@ -370,15 +355,26 @@ function scrollToBottomIfAtBottom() { } -