You've already forked DataMate
feat(auth): 添加登录功能和路由保护
- 在侧边栏添加退出登录按钮并实现登出逻辑 - 添加 ProtectedRoute 组件用于路由权限控制 - 创建 LoginPage 组件实现登录界面和逻辑 - 集成本地登录验证到 authSlice 状态管理 - 配置路由表添加登录页面和保护路由 - 实现自动跳转到登录页面的重定向逻辑
This commit is contained in:
@@ -49,243 +49,254 @@ import EvaluationDetailPage from "@/pages/DataEvaluation/Detail/TaskDetail.tsx";
|
||||
import SynthDataDetail from "@/pages/SynthesisTask/SynthDataDetail.tsx";
|
||||
import Home from "@/pages/Home/Home";
|
||||
import ContentGenerationPage from "@/pages/ContentGeneration/ContentGenerationPage";
|
||||
import LoginPage from "@/pages/Login/LoginPage";
|
||||
import ProtectedRoute from "@/components/ProtectedRoute";
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: "/login",
|
||||
Component: LoginPage,
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
Component: Home,
|
||||
},
|
||||
{
|
||||
path: "/chat",
|
||||
Component: withErrorBoundary(AgentPage),
|
||||
},
|
||||
{
|
||||
path: "/orchestration",
|
||||
Component: ProtectedRoute,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: withErrorBoundary(OrchestrationPage),
|
||||
path: "/chat",
|
||||
Component: withErrorBoundary(AgentPage),
|
||||
},
|
||||
{
|
||||
path: "create-workflow",
|
||||
Component: withErrorBoundary(WorkflowEditor),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/data",
|
||||
Component: withErrorBoundary(MainLayout),
|
||||
children: [
|
||||
{
|
||||
path: "collection",
|
||||
path: "/orchestration",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataCollection,
|
||||
Component: withErrorBoundary(OrchestrationPage),
|
||||
},
|
||||
{
|
||||
path: "create-task",
|
||||
Component: CollectionTaskCreate,
|
||||
path: "create-workflow",
|
||||
Component: withErrorBoundary(WorkflowEditor),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "management",
|
||||
path: "/data",
|
||||
Component: withErrorBoundary(MainLayout),
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DatasetManagement,
|
||||
path: "collection",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataCollection,
|
||||
},
|
||||
{
|
||||
path: "create-task",
|
||||
Component: CollectionTaskCreate,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "create/:id?",
|
||||
Component: DatasetCreate,
|
||||
path: "management",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DatasetManagement,
|
||||
},
|
||||
{
|
||||
path: "create/:id?",
|
||||
Component: DatasetCreate,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: DatasetDetail,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: DatasetDetail,
|
||||
path: "knowledge-management",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: KnowledgeManagementPage,
|
||||
},
|
||||
{
|
||||
path: "search",
|
||||
Component: KnowledgeManagementSearch,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: KnowledgeSetDetail,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "cleansing",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataCleansing,
|
||||
},
|
||||
{
|
||||
path: "create-task",
|
||||
Component: CleansingTaskCreate,
|
||||
},
|
||||
{
|
||||
path: "task-detail/:id",
|
||||
Component: CleansingTaskDetail,
|
||||
},
|
||||
{
|
||||
path: "create-template",
|
||||
Component: CleansingTemplateCreate,
|
||||
},
|
||||
{
|
||||
path: "template-detail/:id",
|
||||
Component: CleansingTemplateDetail,
|
||||
},
|
||||
{
|
||||
path: "update-template/:id",
|
||||
Component: CleansingTemplateCreate,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "annotation",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataAnnotation,
|
||||
},
|
||||
{
|
||||
path: "create-task",
|
||||
Component: AnnotationTaskCreate,
|
||||
},
|
||||
{
|
||||
path: "annotate/:projectId",
|
||||
Component: LabelStudioTextEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "content-generation",
|
||||
Component: ContentGenerationPage,
|
||||
},
|
||||
{
|
||||
path: "synthesis/task",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
Component: DataSynthesisPage,
|
||||
},
|
||||
{
|
||||
path: "create-template",
|
||||
Component: InstructionTemplateCreate,
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
Component: SynthesisTaskCreate,
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
Component: SynthFileTask
|
||||
},
|
||||
{
|
||||
path: "file/:id/detail",
|
||||
Component: SynthDataDetail,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "synthesis/ratio-task",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: RatioTasksPage,
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
Component: CreateRatioTask,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: RatioTaskDetail,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "evaluation",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataEvaluationPage,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: EvaluationDetailPage,
|
||||
},
|
||||
{
|
||||
path: "task-report/:id",
|
||||
Component: EvaluationTaskReport,
|
||||
},
|
||||
{
|
||||
path: "manual-evaluate/:id",
|
||||
Component: ManualEvaluatePage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "knowledge-base",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: KnowledgeBasePage,
|
||||
},
|
||||
{
|
||||
path: "search",
|
||||
Component: KnowledgeBaseSearch,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: KnowledgeBaseDetailPage,
|
||||
},
|
||||
{
|
||||
path: "file-detail/:id",
|
||||
Component: KnowledgeBaseFileDetailPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "operator-market",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: OperatorMarketPage,
|
||||
},
|
||||
{
|
||||
path: "create/:id?",
|
||||
Component: OperatorPluginCreate,
|
||||
},
|
||||
{
|
||||
path: "plugin-detail/:id",
|
||||
Component: OperatorPluginDetail,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "knowledge-management",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: KnowledgeManagementPage,
|
||||
},
|
||||
{
|
||||
path: "search",
|
||||
Component: KnowledgeManagementSearch,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: KnowledgeSetDetail,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "cleansing",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataCleansing,
|
||||
},
|
||||
{
|
||||
path: "create-task",
|
||||
Component: CleansingTaskCreate,
|
||||
},
|
||||
{
|
||||
path: "task-detail/:id",
|
||||
Component: CleansingTaskDetail,
|
||||
},
|
||||
{
|
||||
path: "create-template",
|
||||
Component: CleansingTemplateCreate,
|
||||
},
|
||||
{
|
||||
path: "template-detail/:id",
|
||||
Component: CleansingTemplateDetail,
|
||||
},
|
||||
{
|
||||
path: "update-template/:id",
|
||||
Component: CleansingTemplateCreate,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "annotation",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataAnnotation,
|
||||
},
|
||||
{
|
||||
path: "create-task",
|
||||
Component: AnnotationTaskCreate,
|
||||
},
|
||||
{
|
||||
path: "annotate/:projectId",
|
||||
Component: LabelStudioTextEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "content-generation",
|
||||
Component: ContentGenerationPage,
|
||||
},
|
||||
{
|
||||
path: "synthesis/task",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
Component: DataSynthesisPage,
|
||||
},
|
||||
{
|
||||
path: "create-template",
|
||||
Component: InstructionTemplateCreate,
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
Component: SynthesisTaskCreate,
|
||||
},
|
||||
{
|
||||
path: ":id",
|
||||
Component: SynthFileTask
|
||||
},
|
||||
{
|
||||
path: "file/:id/detail",
|
||||
Component: SynthDataDetail,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "synthesis/ratio-task",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: RatioTasksPage,
|
||||
},
|
||||
{
|
||||
path: "create",
|
||||
Component: CreateRatioTask,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: RatioTaskDetail,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "evaluation",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: DataEvaluationPage,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: EvaluationDetailPage,
|
||||
},
|
||||
{
|
||||
path: "task-report/:id",
|
||||
Component: EvaluationTaskReport,
|
||||
},
|
||||
{
|
||||
path: "manual-evaluate/:id",
|
||||
Component: ManualEvaluatePage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "knowledge-base",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: KnowledgeBasePage,
|
||||
},
|
||||
{
|
||||
path: "search",
|
||||
Component: KnowledgeBaseSearch,
|
||||
},
|
||||
{
|
||||
path: "detail/:id",
|
||||
Component: KnowledgeBaseDetailPage,
|
||||
},
|
||||
{
|
||||
path: "file-detail/:id",
|
||||
Component: KnowledgeBaseFileDetailPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "operator-market",
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
Component: OperatorMarketPage,
|
||||
},
|
||||
{
|
||||
path: "create/:id?",
|
||||
Component: OperatorPluginCreate,
|
||||
},
|
||||
{
|
||||
path: "plugin-detail/:id",
|
||||
Component: OperatorPluginDetail,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
export default router;
|
||||
export default router;
|
||||
Reference in New Issue
Block a user