From ea3c18052f439caa4c830d73b210ad95aabb8b7f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Aug 2026 16:54:45 +0000 Subject: [PATCH] =?UTF-8?q?docs(runner):=20=C2=A7Add=20Custom=20Routes=20?= =?UTF-8?q?=E6=94=B9=E5=86=99=E4=B8=BA=E6=8C=87=E5=90=91=20Add=20Custom=20?= =?UTF-8?q?Schemas=20=E7=9A=84=E5=85=83=E6=95=B0=E6=8D=AE=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E8=AF=B4=E6=98=8E=20(#3618)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `### Add Custom Routes` 让读者 "Edit src/App.tsx" 并给了一段 react-router 代码。 两处与实现相反: 1. `react-router-dom` 不在 `packages/runner/package.json` 的任何依赖里(dependencies 只有 @object-ui/{components,core,plugin-charts,plugin-kanban,react,types} + class-variance-authority / clsx / lucide-react / react / react-dom / tailwind-merge / tailwindcss-animate),全包 grep 'react-router' 零命中 —— 照抄直接 Failed to resolve import。 2. Runner 不是这个路由模型。App.tsx:83 用 useState 持有 currentPath,:120 history.pushState 导航,:127 监听 popstate,:137 把路径喂给 loader.loadPage(currentPath) —— 路由由元数据决定,没有路由表可改。 示例里的 Home / Dashboard / CustomPage 三个组件包里同样不存在。 处置取"保留标题 + 改写为正确说明"而非整节删除:与 #3538/#3633 删掉的 `## Environment Variables` / `### 2. Environment Configuration` 不同,那两处描述的 配置面在实现里**不存在**,删掉即无残留问题;而"加路由"是 Runner 真实支持的能力, 只是机制不同(加 JSON 文件),答案就在同页 40 行之下的 `### Add Custom Schemas`。 删掉标题会让按"routes"检索的读者一无所获,并可能重新自行推导出"改 App.tsx"的错误 直觉。本页已有同形态先例:`### Metadata — Supplied by You`(:59)同样是"短说明 + 指向权威小节"的路标节,两处 [Metadata Loading](#metadata-loading) 交叉引用(:63、 :87)也证明页内锚点是本页既有节奏。 `#add-custom-routes` 锚点全仓无任何引用(grep 零命中),故两种处置都不会断链; 保留标题额外保住了站外深链。 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt --- content/docs/utilities/runner.mdx | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/content/docs/utilities/runner.mdx b/content/docs/utilities/runner.mdx index 355c350f19..db5f6168f8 100644 --- a/content/docs/utilities/runner.mdx +++ b/content/docs/utilities/runner.mdx @@ -408,23 +408,12 @@ Key dependencies: ### Add Custom Routes -Edit `src/App.tsx`: - -```typescript -import { BrowserRouter, Routes, Route } from 'react-router-dom' - -function App() { - return ( - - - } /> - } /> - } /> - - - ) -} -``` +There is no route table to edit and no router dependency to install — the Runner derives +routes from metadata. `src/App.tsx` keeps the current path in state, navigates with +`history.pushState`, and asks the active loader for whatever page answers that path. So +adding a route means adding the page document it resolves to: see +[Add Custom Schemas](#add-custom-schemas) below, and [Metadata Loading](#metadata-loading) +for how a route maps to a file or a request. ### Add Custom Components