feat: implement backend API for installing hook templates in HookManager and HookWizard components

This commit is contained in:
catlog22
2026-03-03 10:26:32 +08:00
parent 25f766ef26
commit 9cfd5c05fc
3 changed files with 86 additions and 132 deletions

View File

@@ -268,12 +268,25 @@ export function HookManagerPage() {
setInstallingTemplateId(templateId);
try {
await installHookTemplate(template.trigger, {
id: template.id,
command: template.command,
args: template.args ? [...template.args] : undefined,
matcher: template.matcher,
// Use backend API to install template
const response = await fetch('/api/hooks/templates/install', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
templateId,
scope: 'project',
}),
});
if (!response.ok) {
throw new Error(`Failed to install template: ${response.statusText}`);
}
const result = await response.json();
if (!result.success) {
throw new Error(result.error || 'Unknown error');
}
await refetch();
} catch (error) {
console.error('Failed to install template:', error);