初始化仓库:AI 接口自动化测试平台
纳入 FastAPI 后端、Vue 管理端、MCP 桥接与文档;通过 .gitignore 排除本地数据库与构建产物。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import { authState, getAccessToken } from "../auth/session";
|
||||
import AdminLayout from "../layout/AdminLayout.vue";
|
||||
import ApiEditorView from "../views/ApiEditorView.vue";
|
||||
import ApiManagementView from "../views/ApiManagementView.vue";
|
||||
import DashboardView from "../views/DashboardView.vue";
|
||||
import LoginView from "../views/LoginView.vue";
|
||||
import McpManagementView from "../views/McpManagementView.vue";
|
||||
import SshManagementView from "../views/SshManagementView.vue";
|
||||
import UserManagementView from "../views/UserManagementView.vue";
|
||||
import WorkflowBatchView from "../views/WorkflowBatchView.vue";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/login",
|
||||
name: "login",
|
||||
component: LoginView,
|
||||
meta: {
|
||||
public: true,
|
||||
title: "登录",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
component: AdminLayout,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
name: "dashboard",
|
||||
component: DashboardView,
|
||||
meta: {
|
||||
title: "工作台",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "apis",
|
||||
name: "apis",
|
||||
component: ApiManagementView,
|
||||
meta: {
|
||||
title: "接口管理",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "ssh",
|
||||
name: "ssh",
|
||||
component: SshManagementView,
|
||||
meta: {
|
||||
title: "SSH 管理",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "workflow-batches",
|
||||
name: "workflow-batches",
|
||||
component: WorkflowBatchView,
|
||||
meta: {
|
||||
title: "跑批工作流执行",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "workflow-runtime",
|
||||
redirect: "/workflow-batches",
|
||||
},
|
||||
{
|
||||
path: "mcp-config",
|
||||
name: "mcp",
|
||||
component: McpManagementView,
|
||||
meta: {
|
||||
title: "MCP 配置",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "apis/:apiId/edit",
|
||||
name: "api-edit",
|
||||
component: ApiEditorView,
|
||||
meta: {
|
||||
title: "接口编辑",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "users",
|
||||
name: "users",
|
||||
component: UserManagementView,
|
||||
meta: {
|
||||
title: "用户管理",
|
||||
requiresSuperadmin: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
});
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const token = getAccessToken();
|
||||
if (to.meta.public) {
|
||||
if (token && to.path === "/login") {
|
||||
return "/";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!token) {
|
||||
return "/login";
|
||||
}
|
||||
if (to.meta.requiresSuperadmin && authState.user?.role !== "superadmin") {
|
||||
return "/";
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user