Add proxy install session client API

This commit is contained in:
RWDai
2026-05-14 19:34:56 +08:00
parent 2db85b1c53
commit 98a54b4633
2 changed files with 31 additions and 0 deletions

View File

@@ -164,6 +164,20 @@ export interface ManualProxyNodeUpdateRequest {
region?: string
}
export interface ProxyNodeInstallSessionCreateRequest {
node_name: string
}
export interface ProxyNodeInstallSession {
install_code: string
expires_at_unix_secs: number
expires_in_seconds: number
node_name: string
aether_url: string
unix_command: string
powershell_command: string
}
export interface ProxyNodeTestResult {
success: boolean
latency_ms: number | null
@@ -245,6 +259,11 @@ export const proxyNodesApi = {
return response.data
},
async createInstallSession(data: ProxyNodeInstallSessionCreateRequest): Promise<ProxyNodeInstallSession> {
const response = await apiClient.post<ProxyNodeInstallSession>('/api/admin/proxy-nodes/install-sessions', data)
return response.data
},
async updateManualNode(nodeId: string, data: ManualProxyNodeUpdateRequest): Promise<{ node_id: string; node: ProxyNode }> {
const response = await apiClient.patch<{ node_id: string; node: ProxyNode }>(`/api/admin/proxy-nodes/${nodeId}`, data)
return response.data

View File

@@ -4,6 +4,8 @@ import {
proxyNodesApi,
type ManualProxyNodeCreateRequest,
type ProxyNode,
type ProxyNodeInstallSession,
type ProxyNodeInstallSessionCreateRequest,
type ProxyNodeUpgradeRolloutStatus,
} from '@/api/proxy-nodes'
import { parseApiError } from '@/utils/errorParser'
@@ -68,6 +70,15 @@ export const useProxyNodesStore = defineStore('proxy-nodes', () => {
}
}
async function createInstallSession(data: ProxyNodeInstallSessionCreateRequest): Promise<ProxyNodeInstallSession> {
try {
return await proxyNodesApi.createInstallSession(data)
} catch (err: unknown) {
error.value = parseApiError(err, '生成代理节点安装命令失败')
throw err
}
}
async function deleteNode(nodeId: string) {
loading.value = true
error.value = null
@@ -95,6 +106,7 @@ export const useProxyNodesStore = defineStore('proxy-nodes', () => {
fetchNodes,
ensureLoaded,
createManualNode,
createInstallSession,
deleteNode,
}
})