From 535bfa98ce0a2b2f4072c6b68423d62c11f3a77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Sat, 17 Oct 2026 11:13:09 +0800 Subject: [PATCH] feat(console): give each group its own routes URL Resolve the selected group from /admin/groups/{groupId}, validate console paths, and use browser history for back navigation. Keep Groups active and let an active mobile-tab tap return to the list. Scope pending route loads to their group and retain the count beside long headings. --- AGENTS.md | 4 +- app/components/AdminHome.vue | 2 +- app/components/ConsolePage.vue | 164 +++++++++++++++++++++--------- app/composables/useGroupRoutes.ts | 54 ++++++++-- app/composables/useGroups.ts | 4 + app/composables/useI18n.ts | 8 +- app/pages/admin/[...slug].vue | 9 ++ app/utils/admin-path.ts | 27 +++++ docs/guide/configuration.md | 2 +- docs/zh/guide/configuration.md | 2 +- tests/admin-path.test.ts | 36 +++++++ 11 files changed, 249 insertions(+), 63 deletions(-) create mode 100644 app/utils/admin-path.ts create mode 100644 tests/admin-path.test.ts diff --git a/AGENTS.md b/AGENTS.md index 3595b2b..a8923f8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord - Per-group webhook ingress: optional `POST /webhook/{groupId}` with a per-group secret in KV (`tenant:{groupId}`) — Gitea/classic-GitHub/custom webhooks are verified against the group's secret instead of the operator's global ones; only that group's routes fire. The legacy `POST /webhook` (global secrets, all routes) stays untouched - GitHub App tenant isolation: `Group.installationId` binds a group to one GitHub App installation; events whose `payload.installation.id` differs are rejected at dispatch (hard isolation on top of the optional `owners` list). The App's Setup URL points at `GET /auth/github/install`, which renders a choice page (create `inst-{installationId}` or bind to a group the signed-in user owns, verified by role); `POST /auth/github/install/bind` performs the provisioning. `installation.created` webhook events auto-provision as a fallback (create `inst-{installationId}` or bind existing groups whose `owners` match the installing account) - GitHub OAuth: octokit (token is stored hashed for reverse lookup) -- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/logs` · `/admin/audit` · `/admin/metrics`); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies +- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/groups/{groupId}` a group's routes, members and webhook · `/admin/logs` · `/admin/audit` · `/admin/metrics`, parsed by `app/utils/admin-path.ts`; the admin page's `validate` 404s any other path); every page is a history entry, so the browser's back button returns from a group to the list (no in-page back button); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies - Access control: every group has role-based members (`owner` / `admin` / `viewer`); super admins bypass; legacy `adminIds` are read as owners (backward compatible); owners manage members + invites; `owners` field stays super-only - Invites: single-use 7-day links (`invite:{token}`) for joining a group as admin/viewer; `ALLOW_SELF_SIGNUP=1` gives access-less users a personal group on first login (self-service SaaS entry) - Audit log: every admin operation (logins, group/route/member/invite changes) recorded in D1 `audit_logs`; pruned by the scheduled trigger after `AUDIT_RETENTION_DAYS` (default 90) @@ -45,7 +45,7 @@ app/ # Vue 3 UI (Nuxt app dir) │ # backdrop clicks), useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs, │ # useAudit, useInvites, useWebhook ├── types.ts # shared client types (Route, Group, Filter, ...) -└── utils/ # legal.ts (terms/privacy HTML bodies, zh/en), format.ts, +└── utils/ # legal.ts (terms/privacy HTML bodies, zh/en), format.ts, admin-path.ts (console URL parsing), # filter-catalog.ts (bilingual filter suggestions + value/path validators) server/ # Nitro server ├── routes/ # H3 handlers: /health, /webhook[/:groupId], /discord/interactions, /telegram/webhook, diff --git a/app/components/AdminHome.vue b/app/components/AdminHome.vue index fc6613d..f1d9d85 100644 --- a/app/components/AdminHome.vue +++ b/app/components/AdminHome.vue @@ -89,7 +89,7 @@ function fmtTime(ts: number): string {

{{ t("overview.recent") }}

- + {{ t("overview.viewAll") }}
diff --git a/app/components/ConsolePage.vue b/app/components/ConsolePage.vue index c74a4ae..7f53b80 100644 --- a/app/components/ConsolePage.vue +++ b/app/components/ConsolePage.vue @@ -58,7 +58,7 @@ -
+