2024-05-07 21:59:47 +08:00
|
|
|
|
<template>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<el-container class="ai-layout">
|
2024-05-07 21:59:47 +08:00
|
|
|
|
<!-- 左侧:会话列表 -->
|
|
|
|
|
<el-aside width="260px" class="conversation-container">
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<div>
|
|
|
|
|
<!-- 左顶部:新建对话 -->
|
2024-05-15 00:00:03 +08:00
|
|
|
|
<el-button class="w-1/1 btn-new-conversation" type="primary" @click="createConversation">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:plus" class="mr-5px" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
新建对话
|
|
|
|
|
</el-button>
|
|
|
|
|
<!-- 左顶部:搜索对话 -->
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="searchName"
|
|
|
|
|
size="large"
|
|
|
|
|
class="mt-10px search-input"
|
|
|
|
|
placeholder="搜索历史记录"
|
|
|
|
|
@keyup="searchConversation"
|
|
|
|
|
>
|
|
|
|
|
<template #prefix>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:search" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
<!-- 左中间:对话列表 -->
|
2024-05-10 23:35:47 +08:00
|
|
|
|
<div class="conversation-list">
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<!-- TODO @芋艿,置顶、聊天记录、一星期钱、30天前,前端对数据重新做一下分组,或者后端接口改一下 -->
|
|
|
|
|
<div>
|
|
|
|
|
<el-text class="mx-1" size="small" tag="b">置顶</el-text>
|
2024-05-07 21:59:47 +08:00
|
|
|
|
</div>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<el-row v-for="conversation in conversationList" :key="conversation.id">
|
|
|
|
|
<div
|
|
|
|
|
:class="conversation.id === conversationId ? 'conversation active' : 'conversation'"
|
2024-05-15 00:00:03 +08:00
|
|
|
|
@click="changeConversation(conversation.id)"
|
2024-05-09 22:13:23 +08:00
|
|
|
|
>
|
|
|
|
|
<div class="title-wrapper">
|
2024-05-15 00:00:03 +08:00
|
|
|
|
<img class="avatar" :src="conversation.roleAvatar" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<span class="title">{{ conversation.title }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="button-wrapper">
|
|
|
|
|
<el-icon title="编辑" @click="updateConversationTitle(conversation)">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:edit" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</el-icon>
|
|
|
|
|
<el-icon title="删除会话" @click="deleteConversationTitle(conversation)">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:delete" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</el-icon>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-row>
|
|
|
|
|
</div>
|
2024-05-07 21:59:47 +08:00
|
|
|
|
</div>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<!-- 左底部:工具栏 -->
|
2024-05-07 21:59:47 +08:00
|
|
|
|
<div class="tool-box">
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<div>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:user" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<el-text size="small">角色仓库</el-text>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:delete" />
|
2024-05-10 23:35:47 +08:00
|
|
|
|
<el-text size="small">清空未置顶对话</el-text>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</div>
|
2024-05-07 21:59:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
</el-aside>
|
|
|
|
|
<!-- 右侧:会话详情 -->
|
|
|
|
|
<el-container class="detail-container">
|
|
|
|
|
<!-- 右顶部 TODO 芋艿:右对齐 -->
|
|
|
|
|
<el-header class="header">
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<div class="title">
|
2024-05-14 18:02:07 +08:00
|
|
|
|
{{ useConversation?.title }}
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<el-dropdown style="margin-right: 12px" @command="modalClick">
|
2024-05-14 13:43:56 +08:00
|
|
|
|
<el-button type="primary">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<span v-html="useModal?.name"></span>
|
|
|
|
|
<Icon icon="ep:setting" style="margin-left: 10px" />
|
2024-05-14 13:43:56 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
<template #dropdown>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<el-dropdown-menu v-for="(item, index) in modalList" :key="index">
|
|
|
|
|
<el-dropdown-item :command="item">{{ item.name }}</el-dropdown-item>
|
2024-05-14 13:43:56 +08:00
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dropdown>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
<el-button>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:user" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
<el-button>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:download" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
<el-button>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<Icon icon="ep:arrow-up" />
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
2024-05-07 21:59:47 +08:00
|
|
|
|
</el-header>
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-12 14:28:27 +08:00
|
|
|
|
<!-- main -->
|
|
|
|
|
<el-main class="main-container">
|
2024-05-12 19:02:45 +08:00
|
|
|
|
<div class="message-container" ref="messageContainer">
|
|
|
|
|
<div class="chat-list" v-for="(item, index) in list" :key="index">
|
|
|
|
|
<!-- 靠左 message -->
|
|
|
|
|
<div class="left-message message-item" v-if="item.type === 'system'">
|
2024-05-13 23:22:42 +08:00
|
|
|
|
<div class="avatar">
|
2024-05-12 19:02:45 +08:00
|
|
|
|
<el-avatar
|
|
|
|
|
src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="message">
|
|
|
|
|
<div>
|
2024-05-13 23:22:42 +08:00
|
|
|
|
<el-text class="time">{{ formatDate(item.createTime) }}</el-text>
|
2024-05-12 19:02:45 +08:00
|
|
|
|
</div>
|
2024-05-13 23:22:42 +08:00
|
|
|
|
<div class="left-text-container" ref="markdownViewRef">
|
|
|
|
|
<div class="left-text markdown-view" v-html="item.content"></div>
|
|
|
|
|
<!-- <mdPreview :content="item.content" :delay="false" />-->
|
2024-05-12 19:02:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="left-btns">
|
|
|
|
|
<div class="btn-cus" @click="noCopy(item.content)">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<img class="btn-image" src="../../../assets/ai/copy.svg" />
|
2024-05-12 19:02:45 +08:00
|
|
|
|
<el-text class="btn-cus-text">复制</el-text>
|
|
|
|
|
</div>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<div class="btn-cus" style="margin-left: 20px" @click="onDelete(item.id)">
|
|
|
|
|
<img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px" />
|
2024-05-12 19:02:45 +08:00
|
|
|
|
<el-text class="btn-cus-text">删除</el-text>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 靠右 message -->
|
|
|
|
|
<div class="right-message message-item" v-if="item.type === 'user'">
|
|
|
|
|
<div class="avatar">
|
|
|
|
|
<el-avatar
|
|
|
|
|
src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="message">
|
|
|
|
|
<div>
|
2024-05-13 23:22:42 +08:00
|
|
|
|
<el-text class="time">{{ formatDate(item.createTime) }}</el-text>
|
2024-05-12 19:02:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="right-text-container">
|
2024-05-13 23:22:42 +08:00
|
|
|
|
<div class="right-text">{{ item.content }}</div>
|
2024-05-12 19:02:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="right-btns">
|
2024-05-13 23:22:42 +08:00
|
|
|
|
<div class="btn-cus" @click="noCopy(item.content)">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<img class="btn-image" src="@/assets/ai/copy.svg" />
|
2024-05-12 19:02:45 +08:00
|
|
|
|
<el-text class="btn-cus-text">复制</el-text>
|
|
|
|
|
</div>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<div class="btn-cus" style="margin-left: 20px" @click="onDelete(item.id)">
|
|
|
|
|
<img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px" />
|
2024-05-12 19:02:45 +08:00
|
|
|
|
<el-text class="btn-cus-text">删除</el-text>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-05-10 23:35:47 +08:00
|
|
|
|
</el-main>
|
|
|
|
|
<el-footer class="footer-container">
|
2024-05-12 22:22:34 +08:00
|
|
|
|
<form @submit.prevent="onSend" class="prompt-from">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<textarea
|
|
|
|
|
class="prompt-input"
|
|
|
|
|
v-model="prompt"
|
|
|
|
|
@keyup.enter="onSend"
|
|
|
|
|
@input="onPromptInput"
|
|
|
|
|
@compositionstart="onCompositionstart"
|
|
|
|
|
@compositionend="onCompositionend"
|
|
|
|
|
placeholder="问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"
|
|
|
|
|
></textarea>
|
2024-05-12 22:22:34 +08:00
|
|
|
|
<div class="prompt-btns">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<el-switch />
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
size="default"
|
|
|
|
|
@click="onSend()"
|
|
|
|
|
:loading="conversationInProgress"
|
|
|
|
|
v-if="conversationInProgress == false"
|
|
|
|
|
>
|
2024-05-13 23:22:42 +08:00
|
|
|
|
{{ conversationInProgress ? '进行中' : '发送' }}
|
2024-05-13 17:49:18 +08:00
|
|
|
|
</el-button>
|
2024-05-14 23:55:23 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="danger"
|
|
|
|
|
size="default"
|
|
|
|
|
@click="stopStream()"
|
|
|
|
|
v-if="conversationInProgress == true"
|
|
|
|
|
>
|
2024-05-13 17:49:18 +08:00
|
|
|
|
停止
|
|
|
|
|
</el-button>
|
2024-05-12 22:22:34 +08:00
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
</el-footer>
|
2024-05-07 21:59:47 +08:00
|
|
|
|
</el-container>
|
|
|
|
|
</el-container>
|
|
|
|
|
</template>
|
2024-05-12 14:28:27 +08:00
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
<script setup lang="ts">
|
2024-05-14 23:55:23 +08:00
|
|
|
|
import { ChatMessageApi, ChatMessageSendVO, ChatMessageVO } from '@/api/ai/chat/message'
|
2024-05-14 17:58:06 +08:00
|
|
|
|
import {
|
|
|
|
|
ChatConversationApi,
|
|
|
|
|
ChatConversationUpdateVO,
|
|
|
|
|
ChatConversationVO
|
2024-05-14 23:55:23 +08:00
|
|
|
|
} from '@/api/ai/chat/conversation'
|
|
|
|
|
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
|
|
|
|
import { formatDate } from '@/utils/formatTime'
|
|
|
|
|
import { useClipboard } from '@vueuse/core'
|
2024-05-13 23:22:42 +08:00
|
|
|
|
// 转换 markdown
|
2024-05-14 23:55:23 +08:00
|
|
|
|
import { marked } from 'marked'
|
2024-05-13 23:22:42 +08:00
|
|
|
|
// 代码高亮 https://highlightjs.org/
|
2024-05-14 23:55:23 +08:00
|
|
|
|
import 'highlight.js/styles/vs2015.min.css'
|
|
|
|
|
import hljs from 'highlight.js'
|
2024-05-13 23:22:42 +08:00
|
|
|
|
|
2024-05-15 08:59:30 +08:00
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
|
2024-05-13 23:22:42 +08:00
|
|
|
|
// 自定义渲染器
|
|
|
|
|
const renderer = {
|
|
|
|
|
code(code, language, c) {
|
2024-05-14 23:55:23 +08:00
|
|
|
|
const highlightHtml = hljs.highlight(code, { language: language, ignoreIllegals: true }).value
|
2024-05-13 23:22:42 +08:00
|
|
|
|
const copyHtml = `<div id="copy" data-copy='${code}' style="position: absolute; right: 10px; top: 5px; color: #fff;cursor: pointer;">复制</div>`
|
|
|
|
|
return `<pre>${copyHtml}<code class="hljs">${highlightHtml}</code></pre>`
|
2024-05-14 23:55:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-13 23:22:42 +08:00
|
|
|
|
marked.use({
|
2024-05-14 23:55:23 +08:00
|
|
|
|
renderer: renderer
|
2024-05-13 23:22:42 +08:00
|
|
|
|
})
|
2024-05-12 19:02:45 +08:00
|
|
|
|
|
2024-05-15 00:00:03 +08:00
|
|
|
|
const conversationList = ref([] as ChatConversationVO[])
|
2024-05-12 22:22:34 +08:00
|
|
|
|
// 初始化 copy 到粘贴板
|
2024-05-14 23:55:23 +08:00
|
|
|
|
const { copy } = useClipboard()
|
2024-05-12 22:22:34 +08:00
|
|
|
|
|
2024-05-12 19:02:45 +08:00
|
|
|
|
const searchName = ref('') // 查询的内容
|
2024-05-14 17:17:26 +08:00
|
|
|
|
const inputTimeout = ref<any>() // 处理输入中回车的定时器
|
2024-05-15 00:00:03 +08:00
|
|
|
|
const conversationId = ref(0) // 选中的对话编号
|
2024-05-13 23:22:42 +08:00
|
|
|
|
const conversationInProgress = ref<Boolean>() // 对话进行中
|
|
|
|
|
conversationInProgress.value = false
|
2024-05-12 22:22:34 +08:00
|
|
|
|
const conversationInAbortController = ref<any>() // 对话进行中 abort 控制器(控制 stream 对话)
|
|
|
|
|
|
2024-05-12 19:02:45 +08:00
|
|
|
|
const prompt = ref<string>() // prompt
|
2024-05-12 22:22:34 +08:00
|
|
|
|
|
|
|
|
|
// 判断 消息列表 滚动的位置(用于判断是否需要滚动到消息最下方)
|
2024-05-14 23:55:23 +08:00
|
|
|
|
const messageContainer: any = ref(null)
|
|
|
|
|
const isScrolling = ref(false) //用于判断用户是否在滚动
|
2024-05-14 17:17:26 +08:00
|
|
|
|
const isComposing = ref(false) // 判断用户是否在输入
|
2024-05-12 22:22:34 +08:00
|
|
|
|
|
|
|
|
|
/** chat message 列表 */
|
2024-05-13 21:38:18 +08:00
|
|
|
|
// defineOptions({ name: 'chatMessageList' })
|
2024-05-12 22:22:34 +08:00
|
|
|
|
const list = ref<ChatMessageVO[]>([]) // 列表的数据
|
2024-05-14 15:32:04 +08:00
|
|
|
|
const useModal = ref<ChatModelVO>() // 使用的modal
|
2024-05-14 17:58:06 +08:00
|
|
|
|
const useConversation = ref<ChatConversationVO>() // 使用的 Conversation
|
2024-05-14 13:43:56 +08:00
|
|
|
|
const modalList = ref<ChatModelVO[]>([]) // 列表的数据
|
|
|
|
|
|
2024-05-15 00:00:03 +08:00
|
|
|
|
/** 新建对话 */
|
|
|
|
|
const createConversation = async () => {
|
|
|
|
|
// 新建对话
|
|
|
|
|
const conversationId = await ChatConversationApi.createChatConversationMy(
|
|
|
|
|
{} as unknown as ChatConversationVO
|
|
|
|
|
)
|
|
|
|
|
changeConversation(conversationId)
|
|
|
|
|
// 刷新对话列表
|
|
|
|
|
await getChatConversationList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const changeConversation = (id: number) => {
|
|
|
|
|
conversationId.value = id
|
2024-05-07 21:59:47 +08:00
|
|
|
|
// TODO 芋艿:待实现
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-15 08:59:30 +08:00
|
|
|
|
/** 更新聊天会话的标题 */
|
|
|
|
|
const updateConversationTitle = async (conversation: ChatConversationVO) => {
|
|
|
|
|
// 二次确认
|
|
|
|
|
const { value } = await ElMessageBox.prompt('修改标题', {
|
|
|
|
|
inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
|
|
|
|
|
inputErrorMessage: '标题不能为空',
|
|
|
|
|
inputValue: conversation.title
|
|
|
|
|
})
|
|
|
|
|
// 发起修改
|
|
|
|
|
await ChatConversationApi.updateConversationMy({
|
|
|
|
|
id: conversation.id,
|
|
|
|
|
title: value
|
|
|
|
|
} as ChatConversationVO)
|
|
|
|
|
message.success('修改标题成功')
|
|
|
|
|
// 刷新列表
|
|
|
|
|
await getChatConversationList()
|
2024-05-07 21:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const deleteConversationTitle = (conversation) => {
|
|
|
|
|
console.log(conversation)
|
|
|
|
|
// TODO 芋艿:待实现
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const searchConversation = () => {
|
|
|
|
|
// TODO 芋艿:待实现
|
|
|
|
|
}
|
2024-05-12 14:28:27 +08:00
|
|
|
|
|
2024-05-12 19:02:45 +08:00
|
|
|
|
/** send */
|
|
|
|
|
const onSend = async () => {
|
2024-05-14 17:17:26 +08:00
|
|
|
|
// 判断用户是否在输入
|
|
|
|
|
if (isComposing.value) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-05-13 17:49:18 +08:00
|
|
|
|
// 进行中不允许发送
|
|
|
|
|
if (conversationInProgress.value) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-05-14 23:55:23 +08:00
|
|
|
|
const content = prompt.value?.trim()
|
2024-05-14 17:17:26 +08:00
|
|
|
|
if (content?.length < 2) {
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: '请输入内容!',
|
2024-05-14 23:55:23 +08:00
|
|
|
|
type: 'error'
|
2024-05-14 17:17:26 +08:00
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-05-12 22:22:34 +08:00
|
|
|
|
// 清空输入框
|
|
|
|
|
prompt.value = ''
|
2024-05-12 19:02:45 +08:00
|
|
|
|
const requestParams = {
|
|
|
|
|
conversationId: conversationId.value,
|
2024-05-14 23:55:23 +08:00
|
|
|
|
content: content
|
2024-05-12 19:02:45 +08:00
|
|
|
|
} as unknown as ChatMessageSendVO
|
|
|
|
|
// 添加 message
|
2024-05-14 23:55:23 +08:00
|
|
|
|
const userMessage = (await ChatMessageApi.add(requestParams)) as unknown as ChatMessageVO
|
2024-05-12 19:02:45 +08:00
|
|
|
|
list.value.push(userMessage)
|
|
|
|
|
// 滚动到住下面
|
2024-05-14 23:55:23 +08:00
|
|
|
|
scrollToBottom()
|
2024-05-12 22:22:34 +08:00
|
|
|
|
// stream
|
2024-05-12 19:02:45 +08:00
|
|
|
|
await doSendStream(userMessage)
|
2024-05-12 22:22:34 +08:00
|
|
|
|
//
|
2024-05-12 19:02:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const doSendStream = async (userMessage: ChatMessageVO) => {
|
|
|
|
|
// 创建AbortController实例,以便中止请求
|
2024-05-12 22:22:34 +08:00
|
|
|
|
conversationInAbortController.value = new AbortController()
|
|
|
|
|
// 标记对话进行中
|
|
|
|
|
conversationInProgress.value = true
|
|
|
|
|
try {
|
|
|
|
|
// 发送 event stream
|
|
|
|
|
let isFirstMessage = true
|
2024-05-13 23:22:42 +08:00
|
|
|
|
let content = ''
|
2024-05-14 23:55:23 +08:00
|
|
|
|
ChatMessageApi.sendStream(
|
|
|
|
|
userMessage.id,
|
|
|
|
|
conversationInAbortController.value,
|
|
|
|
|
(message) => {
|
|
|
|
|
console.log('message', message)
|
|
|
|
|
const data = JSON.parse(message.data) as unknown as ChatMessageVO
|
|
|
|
|
// 如果没有内容结束链接
|
|
|
|
|
if (data.content === '') {
|
|
|
|
|
// 标记对话结束
|
|
|
|
|
conversationInProgress.value = false
|
|
|
|
|
// 结束 stream 对话
|
|
|
|
|
conversationInAbortController.value.abort()
|
|
|
|
|
}
|
|
|
|
|
// 首次返回需要添加一个 message 到页面,后面的都是更新
|
|
|
|
|
if (isFirstMessage) {
|
|
|
|
|
isFirstMessage = false
|
|
|
|
|
list.value.push(data)
|
|
|
|
|
} else {
|
|
|
|
|
content = content + data.content
|
|
|
|
|
const lastMessage = list.value[list.value.length - 1]
|
|
|
|
|
lastMessage.content = marked(content) as unknown as string
|
|
|
|
|
list.value[list.value - 1] = lastMessage
|
|
|
|
|
}
|
|
|
|
|
// 滚动到最下面
|
|
|
|
|
scrollToBottom()
|
|
|
|
|
},
|
|
|
|
|
(error) => {
|
|
|
|
|
console.log('error', error)
|
2024-05-12 22:22:34 +08:00
|
|
|
|
// 标记对话结束
|
2024-05-14 23:55:23 +08:00
|
|
|
|
conversationInProgress.value = false
|
|
|
|
|
// 结束 stream 对话
|
|
|
|
|
conversationInAbortController.value.abort()
|
|
|
|
|
},
|
|
|
|
|
() => {
|
|
|
|
|
console.log('close')
|
|
|
|
|
// 标记对话结束
|
|
|
|
|
conversationInProgress.value = false
|
2024-05-12 22:22:34 +08:00
|
|
|
|
// 结束 stream 对话
|
|
|
|
|
conversationInAbortController.value.abort()
|
|
|
|
|
}
|
2024-05-14 23:55:23 +08:00
|
|
|
|
)
|
2024-05-12 22:22:34 +08:00
|
|
|
|
} finally {
|
|
|
|
|
}
|
2024-05-12 19:02:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
|
const messageList = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 获取列表数据
|
|
|
|
|
const res = await ChatMessageApi.messageList(conversationId.value)
|
2024-05-13 18:26:28 +08:00
|
|
|
|
|
|
|
|
|
// 处理 markdown
|
|
|
|
|
// marked(this.markdownText)
|
2024-05-14 23:55:23 +08:00
|
|
|
|
res.map((item) => {
|
2024-05-13 21:38:18 +08:00
|
|
|
|
// item.content = marked(item.content)
|
2024-05-13 23:22:42 +08:00
|
|
|
|
if (item.type !== 'user') {
|
|
|
|
|
item.content = marked(item.content)
|
|
|
|
|
}
|
2024-05-13 18:26:28 +08:00
|
|
|
|
})
|
|
|
|
|
|
2024-05-14 23:55:23 +08:00
|
|
|
|
list.value = res
|
2024-05-13 18:26:28 +08:00
|
|
|
|
|
2024-05-12 19:02:45 +08:00
|
|
|
|
// 滚动到最下面
|
2024-05-14 23:55:23 +08:00
|
|
|
|
scrollToBottom()
|
2024-05-12 19:02:45 +08:00
|
|
|
|
} finally {
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-12 22:22:34 +08:00
|
|
|
|
|
2024-05-12 19:02:45 +08:00
|
|
|
|
function scrollToBottom() {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
//注意要使用nexttick以免获取不到dom
|
|
|
|
|
console.log('isScrolling.value', isScrolling.value)
|
|
|
|
|
if (!isScrolling.value) {
|
2024-05-14 23:55:23 +08:00
|
|
|
|
messageContainer.value.scrollTop =
|
|
|
|
|
messageContainer.value.scrollHeight - messageContainer.value.offsetHeight
|
2024-05-12 19:02:45 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleScroll() {
|
|
|
|
|
const scrollContainer = messageContainer.value
|
|
|
|
|
const scrollTop = scrollContainer.scrollTop
|
|
|
|
|
const scrollHeight = scrollContainer.scrollHeight
|
|
|
|
|
const offsetHeight = scrollContainer.offsetHeight
|
|
|
|
|
|
|
|
|
|
if (scrollTop + offsetHeight < scrollHeight) {
|
|
|
|
|
// 用户开始滚动并在最底部之上,取消保持在最底部的效果
|
|
|
|
|
isScrolling.value = true
|
|
|
|
|
} else {
|
|
|
|
|
// 用户停止滚动并滚动到最底部,开启保持到最底部的效果
|
|
|
|
|
isScrolling.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function noCopy(content) {
|
|
|
|
|
copy(content)
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: '复制成功!',
|
2024-05-14 23:55:23 +08:00
|
|
|
|
type: 'success'
|
2024-05-12 19:02:45 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onDelete = async (id) => {
|
|
|
|
|
// 删除 message
|
|
|
|
|
await ChatMessageApi.delete(id)
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: '删除成功!',
|
2024-05-14 23:55:23 +08:00
|
|
|
|
type: 'success'
|
2024-05-12 19:02:45 +08:00
|
|
|
|
})
|
2024-05-13 17:49:18 +08:00
|
|
|
|
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
|
|
|
|
|
stopStream()
|
|
|
|
|
// 重新获取 message 列表
|
2024-05-14 23:55:23 +08:00
|
|
|
|
await messageList()
|
2024-05-13 17:49:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const stopStream = async () => {
|
2024-05-12 22:22:34 +08:00
|
|
|
|
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
|
|
|
|
|
if (conversationInAbortController.value) {
|
|
|
|
|
conversationInAbortController.value.abort()
|
|
|
|
|
}
|
2024-05-13 17:49:18 +08:00
|
|
|
|
// 设置为 false
|
|
|
|
|
conversationInProgress.value = false
|
2024-05-12 19:02:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 13:43:56 +08:00
|
|
|
|
const modalClick = async (command) => {
|
2024-05-14 15:32:04 +08:00
|
|
|
|
const update = {
|
|
|
|
|
id: conversationId.value,
|
2024-05-14 23:55:23 +08:00
|
|
|
|
modelId: command.id
|
2024-05-14 15:32:04 +08:00
|
|
|
|
} as unknown as ChatConversationUpdateVO
|
|
|
|
|
// 切换 modal
|
|
|
|
|
useModal.value = command
|
|
|
|
|
// 更新
|
2024-05-15 08:59:30 +08:00
|
|
|
|
await ChatConversationApi.updateConversationMy(update)
|
2024-05-14 13:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getModalList = async () => {
|
|
|
|
|
// 获取模型 as unknown as ChatModelVO
|
2024-05-14 23:55:23 +08:00
|
|
|
|
modalList.value = (await ChatModelApi.getChatModelSimpleList(0)) as unknown as ChatModelVO[]
|
2024-05-14 13:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 17:17:26 +08:00
|
|
|
|
// 输入
|
|
|
|
|
const onCompositionstart = () => {
|
|
|
|
|
console.log('onCompositionstart。。。.')
|
2024-05-14 23:55:23 +08:00
|
|
|
|
isComposing.value = true
|
2024-05-14 17:17:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onCompositionend = () => {
|
|
|
|
|
// console.log('输入结束...')
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
console.log('输入结束...')
|
|
|
|
|
isComposing.value = false
|
|
|
|
|
}, 200)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onPromptInput = (event) => {
|
|
|
|
|
// 非输入法 输入设置为 true
|
|
|
|
|
if (!isComposing.value) {
|
|
|
|
|
// 回车 event data 是 null
|
|
|
|
|
if (event.data == null) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log('setTimeout 输入开始...')
|
|
|
|
|
isComposing.value = true
|
|
|
|
|
}
|
|
|
|
|
// 清理定时器
|
|
|
|
|
if (inputTimeout.value) {
|
|
|
|
|
clearTimeout(inputTimeout.value)
|
|
|
|
|
}
|
|
|
|
|
// 重置定时器
|
|
|
|
|
inputTimeout.value = setTimeout(() => {
|
|
|
|
|
console.log('setTimeout 输入结束...')
|
|
|
|
|
isComposing.value = false
|
|
|
|
|
}, 400)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 17:58:06 +08:00
|
|
|
|
const getConversation = async (conversationId: string) => {
|
|
|
|
|
// 获取对话信息
|
|
|
|
|
useConversation.value = await ChatConversationApi.get(conversationId)
|
|
|
|
|
console.log('useConversation.value', useConversation.value)
|
|
|
|
|
// 选中 modal
|
|
|
|
|
if (useConversation.value) {
|
2024-05-14 23:55:23 +08:00
|
|
|
|
modalList.value.forEach((item) => {
|
2024-05-14 17:58:06 +08:00
|
|
|
|
if (useConversation.value?.modelId === item.id) {
|
|
|
|
|
useModal.value = item
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-14 17:17:26 +08:00
|
|
|
|
|
2024-05-15 00:00:03 +08:00
|
|
|
|
/** 获得聊天会话列表 */
|
|
|
|
|
const getChatConversationList = async () => {
|
|
|
|
|
conversationList.value = await ChatConversationApi.getChatConversationMyList()
|
|
|
|
|
// 默认选中第一条
|
|
|
|
|
if (conversationList.value.length === 0) {
|
|
|
|
|
conversationId.value = 0
|
|
|
|
|
// TODO 芋艿:清空对话
|
|
|
|
|
} else {
|
|
|
|
|
if (conversationId.value === 0) {
|
|
|
|
|
conversationId.value = conversationList.value[0].id
|
|
|
|
|
changeConversation(conversationList.value[0].id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 14:28:27 +08:00
|
|
|
|
/** 初始化 **/
|
2024-05-12 19:02:45 +08:00
|
|
|
|
onMounted(async () => {
|
2024-05-15 00:00:03 +08:00
|
|
|
|
// 获得聊天会话列表
|
|
|
|
|
await getChatConversationList()
|
2024-05-14 13:43:56 +08:00
|
|
|
|
// 获取模型
|
2024-05-14 23:55:23 +08:00
|
|
|
|
getModalList()
|
2024-05-14 17:58:06 +08:00
|
|
|
|
// 获取对话信息
|
2024-05-14 23:55:23 +08:00
|
|
|
|
getConversation(conversationId.value)
|
2024-05-12 19:02:45 +08:00
|
|
|
|
// 获取列表数据
|
2024-05-14 23:55:23 +08:00
|
|
|
|
messageList()
|
2024-05-12 19:02:45 +08:00
|
|
|
|
// scrollToBottom();
|
|
|
|
|
// await nextTick
|
|
|
|
|
// 监听滚动事件,判断用户滚动状态
|
|
|
|
|
messageContainer.value.addEventListener('scroll', handleScroll)
|
2024-05-13 23:22:42 +08:00
|
|
|
|
// 添加 copy 监听
|
|
|
|
|
messageContainer.value.addEventListener('click', (e: any) => {
|
|
|
|
|
console.log(e)
|
|
|
|
|
if (e.target.id === 'copy') {
|
|
|
|
|
copy(e.target?.dataset?.copy)
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: '复制成功!',
|
2024-05-14 23:55:23 +08:00
|
|
|
|
type: 'success'
|
2024-05-13 23:22:42 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-05-12 14:28:27 +08:00
|
|
|
|
})
|
2024-05-07 21:59:47 +08:00
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
2024-05-09 22:13:23 +08:00
|
|
|
|
.ai-layout {
|
|
|
|
|
// TODO @范 这里height不能 100% 先这样临时处理
|
|
|
|
|
position: absolute;
|
|
|
|
|
flex: 1;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
//padding: 15px 15px;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.conversation-container {
|
2024-05-09 22:13:23 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
padding-top: 10px;
|
|
|
|
|
|
|
|
|
|
.btn-new-conversation {
|
|
|
|
|
padding: 18px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.conversation-list {
|
2024-05-09 22:13:23 +08:00
|
|
|
|
margin-top: 20px;
|
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.conversation {
|
|
|
|
|
display: flex;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
flex: 1;
|
|
|
|
|
padding: 0 5px;
|
|
|
|
|
margin-top: 10px;
|
2024-05-07 21:59:47 +08:00
|
|
|
|
cursor: pointer;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
border-radius: 5px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
line-height: 30px;
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
&.active {
|
2024-05-09 22:13:23 +08:00
|
|
|
|
background-color: #e6e6e6;
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.button {
|
2024-05-09 22:13:23 +08:00
|
|
|
|
display: inline-block;
|
2024-05-07 21:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-09 22:13:23 +08:00
|
|
|
|
|
|
|
|
|
.title-wrapper {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.title {
|
|
|
|
|
padding: 5px 10px;
|
|
|
|
|
max-width: 220px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.avatar {
|
|
|
|
|
width: 28px;
|
|
|
|
|
height: 28px;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-items: center;
|
2024-05-07 21:59:47 +08:00
|
|
|
|
}
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-09 22:13:23 +08:00
|
|
|
|
// 对话编辑、删除
|
|
|
|
|
.button-wrapper {
|
2024-05-07 21:59:47 +08:00
|
|
|
|
right: 2px;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-items: center;
|
|
|
|
|
color: #606266;
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.el-icon {
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-09 22:13:23 +08:00
|
|
|
|
}
|
2024-05-07 21:59:47 +08:00
|
|
|
|
|
2024-05-09 22:13:23 +08:00
|
|
|
|
// 角色仓库、清空未设置对话
|
|
|
|
|
.tool-box {
|
|
|
|
|
line-height: 35px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: var(--el-text-color);
|
|
|
|
|
|
|
|
|
|
> div {
|
2024-05-07 21:59:47 +08:00
|
|
|
|
display: flex;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
align-items: center;
|
|
|
|
|
color: #606266;
|
|
|
|
|
padding: 0;
|
|
|
|
|
margin: 0;
|
2024-05-10 23:35:47 +08:00
|
|
|
|
|
2024-05-09 22:13:23 +08:00
|
|
|
|
> span {
|
|
|
|
|
margin-left: 5px;
|
|
|
|
|
}
|
2024-05-07 21:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 23:35:47 +08:00
|
|
|
|
// 头部
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.detail-container {
|
2024-05-09 22:13:23 +08:00
|
|
|
|
background: #ffffff;
|
|
|
|
|
|
2024-05-07 21:59:47 +08:00
|
|
|
|
.header {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
align-items: center;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
justify-content: space-between;
|
|
|
|
|
background: #fbfbfb;
|
2024-05-10 23:35:47 +08:00
|
|
|
|
box-shadow: 0 0 0 0 #dcdfe6;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
|
|
|
|
|
.title {
|
2024-05-10 23:35:47 +08:00
|
|
|
|
font-size: 18px;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 23:35:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 14:28:27 +08:00
|
|
|
|
// main 容器
|
|
|
|
|
.main-container {
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
position: relative;
|
2024-05-10 23:35:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 19:02:45 +08:00
|
|
|
|
.message-container {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
bottom: 0;
|
2024-05-13 17:52:39 +08:00
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
//width: 100%;
|
|
|
|
|
//height: 100%;
|
2024-05-12 19:02:45 +08:00
|
|
|
|
overflow-y: scroll;
|
|
|
|
|
padding: 0 15px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 中间
|
|
|
|
|
.chat-list {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
overflow-y: hidden;
|
|
|
|
|
|
|
|
|
|
.message-item {
|
|
|
|
|
margin-top: 50px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.left-message {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right-message {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row-reverse;
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatar {
|
|
|
|
|
//height: 170px;
|
|
|
|
|
//width: 170px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.message {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
text-align: left;
|
|
|
|
|
margin: 0 15px;
|
|
|
|
|
|
|
|
|
|
.time {
|
|
|
|
|
text-align: left;
|
|
|
|
|
line-height: 30px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.left-text-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
overflow-wrap: break-word;
|
2024-05-14 23:55:23 +08:00
|
|
|
|
background-color: rgba(228, 228, 228, 0.8);
|
|
|
|
|
box-shadow: 0 0 0 1px rgba(228, 228, 228, 0.8);
|
2024-05-12 19:02:45 +08:00
|
|
|
|
border-radius: 10px;
|
|
|
|
|
padding: 10px 10px 5px 10px;
|
|
|
|
|
|
|
|
|
|
.left-text {
|
|
|
|
|
color: #393939;
|
2024-05-13 21:38:18 +08:00
|
|
|
|
font-size: 0.95rem;
|
2024-05-12 19:02:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right-text-container {
|
|
|
|
|
display: flex;
|
2024-05-13 21:38:18 +08:00
|
|
|
|
flex-direction: row-reverse;
|
2024-05-12 19:02:45 +08:00
|
|
|
|
|
|
|
|
|
.right-text {
|
2024-05-13 21:38:18 +08:00
|
|
|
|
font-size: 0.95rem;
|
2024-05-14 23:55:23 +08:00
|
|
|
|
color: #fff;
|
2024-05-13 21:38:18 +08:00
|
|
|
|
display: inline;
|
|
|
|
|
background-color: #267fff;
|
2024-05-14 23:55:23 +08:00
|
|
|
|
color: #fff;
|
2024-05-13 21:38:18 +08:00
|
|
|
|
box-shadow: 0 0 0 1px #267fff;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
width: auto;
|
|
|
|
|
overflow-wrap: break-word;
|
2024-05-12 19:02:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 23:55:23 +08:00
|
|
|
|
.left-btns,
|
|
|
|
|
.right-btns {
|
2024-05-12 19:02:45 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 复制、删除按钮
|
|
|
|
|
.btn-cus {
|
|
|
|
|
display: flex;
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.btn-image {
|
|
|
|
|
height: 20px;
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn-cus-text {
|
|
|
|
|
color: #757575;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn-cus:hover {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.btn-cus:focus {
|
|
|
|
|
background-color: #8c939d;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 23:35:47 +08:00
|
|
|
|
// 底部
|
|
|
|
|
.footer-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: auto;
|
2024-05-12 22:22:34 +08:00
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
|
|
.prompt-from {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: auto;
|
|
|
|
|
border: 1px solid #e3e3e3;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
margin: 20px 20px;
|
|
|
|
|
padding: 9px 10px;
|
|
|
|
|
}
|
2024-05-09 22:13:23 +08:00
|
|
|
|
|
|
|
|
|
.prompt-input {
|
2024-05-10 23:35:47 +08:00
|
|
|
|
height: 80px;
|
|
|
|
|
//box-shadow: none;
|
|
|
|
|
border: none;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
resize: none;
|
|
|
|
|
padding: 0px 2px;
|
|
|
|
|
//padding: 5px 5px;
|
2024-05-09 22:13:23 +08:00
|
|
|
|
|
2024-05-10 23:35:47 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.prompt-input:focus {
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.prompt-btns {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding-bottom: 0px;
|
|
|
|
|
padding-top: 5px;
|
2024-05-07 21:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
2024-05-13 23:22:42 +08:00
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.markdown-view {
|
|
|
|
|
font-family: PingFang SC;
|
|
|
|
|
font-size: 0.95rem;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
line-height: 1.6rem;
|
|
|
|
|
letter-spacing: 0em;
|
|
|
|
|
text-align: left;
|
2024-05-14 23:55:23 +08:00
|
|
|
|
color: #3b3e55;
|
2024-05-13 23:22:42 +08:00
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
|
|
|
|
pre {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pre code.hljs {
|
|
|
|
|
width: auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
code.hljs {
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
padding-top: 20px;
|
|
|
|
|
width: auto;
|
|
|
|
|
@media screen and (min-width: 1536px) {
|
|
|
|
|
width: 960px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (max-width: 1536px) and (min-width: 1024px) {
|
|
|
|
|
width: calc(100vw - 400px - 64px - 32px * 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (max-width: 1024px) and (min-width: 768px) {
|
|
|
|
|
width: calc(100vw - 32px * 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
|
width: calc(100vw - 16px * 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p,
|
|
|
|
|
code.hljs {
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p {
|
2024-05-14 18:02:07 +08:00
|
|
|
|
//margin-bottom: 1rem !important;
|
|
|
|
|
margin: 0;
|
|
|
|
|
margin-bottom: 3px;
|
2024-05-13 23:22:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 标题通用格式 */
|
|
|
|
|
h1,
|
|
|
|
|
h2,
|
|
|
|
|
h3,
|
|
|
|
|
h4,
|
|
|
|
|
h5,
|
|
|
|
|
h6 {
|
|
|
|
|
color: var(--color-G900);
|
|
|
|
|
margin: 24px 0 8px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
|
font-size: 22px;
|
|
|
|
|
line-height: 32px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
line-height: 30px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
line-height: 28px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h4 {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 26px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h5 {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h6 {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 列表(有序,无序) */
|
|
|
|
|
ul,
|
|
|
|
|
ol {
|
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
color: #3b3e55; // var(--color-CG600);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
li {
|
|
|
|
|
margin: 4px 0 0 20px;
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ol > li {
|
|
|
|
|
list-style-type: decimal;
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
// 表达式,修复有序列表序号展示不全的问题
|
|
|
|
|
// &:nth-child(n + 10) {
|
|
|
|
|
// margin-left: 30px;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// &:nth-child(n + 100) {
|
|
|
|
|
// margin-left: 30px;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ul > li {
|
|
|
|
|
list-style-type: disc;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
margin-right: 11px;
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
color: #3b3e55; // var(--color-G900);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ol ul,
|
|
|
|
|
ol ul > li,
|
|
|
|
|
ul ul,
|
|
|
|
|
ul ul li {
|
|
|
|
|
// list-style: circle;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
list-style: none;
|
|
|
|
|
margin-left: 6px;
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ul ul ul,
|
|
|
|
|
ul ul ul li,
|
|
|
|
|
ol ol,
|
|
|
|
|
ol ol > li,
|
|
|
|
|
ol ul ul,
|
|
|
|
|
ol ul ul > li,
|
|
|
|
|
ul ol,
|
|
|
|
|
ul ol > li {
|
|
|
|
|
list-style: square;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|