opt: 优化前端登录判断逻辑

This commit is contained in:
RockYang
2023-06-25 09:46:23 +08:00
parent 0b6940b121
commit d971e95900
5 changed files with 26 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="admin-home">
<div class="admin-home" v-if="isLogin">
<admin-header/>
<admin-sidebar/>
<div class="content-box" :class="{ 'content-collapse': sidebar.collapse }">
@@ -22,9 +22,21 @@ import {useTagsStore} from '@/store/tags';
import AdminHeader from "@/components/admin/AdminHeader.vue";
import AdminSidebar from "@/components/admin/AdminSidebar.vue";
import AdminTags from "@/components/admin/AdminTags.vue";
import {useRouter} from "vue-router";
import {checkAdminSession} from "@/action/session";
import {ref} from "vue";
const sidebar = useSidebarStore();
const tags = useTagsStore();
const isLogin = ref(false)
// 获取会话信息
const router = useRouter();
checkAdminSession().then(() => {
isLogin.value = true
}).catch(() => {
router.replace('/admin/login')
})
</script>
<style scoped lang="stylus">