// CICDWebhookContent.tsx — CI/CD Webhook 弹窗内容 // 作者: Logan.Li import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { useToast } from '@/hooks/use-toast'; import { useUserStore } from '@/store'; export interface CICDWebhookContentProps { clusterCode: string; namespace: string; deploymentName: string; } export function CICDWebhookContent({ clusterCode, namespace, deploymentName }: CICDWebhookContentProps) { const { toast } = useToast(); const token = useUserStore(( s: any) => s.token) || localStorage.getItem('token') || ''; const webhookUrl = `${window.location.origin}/api/v1/clusters/${clusterCode}/namespaces/${namespace}/deployments/${deploymentName}/update-image`; const curlCmd = `curl -X POST '${webhookUrl}' \\ -H 'Authorization: Bearer ${token ? token.substring(0, 16) + '...' : 'YOUR_TOKEN'}' \\ -H 'Content-Type: application/json' \\ -d '{"image": "harbor.example.com/app:v1.0", "container": "your-container-name"}'`; const copy = (text: string) => { navigator.clipboard.writeText(text).then(() => toast({ title: '已复制' })).catch(() => {}); }; return (
{webhookUrl}
{curlCmd}
• 使用 Bearer Token 认证(JWT 登录令牌)
• image 必填,指定新镜像地址
• container 可选,不填则更新第一个容器