diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 91e547d..b14aeeb 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -34,6 +34,7 @@ src/ health.ts GET /health shared/ api.ts 前后端共享 TypeScript 类型 + app.ts 应用全局常量(name、title、subtitle、description、version) web/ React 前端(通过 Vite 构建) index.html HTML 入口 app.tsx 根组件(Layout + Header + Content,/health 联调示例展示) @@ -161,6 +162,7 @@ export function handleHealth(mode: RuntimeMode): Response; ### 1.5 类型定义规范 - **共享类型**以 `src/shared/api.ts` 为唯一源头,前后端共同引用 +- **应用常量**以 `src/shared/app.ts` 为唯一源头,定义 `APP` 对象(name、title、subtitle、description、version),前后端及构建脚本共同引用 - 前端不得 `import src/server/` 下的任何文件 - **严格联合类型**优先于宽类型:如 `RuntimeMode: "development" | "production" | "test"` 而非 `RuntimeMode: string` - API 响应类型(`ApiErrorResponse`、`HealthResponse`)定义在 shared 中 @@ -233,7 +235,7 @@ main.tsx hooks/use-theme-preference.ts(浏览器 UI 偏好) ├── ThemePreference: system / light / dark(RadioGroup 受控值) ├── EffectiveTheme: light / dark(写入 document.documentElement theme-mode) -├── localStorage key: my-app.theme.preference(同一浏览器记忆) +├── localStorage key: theme.preference(同一浏览器记忆) └── matchMedia("(prefers-color-scheme: dark)")(系统模式下跟随系统明暗变化) ``` diff --git a/README.md b/README.md index d3a8da0..52f12e5 100644 --- a/README.md +++ b/README.md @@ -25,23 +25,23 @@ cd my-project rm -rf .git && git init ``` -### 2. 替换占位符 `my-app` +### 2. 配置应用信息 -在整个项目中全局搜索替换 `my-app` 为你的项目名称(如 `your-project`)。以下为所有出现位置: +编辑 `src/shared/app.ts`,修改应用元信息: -| # | 文件 | 说明 | -| --- | --------------------------------------- | ------------------------------------------ | -| 1 | `package.json` | `name` 字段 | -| 2 | `scripts/build.ts` | 可执行文件路径 | -| 3 | `src/server/config.ts` | CLI 帮助文本 | -| 4 | `src/server/helpers.ts` | `createHealthResponse()` 的 `service` 字段 | -| 5 | `src/server/server.ts` | 服务启动日志消息 | -| 6 | `src/web/index.html` | `
在此构建你的应用。以下是 /health API 的返回数据(前后端联调示例):
{health &&{JSON.stringify(health, null, 2)}}