feat: 重构用户认证逻辑,添加导航重定向功能,更新相关组件和路由
This commit is contained in:
@@ -2,6 +2,11 @@ import type { Router } from "vue-router";
|
||||
|
||||
export function createRouterGuard(router: Router) {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const userStore = useUserStore();
|
||||
if (to.meta.requiresAuth && !userStore.isAuthenticated) {
|
||||
const redirect = encodeURIComponent(to.fullPath);
|
||||
return next({ path: "/auth/login", query: { redirect } });
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,40 +36,49 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: "user",
|
||||
component: () => import("@/views/user/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/onchain-address",
|
||||
component: () => import("@/views/onchain-address/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/deposit/fiat",
|
||||
component: () => import("@/views/deposit/fiat.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/withdraw/index",
|
||||
component: () => import("@/views/withdraw/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/user/settings",
|
||||
component: () => import("@/views/user-settings/outlet.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
component: () => import("@/views/user-settings/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "username",
|
||||
component: () => import("@/views/user-settings/username.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "nickname",
|
||||
component: () => import("@/views/user-settings/nickname.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "email",
|
||||
component: () => import("@/views/user-settings/email.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -95,23 +104,28 @@ const routes: Array<RouteRecordRaw> = [
|
||||
path: "/issue/issuing-apply",
|
||||
props: ({ query, params }) => ({ query, params }),
|
||||
component: () => import("@/views/issue/issuing-apply/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/trade-settings/bank-management",
|
||||
component: () => import("@/views/trade-settings/bank-management/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/trade-settings/my-subscribe",
|
||||
component: () => import("@/views/trade-settings/my-subscribe/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/trade-settings/bank-management/add",
|
||||
component: () => import("@/views/trade-settings/bank-management/add.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/trade-rwa/:id",
|
||||
props: true,
|
||||
component: () => import("@/views/trade-rwa/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user