diff --git a/web/src/api/index.ts b/web/src/api/index.ts index 94b2594..e3f24f7 100644 --- a/web/src/api/index.ts +++ b/web/src/api/index.ts @@ -206,6 +206,19 @@ export const api = { reinstall: (id: number) => request(`/deps/reinstall/${id}`, { method: 'POST' }), reinstallAll: (type: string) => request(`/deps/reinstall-all?type=${type}`, { method: 'POST' }), getInstalled: (type: string) => request(`/deps/installed?type=${type}`) + }, + agents: { + list: () => request('/agents'), + listPending: () => request('/agents/pending'), + getVersion: () => request<{ version: string; platforms: { os: string; arch: string; filename: string }[] }>('/agents/version'), + approve: (id: number) => request('/agents/' + id + '/approve', { method: 'POST' }), + reject: (id: number) => request('/agents/' + id + '/reject', { method: 'POST' }), + update: (id: number, data: { name: string; description?: string; enabled: boolean }) => + request('/agents/' + id, { method: 'PUT', body: JSON.stringify(data) }), + delete: (id: number) => request('/agents/' + id, { method: 'DELETE' }), + regenerateToken: (id: number) => request<{ token: string }>('/agents/' + id + '/token', { method: 'POST' }), + forceUpdate: (id: number) => request('/agents/' + id + '/update', { method: 'POST' }), + downloadUrl: (os: string, arch: string) => `${BASE_URL}/agent/download?os=${os}&arch=${arch}` } } @@ -227,6 +240,7 @@ export interface Task { work_dir: string clean_config: string envs: string + agent_id: number | null enabled: boolean last_run: string next_run: string @@ -375,3 +389,19 @@ export interface Dependency { created_at: string updated_at: string } + +export interface Agent { + id: number + name: string + token: string + description: string + status: string + last_seen: string + ip: string + version: string + build_time: string + hostname: string + enabled: boolean + created_at: string + updated_at: string +} diff --git a/web/src/layouts/MainLayout.vue b/web/src/layouts/MainLayout.vue index a642618..54732e2 100644 --- a/web/src/layouts/MainLayout.vue +++ b/web/src/layouts/MainLayout.vue @@ -2,7 +2,7 @@ import { ref, onMounted } from 'vue' import { RouterLink, RouterView, useRoute } from 'vue-router' import { resetAuthCache } from '@/router' -import { LayoutDashboard, ListTodo, FileCode, Settings, LogOut, ScrollText, Terminal, Variable, KeyRound, Package, Menu, X } from 'lucide-vue-next' +import { LayoutDashboard, ListTodo, FileCode, Settings, LogOut, ScrollText, Terminal, Variable, KeyRound, Package, Menu, X, Server } from 'lucide-vue-next' import { Button } from '@/components/ui/button' import ThemeToggle from '@/components/ThemeToggle.vue' import { api } from '@/api' @@ -16,6 +16,7 @@ const mobileMenuOpen = ref(false) const navItems = [ { to: '/', icon: LayoutDashboard, label: '数据仪表', exact: true }, { to: '/tasks', icon: ListTodo, label: '定时任务', exact: true }, + { to: '/agents', icon: Server, label: '远程执行', exact: true }, { to: '/editor', icon: FileCode, label: '脚本编辑', exact: false }, { to: '/history', icon: ScrollText, label: '执行历史', exact: true }, { to: '/environments', icon: Variable, label: '环境变量', exact: true }, diff --git a/web/src/router/index.ts b/web/src/router/index.ts index 183583d..d5c35a3 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -39,6 +39,7 @@ const router = createRouter({ { path: 'editor/:path(.*)?', name: 'editor', component: () => import('@/views/editor/Editor.vue') }, { path: 'environments', name: 'environments', component: () => import('@/views/environments/Environments.vue') }, { path: 'dependencies', name: 'dependencies', component: () => import('@/views/dependencies/Dependencies.vue') }, + { path: 'agents', name: 'agents', component: () => import('@/views/agents/Agents.vue') }, { path: 'history', name: 'history', component: () => import('@/views/history/History.vue') }, { path: 'loginlogs', name: 'loginlogs', component: () => import('@/views/loginlogs/LoginLogs.vue') }, { path: 'terminal', name: 'terminal', component: () => import('@/views/terminal/Terminal.vue') }, diff --git a/web/src/views/agents/Agents.vue b/web/src/views/agents/Agents.vue new file mode 100644 index 0000000..f40361f --- /dev/null +++ b/web/src/views/agents/Agents.vue @@ -0,0 +1,381 @@ + + + +