Skip to content

Commit a76ebee

Browse files
committed
feat: chat
1 parent 5a67402 commit a76ebee

File tree

12 files changed

+1023
-447
lines changed

12 files changed

+1023
-447
lines changed

frontend/src/api/chat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface ChatMessage {
2424
isTyping?: boolean
2525
first_chat?: boolean
2626
recommended_question?: string
27+
index: number
2728
}
2829

2930
export class ChatRecord {
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

frontend/src/i18n/zh-CN.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
"continue_to_ask": "继续提问:",
8383
"data_analysis": "数据预测",
8484
"data_predict": "数据分析",
85-
"chat_search": "搜索"
85+
"chat_search": "搜索",
86+
"thinking": "思考中",
87+
"thinking_step": "思考过程"
8688
},
8789
"ds": {
8890
"title": "数据源",
@@ -354,4 +356,4 @@
354356
"back_community": "还原至社区版",
355357
"confirm_tips": "确定还原至社区版?"
356358
}
357-
}
359+
}

frontend/src/views/chat/ChatBlock.vue

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<script setup lang="ts">
2-
// import ChatBlock from './ChatBlock.vue'
3-
// import ChatRecordFirst from './ChatRecordFirst.vue'
42
import { ChatInfo, type ChatMessage } from '@/api/chat.ts'
5-
// import { UserFilled } from '@element-plus/icons-vue'
63
import logo_fold from '@/assets/LOGO-fold.svg'
74
85
withDefaults(
@@ -18,42 +15,52 @@ withDefaults(
1815
</script>
1916

2017
<template>
21-
<div class="chat-row" :class="{ 'right-to-left': msg.role === 'user' }">
22-
<el-avatar v-if="msg.role === 'assistant'" class="ai-avatar" shape="square">
23-
<el-icon>
24-
<logo_fold v-if="!hideAvatar" />
25-
</el-icon>
26-
</el-avatar>
27-
<div :class="{ 'row-full': msg.role === 'assistant' }">
28-
<slot></slot>
18+
<div class="chat-row-container">
19+
<div class="chat-row" :class="{ 'right-to-left': msg.role === 'user' }">
20+
<div v-if="msg.role === 'assistant'" class="ai-avatar">
21+
<el-icon>
22+
<logo_fold v-if="!hideAvatar" />
23+
</el-icon>
24+
</div>
25+
<div :class="{ 'row-full': msg.role === 'assistant' }">
26+
<slot></slot>
27+
</div>
2928
</div>
29+
<slot name="footer"></slot>
3030
</div>
3131
</template>
3232

3333
<style scoped lang="less">
34-
.chat-row {
34+
.chat-row-container {
3535
display: flex;
36-
flex-direction: row;
37-
align-items: flex-start;
36+
flex-direction: column;
3837
gap: 8px;
39-
40-
padding: 20px 0 0;
41-
max-width: 800px;
4238
width: 100%;
39+
max-width: 800px;
4340
44-
&.right-to-left {
45-
flex-direction: row-reverse;
46-
}
41+
.chat-row {
42+
display: flex;
43+
flex-direction: row;
44+
align-items: flex-start;
45+
gap: 8px;
46+
padding: 20px 0 0;
4747
48-
.row-full {
49-
flex: 1;
50-
width: 0;
51-
}
48+
width: 100%;
49+
50+
&.right-to-left {
51+
flex-direction: row-reverse;
52+
}
53+
54+
.row-full {
55+
flex: 1;
56+
width: 0;
57+
}
5258
53-
.ai-avatar {
54-
font-size: 28px;
55-
background: transparent;
56-
width: 28px;
59+
.ai-avatar {
60+
font-size: 28px;
61+
background: transparent;
62+
width: 28px;
63+
}
5764
}
5865
}
5966
</style>

frontend/src/views/chat/RecommendQuestion.vue

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,51 @@ function clickQuestion(question: string): void {
3737
<template>
3838
<div v-if="computedQuestions.length > 0" class="recommend-questions">
3939
<div v-if="firstChat">{{ t('qa.guess_u_ask') }}</div>
40-
<div v-else>{{ t('qa.continue_to_ask') }}</div>
41-
<div v-for="(question, index) in computedQuestions" :key="index">
42-
<span class="question" @click="clickQuestion(question)">
40+
<div v-else class="continue-ask">{{ t('qa.continue_to_ask') }}</div>
41+
<div class="question-grid">
42+
<div
43+
v-for="(question, index) in computedQuestions"
44+
:key="index"
45+
class="question"
46+
@click="clickQuestion(question)"
47+
>
4348
{{ question }}
44-
</span>
49+
</div>
4550
</div>
4651
</div>
4752
</template>
4853

4954
<style scoped lang="less">
5055
.recommend-questions {
5156
padding: 8px;
52-
font-size: 12px;
53-
font-weight: 400;
57+
font-size: 14px;
58+
font-weight: 500;
59+
line-height: 22px;
5460
display: flex;
5561
flex-direction: column;
5662
gap: 4px;
63+
64+
.continue-ask {
65+
color: rgba(100, 106, 115, 1);
66+
font-weight: 400;
67+
}
68+
69+
.question-grid {
70+
display: grid;
71+
grid-gap: 12px;
72+
grid-template-columns: repeat(2, 50%);
73+
}
74+
5775
.question {
76+
font-weight: 400;
5877
cursor: pointer;
59-
background: lightgray;
60-
border-radius: 4px;
61-
padding: 4px;
62-
line-height: 20px;
78+
background: rgba(245, 246, 247, 1);
79+
min-height: 46px;
80+
border-radius: 6px;
81+
padding: 12px;
82+
line-height: 22px;
6383
&:hover {
64-
background: grey;
84+
background: rgba(31, 35, 41, 0.1);
6585
}
6686
}
6787
}

0 commit comments

Comments
 (0)