mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
fixed bug for ctrl + enter key start a new row
This commit is contained in:
parent
646c39792b
commit
d2201596f6
@ -33,7 +33,7 @@ const routes = [
|
||||
},
|
||||
{
|
||||
name: 'free', path: '/free', component: ChatFree, meta: {
|
||||
title: '【文心一言】免费版'
|
||||
title: 'Chat-Plus AI 助理'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -105,7 +105,7 @@
|
||||
v-on:focus="focus"
|
||||
autofocus
|
||||
type="textarea"
|
||||
placeholder="开始你的提问"
|
||||
placeholder="输入 Ctrl + Enter 换行"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -308,9 +308,11 @@ export default defineComponent({
|
||||
}
|
||||
this.activelyClose = false;
|
||||
|
||||
// 显示打招呼信息
|
||||
this.chatData.push(this.helloMsg);
|
||||
// 获取历史记录
|
||||
this.fetchChatHistory(this.curChat.id);
|
||||
if (this.chatData.length === 0) { // 显示打招呼信息
|
||||
this.chatData.push(this.helloMsg);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener('message', event => {
|
||||
@ -319,6 +321,10 @@ export default defineComponent({
|
||||
reader.readAsText(event.data, "UTF-8");
|
||||
reader.onload = () => {
|
||||
const data = JSON.parse(String(reader.result));
|
||||
if (data['is_hello_msg'] === true) { // 过滤掉打招呼消息
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === 'start') {
|
||||
this.chatData.push({
|
||||
type: "reply",
|
||||
@ -326,23 +332,19 @@ export default defineComponent({
|
||||
icon: this.replyIcon,
|
||||
content: "",
|
||||
});
|
||||
if (data['is_hello_msg'] !== true) {
|
||||
this.canReGenerate = true;
|
||||
}
|
||||
this.canReGenerate = true;
|
||||
} else if (data.type === 'end') {
|
||||
// 保存聊天记录
|
||||
appendChatHistory(this.curChat.id, this.curPrompt);
|
||||
appendChatHistory(this.curChat.id, {
|
||||
type: "reply",
|
||||
id: randString(32),
|
||||
icon: this.replyIcon,
|
||||
content: this.lineBuffer,
|
||||
})
|
||||
this.sending = false;
|
||||
if (data['is_hello_msg'] !== true) {
|
||||
this.showReGenerate = true;
|
||||
// 保存聊天记录
|
||||
appendChatHistory(this.curChat.id, this.curPrompt);
|
||||
appendChatHistory(this.curChat.id, {
|
||||
type: "reply",
|
||||
id: randString(32),
|
||||
icon: this.replyIcon,
|
||||
content: this.lineBuffer,
|
||||
})
|
||||
}
|
||||
this.showStopGenerate = false;
|
||||
this.showReGenerate = true;
|
||||
this.lineBuffer = ''; // 清空缓冲
|
||||
|
||||
// 追加会话
|
||||
@ -441,6 +443,11 @@ export default defineComponent({
|
||||
|
||||
inputKeyDown: function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
if (e.ctrlKey) { // Ctrl + Enter 换行
|
||||
this.inputValue += "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.sending) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
@ -660,6 +667,8 @@ export default defineComponent({
|
||||
this.appendChat();
|
||||
this.chatData = [];
|
||||
this.curChat = chat;
|
||||
this.showStopGenerate = false;
|
||||
this.showReGenerate = false;
|
||||
this.connect();
|
||||
},
|
||||
|
||||
@ -1024,6 +1033,18 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nav {
|
||||
ul {
|
||||
.active {
|
||||
a {
|
||||
.btn {
|
||||
display inline
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar.show {
|
||||
|
@ -114,6 +114,8 @@
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
|
||||
<span class="text">Ctrl + Enter 换行</span>
|
||||
|
||||
</el-row>
|
||||
|
||||
<div class="input-box">
|
||||
@ -457,6 +459,11 @@ export default defineComponent({
|
||||
|
||||
inputKeyDown: function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
if (e.ctrlKey) { // Ctrl + Enter 换行
|
||||
this.inputValue += "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.sending) {
|
||||
ElMessage.warning("AI 正在作答中,请稍后...");
|
||||
e.preventDefault();
|
||||
@ -812,6 +819,11 @@ export default defineComponent({
|
||||
background-color #232425
|
||||
cursor pointer
|
||||
}
|
||||
.text {
|
||||
margin-left 10px;
|
||||
font-size 12px;
|
||||
color #9f9f9f;
|
||||
}
|
||||
}
|
||||
|
||||
.input-box {
|
||||
|
Loading…
Reference in New Issue
Block a user