---
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

在项目组件页面显示 `Hello, Nexus` 。React 和 Angular 各有 Native UI、Custom UI 两个示例，页面都通过 Bridge 的 `invoke` 调用 Resolver 来显示。

|实现方式|源码|类型|说明|
|---|---|---|---|
|React + Native UI|[nexus-hello-world-react-native-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-react-native-ui)|Native UI|使用平台组件，样式与 PingCode 一致|
|React + Custom UI|[nexus-hello-world-react-custom-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-react-custom-ui)|Custom UI|自行编写页面，样式可单独调整|
|Angular + Native UI|[nexus-hello-world-angular-native-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-angular-native-ui)|Native UI|使用平台组件，样式与 PingCode 一致|
|Angular + Custom UI|[nexus-hello-world-angular-custom-ui](https://github.com/atinc/nexus-examples/tree/develop/nexus-hello-world-angular-custom-ui)|Custom UI|自行编写页面，样式可单独调整|

**详情**

* **模块** ： [项目 - 组件页面](https://developer.pingcode.com/reference/resource/extensions/pjm-project-page) （ `pcm:pjm:project:page` ）
* **Bridge** ： `@pc-nexus/bridge` 的 `invoke`
* **运行时** ： `@pc-nexus/core` 的 `Resolver`

### 敏捷开发问答（Custom UI）

在项目首页导航中添加敏捷开发问答，支持中文和英文，切换语言后重新打开即可看到。使用 [项目 - 首页导航](https://developer.pingcode.com/reference/resource/extensions/pjm-project-hub) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-agile-quiz)
* **模块** ： [项目 - 首页导航](https://developer.pingcode.com/reference/resource/extensions/pjm-project-hub) （ `pcm:pjm:project:hub` ）
* **Custom UI** ：通过 `@pc-nexus/bridge` 的 `i18n` 读取 manifest 声明的 `translations` 。文案在 `locales` 中。
* **运行时** ： `@pc-nexus/core` 的 `Resolver` 。

### 应用内路由与宿主导航（Custom UI）

通过侧边栏切换应用内页面，并从应用中打开 PingCode 页面。使用 [全局 - 独立应用](https://developer.pingcode.com/reference/resource/extensions/global-app-hub) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-router)
* **模块** ： [全局 - 独立应用](https://developer.pingcode.com/reference/resource/extensions/global-app-hub) （ `pcm:global:app:hub` ）
* **Custom UI** ：使用 `@pc-nexus/react/router` 的 `BrowserRouter` 管理应用内页面，使用 `@pc-nexus/bridge` 的 `router` 打开 PingCode 页面。
* **运行时** ： `@pc-nexus/core` 的 `Resolver` 。

### 我的待办（Custom UI）

在工作台仪表盘新增、勾选和删除个人待办。使用 [工作台 - 仪表盘部件](https://developer.pingcode.com/reference/resource/extensions/global-dashboard-widget) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-my-todos-widget)
* **模块** ： [工作台 - 仪表盘部件](https://developer.pingcode.com/reference/resource/extensions/global-dashboard-widget) （ `pcm:global:dashboard:widget` ）
* **Custom UI** ：使用 `@pc-nexus/bridge` 的 `view` 和 `invoke` 。查看模式会立即保存；编辑模式只配置显示条数和是否显示已完成。
* **运行时** ： `@pc-nexus/core` 的 Resolver 读取和保存待办。
* **存储** ：CES 保存待办记录。

### Wiki HTML 预览（Custom UI）

在 Wiki 中插入 HTML 内容块，在编辑弹窗中实时预览。使用 [页面 - 文档内容块](https://developer.pingcode.com/reference/resource/extensions/wiki-document-block) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-wiki-html-preview)
* **模块** ： [页面 - 文档内容块](https://developer.pingcode.com/reference/resource/extensions/wiki-document-block) （ `pcm:wiki:document:block` ）
* **Custom UI** ：展示用 `main` ，编辑用 `edit` 。通过 `@pc-nexus/bridge` 的 `view` 提交 HTML，保存后通过 `events` 刷新展示内容。
* **运行时** ： `@pc-nexus/core` 的 `Resolver` 。

### 迭代统计（Custom UI）

在迭代详情中按工作项类型查看完成情况。使用 [迭代 - 详情导航](https://developer.pingcode.com/reference/resource/extensions/pjm-sprint-page) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-sprint-stats)
* **模块** ： [迭代 - 详情导航](https://developer.pingcode.com/reference/resource/extensions/pjm-sprint-page) （ `pcm:pjm:sprint:page` ）
* **Custom UI** ：通过 `@pc-nexus/bridge` 的 `invoke` 读取统计结果。
* **运行时** ： `@pc-nexus/core` 的 Resolver 通过 `api.invoke` 调用 PingCode REST API。

### 项目附件（Custom UI）

在项目中上传、重传、搜索、重命名、下载和删除附件。使用 [项目 - 组件页面](https://developer.pingcode.com/reference/resource/extensions/pjm-project-page) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-project-attachments)
* **模块** ： [项目 - 组件页面](https://developer.pingcode.com/reference/resource/extensions/pjm-project-page) （ `pcm:pjm:project:page` ）
* **Custom UI** ：使用 `@pc-nexus/bridge` 的 `store` 、 `view` 和 `invoke` 。 `store` 负责上传和下载文件。
* **运行时** ： `@pc-nexus/core` 的 Resolver 管理附件记录。
* **存储** ：NOS 保存文件，CES 保存附件记录。

### 项目经费（Custom UI）

在项目中查询和维护经费，数据保存在独立部署的 Node.js 或 Java 服务里。两种服务都要改 `node-remote` 的地址和外部访问来源，只改 `java-remote` 无效。使用 [项目 - 组件页面](https://developer.pingcode.com/reference/resource/extensions/pjm-project-page) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-project-expenses)
* **模块** ： [项目 - 组件页面](https://developer.pingcode.com/reference/resource/extensions/pjm-project-page) （ `pcm:pjm:project:page` ），入口为远程端点（ `expenses-remote` ）和 Resolver 查询（ `expenses-function` ）。
* **Custom UI** ：远程端点用 `@pc-nexus/bridge` 的 `remote.request` 读费用类别，用 `remote.invoke` 经 Endpoint 增删查费用。Resolver 查询用 `invoke` ，只能查看。
* **运行时** ：Resolver 经 `@pc-nexus/network` 的 `remote.invoke` 查询同一份记录。项目更新经 Endpoint 转发后，服务调用 PingCode REST API 读取项目详情。
* **存储** ：费用保存在 Remote 服务内存中，重启后清空。

### GitHub 公开资料绑定（Custom UI）

在个人设置中绑定 GitHub 用户名并查看公开资料。使用 [帐号 - 个人设置](https://developer.pingcode.com/reference/resource/extensions/global-personal-setting) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-external-profile)
* **模块** ： [帐号 - 个人设置](https://developer.pingcode.com/reference/resource/extensions/global-personal-setting) （ `pcm:global:personal:setting` ）
* **Custom UI** ：通过 `@pc-nexus/bridge` 的 `invoke` 调用后端。
* **运行时** ： `@pc-nexus/core` 的 Resolver 使用 `fetch.request` 调用 GitHub REST API。访问 GitHub 的外部权限写在 manifest 中。
* **存储** ：KVS 按 PingCode 用户保存 GitHub 用户名。

### 工作项实时查看者（Custom UI）

用两个账号打开同一个工作项，可以在详情右侧的 Live Viewer 中看到彼此的头像。使用 [工作项 - 详情后台脚本](https://developer.pingcode.com/reference/resource/extensions/pjm-workitem-background) 和 [工作项 - 详情上下文](https://developer.pingcode.com/reference/resource/extensions/pjm-workitem-context) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-workitem-live-viewer)
* **模块** ： [工作项 - 详情后台脚本](https://developer.pingcode.com/reference/resource/extensions/pjm-workitem-background) （ `pcm:pjm:workitem:background` ）、 [工作项 - 详情上下文](https://developer.pingcode.com/reference/resource/extensions/pjm-workitem-context) （ `pcm:pjm:workitem:context` ）
* **Custom UI** ：通过 `@pc-nexus/bridge` 的 `realtime` 同步当前查看者，使用 `view` 获取上下文，使用 `invoke` 查询用户资料。
* **运行时** ： `@pc-nexus/core` 的 Resolver 使用 `api.invoke` 获取用户资料。

### 事件动态（Custom UI）

在一条时间线查看生命周期、系统、定时、Webhook 和应用事件。使用 [全局 - 独立应用](https://developer.pingcode.com/reference/resource/extensions/global-app-hub) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-event-feed)
* **模块** ： [全局 - 独立应用](https://developer.pingcode.com/reference/resource/extensions/global-app-hub) （ `pcm:global:app:hub` ）
* **Custom UI** ：通过 `@pc-nexus/bridge` 的 `invoke` 读取动态。
* **运行时** ： `@pc-nexus/core` 的 Resolver 与 `@pc-nexus/event` 处理函数。manifest 声明触发器和应用事件，定时处理函数汇总条目并发布应用事件。
* **存储** ：CES 保存动态条目。

### 工作项完成条件校验（Native UI）

工作项状态流转时，按配置检查工时、子任务和关联测试用例。使用 [工作项 - 工作流验证](https://developer.pingcode.com/reference/resource/extensions/pjm-workitem-validator) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-workitem-dod-validator)
* **模块** ： [工作项 - 工作流验证](https://developer.pingcode.com/reference/resource/extensions/pjm-workitem-validator) （ `pcm:pjm:workitem:validator` ）
* **Native UI** ：使用 `@pc-nexus/react` 构建创建和编辑共用的配置面板。
* **运行时** ：状态流转时执行 `dodValidate` Resolver。

### 工作流动作（Native UI）

在工作流添加该动作，接收上游工作项并通知企业微信群，下游步骤可引用投递结果。使用 [工作流 - 动作](https://developer.pingcode.com/reference/resource/extensions/pcm-flow-workflow-action) 扩展点。

**详情**

* **源码** ： [查看源码与运行步骤](https://github.com/atinc/nexus-examples/tree/develop/nexus-flow-workitem-notify)
* **模块** ： [工作流 - 动作](https://developer.pingcode.com/reference/resource/extensions/pcm-flow-workflow-action) （ `pcm:flow:workflow:action` ）
* **Native UI** ：使用 `@pc-nexus/react` 构建动作配置面板。
* **运行时** ：Resolver 向 Webhook 发送通知。 `inputSchema` 声明输入， `dynamicPropertySchema` 声明可供下游引用的 `notifyDelivered` 。
