# 分诊管理 **Repository Path**: feifei_code/triage-workbench ## Basic Information - **Project Name**: 分诊管理 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-14 - **Last Updated**: 2026-09-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DeZhen Frontend DeZhen 前端 Monorepo 工作空间,基于 Nx + Angular 21 构建。 ## 技术栈 | 类别 | 技术 | | ------ | --------------------------------------------- | | 框架 | Angular 21 (Signal First, Standalone, OnPush) | | 构建 | Nx 22 + @angular/build | | 状态 | Signal + Immer | | 样式 | Tailwind CSS + ng-zorro-antd | | 包管理 | pnpm | ## 项目结构 ``` apps/ demo # Demo 应用 demo-e2e # E2E 测试 libs/ base-ui # 基础 UI 组件(button, drawer, modal, tabs 等) business-components # 业务组件(bordered-tabs, emr, herb-order 等) cdss # 临床决策支持系统 core # 核心基础设施(base-api, server-time, signalr-hub, storage) data-access # 数据访问层(API 定义、HTTP 封装) data-engine # 数据引擎(query pipeline, runtime, registry) data-service # 业务数据服务(theme-service, user-service 等) data-store # 状态管理(theme-store, user-store 等) messaging # 消息通信(event-bus, message) shared # 共享资源(types, utils, env-config) validator-engine # 验证引擎 ``` ## 架构分层 ``` ┌─────────────────────────────────────────────────────────┐ │ Page / Component │ │ (注入 Service,处理 UI 渲染和用户交互) │ └─────────────────────────┬───────────────────────────────┘ │ ┌─────────────────────────▼───────────────────────────────┐ │ Service │ │ (业务逻辑、API 协调、消息发布、组合 data-service) │ └─────────────────────────┬───────────────────────────────┘ │ ┌─────────────────────────▼───────────────────────────────┐ │ Data Service │ │ (业务转换、缓存、过滤、聚合) │ └─────────────────────────┬───────────────────────────────┘ │ ┌─────────────────────────▼───────────────────────────────┐ │ Data Access │ │ (API 定义、类型建模、HTTP 请求、ResponseModel 解包) │ └─────────────────────────┬───────────────────────────────┘ │ ┌─────────────────────────▼───────────────────────────────┐ │ AppApiBase │ │ (URL 拼接、统一错误处理、Token 管理) │ └─────────────────────────────────────────────────────────┘ ``` ## 数据流向 ``` Component → DataService → DataAccessApi → Backend API ↑ │ └──────────── BaseStore ←────────────┘ ``` - **Component**:Signal 驱动,OnPush 变更检测,只做 UI 渲染 - **DataService**:业务判断、API 协调、消息发布 - **DataAccess**:继承 AppApiBase,定义 API 方法,返回 Observable - **BaseStore**:Signal 状态存储,produce 更新,不可写业务逻辑 ## 组件层级 组件按通用性分层,演进路径为 `apps → business-components → base-ui`: | 层级 | 描述 | 位置 | | -------- | ------------------------------- | -------------------------- | | Page | 容器化布局,调用组件/服务 | `apps/*/src/app/pages` | | 业务组件 | 业务逻辑与展示,可组合 NG-ZORRO | `libs/business-components` | | 基础组件 | 纯 UI 展示,功能极简 | `libs/base-ui` | | 共享文件 | 类型、枚举、工具类 | `libs/shared` | ## libs 发布 libs 产物发布到私有 npm registry,包名以 `@dezhen/` 开头。 ### 发布流程 推荐优先使用 repo 内的 `nx release`,它会按库独立版本管理,并从 `dist/@dezhen/` 发布产物。 ```bash # 1. 仅在仓库内配置 npm registry,不改全局 # 把用户名/密码或 token 写入仓库根 .npmrc # 2. 仅预演版本变更 pnpm exec nx release patch --projects=business-components --dry-run --skip-publish # 3. 预演完整 release(version + publish) CI=1 pnpm exec nx release patch --projects=business-components --dry-run --yes # 4. 正式执行 CI=1 pnpm exec nx release patch --projects=business-components --yes ``` ### 直接 dist 发布 如果只想直接发布已经构建好的产物,仍然可以保留 dist 发布方式: ```bash # 1. 全部重新构建(排除有构建问题的) pnpm nx run-many -t build -p libs/* --exclude=business-components,data-service # 2. 运行发布脚本 ./scripts/publish-libs.sh ``` ### 更新源地址 修改仓库根 `.npmrc` 即可,不要改全局 npm 配置。例如: ```ini @dezhen:registry= always-auth=true ////:username= ////:_password= ////:email= ``` | 包 | 说明 | | --------------------------- | ----------------- | | @dezhen/base-ui | 基础 UI 组件 | | @dezhen/business-components | 业务组件 | | @dezhen/cdss | CDSS 临床决策支持 | | @dezhen/core | 核心基础设施 | | @dezhen/data-access | 数据访问层 | | @dezhen/data-engine | 数据引擎 | | @dezhen/data-service | 业务数据服务 | | @dezhen/data-store | 状态管理 | | @dezhen/messaging | 消息通信 | | @dezhen/shared | 共享资源 | | @dezhen/validator-engine | 验证引擎 | ### npm 配置 (.npmrc) ```ini @dezhen:registry=http://47.99.124.43:58769/repository/npm-hosted/ always-auth=true //47.99.124.43:58769/repository/npm-hosted/:username= //47.99.124.43:58769/repository/npm-hosted/:_password= //47.99.124.43:58769/repository/npm-hosted/:email= ``` ## 常用命令 ```bash # 构建 pnpm build # 构建所有项目 pnpm nx build # 构建指定项目 # 开发 pnpm dev # 启动 demo 开发服务器 pnpm nx serve demo # 同上 # Lint pnpm lint # 测试 pnpm nx run-many -t test pnpm nx run-many -t test --parallel=4 # 并行测试 # E2E pnpm nx e2e demo-e2e # 依赖图 pnpm nx graph ``` ## 核心规范 ### Signal First ```typescript // ✅ 正确 readonly user = signal(null); readonly isEmpty = computed(() => !this.user()); // ❌ 错误 user: User | null = null; ``` ### 组件规范 ```typescript // ✅ 正确 @Component({ standalone: true, changeDetection: ChangeDetectionStrategy.OnPush }) export class UserCardComponent { readonly user = input(); readonly onNameChange = output(); } // ❌ 错误 @Input() user!: User; @Output() nameChange = new EventEmitter(); ``` ### 时间处理 禁止使用 `Date.now()` / `new Date()`,统一使用 `ServerTimeService`: ```typescript import { ServerTimeService } from '@dezhen/core'; const now = this.serverTime.serverNow(); const date = this.serverTime.serverDate(); ```