Implement webhook

This commit is contained in:
Xin Wang
2026-08-07 14:08:49 +08:00
parent 39ee5ef96e
commit b2e99baa19
14 changed files with 886 additions and 34 deletions
+39
View File
@@ -114,6 +114,45 @@ export const authApi = {
me: () => request<AdminUser>("/api/auth/me"),
};
// ---------- 站点级设置 ----------
export type AnalysisWebhookSetting = {
enabled: boolean;
url: string;
secretConfigured: boolean;
updatedAt: string | null;
};
export type AnalysisWebhookTestResult = {
ok: boolean;
statusCode: number | null;
latencyMs: number | null;
message: string;
payload: Record<string, unknown>;
};
export const siteSettingsApi = {
getAnalysisWebhook: () =>
request<AnalysisWebhookSetting>("/api/settings/analysis-webhook"),
updateAnalysisWebhook: (body: {
enabled: boolean;
url: string;
secret?: string;
clearSecret?: boolean;
}) =>
request<AnalysisWebhookSetting>("/api/settings/analysis-webhook", {
method: "PUT",
body: JSON.stringify(body),
}),
testAnalysisWebhook: (body: { url: string; secret?: string }) =>
request<AnalysisWebhookTestResult>(
"/api/settings/analysis-webhook/test",
{
method: "POST",
body: JSON.stringify(body),
},
),
};
// ---------- 接口定义驱动的模型注册表 ----------
export type InterfaceField = {
key: string;