---
url: /guide/development/example-apps.md
---

# 示例应用

通过可运行的示例，了解如何用 Nexus 为 PingCode 增加页面、调用平台能力、访问和保存数据、对接独立部署的后端服务、处理事件，以及扩展工作流。

# 开始之前

请先完成 [开发环境准备](https://developer.pingcode.com/guide/started/setup) 并安装 Nexus CLI。克隆 [示例仓库](https://github.com/atinc/nexus-examples/tree/develop) 后，进入所选示例目录，按 README 注册、构建和部署。第一次开发 Nexus 应用可以从 Hello World 开始。

# 示例应用

## Hello World

在项目组件页面显示 `你好，Nexus` 。React 和 Angular 各有 Native UI 与 Custom UI 两种实现。示例演示同一个应用函数在不同 UI 方案中的调用方式。

### 详情

* **示例代码** ：
  * [nexus-hello-world-react-native-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-react-native-ui)
  * [nexus-hello-world-react-custom-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-react-custom-ui)
  * [nexus-hello-world-angular-native-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-angular-native-ui)
  * [nexus-hello-world-angular-custom-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-angular-custom-ui)
* **扩展点** ：
  * 项目 — 组件页面（ `pcm:pjm:project:page` ）
* **UI 类型** ：
  * Native UI（React）
  * Custom UI（React）
  * Native UI（Angular）
  * Custom UI（Angular）
* **核心依赖** ：
  * `@pc-nexus/bridge` ：调用应用函数并显示返回结果。
  * `@pc-nexus/core` ：Resolver 返回 `你好，Nexus` 。

## 敏捷开发问答

在项目首页导航中添加敏捷知识问答页面，涵盖 Scrum、Kanban 等主题。示例演示 Nexus 国际化能力，让扩展标题、页面内容和应用函数返回的答题评语根据宿主语言显示中文或英文。

### 详情

* **示例代码** ： [nexus-agile-quiz](https://github.com/atinc/nexus-examples/tree/develop/nexus-agile-quiz)
* **扩展点** ：
  * 项目 — 首页导航（ `pcm:pjm:project:hub` ）
* **UI 类型** ：Custom UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：通过 `i18n.createTranslator` 翻译页面内容，并调用应用函数获取答题评语。
  * `@pc-nexus/core` ：通过 Resolver 处理评分，根据用户或团队语言生成对应的评语。

## 应用内路由与宿主导航

在全局独立应用中管理链接：侧栏切换应用内页面，刷新后仍停留在当前页，并可前进后退；打开链接时按设置在当前标签跳转 PingCode 页面，或在新窗口打开。示例演示应用内路由与宿主导航的分工。

### 详情

* **示例代码** ：
  * [nexus-router-react](https://github.com/atinc/nexus-examples/tree/develop/nexus-router-react)
  * [nexus-router-angular](https://github.com/atinc/nexus-examples/tree/develop/nexus-router-angular)
* **扩展点** ：
  * 全局 — 独立应用（ `pcm:global:app:hub` ）
* **UI 类型** ：
  * Custom UI（React）
  * Custom UI（Angular）
* **核心依赖** ：
  * `@pc-nexus/react/router` （React）：通过 `BrowserRouter` 实现应用内多页路由。
  * `@pc-nexus/angular/router` （Angular）：通过 Angular Router 集成实现应用内多页路由。
  * `@pc-nexus/bridge` ：通过 `router` 在宿主中打开页面并生成宿主地址。

## 活动报名表

在全局独立应用中以表格展示团队的活动报名记录，页面只读；增删改由外部系统通过带 scope 授权的自定义 REST API 完成，刷新页面即可看到写入结果。示例演示开放自定义 API、Resolver、Bridge 与 CES 的组合使用。

### 详情

* **示例代码** ： [nexus-exposer](https://github.com/atinc/nexus-examples/tree/develop/nexus-exposer)
* **扩展点** ：
  * 全局 — 独立应用（ `pcm:global:app:hub` ）
* **UI 类型** ：Native UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/core` ：Resolver 查询报名，开放 API 通过 Route Handler 提供增删改查。
  * `@pc-nexus/storage` ：通过 CES 实体保存报名数据。
  * `@pc-nexus/bridge` ：调用应用函数获取报名列表。
  * `@pc-nexus/angular` ：通过 `NxLayout` 、 `NxDynamicTable` 等 Native 组件渲染表格页面。

## 我的待办

在工作台仪表盘的 `我的待办` 部件中添加、勾选、删除待办，操作后立即保存，刷新后仍在；编辑部件可设置显示条数和是否显示已完成项。示例演示用 CES 保存部件数据，并按部件 ID 隔离不同实例的待办。

### 详情

* **示例代码** ： [nexus-my-todos-widget](https://github.com/atinc/nexus-examples/tree/develop/nexus-my-todos-widget)
* **扩展点** ：
  * 工作台 — 仪表盘部件（ `pcm:global:dashboard:widget` ）
* **UI 类型** ：Custom UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：读取部件配置，并调用应用函数读取和保存待办。
  * `@pc-nexus/core` ：Resolver 处理待办查询与保存。
  * `@pc-nexus/storage` ：通过 CES 实体保存待办，以 `widget_id` 索引。

## Wiki 标签页

在 Wiki 文档中插入标签页内容块，在只读视图中切换标签查看正文，配置弹窗可增删、改名和调整标签顺序。示例演示文档内容块的配置提交，标签通过 ID 关联正文，重开后标题、顺序和内容保持一致。

### 详情

* **示例代码** ： [nexus-wiki-tabs](https://github.com/atinc/nexus-examples/tree/develop/nexus-wiki-tabs)
* **扩展点** ：
  * 页面 — 文档内容块（ `pcm:wiki:document:block` ）
* **UI 类型** ：Native UI (React)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：通过 `view` 读取和提交内容块配置，并用 `dialog` 确认操作。
  * `@pc-nexus/react` ：使用 `NxTabs` 、 `NxBlockContent` 等组件渲染标签页。
  * `@pc-nexus/models` ：定义内容块提交数据结构。

## 迭代统计

在迭代详情页查看工作日、故事点和工作项的完成情况，逾期未完成时给出提醒，并按工作项类型展示完成率。示例演示通过 Resolver 调用 PingCode API 按迭代聚合数据。

### 详情

* **示例代码** ： [nexus-sprint-stats](https://github.com/atinc/nexus-examples/tree/develop/nexus-sprint-stats)
* **扩展点** ：
  * 迭代 — 详情导航（ `pcm:pjm:sprint:page` ）
* **UI 类型** ：Custom UI (React)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：调用应用函数获取迭代统计。
  * `@pc-nexus/core` ：Resolver 聚合统计数据。
  * `@pc-nexus/network` ：调用 PingCode API 读取工作项。

## 项目附件库

在项目中添加附件管理页面，支持文件上传、下载、重传、重命名、删除和搜索，上传人通过资料引用展示头像。点击 `批量下载` 可将当前项目的全部附件打包：任务进入异步队列，由消费者从 NOS 拉取文件、打包为 ZIP 并写回 NOS，并在进程器中展示进度、提供下载。示例演示对象存储与实体存储的组合使用，以及异步队列、实时进度与进程器的配合。

### 详情

* **示例代码** ： [nexus-project-attachments](https://github.com/atinc/nexus-examples/tree/develop/nexus-project-attachments)
* **扩展点** ：
  * 项目 — 组件页面（ `pcm:pjm:project:page` ），路由 `attachments`
  * 全局 — 主界面后台脚本（ `pcm:global:main:background` ）
* **UI 类型** ：Custom UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：调用应用函数；通过 `store.upload` 和 `store.download` 上传、下载文件；批量下载时用 `events` 通知后台，并用 `realtime` 订阅打包进度。
  * `@pc-nexus/core` ：Resolver 处理附件管理与批量下载入队。
  * `@pc-nexus/storage` ：通过 NOS 保存文件内容和 ZIP，通过 CES 保存附件记录并关联当前项目。
  * `@pc-nexus/network` ：调用 PingCode API 读取上传人资料。
  * `@pc-nexus/async` ：异步队列消费批量下载任务，将当前项目的全部附件打包为 ZIP。
  * `@pc-nexus/realtime` ：向当前会话推送打包进度。
  * `@pc-nexus/capabilities` ：通过 `processor` 展示进度并下载 ZIP。

## 项目经费

在项目中查看和维护经费，数据保存在独立部署的 Node.js 或 Java 服务里。示例演示同一份账本如何通过不同路径读写：浏览器经 Remote 直连、Resolver 经 Remote 查询、项目更新事件转发到后端服务。

### 详情

* **示例代码** ： [nexus-project-expenses](https://github.com/atinc/nexus-examples/tree/develop/nexus-project-expenses)
* **扩展点** ：
  * 项目 — 组件页面（ `pcm:pjm:project:page` ），路由 `expenses-remote` ：浏览器经 Remote 直连
  * 项目 — 组件页面（ `pcm:pjm:project:page` ），路由 `expenses-function` ：Resolver 经 Remote 查询
  * 项目 — 项目更新事件（ `pce:pjm:project:updated` ）：转发到远程服务
* **UI 类型** ：Custom UI (React)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：直连远程服务、调用远程函数，并调用应用函数查询经费、用弹窗展示新增表单。
  * `@pc-nexus/core` ：Resolver 查询经费，Endpoint 将项目更新事件转发到远程服务。
  * `@pc-nexus/network` ：Resolver 查询独立部署的 Node.js / Java 服务。

## GitHub 公开资料绑定

在个人设置中绑定 GitHub 用户名并查看公开资料，可随时重新绑定。示例演示在 Resolver 中请求 GitHub 公开接口，并把用户名按当前用户存入 KVS，重新打开页面仍能读回绑定。

### 详情

* **示例代码** ： [nexus-external-profile](https://github.com/atinc/nexus-examples/tree/develop/nexus-external-profile)
* **扩展点** ：
  * 帐号 — 个人设置（ `pcm:global:personal:setting` ）
* **UI 类型** ：Custom UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：调用应用函数获取 GitHub 资料。
  * `@pc-nexus/core` ：Resolver 读取绑定并查询公开资料。
  * `@pc-nexus/network` ：请求 GitHub 公开接口。
  * `@pc-nexus/storage` ：按用户保存 GitHub 用户名。

## 工作项实时查看者

在工作项详情侧栏展示正在查看同一工作项的用户。示例组合 Nexus 后台扩展与实时通道，在打开详情时上报查看状态，并将变化同步到查看者列表，支持多标签页会话识别和离线超时清理。

### 详情

* **示例代码** ： [nexus-workitem-live-viewer](https://github.com/atinc/nexus-examples/tree/develop/nexus-workitem-live-viewer)
* **扩展点** ：
  * 工作项 — 详情后台脚本（ `pcm:pjm:workitem:background` ）
  * 工作项 — 详情上下文（ `pcm:pjm:workitem:context` ）
* **UI 类型** ：Custom UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：通过 `realtime` 发布和订阅查看状态，使用工作项上下文限定消息范围。
  * `@pc-nexus/core` ：Resolver 查询查看者信息。
  * `@pc-nexus/network` ：调用 PingCode API 读取用户头像与姓名。

## 事件动态

在全局独立应用中用一张时间线汇总生命周期、系统、定时、Webhook 和应用事件。示例演示各类事件处理函数如何写入 CES，并通过定时任务把待汇总事件标记为已汇总。

### 详情

* **示例代码** ： [nexus-event-feed](https://github.com/atinc/nexus-examples/tree/develop/nexus-event-feed)
* **扩展点** ：
  * 全局 — 独立应用（ `pcm:global:app:hub` ）
* **UI 类型** ：Custom UI (Angular)
* **核心依赖** ：
  * `@pc-nexus/bridge` ：调用应用函数读取事件时间线。
  * `@pc-nexus/core` ：Resolver 返回事件、Webhook 地址与汇总计划。
  * `@pc-nexus/event` ：用生命周期、系统、定时、Webhook、应用事件处理函数写入记录，并通过 Webhook 地址与事件发布驱动定时汇总。
  * `@pc-nexus/storage` ：通过 CES 实体保存事件与汇总记录。

## 工作项完成条件校验

在工作流中配置要启用的 DoD 规则，状态流转时逐条校验，不通过时列出具体原因。示例演示用配置面板声明规则开关，校验函数在状态流转时查询工时、子任务和关联测试用例。

### 详情

* **示例代码** ： [nexus-workitem-dod-validator](https://github.com/atinc/nexus-examples/tree/develop/nexus-workitem-dod-validator)
* **扩展点** ：
  * 工作项 — 工作流验证（ `pcm:pjm:workitem:validator` ）
* **UI 类型** ：Native UI (React)
* **核心依赖** ：
  * `@pc-nexus/react` ：通过 `NexusReconciler` 与 `NxSelect` 等组件构建规则配置面板。
  * `@pc-nexus/bridge` ：通过 `view` 获取工作流配置上下文。
  * `@pc-nexus/network` ：调用 PingCode API 查询工时、子任务和关联测试用例。
  * `@pc-nexus/core` ： `dodValidate` 校验函数在状态流转时逐条检查规则。

## 工作流动作

在工作流中添加自定义动作：用 Native UI 配置面板收集输入，并把投递状态 `notifyDelivered` 声明为下游步骤可引用的属性。运行时回查上游工作项，向企业微信群机器人发送一条文本，用来走通从配置、绑定到投递结果的数据流。

### 详情

* **示例代码** ： [nexus-flow-workitem-notify](https://github.com/atinc/nexus-examples/tree/develop/nexus-flow-workitem-notify)
* **扩展点** ：
  * 工作流 — 动作（ `pcm:flow:workflow:action` ）
* **UI 类型** ：Native UI (React)
* **核心依赖** ：
  * `@pc-nexus/react` ：通过 `NexusReconciler` 与 `NxInput` 、 `NxSelect` 等组件构建动作配置面板。
  * `@pc-nexus/bridge` ：通过 `view` 获取动作上下文并提交输入配置。
  * `@pc-nexus/network` ：Resolver 调用 PingCode API 回查工作项，并向企业微信 Webhook 发送通知。
  * `@pc-nexus/manifest` ：通过 `inputSchema` 、 `dynamicPropertySchema` （ `notifyDelivered` ）定义输入与下游可引用结果。
