提交 bf6bf05b authored 作者: 朱政's avatar 朱政

feat:登录页功能开发

上级 e4644875
流水线 #362 已通过 于阶段
in 1 分 35 秒
import { createRouter, createWebHistory } from "vue-router";
import { getIsLoggedIn } from "@/utils/auth";
const Home = () => import('@/views/home/index.vue')
const DataLibrary = () => import('@/views/dataLibrary/index.vue')
......@@ -21,6 +22,14 @@ const dataRoutes = Object.keys(datas).reduce((acc, path) => {
}, [])
const routes = [
{
path: "/login",
name: "Login",
component: () => import("@/views/login/index.vue"),
meta: {
title: "登录"
}
},
{
path: "/",
name: "Home",
......@@ -66,6 +75,19 @@ const router = createRouter({
// 路由守卫 - 设置页面标题
router.beforeEach((to, from, next) => {
// 登录态仅保存在运行时内存:刷新/重启后都需重新登录
const isAuthed = getIsLoggedIn();
const isLoginRoute = to.name === "Login" || /^\/login\/?$/.test(String(to.path || ""));
if (!isLoginRoute && !isAuthed) {
next({
path: "/login",
query: { redirect: to.fullPath }
});
return;
}
if (to.meta.title) {
if (to.meta.dynamicTitle) {
console.log('to', to);
......
......@@ -4,7 +4,7 @@ const ZMOverview = () => import('@/views/ZMOverView/index.vue')
const ZMOverviewRoutes = [
{
path: "/",
redirect: "/ZMOverView"
redirect: "/login"
},
{
path: "/ZMOverView",
......
let isLoggedIn = false;
export const getIsLoggedIn = () => isLoggedIn;
export const setIsLoggedIn = (val) => {
isLoggedIn = Boolean(val);
};
差异被折叠。
......@@ -207,7 +207,7 @@
<div class="thinkTank-view">
<div class="thinkTank-image">
<img src="../assets/images/rand-image.png" alt="" />
</div>
</div>
{{ `${domainName} ${consensusList.length + differenceList.length}条` }}
</div>
</div> -->
......@@ -1479,7 +1479,7 @@ onMounted(async () => {
.page-box {
margin-top: 21px;
align-items: center;
align-items: center;
justify-content: center;
display: flex;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论