mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
refactor(admin): unify webui fetch/copy/format helpers; fix audit tab load and delete-group count
- apiFetch + shared needLogin (any 401 shows the login card) replaces six duplicated fetch/401/error-handling blocks in the admin composables - useCopy composable: clipboard + execCommand fallback with timed reset, used by MembersPanel and WebhookPanel - utils/format.ts (fmtTime/splitList/parseMatch) removes inline duplicates across SendLogs, AuditLog, RouteEditor and GroupEditor - fix: load the audit log when the audit tab becomes active (client-side navigation never remounted the page, leaving the list empty on first visit) - fix: fetch the real route count for a group before confirming deletion instead of reusing the currently open group's route list
This commit is contained in:
parent
c438fe96dc
commit
e59b10f739
16 changed files with 137 additions and 202 deletions
|
|
@ -12,16 +12,7 @@ export function useWebhookApi() {
|
|||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const res = await fetch(path, {
|
||||
headers: { accept: "application/json" },
|
||||
credentials: "same-origin",
|
||||
...init,
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = (await res.json().catch(() => ({}))) as { error?: string };
|
||||
throw new Error(data.error ?? `HTTP ${res.status}`);
|
||||
}
|
||||
return (await res.json()) as T;
|
||||
return await apiFetch<T>(path, init);
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
throw err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue