rename Token to User, the chat history function is ready

This commit is contained in:
RockYang
2023-03-28 16:03:41 +08:00
parent 95f9dfa9cb
commit ebc2041e8a
10 changed files with 261 additions and 141 deletions

View File

@@ -10,7 +10,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/json'
axios.interceptors.request.use(
config => {
// set token
config.headers['ChatGPT-Token'] = getSessionId();
config.headers['ChatGPT-TOKEN'] = getSessionId();
return config
}, error => {
return Promise.reject(error)

View File

@@ -185,10 +185,13 @@ export default defineComponent({
window.addEventListener("resize", () => {
this.chatBoxHeight = window.innerHeight - this.toolBoxHeight;
this.inputBoxWidth = window.innerWidth - 20;
});
this.connect();
this.fetchChatHistory();
},
methods: {
@@ -300,6 +303,17 @@ export default defineComponent({
break;
}
}
this.fetchChatHistory();
},
// 从后端获取聊天历史记录
fetchChatHistory: function () {
httpPost("/api/chat/history", {role: this.role}).then((res) => {
this.chatData = res.data
}).catch((e) => {
console.error(e.message)
})
},
inputKeyDown: function (e) {