|
| 1 | +# Central-Platform UI |
| 2 | + |
| 3 | + 本模块是基于`企业级微服务框架`后端 API 所开发的前端项目。 |
| 4 | + |
| 5 | +采用[Ant Design Pro](https://pro.ant.design/)框架,基于[UmiJS v3.x](https://v3.umijs.org/)和[ProComponents](https://procomponents.ant.design/); |
| 6 | +图表采用[Ant Design Charts](https://charts.ant.design/)。 |
| 7 | + |
| 8 | +## 一、目录说明 |
| 9 | +考虑到react的复杂性,保留了layui版本的前端。 |
| 10 | +```lua |
| 11 | +│ ├─layui-web -- layui前端 |
| 12 | +│ │ ├─src |
| 13 | +│ │ │ ├─main |
| 14 | +│ │ │ │ ├─java -- java启动类 |
| 15 | +│ │ │ │ ├─resources -- 前端源码 |
| 16 | +│ │ │ │ │ ├─static -- 前端源码 |
| 17 | +│ ├─react-web -- react前端 |
| 18 | +│ │ ├─src |
| 19 | +│ │ │ ├─main |
| 20 | +│ │ │ │ ├─frontend -- 前端源码(Ant Design Pro) |
| 21 | +│ │ │ │ ├─java -- java启动类(集成frontend-maven-plugin) |
| 22 | +``` |
| 23 | + |
| 24 | + |
| 25 | +## 二、运行方式 |
| 26 | +### 2.1. layui-web |
| 27 | +**以下 2 种运行方式,选一种运行即可。** |
| 28 | + |
| 29 | +#### 2.1.1. 方式一:直接运行 |
| 30 | +运行类 `com.central.web.BackWebApplication` |
| 31 | +> 基于 SpringBoot 内嵌的 web 容器 |
| 32 | +
|
| 33 | +#### 2.1.2. 方式二:静态服务器运行 |
| 34 | +把 `layui-web\src\main\resources\static` 下的内容复制到类似 `Nginx` 之类的静态服务器运行。 |
| 35 | + |
| 36 | + |
| 37 | +### 2.2. react-web |
| 38 | +**以下 3 种运行方式,选一种运行即可。** |
| 39 | + |
| 40 | +需要先安装 `nodejs` 官网地址:https://nodejs.org/en/download/ |
| 41 | + |
| 42 | +#### 2.2.1. 方式一:本地运行 |
| 43 | +##### 2.2.1.1. 安装node_modules |
| 44 | +执行以下命令: |
| 45 | +```bash |
| 46 | +npm install |
| 47 | +``` |
| 48 | +##### 2.2.1.2. 运行 |
| 49 | +运行 `frontend\start.bat` 文件或者执行 `npm start` 命令。 |
| 50 | + |
| 51 | +运行成功后,浏览器访问:http://localhost:8066 |
| 52 | + |
| 53 | + |
| 54 | +#### 2.2.2. 方式二:静态服务器运行 |
| 55 | +运行 `frontend\build.bat` 文件或者执行 `npm run build` 命令进行编译。 |
| 56 | + |
| 57 | +编译成功后,把 `react-web\src\main\frontend\dist` 下的内容复制到类似 `Nginx` 之类的静态服务器运行。 |
| 58 | + |
| 59 | + |
| 60 | +#### 2.2.3. 方式三:使用Java运行 |
| 61 | +模块已集成Maven插件`frontend-maven-plugin`用于编译前端代码 |
| 62 | +>由于需要安装前端环境并编译前端代码,**首次运行需要时间较长**。 |
| 63 | +
|
| 64 | +执行 maven 命令 `mvn package` 打包。 |
| 65 | + |
| 66 | +在target目录下生成zlt-web-x.x.x.jar(springboot jar)。 |
| 67 | +```bash |
| 68 | +java -jar zlt-web-5.4.0.jar |
| 69 | +``` |
| 70 | + |
| 71 | +或者直接在IDE中运行 `react-web\src\main\java\ui\ReactUiBootApplication.java` |
| 72 | +> 运行前必需先使用 maven 对 react-web 工程进行编译或打包。 |
| 73 | +
|
| 74 | + |
| 75 | +## 三、后端接口地址修改 |
| 76 | +两个前端默认请求的后端接口地址默认都是:http://127.0.0.1:9900/ |
| 77 | + |
| 78 | +### 3.1. layui-web |
| 79 | +修改 `layui-web\src\main\resources\static\module\apiUrl.js` 中的地址。 |
| 80 | + |
| 81 | + |
| 82 | +### 3.2. react-web |
| 83 | +修改 `react-web\src\main\frontend\config\proxy.ts` 中的地址。 |
| 84 | + |
| 85 | + |
| 86 | +## 四、More |
| 87 | +开发参考 |
| 88 | +* [Ant Design Pro](https://pro.ant.design/) 开箱即用的中台前端/设计解决方案 |
| 89 | +* [UmiJS v3.x](https://v3.umijs.org/) 可扩展的企业级前端应用框架 |
| 90 | +* [Ant Design](https://ant.design/index-cn) 基于 Ant Design 设计体系的 React UI 组件库 |
| 91 | +* [ProComponents](https://procomponents.ant.design/) 基于 Ant Design 设计规范,提供更高程度的抽象,提供更上层的设计规范 |
| 92 | +* [Ant Design Charts](https://charts.ant.design/) 简单好用的 React 图表库 |
0 commit comments