From d15519e18f0aca3f5263a18ca9f3a182348c148f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=98=89=E6=82=A6?= Date: Tue, 27 May 2025 01:08:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E6=83=85=E5=86=B5=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=92=8C=E6=B7=BB=E5=8A=A0=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 4 +- .../components/FormLogin/AccountPassword.vue | 6 +- src/config/index.ts | 2 +- src/layouts/components/Aside/index.vue | 6 +- .../components/Header/components/Avatar.vue | 9 ++- .../Header/components/CreateChat.vue | 2 +- src/layouts/components/Header/index.vue | 4 +- src/layouts/components/Main/index.vue | 63 ++++++++++++++++++- src/pages/chat/index.vue | 4 +- src/pages/chat/layouts/chatDefaul/index.vue | 1 + src/routers/modules/staticRouter.ts | 2 + src/stores/modules/chat.ts | 3 + src/stores/modules/session.ts | 25 ++++++-- 13 files changed, 114 insertions(+), 17 deletions(-) diff --git a/.env.production b/.env.production index 6832adc..29a5ba8 100644 --- a/.env.production +++ b/.env.production @@ -13,4 +13,6 @@ VITE_WEB_BASE_API = '/prod-api' # 是否在打包时开启压缩,支持 gzip 和 brotli VITE_BUILD_COMPRESS = gzip -VITE_API_URL = http://122.51.75.95:6039 +# VITE_API_URL = http://122.51.75.95:6039 +VITE_API_URL = http://129.211.24.7:6039 + diff --git a/src/components/LoginDialog/components/FormLogin/AccountPassword.vue b/src/components/LoginDialog/components/FormLogin/AccountPassword.vue index 7139267..fb90185 100644 --- a/src/components/LoginDialog/components/FormLogin/AccountPassword.vue +++ b/src/components/LoginDialog/components/FormLogin/AccountPassword.vue @@ -6,8 +6,10 @@ import { reactive, ref } from 'vue'; import { useRouter } from 'vue-router'; import { login } from '@/api'; import { useUserStore } from '@/stores'; +import { useSessionStore } from '@/stores/modules/session'; const userStore = useUserStore(); +const sessionStore = useSessionStore(); const formRef = ref(); @@ -30,8 +32,10 @@ async function handleSubmit() { res.data.token && userStore.setToken(res.data.token); res.data.userInfo && userStore.setUserInfo(res.data.userInfo); ElMessage.success('登录成功'); - router.replace('/'); userStore.closeLoginDialog(); + // 立刻获取回话列表 + await sessionStore.requestSessionList(1, true); + router.replace('/'); } catch (error) { console.error('请求错误:', error); diff --git a/src/config/index.ts b/src/config/index.ts index ce70539..4cc82bd 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -15,4 +15,4 @@ export const COLLAPSE_THRESHOLD: number = 600; export const SIDE_BAR_WIDTH: number = 280; // 路由白名单地址[本地存在的路由 staticRouter.ts 中] -export const ROUTER_WHITE_LIST: string[] = ['/chat', '/500', '/403', '/404']; +export const ROUTER_WHITE_LIST: string[] = ['/chat', '/chat/not_login', '/500', '/403', '/404']; diff --git a/src/layouts/components/Aside/index.vue b/src/layouts/components/Aside/index.vue index 4bba8d4..5303c4b 100644 --- a/src/layouts/components/Aside/index.vue +++ b/src/layouts/components/Aside/index.vue @@ -18,7 +18,7 @@ const sessionStore = useSessionStore(); const sessionId = computed(() => route.params?.id); const conversationsList = computed(() => sessionStore.sessionList); const loadMoreLoading = computed(() => sessionStore.isLoadingMore); -const active = computed(() => sessionStore.currentSession?.id); +const active = ref(); onMounted(async () => { // 获取会话列表 @@ -28,6 +28,7 @@ onMounted(async () => { const currentSessionRes = await get_session(`${sessionId.value}`); // 通过 ID 查询详情,设置当前会话 (因为有分页) sessionStore.setCurrentSession(currentSessionRes.data); + active.value = `${sessionId.value}`; } }); @@ -176,7 +177,8 @@ function handleMenuCommand(command: string, item: ConversationItem diff --git a/src/layouts/components/Header/index.vue b/src/layouts/components/Header/index.vue index 1941f3a..9bbe93b 100644 --- a/src/layouts/components/Header/index.vue +++ b/src/layouts/components/Header/index.vue @@ -14,6 +14,8 @@ const userStore = useUserStore(); const designStore = useDesignStore(); const sessionStore = useSessionStore(); +const currentSession = computed(() => sessionStore.currentSession); + onMounted(() => { // 全局设置侧边栏默认宽度 (这个是不变的,一开始就设置) document.documentElement.style.setProperty(`--sidebar-default-width`, `${SIDE_BAR_WIDTH}px`); @@ -55,7 +57,7 @@ onKeyStroke(event => event.ctrlKey && event.key.toLowerCase() === 'k', handleCtr > -
+
diff --git a/src/layouts/components/Main/index.vue b/src/layouts/components/Main/index.vue index 218c3ce..14c0c5d 100644 --- a/src/layouts/components/Main/index.vue +++ b/src/layouts/components/Main/index.vue @@ -1,10 +1,21 @@