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
|
|
@ -8,17 +8,10 @@ export function useInvitesApi() {
|
|||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const res = await fetch(`/admin/api/groups/${encodeURIComponent(groupId)}/invites`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify({ role }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = (await res.json().catch(() => ({}))) as { error?: string };
|
||||
throw new Error(data.error ?? `HTTP ${res.status}`);
|
||||
}
|
||||
const data = (await res.json()) as { url?: string };
|
||||
const data = await apiFetch<{ url?: string }>(
|
||||
`/admin/api/groups/${encodeURIComponent(groupId)}/invites`,
|
||||
{ method: "POST", body: JSON.stringify({ role }) },
|
||||
);
|
||||
return data.url ?? "";
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
|
|
@ -32,12 +25,9 @@ export function useInvitesApi() {
|
|||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const res = await fetch(`/admin/api/groups/${encodeURIComponent(groupId)}/invites`, {
|
||||
headers: { accept: "application/json" },
|
||||
credentials: "same-origin",
|
||||
});
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
const data = (await res.json()) as { invites?: GroupInvite[] };
|
||||
const data = await apiFetch<{ invites?: GroupInvite[] }>(
|
||||
`/admin/api/groups/${encodeURIComponent(groupId)}/invites`,
|
||||
);
|
||||
return data.invites ?? [];
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
|
|
@ -51,14 +41,7 @@ export function useInvitesApi() {
|
|||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const res = await fetch(`/admin/api/invites/${encodeURIComponent(token)}`, {
|
||||
method: "DELETE",
|
||||
credentials: "same-origin",
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = (await res.json().catch(() => ({}))) as { error?: string };
|
||||
throw new Error(data.error ?? `HTTP ${res.status}`);
|
||||
}
|
||||
await apiFetch(`/admin/api/invites/${encodeURIComponent(token)}`, { method: "DELETE" });
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
throw err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue