mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-11 19:53:50 +08:00
opt: 优化前端登录判断逻辑
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user