|
@@ -8,7 +8,7 @@
|
|
<div v-if="isLoading && message === currentStreamingMessage && message.type === 'ai'" class="message-loading">
|
|
<div v-if="isLoading && message === currentStreamingMessage && message.type === 'ai'" class="message-loading">
|
|
<i class="el-icon-loading"></i>
|
|
<i class="el-icon-loading"></i>
|
|
</div>
|
|
</div>
|
|
- <div v-if="message.type === 'ai'" class="message-actions">
|
|
|
|
|
|
+ <!-- <div v-if="message.type === 'ai'" class="message-actions">
|
|
<template v-if="message === currentStreamingMessage">
|
|
<template v-if="message === currentStreamingMessage">
|
|
<el-button
|
|
<el-button
|
|
type="text"
|
|
type="text"
|
|
@@ -29,7 +29,7 @@
|
|
</el-button>
|
|
</el-button>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
- </div>
|
|
|
|
|
|
+ </div> -->
|
|
<!-- <div class="content-text">{{ message.isTyping ? message.displayContent : message.content }}</div> -->
|
|
<!-- <div class="content-text">{{ message.isTyping ? message.displayContent : message.content }}</div> -->
|
|
<!-- <div class="content-text markdown-body"
|
|
<!-- <div class="content-text markdown-body"
|
|
v-html="message.isTyping ?
|
|
v-html="message.isTyping ?
|
|
@@ -58,7 +58,30 @@
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
- <div class="message-time">{{ message.timestamp }}</div>
|
|
|
|
|
|
+ <div class="message-time">
|
|
|
|
+ {{ message.timestamp }}
|
|
|
|
+ <span v-if="message.type === 'ai'">
|
|
|
|
+ <template v-if="message === currentStreamingMessage">
|
|
|
|
+ <el-button
|
|
|
|
+ type="text"
|
|
|
|
+ @click="stopGeneration"
|
|
|
|
+ title="停止生成">
|
|
|
|
+ 停止生成
|
|
|
|
+ </el-button>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else>
|
|
|
|
+ <el-button type="text" @click="copyMessage(message.content)" title="复制">
|
|
|
|
+ <i class="el-icon-document-copy"></i>
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button type="text"
|
|
|
|
+ @click="regenerateResponse(index)"
|
|
|
|
+ title="重新生成"
|
|
|
|
+ :disabled="isLoading">
|
|
|
|
+ <i class="el-icon-refresh"></i>
|
|
|
|
+ </el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -75,11 +98,12 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<div class="input-group">
|
|
<div class="input-group">
|
|
- <input type="text"
|
|
|
|
|
|
+ <el-input type="textarea" autosize resize="none"
|
|
v-model="userInput"
|
|
v-model="userInput"
|
|
- @keyup.enter="sendMessage"
|
|
|
|
- placeholder="输入您的问题...">
|
|
|
|
- <button @click="sendMessage" :disabled="isLoading">发送</button>
|
|
|
|
|
|
+ @keydown.native="handleKeyCode($event)"
|
|
|
|
+ placeholder="请输入您想问的内容,按 Ctrl+Enter 换行"
|
|
|
|
+ />
|
|
|
|
+ <el-button type="primary" size="small" class="margin-left_10" @click="sendMessage" :disabled="isLoading">发送</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -183,12 +207,17 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
watch: {
|
|
watch: {
|
|
- chatHistory: {
|
|
|
|
- handler(newVal) {
|
|
|
|
- // 保存到 localStorage
|
|
|
|
- localStorage.setItem('chatHistory', JSON.stringify(newVal))
|
|
|
|
- },
|
|
|
|
- deep: true
|
|
|
|
|
|
+ // chatHistory: {
|
|
|
|
+ // handler(newVal) {
|
|
|
|
+ // // 保存到 localStorage
|
|
|
|
+ // localStorage.setItem('chatHistory', JSON.stringify(newVal))
|
|
|
|
+ // },
|
|
|
|
+ // deep: true
|
|
|
|
+ // },
|
|
|
|
+ isLoading(val,oldVal){
|
|
|
|
+ if(oldVal && !val){
|
|
|
|
+ localStorage.setItem('chatHistory', JSON.stringify(this.chatHistory))
|
|
|
|
+ }
|
|
},
|
|
},
|
|
selectedQuestion(val) {
|
|
selectedQuestion(val) {
|
|
if (val) {
|
|
if (val) {
|
|
@@ -221,6 +250,17 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
|
+ //键盘按下事件
|
|
|
|
+ handleKeyCode(event) {
|
|
|
|
+ if (event.keyCode == 13) {
|
|
|
|
+ if (!event.ctrlKey) {
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ this.sendMessage()
|
|
|
|
+ } else {
|
|
|
|
+ this.userInput += "\n";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
//发送信息
|
|
//发送信息
|
|
async sendMessage() {
|
|
async sendMessage() {
|
|
if (!this.userInput.trim()) return;
|
|
if (!this.userInput.trim()) return;
|
|
@@ -553,14 +593,23 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
-
|
|
|
|
-<style scoped>
|
|
|
|
|
|
+<style lang="scss">
|
|
|
|
+ .chat-container{
|
|
|
|
+ .user{
|
|
|
|
+ .markdown-body{
|
|
|
|
+ background: #007bff !important;
|
|
|
|
+ color: white !important;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+</style>
|
|
|
|
+<style lang="scss" scoped>
|
|
.chat-container {
|
|
.chat-container {
|
|
width: 100%;
|
|
width: 100%;
|
|
max-width: 600px;
|
|
max-width: 600px;
|
|
margin: 0 auto;
|
|
margin: 0 auto;
|
|
- border: 1px solid #ddd;
|
|
|
|
- border-radius: 8px;
|
|
|
|
|
|
+ /* border: 1px solid #ddd;
|
|
|
|
+ border-radius: 8px; */
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -568,7 +617,7 @@ export default {
|
|
height: 400px;
|
|
height: 400px;
|
|
overflow-y: auto;
|
|
overflow-y: auto;
|
|
padding: 20px;
|
|
padding: 20px;
|
|
- background: #f5f5f5;
|
|
|
|
|
|
+ /* background: #f5f5f5; */
|
|
scroll-behavior: smooth;
|
|
scroll-behavior: smooth;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -582,6 +631,9 @@ export default {
|
|
/* margin-left: auto; */
|
|
/* margin-left: auto; */
|
|
display: flex;
|
|
display: flex;
|
|
flex-direction: row-reverse;
|
|
flex-direction: row-reverse;
|
|
|
|
+ .message-time{
|
|
|
|
+ color: rgb(212, 208, 208);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
.message-content {
|
|
.message-content {
|
|
@@ -596,8 +648,8 @@ export default {
|
|
}
|
|
}
|
|
|
|
|
|
.user .message-content {
|
|
.user .message-content {
|
|
- /* background: #007bff; */
|
|
|
|
- background: white;
|
|
|
|
|
|
+ background: #007bff;
|
|
|
|
+ /* background: white; */
|
|
color: white;
|
|
color: white;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -613,6 +665,7 @@ export default {
|
|
|
|
|
|
.input-group {
|
|
.input-group {
|
|
display: flex;
|
|
display: flex;
|
|
|
|
+ align-items: flex-end;
|
|
margin-top: 10px;
|
|
margin-top: 10px;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -654,6 +707,8 @@ button:hover {
|
|
font-size: 0.8em;
|
|
font-size: 0.8em;
|
|
color: #999;
|
|
color: #999;
|
|
margin-top: 4px;
|
|
margin-top: 4px;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
}
|
|
}
|
|
|
|
|
|
/* 添加一个清空历史记录的按钮样式 */
|
|
/* 添加一个清空历史记录的按钮样式 */
|