diff --git a/src/views/aside.vue b/src/views/aside.vue
index da9f778..715b628 100644
--- a/src/views/aside.vue
+++ b/src/views/aside.vue
@@ -12,7 +12,11 @@
:class="{ active: it.id === $store.conversation.id }"
>
{{ it.name }}
- ╳
+
@@ -38,21 +42,22 @@ export default {
},
removeConversation(it, idx) {
- this.$confirm(`是否删除此会话【${it.name}】`)
+ layer
+ .confirm(`是否删除此会话【${it.name}】`)
.then(_ => {
- removeConversation(it.id)
- .then(r => {
- this.$message.success('删除会话成功')
- this.conversations.splice(idx, 1)
- if (this.conversations.length) {
- this.pickThisConversation(this.conversations[0])
- } else {
- this.createNewConversation()
- }
- })
- .catch(r => {
- this.$message.success('删除会话失败')
- })
+ // removeConversation(it.id)
+ // .then(r => {
+ layer.toast('删除会话成功', 'success')
+ this.$store.conversations.splice(idx, 1)
+ if (this.$store.conversations.length) {
+ this.pickThisConversation(this.$store.conversations[0])
+ } else {
+ this.createNewConversation()
+ }
+ // })
+ // .catch(r => {
+ // this.$message.success('删除会话失败')
+ // })
})
.catch(function () {})
},
@@ -112,21 +117,24 @@ export default {
}
.close {
- font-size: 12px;
- opacity: 0.1;
- transition: opacity 0.2s ease-in;
+ width: 18px;
+ height: 18px;
+ padding: 3px;
+ border-radius: 50%;
+ cursor: pointer;
+ color: var(--color-blue-a);
+ transition: color 0.2s ease-in, background 0.2s ease-in;
+
+ &:hover {
+ background: var(--color-red-1);
+ color: #fff;
+ }
}
&.active,
&:hover {
color: var(--color-blue-1);
background: #ecf5ff;
-
- .close {
- opacity: 1;
- cursor: pointer;
- transform: scale(1.2);
- }
}
}
}
diff --git a/src/views/chat.vue b/src/views/chat.vue
index 94ead7f..e08ecc1 100644
--- a/src/views/chat.vue
+++ b/src/views/chat.vue
@@ -1,7 +1,11 @@
-
+
@@ -25,14 +29,15 @@ import Avatar from '@/components/avatar.vue'
import '//jscdn.ink/@bd/ui/latest/code/index.js'
import { nextTick } from 'vue'
import md2html from '//jscdn.ink/@bd/ui/latest/markd/core.js'
+import { uuid } from '//jscdn.ink/crypto.web.js/latest/crypto.js'
-function ask() {
+function ask(content, id) {
//
return Promise.resolve({
data: {
- conversation: '',
- id: '',
+ conversation: id || uuid(),
+ id: uuid(),
text: 'blabla...'
}
})
@@ -46,7 +51,6 @@ export default {
components: { Avatar },
data() {
return {
- records: [],
question: '',
loading: false
}
@@ -64,7 +68,7 @@ export default {
ask(ev) {
let question = this.question.trim()
- let { id, lastMessageId } = this.$store.conversation
+ let { id } = this.$store.conversation
if (ev.keyCode === 13) {
if (ev.shiftKey) {
@@ -83,19 +87,23 @@ export default {
this.question = ''
- this.records.push({ id: Date.now(), role: 0, content: question })
+ this.$store.conversation.records.push({
+ id: uuid(),
+ role: 0,
+ content: question
+ })
nextTick(_ => (this.$refs.records.scrollTop = Number.MAX_SAFE_INTEGER))
this.loading = true
- this.records.push({
- id: Date.now(),
+ this.$store.conversation.records.push({
+ id: uuid(),
role: 1,
content: '
'
})
- ask(question, lastMessageId, id)
+ ask(question, id)
.then(r => {
if (!id) {
this.$store.conversations.unshift({
@@ -104,14 +112,13 @@ export default {
})
}
this.$store.conversation.id = r.data.conversation
- this.$store.conversation.lastMessageId = r.data.id
-
- this.records.at(-1).id = r.data.id
- this.records.at(-1).content = r.data.text
+ this.$store.conversation.records.at(-1).id = r.data.id
+ this.$store.conversation.records.at(-1).content = r.data.text
})
.catch(r => {
console.log(r)
- this.records.at(-1).content = r.msg || r.toString()
+ this.$store.conversation.records.at(-1).content =
+ r.msg || r.toString()
this.$message.error(r.msg || r.toString())
})