feat: 新增应用全局常量 APP,消除硬编码散落

- 新增 src/shared/app.ts,定义应用元信息(name、title、subtitle、description、version)
- 后端 3 处硬编码改为引用 APP.name
- 前端 3 处硬编码改为引用 APP.title/APP.description
- localStorage key 从 my-app.theme.preference 改为 theme.preference
- 构建脚本可执行文件名改为引用 APP.name
- 更新 README.md 和 DEVELOPMENT.md 文档
- 新增 openspec/specs/app-constants/spec.md 规范文档
This commit is contained in:
2026-05-20 15:54:15 +08:00
parent 4a38d4dac7
commit 5aed73523e
12 changed files with 112 additions and 26 deletions

View File

@@ -4,6 +4,7 @@ import { render, screen } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement, StrictMode } from "react";
import { APP } from "../../src/shared/app";
import { App } from "../../src/web/app";
import { ErrorBoundary } from "../../src/web/components/ErrorBoundary";
@@ -46,7 +47,7 @@ describe("App", () => {
renderApp();
expect(screen.getByText("my-app")).not.toBeNull();
expect(screen.getByText(APP.title)).not.toBeNull();
expect(screen.getByText("系统")).not.toBeNull();
expect(screen.getByText("明亮")).not.toBeNull();
expect(screen.getByText("黑暗")).not.toBeNull();