From 38262b11ac918905720f865e1872c5ddb28003c9 Mon Sep 17 00:00:00 2001 From: ivamp Date: Sat, 3 Aug 2024 18:59:52 +0800 Subject: [PATCH] =?UTF-8?q?"=E6=96=B0=E5=A2=9E=E8=81=8A=E5=A4=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1=E5=92=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 本次提交实现了聊天功能,包括在AppBar中添加了聊天链接,新增了聊天页面,以及聊天状态的管理。具体变更如下: 1. 在`AppBar.vue`中为聊天功能添加了图标和路由链接。 2. 新增`index.vue`文件,用于展示聊天内容。 3. 在`chat.ts`中定义了聊天状态的存储和获取方法。 4. 更新了`typed-router.d.ts`,包含了指向新聊天路由的记录。 这些变更使得应用能够提供聊天功能,为用户提供更丰富的交互方式。 --- src/components/AppBar.vue | 20 ++++++++++++++++---- src/pages/chats/[id]/index.vue | 3 +++ src/pages/chats/index.vue | 0 src/stores/chat.ts | 16 ++++++++++++++++ src/typed-router.d.ts | 2 ++ 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/pages/chats/[id]/index.vue create mode 100644 src/pages/chats/index.vue create mode 100644 src/stores/chat.ts diff --git a/src/components/AppBar.vue b/src/components/AppBar.vue index 4d806d2..dd46187 100644 --- a/src/components/AppBar.vue +++ b/src/components/AppBar.vue @@ -19,21 +19,21 @@ + + @@ -62,9 +71,12 @@ import { useConfigStore } from "@/stores/config"; import { useUserStore } from "@/stores/user"; import { useAppStore } from "@/stores/app"; +import { useChatStore } from "@/stores/chat"; +const chatStore = useChatStore(); const configStore = useConfigStore(); const userStore = useUserStore(); - const appStore = useAppStore(); + +chatStore.getChats(); diff --git a/src/pages/chats/[id]/index.vue b/src/pages/chats/[id]/index.vue new file mode 100644 index 0000000..11609bd --- /dev/null +++ b/src/pages/chats/[id]/index.vue @@ -0,0 +1,3 @@ + diff --git a/src/pages/chats/index.vue b/src/pages/chats/index.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/stores/chat.ts b/src/stores/chat.ts new file mode 100644 index 0000000..c0c036f --- /dev/null +++ b/src/stores/chat.ts @@ -0,0 +1,16 @@ +import { ApiV1ChatsGet200Response } from "@/api"; +import { defineStore } from "pinia"; +import { api } from "@/plugins/api"; + +export const useChatStore = defineStore("chats", { + state: () => ({ + chats: [] as ApiV1ChatsGet200Response, + }), + actions: { + getChats() { + api.Chat.apiV1ChatsGet().then((response) => { + this.chats = response.data; + }); + }, + }, +}); diff --git a/src/typed-router.d.ts b/src/typed-router.d.ts index fc6064e..3d30964 100644 --- a/src/typed-router.d.ts +++ b/src/typed-router.d.ts @@ -25,6 +25,8 @@ declare module 'vue-router/auto-routes' { '/assistants/create': RouteRecordInfo<'/assistants/create', '/assistants/create', Record, Record>, '/auth/callback': RouteRecordInfo<'/auth/callback', '/auth/callback', Record, Record>, '/auth/login': RouteRecordInfo<'/auth/login', '/auth/login', Record, Record>, + '/chats/': RouteRecordInfo<'/chats/', '/chats', Record, Record>, + '/chats/[id]/': RouteRecordInfo<'/chats/[id]/', '/chats/:id', { id: ParamValue }, { id: ParamValue }>, '/ping/': RouteRecordInfo<'/ping/', '/ping', Record, Record>, '/tools/': RouteRecordInfo<'/tools/', '/tools', Record, Record>, '/tools/create': RouteRecordInfo<'/tools/create', '/tools/create', Record, Record>,