From 539f3eefcc6e76dd0c40f45d2d7fa81364711190 Mon Sep 17 00:00:00 2001 From: Awuqing <3184394176@qq.com> Date: Sun, 19 Apr 2026 16:40:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD:=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E9=94=AE=E9=83=A8=E7=BD=B2=20API=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=B8=8E=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/services/nodes.ts | 32 +++++++++++++++++++++++++++++++- web/src/types/nodes.ts | 24 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/web/src/services/nodes.ts b/web/src/services/nodes.ts index 018b16c..aa7f53b 100644 --- a/web/src/services/nodes.ts +++ b/web/src/services/nodes.ts @@ -1,5 +1,5 @@ import { http, type ApiEnvelope, unwrapApiEnvelope } from './http' -import type { NodeSummary, DirEntry } from '../types/nodes' +import type { NodeSummary, DirEntry, BatchCreateResult, InstallTokenInput, InstallTokenResult } from '../types/nodes' export async function listNodes() { const response = await http.get>('/nodes') @@ -30,3 +30,33 @@ export async function listNodeDirectory(nodeId: number, path: string) { const response = await http.get>(`/nodes/${nodeId}/fs/list`, { params: { path } }) return unwrapApiEnvelope(response.data) } + +export async function batchCreateNodes(names: string[]) { + const response = await http.post>('/nodes/batch', { names }) + return unwrapApiEnvelope(response.data) +} + +export async function createInstallToken(nodeId: number, input: InstallTokenInput) { + const response = await http.post>( + `/nodes/${nodeId}/install-tokens`, input, + ) + return unwrapApiEnvelope(response.data) +} + +export async function rotateNodeToken(nodeId: number) { + const response = await http.post>( + `/nodes/${nodeId}/rotate-token`, + ) + return unwrapApiEnvelope(response.data) +} + +export async function fetchScriptPreview( + nodeId: number, + params: { mode: string; arch: string; agentVersion: string; downloadSrc: string }, +) { + const response = await http.get(`/nodes/${nodeId}/install-script-preview`, { + params, + responseType: 'text', + }) + return response.data +} diff --git a/web/src/types/nodes.ts b/web/src/types/nodes.ts index c894b4c..3a51138 100644 --- a/web/src/types/nodes.ts +++ b/web/src/types/nodes.ts @@ -18,3 +18,27 @@ export interface DirEntry { isDir: boolean size: number } + +export type InstallMode = 'systemd' | 'docker' | 'foreground' +export type InstallArch = 'amd64' | 'arm64' | 'auto' +export type InstallSource = 'github' | 'ghproxy' + +export interface BatchCreateResult { + id: number + name: string +} + +export interface InstallTokenInput { + mode: InstallMode + arch: InstallArch + agentVersion: string + downloadSrc: InstallSource + ttlSeconds: number +} + +export interface InstallTokenResult { + installToken: string + expiresAt: string + url: string + composeUrl: string +}