2021-08-23 16:57:25 +08:00
|
|
|
|
## 开发
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# 克隆项目
|
2021-08-23 17:56:19 +08:00
|
|
|
|
git clone https://gitee.com/izory/ZrAdminNetCore
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
# 进入项目目录
|
2021-08-23 17:56:19 +08:00
|
|
|
|
cd ZR.Vue
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
# 安装依赖
|
|
|
|
|
|
npm install
|
|
|
|
|
|
|
|
|
|
|
|
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
|
|
|
|
|
|
npm install --registry=https://registry.npm.taobao.org
|
|
|
|
|
|
|
|
|
|
|
|
# 启动服务
|
|
|
|
|
|
npm run dev
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2021-08-23 17:56:19 +08:00
|
|
|
|
浏览器访问 http://localhost:8887
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
## 发布
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# 构建测试环境
|
|
|
|
|
|
npm run build:stage
|
|
|
|
|
|
|
|
|
|
|
|
# 构建生产环境
|
|
|
|
|
|
npm run build:prod
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## nginx配置
|
|
|
|
|
|
|
|
|
|
|
|
``` shell
|
|
|
|
|
|
server {
|
2021-08-23 17:56:19 +08:00
|
|
|
|
#修改要监听的端口
|
|
|
|
|
|
listen 8080;
|
|
|
|
|
|
#修改要绑定的域名或IP地址
|
|
|
|
|
|
server_name localhost;
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
# charset koi8-r;
|
|
|
|
|
|
access_log logs/logs.access.log main;
|
|
|
|
|
|
|
|
|
|
|
|
# 后端接口 生产环境
|
|
|
|
|
|
location /prod-api/ {
|
2021-08-23 17:56:19 +08:00
|
|
|
|
proxy_pass http://localhost:8888/;
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
# 后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
|
|
|
|
|
|
|
# 如果请求被负载均衡的服务器返回类似500这样的,将继续请求下一台应用服务器,默认 对post,lock,patch的请求不进行重试,如果要设置在后面添加 non_idemponent
|
|
|
|
|
|
# proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-23 17:56:19 +08:00
|
|
|
|
# vue项目配置
|
|
|
|
|
|
location / {
|
|
|
|
|
|
#将xxxxx路径改成你的发布路径
|
|
|
|
|
|
root html/zradmin_vue;
|
|
|
|
|
|
index index.html;
|
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-23 16:57:25 +08:00
|
|
|
|
error_page 404 /404.html;
|
|
|
|
|
|
|
|
|
|
|
|
# redirect server error pages to the static page /50x.html
|
|
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
|
|
location = /50x.html {
|
|
|
|
|
|
root html;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|