diff --git a/docs/development.md b/docs/development.md index f7fe43a..80d26fc 100644 --- a/docs/development.md +++ b/docs/development.md @@ -253,7 +253,7 @@ npm test -- --watch - Web 前端:rsbuild 开发服务器,端口 **5173** - CLI 内容服务器:`tttk serve`,端口 **3000**(内容 API + Journal) -rsbuild 会把 `/__CONTENT_INDEX.json`、`/__COMPLETIONS.json`、`/content`、`/.ttrpg` 代理到 CLI 的 +rsbuild 会把 `/__CONTENT_INDEX.json`、`/__COMPLETIONS.json`、`/__CONTENT_REGISTRY.json`、`/content`、`/.ttrpg` 代理到 CLI 的 3000 端口,因此必须先启动 CLI,否则前端拿不到内容。 ### Web 开发 diff --git a/rsbuild.config.ts b/rsbuild.config.ts index 53dfcbe..5b495c3 100644 --- a/rsbuild.config.ts +++ b/rsbuild.config.ts @@ -55,6 +55,7 @@ export default defineConfig({ // Proxy content API requests to the CLI dev server (npm run tttk) "/__CONTENT_INDEX.json": "http://localhost:3000", "/__COMPLETIONS.json": "http://localhost:3000", + "/__CONTENT_REGISTRY.json": "http://localhost:3000", "/content": "http://localhost:3000", "/.ttrpg": "http://localhost:3000", }, diff --git a/src/components/journal/completions.ts b/src/components/journal/completions.ts index 59c89f3..17cae7c 100644 --- a/src/components/journal/completions.ts +++ b/src/components/journal/completions.ts @@ -138,8 +138,11 @@ const _initPromise: Promise = (async () => { // 1. Try server first (CLI mode) const serverData = await tryServer(); if (serverData) { - setCompletionsState({ status: "loaded", data: serverData }); + // Load the registry before publishing the loaded state: dispatching a + // command only becomes possible once completions are "loaded", and inline + // spark-table CSVs are resolved through this registry at roll time. await tryServerRegistry(); + setCompletionsState({ status: "loaded", data: serverData }); try { initReactivity({ declarations: serverData.declarations, diff --git a/src/data-loader/file-index.ts b/src/data-loader/file-index.ts index 0f5107d..d31c72b 100644 --- a/src/data-loader/file-index.ts +++ b/src/data-loader/file-index.ts @@ -8,7 +8,7 @@ * Dev 工作流:运行 CLI 服务器并在 rsbuild 配置中设置代理 * > npm run tttk serve ./content * > npm run dev - * rsbuild 会将 /__CONTENT_INDEX.json、/__COMPLETIONS.json、/content/ 代理到 CLI 服务器 + * rsbuild 会将 /__CONTENT_INDEX.json、/__COMPLETIONS.json、/__CONTENT_REGISTRY.json、/content/ 代理到 CLI 服务器 */ import {