diff --git a/index.html b/index.html index 9e5fc8f..f8c23b0 100644 --- a/index.html +++ b/index.html @@ -3,11 +3,31 @@ - - Vite App + + Animo
+ diff --git a/src/App.vue b/src/App.vue index 4d67a69..ebf27d2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,10 +21,10 @@ - 你好,{{ name }} + 你好,{{ user.name }} -
+
@@ -34,7 +34,7 @@
- +
@@ -49,6 +49,8 @@ import LoginProcess from '@/components/login/LoginProcess.vue' import { RefreshIcon } from 'tdesign-icons-vue-next' import Menu from '@/components/Menu.vue' import { getCookie } from '@/utils/cookie.ts' +import { getUserInfo } from '@/api/auth.ts' +import { useUserStore } from '@/stores/user.ts' const login = ref(false) const weCome = ref(false) @@ -56,7 +58,6 @@ const hideLoading = ref(false) const showTitle = ref(false) const passkey = ref(true) -const name = ref('Amico') const menuVisible = ref(false) @@ -64,8 +65,22 @@ if (!navigator.credentials) { passkey.value = false } +const user = ref() function handleLogin() { login.value = true + getUserInfo().then((x: any) => { + if (x.code === 200){ + useUserStore().setUser(x.data) + user.value = x.data + weCome.value = true + setTimeout(() => { + hideLoading.value = true + setTimeout(() => { + showTitle.value = true + }, 500) + }, 500) + } + }) } function handleMenu() { @@ -74,24 +89,15 @@ function handleMenu() { } } +const contentVisible = ref(true) +function handleRefresh() { + contentVisible.value = false + setTimeout(() => contentVisible.value = true, 500) +} + onMounted(() => { if (getCookie('satoken')){ - login.value = true - } -}) - -// 登录动画流程 -watch(login, (val) => { - if (val) { - setTimeout(() => { - weCome.value = true - setTimeout(() => { - hideLoading.value = true - setTimeout(() => { - showTitle.value = true - }, 500) - }, 500) - }, 1000) + handleLogin() } }) @@ -158,10 +164,10 @@ header { animation: circle 1s linear infinite; } } - .title { - margin: 1rem; - flex: 98; - } + } + .title { + padding: 0 1rem; + flex: 98; } &.login { height: 10vh; diff --git a/src/api/auth.ts b/src/api/auth.ts index 0dc98e9..2eeac47 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -14,6 +14,12 @@ export function register(data: any) { data: data }) } +export function getUserInfo(){ + return request({ + url: '/auth/getUserInfo', + method: 'get' + }) +} export function credentials(){ return request({ diff --git a/src/components/login/Login.vue b/src/components/login/Login.vue index f26c9fa..e1443c6 100644 --- a/src/components/login/Login.vue +++ b/src/components/login/Login.vue @@ -2,22 +2,33 @@
- + - + diff --git a/src/stores/user.ts b/src/stores/user.ts new file mode 100644 index 0000000..88d89d1 --- /dev/null +++ b/src/stores/user.ts @@ -0,0 +1,10 @@ +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const useUserStore = defineStore('userStore', () => { + const user = ref(null) + function setUser(userData: any) { + user.value = userData + } + return { user, setUser } +})