refactor: remove /app prefix from tool-related routes
- Move tool routes (tools, tool-marketplace, publish-tool, my-published-tools) out of /app sub-routes - Create separate layout route groups for tool-related pages - Update dynamic tool route registration from AppLayout to ToolsLayout - Simplify route path generation by removing tools/ prefix - Update AppHeader breadcrumb path references All tool-related routes now use /tools/* instead of /app/tools/* while maintaining the same layout structure.
This commit is contained in:
parent
f494f32a20
commit
307bb226f5
@ -125,7 +125,7 @@ const breadcrumbItems = computed(() => {
|
||||
if (route.meta?.toolName) {
|
||||
// 工具路由:显示 Tools / 工具名称
|
||||
// 自动解析 Tools 路由的路径(用于面包屑链接)
|
||||
let toolsPath = '/app/tools' // 默认值
|
||||
let toolsPath = '/tools'
|
||||
try {
|
||||
const resolved = router.resolve({ name: 'Tools' })
|
||||
if (resolved.matched.length > 0) {
|
||||
|
||||
@ -97,11 +97,6 @@ const router = createRouter({
|
||||
name: 'Settings',
|
||||
component: () => import('../../views/settings/Settings.vue')
|
||||
},
|
||||
{
|
||||
path: 'tools',
|
||||
name: 'Tools',
|
||||
component: () => import('../../views/Tools.vue')
|
||||
},
|
||||
{
|
||||
path: 'search',
|
||||
name: 'SearchResults',
|
||||
@ -153,22 +148,6 @@ const router = createRouter({
|
||||
name: 'AgentDetail',
|
||||
component: () => import('../../views/dev/AgentDetail.vue')
|
||||
},
|
||||
{
|
||||
path: 'tool-marketplace',
|
||||
name: 'ToolMarketplace',
|
||||
component: () => import('../../views/dev/ToolMarketplace.vue')
|
||||
},
|
||||
{
|
||||
path: 'tool-marketplace/:name',
|
||||
name: 'ToolDetail',
|
||||
component: () => import('../../views/dev/ToolDetail.vue')
|
||||
},
|
||||
{
|
||||
path: 'publish-tool',
|
||||
name: 'PublishTool',
|
||||
component: () => import('../../views/dev/PublishTool.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: 'app-marketplace/:name',
|
||||
name: 'AppDetail',
|
||||
@ -197,9 +176,63 @@ const router = createRouter({
|
||||
name: 'MyPublishedAgents',
|
||||
component: () => import('../../views/dev/MyPublishedAgents.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
// 工具相关路由 - 不使用 /app 前缀,但仍使用 AppLayout
|
||||
{
|
||||
path: '/tools',
|
||||
name: 'ToolsLayout',
|
||||
component: () => import('../layouts/AppLayout.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'Tools',
|
||||
component: () => import('../../views/Tools.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/tool-marketplace',
|
||||
name: 'ToolMarketplaceLayout',
|
||||
component: () => import('../layouts/AppLayout.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'ToolMarketplace',
|
||||
component: () => import('../../views/dev/ToolMarketplace.vue')
|
||||
},
|
||||
{
|
||||
path: 'my-published-tools',
|
||||
path: ':name',
|
||||
name: 'ToolDetail',
|
||||
component: () => import('../../views/dev/ToolDetail.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/publish-tool',
|
||||
name: 'PublishToolLayout',
|
||||
component: () => import('../layouts/AppLayout.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'PublishTool',
|
||||
component: () => import('../../views/dev/PublishTool.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/my-published-tools',
|
||||
name: 'MyPublishedToolsLayout',
|
||||
component: () => import('../layouts/AppLayout.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'MyPublishedTools',
|
||||
component: () => import('../../views/dev/MyPublishedTools.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
|
||||
@ -14,8 +14,7 @@ function generateRouteName(toolName: string): string {
|
||||
}
|
||||
|
||||
function generateRoutePath(toolName: string): string {
|
||||
const pathName = toolName.replace(/_/g, '-')
|
||||
return `tools/${pathName}`
|
||||
return toolName.replace(/_/g, '-')
|
||||
}
|
||||
|
||||
export function ensureToolRoutes(tool: Tool): Tool {
|
||||
@ -60,7 +59,7 @@ export function registerToolRoute(
|
||||
|
||||
const routePath = toolWithRoutes.routePath || (() => {
|
||||
const toolDirName = toolWithRoutes.toolName || toolWithRoutes.id
|
||||
return `tools/${toolDirName.replace(/_/g, '-')}`
|
||||
return toolDirName.replace(/_/g, '-')
|
||||
})()
|
||||
|
||||
const route: RouteRecordRaw = {
|
||||
@ -106,7 +105,7 @@ export function registerToolRoute(
|
||||
}
|
||||
|
||||
try {
|
||||
router.addRoute('AppLayout', route)
|
||||
router.addRoute('ToolsLayout', route)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.error(`Failed to register tool route ${toolWithRoutes.routeName}:`, error)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user