整理聊天函数
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</el-row>
|
||||
</el-row>
|
||||
<thinking-bar v-show="loading"/>
|
||||
<chat-content class="fill"/>
|
||||
<chat-content class="fill" :list="chatHistory"/>
|
||||
<el-row class="mar-t8" align="middle">
|
||||
<chat-input class="fill mar-r8" v-model="inputText"/>
|
||||
<el-button type="primary" @click="handleSend">发送</el-button>
|
||||
@@ -24,9 +24,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {dayjs} from "element-plus";
|
||||
import ChatContent from "../components/chatContent";
|
||||
import ChatInput from "../components/chatInput";
|
||||
import ThinkingBar from "../components/thinkingBar";
|
||||
import {USER_AVATAR} from "../utils/env";
|
||||
|
||||
export default {
|
||||
name: "chat",
|
||||
@@ -38,11 +40,26 @@ export default {
|
||||
return {
|
||||
loading: false,
|
||||
inputText: "",
|
||||
chatHistory: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSend() {
|
||||
|
||||
if (!!this.inputText) {
|
||||
const myMsg = {
|
||||
headImg: USER_AVATAR,
|
||||
name: "我",
|
||||
time: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
msg: this.inputText,
|
||||
chatType: 0, //信息类型,0文字,1图片
|
||||
uid: "me", //uid
|
||||
}
|
||||
this.chatHistory.push(myMsg)
|
||||
this.loading = true
|
||||
this.settings.model.chat().finally(() => this.loading = false)
|
||||
} else {
|
||||
this.$message.error("请不要发送空消息!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user