feat(service): add deployment task integration

This commit is contained in:
mac
2026-07-21 18:26:50 +08:00
parent c324e2ec59
commit 2db8264c8e
12 changed files with 2226 additions and 382 deletions
+1
View File
@@ -17,6 +17,7 @@ declare module 'vue' {
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElOption: typeof import('element-plus/es')['ElOption']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElTable: typeof import('element-plus/es')['ElTable']
+68
View File
@@ -0,0 +1,68 @@
import { getToken } from '@/utils/auth'
export interface DeploymentCreatePayload {
component: string
business_line_id: number
params: Record<string, unknown>
}
export interface DeploymentCreateResult {
deployment_id: string
status: string
}
export const deploymentApi = {
async create(payload: DeploymentCreatePayload): Promise<DeploymentCreateResult> {
const data = await authRequest('/auth/api/v1/deployments', {
method: 'POST',
body: JSON.stringify(payload),
})
return {
deployment_id: String(data.deployment_id || ''),
status: String(data.status || ''),
}
},
async cancel(deploymentId: string): Promise<void> {
await authRequest(`/auth/api/v1/deployments/${encodeURIComponent(deploymentId)}/cancel`, {
method: 'POST',
})
},
eventsURL(deploymentId: string): string {
const token = getToken()
const params = token ? `?access_token=${encodeURIComponent(token)}` : ''
return `/auth/api/v1/deployments/${encodeURIComponent(deploymentId)}/events${params}`
},
}
async function authRequest(path: string, init: RequestInit = {}) {
const token = getToken()
const response = await fetch(path, {
...init,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...(token ? { Authorization: `Bearer ${token}` } : {}),
...init.headers,
},
})
const text = await response.text()
const data = parseResponseBody(text)
if (!response.ok) {
const message = data?.error || data?.message || text || `HTTP ${response.status}`
throw new Error(message)
}
return data || {}
}
function parseResponseBody(text: string) {
if (!text.trim()) {
return {}
}
try {
return JSON.parse(text)
} catch {
return { error: text }
}
}
+6
View File
@@ -105,6 +105,12 @@ const router = createRouter({
component: () => import('@/views/service/Catalog.vue'),
meta: { title: '基础服务' },
},
{
path: 'service/catalog/:component',
name: 'ServiceDelivery',
component: () => import('@/views/service/Catalog.vue'),
meta: { title: '基础服务交付' },
},
{
path: 'service/management',
name: 'ServiceManagement',
File diff suppressed because it is too large Load Diff