File tree Expand file tree Collapse file tree 6 files changed +198
-210
lines changed Expand file tree Collapse file tree 6 files changed +198
-210
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import request from '@/config/axios'
2
2
3
3
// AI 聊天对话 VO
4
4
export interface ChatConversationVO {
5
- id : string // ID 编号
5
+ id : number // ID 编号
6
6
userId : number // 用户编号
7
7
title : string // 对话标题
8
8
pinned : boolean // 是否置顶
@@ -23,7 +23,7 @@ export interface ChatConversationVO {
23
23
// AI 聊天对话 API
24
24
export const ChatConversationApi = {
25
25
// 获得【我的】聊天对话
26
- getChatConversationMy : async ( id : string ) => {
26
+ getChatConversationMy : async ( id : number ) => {
27
27
return await request . get ( { url : `/ai/chat/conversation/get-my?id=${ id } ` } )
28
28
} ,
29
29
Original file line number Diff line number Diff line change @@ -19,22 +19,17 @@ export interface ChatMessageVO {
19
19
userAvatar : string // 创建时间
20
20
}
21
21
22
- export interface ChatMessageSendVO {
23
- conversationId : string // 对话编号
24
- content : number // 聊天内容
25
- }
26
-
27
22
// AI chat 聊天
28
23
export const ChatMessageApi = {
29
24
// 消息列表
30
- messageList : async ( conversationId : string | null ) => {
25
+ getChatMessageListByConversationId : async ( conversationId : number | null ) => {
31
26
return await request . get ( {
32
27
url : `/ai/chat/message/list-by-conversation-id?conversationId=${ conversationId } `
33
28
} )
34
29
} ,
35
30
36
- // 发送 send stream 消息
37
- // TODO axios 可以么? https://apifox.com/apiskills/how-to-create-axios-stream/
31
+ // 发送 Stream 消息
32
+ // 为什么不用 axios 呢?因为它不支持 SSE 调用
38
33
sendStream : async (
39
34
conversationId : number ,
40
35
content : string ,
@@ -70,7 +65,7 @@ export const ChatMessageApi = {
70
65
} ,
71
66
72
67
// 删除消息 - 对话所有消息
73
- deleteByConversationId : async ( conversationId : string ) => {
68
+ deleteByConversationId : async ( conversationId : number ) => {
74
69
return await request . delete ( {
75
70
url : `/ai/chat/message/delete-by-conversation-id?conversationId=${ conversationId } `
76
71
} )
Original file line number Diff line number Diff line change 1
1
<!-- message 新增对话 -->
2
2
<template >
3
- <div class =" new-chat" >
3
+ <div class =" new-chat" >
4
4
<div class =" box-center" >
5
5
<div class =" tip" >点击下方按钮,开始你的对话吧</div >
6
- <div class =" btns" ><el-button type =" primary" round @click =" handlerNewChat" >新建对话</el-button ></div >
6
+ <div class =" btns" >
7
+ <el-button type =" primary" round @click =" handlerNewChat" >新建对话</el-button >
8
+ </div >
7
9
</div >
8
10
</div >
9
11
</template >
10
12
11
13
<script setup lang="ts">
12
-
13
14
// 定义钩子
14
15
const emits = defineEmits ([' onNewChat' ])
15
16
@@ -19,7 +20,6 @@ const emits = defineEmits(['onNewChat'])
19
20
const handlerNewChat = async () => {
20
21
await emits (' onNewChat' )
21
22
}
22
-
23
23
</script >
24
24
<style scoped lang="scss">
25
25
.new-chat {
Original file line number Diff line number Diff line change 98
98
<script setup lang="ts">
99
99
import { ChatConversationApi , ChatConversationVO } from ' @/api/ai/chat/conversation'
100
100
import { ref } from ' vue'
101
- import Role from ' ./role/index.vue'
101
+ import Role from ' ../.. /role/index.vue'
102
102
import { Bottom , Top } from ' @element-plus/icons-vue'
103
103
import roleAvatarDefaultImg from ' @/assets/ai/gpt.svg'
104
104
@@ -398,8 +398,7 @@ onMounted(async () => {
398
398
display : flex ;
399
399
flex - direction : column ;
400
400
justify - content : space - between ;
401
- padding : 0 10px ;
402
- padding - top : 10px ;
401
+ padding : 10px 10px 0 ;
403
402
overflow : hidden ;
404
403
405
404
.btn - new - conversation {
Original file line number Diff line number Diff line change 8
8
v-loading =" formLoading"
9
9
>
10
10
<el-form-item label =" 角色设定" prop =" systemMessage" >
11
- <el-input type =" textarea" v-model =" formData.systemMessage" rows =" 4" placeholder =" 请输入角色设定" />
11
+ <el-input
12
+ type =" textarea"
13
+ v-model =" formData.systemMessage"
14
+ rows =" 4"
15
+ placeholder =" 请输入角色设定"
16
+ />
12
17
</el-form-item >
13
18
<el-form-item label =" 模型" prop =" modelId" >
14
19
<el-select v-model =" formData.modelId" placeholder =" 请选择模型" >
@@ -57,10 +62,9 @@ import { CommonStatusEnum } from '@/utils/constants'
57
62
import { ChatModelApi , ChatModelVO } from ' @/api/ai/model/chatModel'
58
63
import { ChatConversationApi , ChatConversationVO } from ' @/api/ai/chat/conversation'
59
64
60
- /** AI 聊天角色 表单 */
65
+ /** AI 聊天对话的更新表单 */
61
66
defineOptions ({ name: ' ChatConversationUpdateForm' })
62
67
63
- const { t } = useI18n () // 国际化
64
68
const message = useMessage () // 消息弹窗
65
69
66
70
const dialogVisible = ref (false ) // 弹窗的是否展示
You can’t perform that action at this time.
0 commit comments