From 21a6ba64ea10cd8bdd1315d8262866b4673e31e5 Mon Sep 17 00:00:00 2001 From: unitwk Date: Wed, 23 Aug 2023 11:04:39 +0800 Subject: [PATCH] Feat: login ok --- frontend/src/App.vue | 20 +++++++++++++++----- frontend/src/views/Login.vue | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index fe3549a5..ce7f6a65 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -10,9 +10,11 @@ import { onMounted, ref, unref } from "vue"; import { useAppConfigStore } from "@/stores/useAppConfigStore"; import { useAppStateStore } from "@/stores/useAppStateStore"; import { theme } from "ant-design-vue"; - +import { message } from "ant-design-vue"; import InputDialogProvider from "./components/InputDialogProvider.vue"; import { userInfoApi } from "./services/apis"; +import { t } from "./lang/i18n"; +import { router } from "./config/router"; const { getCurrentLanguage, isDarkTheme } = useAppConfigStore(); const { state } = useAppStateStore(); @@ -40,11 +42,19 @@ if (isDarkUI) { const { execute: reqUserInfo, isLoading } = userInfoApi(); onMounted(async () => { - const info = await reqUserInfo(); - if (info.value) { - state.userInfo = info.value; + try { + const info = await reqUserInfo(); + if (info.value) { + state.userInfo = info.value; + } else { + throw new Error(); + } + console.log("用户信息:", state.userInfo); + } catch (error) { + router.push({ + path: "/login" + }); } - console.log("用户信息:", state.userInfo); }); diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index d525dba3..f49c6fd3 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -153,6 +153,7 @@ const loginSuccess = () => {