diff --git a/admin/components/ConsolePage.vue b/admin/components/ConsolePage.vue new file mode 100644 index 0000000..f4a8abb --- /dev/null +++ b/admin/components/ConsolePage.vue @@ -0,0 +1,456 @@ + + + diff --git a/admin/pages/[...slug].vue b/admin/pages/[...slug].vue deleted file mode 100644 index eff5d5f..0000000 --- a/admin/pages/[...slug].vue +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/admin/pages/admin.vue b/admin/pages/admin.vue index 01a9ec6..771b572 100644 --- a/admin/pages/admin.vue +++ b/admin/pages/admin.vue @@ -1,440 +1,3 @@ - - diff --git a/admin/pages/admin/[slug].vue b/admin/pages/admin/[slug].vue new file mode 100644 index 0000000..771b572 --- /dev/null +++ b/admin/pages/admin/[slug].vue @@ -0,0 +1,3 @@ + diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 25eb040..9cf3e65 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -56,6 +56,8 @@ WebHooker ships with a built-in config console at `/admin` for managing routes i ### Endpoints +The console is served as an SPA at `/admin`; its tabs are deep-linkable via the URL path (`/admin/groups`, `/admin/logs`, `/admin/audit`). URLs outside `/admin` that do not match an endpoint below return a plain `404` instead of the console. + | Endpoint | Description | | ----------------------------------------- | -------------------------------------------- | | `GET /admin` | Config console UI | diff --git a/docs/zh/guide/configuration.md b/docs/zh/guide/configuration.md index 7fff21d..ef6d38f 100644 --- a/docs/zh/guide/configuration.md +++ b/docs/zh/guide/configuration.md @@ -56,6 +56,8 @@ WebHooker 内置了位于 `/admin` 的配置控制台,可在浏览器中管理 ### 端点 +控制台以 SPA 形式挂在 `/admin`,各标签页可通过 URL 路径直达(`/admin/groups`、`/admin/logs`、`/admin/audit`)。`/admin` 之外且未匹配下方端点的 URL 直接返回 `404`,不会再被吞进控制台。 + | 端点 | 说明 | | ------------------------------------- | ------------------------------------ | | `GET /admin` | 配置控制台页面 | diff --git a/src/server.ts b/src/server.ts index b404ea5..6df056e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -79,7 +79,18 @@ export function createServer(): Hono<{ Bindings: Env }> { app.notFound((c) => { if (c.env.ASSETS) { - return c.env.ASSETS.fetch(c.req.raw); + // The console SPA (and its _nuxt chunks) lives under /admin; the worker + // already owns /admin/api, /admin/login|logout|invite. Serve the SPA + // only for admin-scoped paths — every other unknown URL is a plain 404 + // instead of being swallowed into the console. + const pathname = new URL(c.req.url).pathname; + if ( + pathname === "/admin" || + pathname.startsWith("/admin/") || + pathname.startsWith("/_nuxt/") + ) { + return c.env.ASSETS.fetch(c.req.raw); + } } return c.json({ error: "Not found" }, 404); });