fix(components): 修复聊天记录排序问题
This commit is contained in:
parent
d79059e7a9
commit
fbce84c580
@ -8,7 +8,7 @@
|
|||||||
<el-button type="primary" :loading="loading" @click="send" plain>发送</el-button>
|
<el-button type="primary" :loading="loading" @click="send" plain>发送</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col style="margin-top: 2rem;" id="messagesContent">
|
<el-col style="margin-top: 2rem;" id="messagesContent">
|
||||||
<el-col v-for="message in Array.prototype.reverse.call(messages)" :key="message.dataId">
|
<el-col v-for="message in messages" :key="message.dataId">
|
||||||
<el-col v-if="message.from === user.account">
|
<el-col v-if="message.from === user.account">
|
||||||
<el-col :span="22" style="text-align: right;">
|
<el-col :span="22" style="text-align: right;">
|
||||||
<div class="from-message">
|
<div class="from-message">
|
||||||
@ -167,6 +167,9 @@ export default {
|
|||||||
content: await _ts.contentEditor.getHTML()
|
content: await _ts.contentEditor.getHTML()
|
||||||
}
|
}
|
||||||
_ts.messages.push(message);
|
_ts.messages.push(message);
|
||||||
|
_ts.messages.sort((a, b) => {
|
||||||
|
return b.dataId - a.dataId;
|
||||||
|
});
|
||||||
_ts.contentEditor.setValue('')
|
_ts.contentEditor.setValue('')
|
||||||
_ts.$axios.$post('/api/openai/chat', {
|
_ts.$axios.$post('/api/openai/chat', {
|
||||||
message: message.content
|
message: message.content
|
||||||
@ -178,6 +181,9 @@ export default {
|
|||||||
dataId: new Date().getTime(),
|
dataId: new Date().getTime(),
|
||||||
content: res[0].message.content
|
content: res[0].message.content
|
||||||
});
|
});
|
||||||
|
_ts.messages.sort((a, b) => {
|
||||||
|
return b.dataId - a.dataId;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user