Browse Source

这是加了样式的修改

hongxilin
donghaolin 3 months ago
parent
commit
d6ab956951
  1. 15
      src/views/chat.vue

15
src/views/chat.vue

@ -4,6 +4,7 @@ import { useUserInfo } from '../store/userPermissionCode'
import axios from 'axios'
import { ElMessage } from 'element-plus';
import { Loading, Position } from '@element-plus/icons-vue'; //
import { marked } from 'marked'; // marked
const { getQueryVariable } = useUserInfo()
// getSessionId
@ -17,7 +18,7 @@ const fnGetToken = () => {
setTimeout(() => {
fnGetToken()
}, 800)
const token = localStorage.getItem('localToken')
// token
const validateToken = async () => {
const token = localStorage.getItem('localToken')
@ -34,7 +35,7 @@ const sessionId = ref(localStorage.getItem('sessionId') || {});
const add = async () => {
try {
const result = await axios.post(
"http://2zhyw2.natappfree.cc/api/v1/chats/8b37cd9cf0c811efa4210242ac120003/completions",
"http://td7idg.natappfree.cc/api/v1/chats/8b37cd9cf0c811efa4210242ac120003/completions",
{},
{
headers: {
@ -132,7 +133,7 @@ const sendMessage = async () => {
try {
// API
const response = await fetch("http://2zhyw2.natappfree.cc/api/v1/chats/8b37cd9cf0c811efa4210242ac120003/completions", {
const response = await fetch("http://td7idg.natappfree.cc/api/v1/chats/8b37cd9cf0c811efa4210242ac120003/completions", {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ragflow-hkNjEwYjcwZjBlMDExZWZiYjYzMDI0Mm' },
body: JSON.stringify({ question: content, stream: false, session_id: sessionId.value })
@ -160,6 +161,9 @@ const sendMessage = async () => {
// }
combinedContent += `<span class="result-content">${result}</span>`;
// 使markedMarkdownHTML
const markdownContent = marked(combinedContent);
//
const botMessageIndex = messages.value.length;
messages.value.push({
@ -171,8 +175,8 @@ const sendMessage = async () => {
// 使
let currentIndex = 0;
const intervalId = setInterval(() => {
if (currentIndex < combinedContent.length) {
messages.value[botMessageIndex].content += combinedContent[currentIndex];
if (currentIndex < markdownContent.length) {
messages.value[botMessageIndex].content += markdownContent[currentIndex];
scrollToBottom();
currentIndex++;
} else {
@ -288,6 +292,7 @@ onMounted(async () => {
/* 其他样式保持不变 */
.message-item.bot {
justify-content: flex-start; /* 让机器人消息靠左对齐 */
text-align: left; /* 新增:设置文本左对齐 */
}
.chat-container {
display: flex;

Loading…
Cancel
Save