finish refine vuex for chat

This commit is contained in:
AceDataCloud committed 2023-12-30 16:33:16 +08:00
1 parent cd5dbaa264
commit 6ab318e3f0
9 files changed
+73 -56

No files matched your search

+7 -15
View File
@@ -1,7 +1,7 @@
<template>
<div class="sidebar">
<el-skeleton v-if="loading && conversations === undefined" />
<div v-else-if="conversations?.length === 0" class="conversations">
<div v-else class="conversations">
<div class="conversation" @click="onNewConversation">
<div class="icons">
<font-awesome-icon icon="fa-solid fa-plus" class="icon" />
@@ -10,8 +10,6 @@
{{ $t('chat.message.startNewChat') }}
</div>
</div>
</div>
<div v-else class="conversations">
<div
v-for="(conversation, conversationIndex) in conversations"
:key="conversationIndex"
@@ -71,9 +69,10 @@ import { defineComponent } from 'vue';
import { ElSkeleton, ElInput } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
import { IApplication, chatOperator } from '@/operators';
import { chatOperator } from '@/operators';
import { IChatConversation } from '@/operators/chat/models';
import { Status } from '@/store/common/models';
import { v4 as uuid } from 'uuid';
export default defineComponent({
name: 'SidePanel',
@@ -95,20 +94,13 @@ export default defineComponent({
return this.$store.state.chat.getConversationsStatus === Status.Request;
}
},
watch: {
applications: {
async handler(val: IApplication[]) {
if (!val) {
return;
}
await this.$store.dispatch('chat/getConversations');
}
}
},
methods: {
async onNewConversation() {
this.$router.push({
name: ROUTE_CHAT_CONVERSATION_NEW
name: ROUTE_CHAT_CONVERSATION,
params: {
id: uuid()
}
});
},
async onConfirm(conversation: IChatConversation) {
+12 -4
View File
@@ -5,7 +5,7 @@
<el-button
:class="{
button: true,
active: $route.name === link.route.name
active: link.routes.includes($route.name as string)
}"
@click="$router.push(link.route)"
>
@@ -28,7 +28,13 @@
import { defineComponent } from 'vue';
import { ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_AUTH_LOGIN, ROUTE_CHAT_INDEX, ROUTE_MIDJOURNEY_INDEX } from '@/router/constants';
import {
ROUTE_AUTH_LOGIN,
ROUTE_CHAT_CONVERSATION,
ROUTE_CHAT_INDEX,
ROUTE_MIDJOURNEY_HISTORY,
ROUTE_MIDJOURNEY_INDEX
} from '@/router/constants';
export default defineComponent({
name: 'Navigator',
@@ -43,13 +49,15 @@ export default defineComponent({
route: {
name: ROUTE_CHAT_INDEX
},
icon: 'fa-regular fa-comment'
icon: 'fa-regular fa-comment',
routes: [ROUTE_CHAT_INDEX, ROUTE_CHAT_CONVERSATION]
},
{
route: {
name: ROUTE_MIDJOURNEY_INDEX
},
icon: 'fa-solid fa-palette'
icon: 'fa-solid fa-palette',
routes: [ROUTE_MIDJOURNEY_INDEX, ROUTE_MIDJOURNEY_HISTORY]
}
]
};