mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-06 00:05:34 +00:00
refactor(ai): align menu order and simplify model routes (#14308)
This commit is contained in:
@@ -86,7 +86,7 @@ func (u *LauncherRepo) ListQuickJump(withAll bool) []model.QuickJump {
|
||||
}
|
||||
if !withAll && len(quicks) == 0 {
|
||||
return []model.QuickJump{
|
||||
{Name: "ModelServices", Title: "aiTools.model.model", Recommend: 0, IsShow: true, Router: "/ai/model"},
|
||||
{Name: "ModelServices", Title: "aiTools.model.model", Recommend: 0, IsShow: true, Router: "/ai/model-services"},
|
||||
{Name: "Agent", Title: "aiTools.agents.agent", Recommend: 1, IsShow: true, Router: "/ai/agents/agent"},
|
||||
{Name: "Website", Title: "menu.website", Recommend: 10, IsShow: true, Router: "/websites"},
|
||||
{Name: "Database", Title: "menu.database", Recommend: 30, IsShow: true, Router: "/databases"},
|
||||
|
||||
@@ -120,6 +120,7 @@ func agentDBMigrations() []*gormigrate.Migration {
|
||||
migrations.AddContainerImageCheckUpdates,
|
||||
migrations.AddModelQuickJump,
|
||||
migrations.MigrateVMDatabase,
|
||||
migrations.UpdateModelServicesQuickJumpRouter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1938,3 +1938,12 @@ var AddModelQuickJump = &gormigrate.Migration{
|
||||
}).Error
|
||||
},
|
||||
}
|
||||
|
||||
var UpdateModelServicesQuickJumpRouter = &gormigrate.Migration{
|
||||
ID: "20261105-update-model-services-quick-jump-router",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return tx.Model(&model.QuickJump{}).
|
||||
Where("name = ? AND router IN ?", "ModelServices", []string{"/ai/model", "/ai/model/account"}).
|
||||
Update("router", "/ai/model-services").Error
|
||||
},
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ var WebUrlMap = map[string]struct{}{
|
||||
"/apps/upgrade": {},
|
||||
"/apps/setting": {},
|
||||
|
||||
"/ai/ollama": {},
|
||||
"/ai/model-services": {},
|
||||
"/ai/vllm": {},
|
||||
"/ai/vllm/models": {},
|
||||
"/ai/vllm/deployments": {},
|
||||
"/ai": {},
|
||||
"/ai/ai-proxy": {},
|
||||
"/ai/ai-proxy/overview": {},
|
||||
@@ -71,12 +76,6 @@ var WebUrlMap = map[string]struct{}{
|
||||
"/ai/skills-hub": {},
|
||||
"/ai/skills-hub/targets": {},
|
||||
"/ai/benchmark": {},
|
||||
"/ai/model": {},
|
||||
"/ai/model/account": {},
|
||||
"/ai/model/local": {},
|
||||
"/ai/model/local/ollama": {},
|
||||
"/ai/model/local/templates": {},
|
||||
"/ai/model/files": {},
|
||||
"/ai/gpu": {},
|
||||
"/ai/gpu/current": {},
|
||||
"/ai/gpu/history": {},
|
||||
|
||||
@@ -96,14 +96,14 @@ func LoadMenus() string {
|
||||
item := []dto.ShowMenu{
|
||||
{ID: "1", Disabled: true, Title: "menu.home", IsShow: true, Label: "Home-Menu", Path: "/", Sort: 100},
|
||||
{ID: "2", Disabled: true, Title: "menu.apps", IsShow: true, Label: "App-Menu", Path: "/apps/all", Sort: 200},
|
||||
{ID: "3", Disabled: false, Title: "menu.aiTools", IsShow: true, Label: "AI-Menu", Path: "/ai/model/files", Sort: 300,
|
||||
{ID: "3", Disabled: false, Title: "menu.aiTools", IsShow: true, Label: "AI-Menu", Path: "/ai/vllm/models", Sort: 300,
|
||||
Children: []dto.ShowMenu{
|
||||
{ID: "48", Disabled: false, Title: "aiTools.model.ollamaManagement", IsShow: true, Label: "OllamaModels", Path: "/ai/model/local/ollama", Sort: 25},
|
||||
{ID: "41", Disabled: false, Title: "aiTools.model.vllmManagement", IsShow: true, Label: "AIModel", Path: "/ai/model/files", Sort: 50},
|
||||
{ID: "49", Disabled: false, Title: "aiTools.model.services", IsShow: true, Label: "ModelServices", Path: "/ai/model/account", Sort: 75},
|
||||
{ID: "44", Disabled: false, Title: "aiTools.agents.agent", IsShow: true, Label: "Agents", Path: "/ai/agents/agent", Sort: 100},
|
||||
{ID: "43", Disabled: false, Title: "aiTools.gpu.gpu", IsShow: true, Label: "GPU", Path: "/ai/gpu", Sort: 10},
|
||||
{ID: "48", Disabled: false, Title: "aiTools.model.ollamaManagement", IsShow: true, Label: "OllamaModels", Path: "/ai/ollama", Sort: 25},
|
||||
{ID: "41", Disabled: false, Title: "aiTools.model.vllmManagement", IsShow: true, Label: "AIModel", Path: "/ai/vllm/models", Sort: 50},
|
||||
{ID: "49", Disabled: false, Title: "aiTools.model.services", IsShow: true, Label: "ModelServices", Path: "/ai/model-services", Sort: 75},
|
||||
{ID: "44", Disabled: false, Title: "aiTools.agents.agent", IsShow: true, Label: "Agents", Path: "/ai/agents/agent", Sort: 150},
|
||||
{ID: "42", Disabled: false, Title: "menu.mcp", IsShow: true, Label: "MCPServer", Path: "/ai/mcp", Sort: 200},
|
||||
{ID: "43", Disabled: false, Title: "aiTools.gpu.gpu", IsShow: true, Label: "GPU", Path: "/ai/gpu", Sort: 300},
|
||||
}},
|
||||
{ID: "4", Disabled: false, Title: "menu.website", IsShow: true, Label: "Website-Menu", Path: "/websites", Sort: 400,
|
||||
Children: []dto.ShowMenu{
|
||||
@@ -151,8 +151,8 @@ func LoadMenus() string {
|
||||
IsShow: true,
|
||||
Label: "AIProxyManagement",
|
||||
Path: "/ai/ai-proxy/model-pool",
|
||||
Sort: 150,
|
||||
}, "Agents")
|
||||
Sort: 125,
|
||||
}, "ModelServices")
|
||||
item[i].Children = UpsertMenuByLabel(item[i].Children, dto.ShowMenu{
|
||||
ID: "47",
|
||||
Disabled: false,
|
||||
@@ -161,7 +161,7 @@ func LoadMenus() string {
|
||||
Label: "SkillsHub",
|
||||
Path: "/ai/skills-hub",
|
||||
Sort: 175,
|
||||
}, "AIProxyManagement")
|
||||
}, "Agents")
|
||||
item[i].Children = UpsertMenuByLabel(item[i].Children, dto.ShowMenu{
|
||||
ID: "45",
|
||||
Disabled: false,
|
||||
@@ -169,8 +169,8 @@ func LoadMenus() string {
|
||||
IsShow: true,
|
||||
Label: "AIBenchmark",
|
||||
Path: "/ai/benchmark",
|
||||
Sort: 350,
|
||||
}, "GPU")
|
||||
Sort: 100,
|
||||
}, "ModelServices")
|
||||
continue
|
||||
}
|
||||
if item[i].Label != "Xpack-Menu" {
|
||||
@@ -206,15 +206,15 @@ func MenuSort() []dto.MenuLabelSort {
|
||||
{Label: "Home-Menu", Sort: 100},
|
||||
{Label: "App-Menu", Sort: 200},
|
||||
{Label: "AI-Menu", Sort: 300},
|
||||
{Label: "GPU", Sort: 10},
|
||||
{Label: "OllamaModels", Sort: 25},
|
||||
{Label: "AIModel", Sort: 50},
|
||||
{Label: "ModelServices", Sort: 75},
|
||||
{Label: "Agents", Sort: 100},
|
||||
{Label: "AIProxyManagement", Sort: 150},
|
||||
{Label: "AIBenchmark", Sort: 100},
|
||||
{Label: "AIProxyManagement", Sort: 125},
|
||||
{Label: "Agents", Sort: 150},
|
||||
{Label: "SkillsHub", Sort: 175},
|
||||
{Label: "MCPServer", Sort: 200},
|
||||
{Label: "GPU", Sort: 300},
|
||||
{Label: "AIBenchmark", Sort: 350},
|
||||
{Label: "Website-Menu", Sort: 400},
|
||||
{Label: "Website", Sort: 100},
|
||||
{Label: "SSL", Sort: 200},
|
||||
|
||||
@@ -76,5 +76,6 @@ func coreMigrations() []*gormigrate.Migration {
|
||||
migrations.MoveVirtualMachineMenuToTopLevel,
|
||||
migrations.UpdateAiModelManagementMenus,
|
||||
migrations.AddModelServicesMenu,
|
||||
migrations.UpdateAiMenus,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1490,3 +1490,47 @@ var UpdateFirewallMenuPath = &gormigrate.Migration{
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
var UpdateAiMenus = &gormigrate.Migration{
|
||||
ID: "20261105-update-ai-menus",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return helper.UpdateHideMenu(tx, func(menus []dto.ShowMenu) []dto.ShowMenu {
|
||||
sorts := map[string]int{
|
||||
"GPU": 10,
|
||||
"OllamaModels": 25,
|
||||
"AIModel": 50,
|
||||
"ModelServices": 75,
|
||||
"AIBenchmark": 100,
|
||||
"AIProxyManagement": 125,
|
||||
"Agents": 150,
|
||||
"SkillsHub": 175,
|
||||
"MCPServer": 200,
|
||||
}
|
||||
paths := map[string]string{
|
||||
"/ai/model": "/ai/vllm",
|
||||
"/ai/model/files": "/ai/vllm/models",
|
||||
"/ai/model/local": "/ai/vllm/deployments",
|
||||
"/ai/model/local/ollama": "/ai/ollama",
|
||||
"/ai/model/account": "/ai/model-services",
|
||||
}
|
||||
for i := range menus {
|
||||
if menus[i].Label != "AI-Menu" {
|
||||
continue
|
||||
}
|
||||
if path, ok := paths[menus[i].Path]; ok {
|
||||
menus[i].Path = path
|
||||
}
|
||||
for j := range menus[i].Children {
|
||||
if sort, ok := sorts[menus[i].Children[j].Label]; ok {
|
||||
menus[i].Children[j].Sort = sort
|
||||
}
|
||||
if path, ok := paths[menus[i].Children[j].Path]; ok {
|
||||
menus[i].Children[j].Path = path
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
return menus
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,14 +6,25 @@ const aiRouter = {
|
||||
path: '/ai',
|
||||
name: 'AI-Menu',
|
||||
component: Layout,
|
||||
redirect: '/ai/model/account',
|
||||
redirect: '/ai/model-services',
|
||||
meta: {
|
||||
icon: 'p-jiqiren2',
|
||||
title: 'menu.aiTools',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/ai/model/local/ollama',
|
||||
path: '/ai/gpu/current',
|
||||
name: 'GPU',
|
||||
component: () => import('@/views/ai/gpu/current/index.vue'),
|
||||
meta: {
|
||||
icon: 'p-gpu-menu',
|
||||
title: 'aiTools.gpu.gpu',
|
||||
activeMenu: '/ai/gpu/current',
|
||||
permission: 'ai_gpu_view',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/ai/ollama',
|
||||
name: 'OllamaModels',
|
||||
component: () => import('@/views/ai/ollama/index.vue'),
|
||||
meta: {
|
||||
@@ -23,13 +34,13 @@ const aiRouter = {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/ai/model/account',
|
||||
path: '/ai/model-services',
|
||||
name: 'ModelServices',
|
||||
component: () => import('@/views/ai/model/index.vue'),
|
||||
meta: {
|
||||
icon: 'p-moxing-menu',
|
||||
title: 'aiTools.model.services',
|
||||
activeMenu: '/ai/model/account',
|
||||
activeMenu: '/ai/model-services',
|
||||
permission: 'ai_model_view',
|
||||
},
|
||||
},
|
||||
@@ -75,17 +86,6 @@ const aiRouter = {
|
||||
permission: 'mcp_access_view',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/ai/gpu/current',
|
||||
name: 'GPU',
|
||||
component: () => import('@/views/ai/gpu/current/index.vue'),
|
||||
meta: {
|
||||
icon: 'p-gpu-menu',
|
||||
title: 'aiTools.gpu.gpu',
|
||||
activeMenu: '/ai/gpu/current',
|
||||
permission: 'ai_gpu_view',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/ai/gpu/history',
|
||||
name: 'GPUHistory',
|
||||
|
||||
@@ -41,7 +41,7 @@ export const jumpToInstall = (type: string, key: string) => {
|
||||
case 'vllm':
|
||||
if (globalStore.isProductPro && router.hasRoute('LocalModel')) {
|
||||
router.push({
|
||||
path: '/ai/model/local',
|
||||
path: '/ai/vllm/deployments',
|
||||
query: {
|
||||
engine: 'vllm',
|
||||
uncached: 'true',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="model-page">
|
||||
<RouterButton :buttons="[{ label: $t('aiTools.model.services'), path: '/ai/model/account' }]" />
|
||||
<RouterButton :buttons="[{ label: $t('aiTools.model.services'), path: '/ai/model-services' }]" />
|
||||
<LayoutContent v-loading="loading">
|
||||
<template #leftToolBar>
|
||||
<el-button v-permission type="primary" @click="createRef.open()">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<RouterButton :buttons="[{ label: $t('aiTools.model.ollamaManagement'), path: '/ai/model/local/ollama' }]" />
|
||||
<RouterButton :buttons="[{ label: $t('aiTools.model.ollamaManagement'), path: '/ai/ollama' }]" />
|
||||
<OllamaModels :key="currentNode" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user