新增用户注册功能
This commit is contained in:
@@ -3,6 +3,7 @@ import { useAuthStore } from "../store/auth";
|
||||
import { useStudyStore } from "../store/study";
|
||||
import Layout from "../components/Layout.vue";
|
||||
import Login from "../views/Login.vue";
|
||||
import Register from "../views/Register.vue";
|
||||
import StudyList from "../views/StudyList.vue";
|
||||
import StudyHome from "../views/StudyHome.vue";
|
||||
import Milestones from "../views/Milestones.vue";
|
||||
@@ -28,10 +29,12 @@ import IssueDetail from "../views/IssueDetail.vue";
|
||||
import Verification from "../views/Verification.vue";
|
||||
import AuditLogs from "../views/admin/AuditLogs.vue";
|
||||
import AdminUsers from "../views/admin/Users.vue";
|
||||
import AdminUserApproval from "../views/admin/AdminUserApproval.vue";
|
||||
import AdminProjects from "../views/admin/Projects.vue";
|
||||
import ProjectMembers from "../views/admin/ProjectMembers.vue";
|
||||
import AdminSites from "../views/admin/Sites.vue";
|
||||
import ProjectDetail from "../views/admin/ProjectDetail.vue";
|
||||
import ProfileSettings from "../views/ProfileSettings.vue";
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
@@ -40,6 +43,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: Login,
|
||||
meta: { public: true, title: "登录" },
|
||||
},
|
||||
{
|
||||
path: "/register",
|
||||
name: "Register",
|
||||
component: Register,
|
||||
meta: { public: true, title: "注册" },
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
component: Layout,
|
||||
@@ -51,6 +60,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: MyWorkbench,
|
||||
meta: { title: "我的工作台" },
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
name: "ProfileSettings",
|
||||
component: ProfileSettings,
|
||||
meta: { title: "个人设置" },
|
||||
},
|
||||
{
|
||||
path: "study/home",
|
||||
name: "StudyHome",
|
||||
@@ -61,7 +76,7 @@ const routes: RouteRecordRaw[] = [
|
||||
path: "study/milestones",
|
||||
name: "StudyMilestones",
|
||||
component: Milestones,
|
||||
meta: { title: "里程碑", requiresStudy: true },
|
||||
meta: { title: "伦理与启动", requiresStudy: true },
|
||||
},
|
||||
{
|
||||
path: "study/milestones/:milestoneId",
|
||||
@@ -196,6 +211,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: AdminUsers,
|
||||
meta: { title: "账号管理", requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: "user-approval",
|
||||
name: "AdminUserApproval",
|
||||
component: AdminUserApproval,
|
||||
meta: { title: "注册审核", requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: "projects",
|
||||
name: "AdminProjects",
|
||||
@@ -257,9 +278,11 @@ router.beforeEach(async (to, _from, next) => {
|
||||
next({ path: "/login" });
|
||||
return;
|
||||
}
|
||||
if (to.path === "/login" && token) {
|
||||
next({ path: studyStore.currentStudy ? "/study/home" : "/studies" });
|
||||
return;
|
||||
if ((to.path === "/login" || to.path === "/register") && token) {
|
||||
if (!auth.forceLogin) {
|
||||
next({ path: studyStore.currentStudy ? "/study/home" : "/studies" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (to.meta.requiresAdmin && auth.user?.role !== "ADMIN") {
|
||||
next({ path: "/studies" });
|
||||
|
||||
Reference in New Issue
Block a user