You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
# 微前端Slave端框架
|
|
|
|
|
|
|
|
|
|
## 私服配置
|
|
|
|
|
- 安装nrm
|
|
|
|
|
```
|
|
|
|
|
npm i nrm -g
|
|
|
|
|
```
|
|
|
|
|
- 私服配置
|
|
|
|
|
```
|
|
|
|
|
# 1. 新增私服源
|
|
|
|
|
nrm add sz http://192.168.10.220:7070/repository/casic-frontend/
|
|
|
|
|
|
|
|
|
|
# 2. 切换到新源
|
|
|
|
|
nrm use sz
|
|
|
|
|
|
|
|
|
|
# 3. 增加认证
|
|
|
|
|
nrm add-auth bmpodHN6Om5qaHRzeg== sz
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 准备工作
|
|
|
|
|
- 请使用node v12 版本
|
|
|
|
|
- 框架采用umi@3.5
|
|
|
|
|
- 状态管理支持MobX和dva, 详情请参考
|
|
|
|
|
```
|
|
|
|
|
https://umijs.org/zh-CN/plugins/plugin-model
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
- 服务统一在/api管理,请参考样例
|
|
|
|
|
|
|
|
|
|
### 关于图片
|
|
|
|
|
从模板项目克隆过来可能会存在图片无法显示的问题,请到 http://192.168.10.236:81/public-htsz/micro-frontend-slave 下载后进行覆盖
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 开始
|
|
|
|
|
- 安装依赖
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ yarn i 或者 npm i
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 启动服务
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ npm start
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 开发环境配置
|
|
|
|
|
- config/config.dev.ts
|
|
|
|
|
```
|
|
|
|
|
proxy: {
|
|
|
|
|
'/gateway/idm': {
|
|
|
|
|
'target': 'http://{开发环境对应的微服务地址}:{端口号}/idm',
|
|
|
|
|
'changeOrigin': true,
|
|
|
|
|
'pathRewrite': {
|
|
|
|
|
'^/gateway/idm': ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 参数
|
|
|
|
|
* 各个应用系统需要后台参数 src/api/setting.service.tsx
|
|
|
|
|
* 目前配置的是 idm 的参数,各个应用系统根据实际业务需要进行调整
|
|
|
|
|
* 参数查询请使用 SettingService的getSystemParam的方法
|
|
|
|
|
* 根据环境变量配置,则需要配置全所有的参数
|
|
|
|
|
* 若需要多个微服务参数合并,请看 src/api/setting.service.tsx 中TODO
|