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 @@