From 76796613b467bee2f90d3256738519d2e30ecb9e Mon Sep 17 00:00:00 2001 From: imbytecat Date: Wed, 21 Jan 2026 15:57:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=B7=AF=E5=BE=84API=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加API路由文件以支持动态参数路径的请求处理 - 添加对 `/api/$` 路由的支持,包括路由配置、类型定义和路由树的完整集成。 --- apps/server/src/routeTree.gen.ts | 24 +++++++++++++++++++++--- apps/server/src/routes/api/$.ts | 3 +++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 apps/server/src/routes/api/$.ts diff --git a/apps/server/src/routeTree.gen.ts b/apps/server/src/routeTree.gen.ts index 1025fc0..98e1a7d 100644 --- a/apps/server/src/routeTree.gen.ts +++ b/apps/server/src/routeTree.gen.ts @@ -10,6 +10,7 @@ import { Route as rootRouteImport } from './routes/__root' import { Route as IndexRouteImport } from './routes/index' +import { Route as ApiSplatRouteImport } from './routes/api/$' import { Route as ApiRpcSplatRouteImport } from './routes/api/rpc.$' const IndexRoute = IndexRouteImport.update({ @@ -17,6 +18,11 @@ const IndexRoute = IndexRouteImport.update({ path: '/', getParentRoute: () => rootRouteImport, } as any) +const ApiSplatRoute = ApiSplatRouteImport.update({ + id: '/api/$', + path: '/api/$', + getParentRoute: () => rootRouteImport, +} as any) const ApiRpcSplatRoute = ApiRpcSplatRouteImport.update({ id: '/api/rpc/$', path: '/api/rpc/$', @@ -25,27 +31,31 @@ const ApiRpcSplatRoute = ApiRpcSplatRouteImport.update({ export interface FileRoutesByFullPath { '/': typeof IndexRoute + '/api/$': typeof ApiSplatRoute '/api/rpc/$': typeof ApiRpcSplatRoute } export interface FileRoutesByTo { '/': typeof IndexRoute + '/api/$': typeof ApiSplatRoute '/api/rpc/$': typeof ApiRpcSplatRoute } export interface FileRoutesById { __root__: typeof rootRouteImport '/': typeof IndexRoute + '/api/$': typeof ApiSplatRoute '/api/rpc/$': typeof ApiRpcSplatRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/api/rpc/$' + fullPaths: '/' | '/api/$' | '/api/rpc/$' fileRoutesByTo: FileRoutesByTo - to: '/' | '/api/rpc/$' - id: '__root__' | '/' | '/api/rpc/$' + to: '/' | '/api/$' | '/api/rpc/$' + id: '__root__' | '/' | '/api/$' | '/api/rpc/$' fileRoutesById: FileRoutesById } export interface RootRouteChildren { IndexRoute: typeof IndexRoute + ApiSplatRoute: typeof ApiSplatRoute ApiRpcSplatRoute: typeof ApiRpcSplatRoute } @@ -58,6 +68,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } + '/api/$': { + id: '/api/$' + path: '/api/$' + fullPath: '/api/$' + preLoaderRoute: typeof ApiSplatRouteImport + parentRoute: typeof rootRouteImport + } '/api/rpc/$': { id: '/api/rpc/$' path: '/api/rpc/$' @@ -70,6 +87,7 @@ declare module '@tanstack/react-router' { const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, + ApiSplatRoute: ApiSplatRoute, ApiRpcSplatRoute: ApiRpcSplatRoute, } export const routeTree = rootRouteImport diff --git a/apps/server/src/routes/api/$.ts b/apps/server/src/routes/api/$.ts new file mode 100644 index 0000000..0940eeb --- /dev/null +++ b/apps/server/src/routes/api/$.ts @@ -0,0 +1,3 @@ +import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/api/$')({})