From c835e38d8293861e650d4732b481d64dd96b4b00 Mon Sep 17 00:00:00 2001 From: Zhao Zhao Shen Date: Tue, 11 Mar 2025 19:13:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=8D=A2=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy-gy.sh | 77 ++++-- src/api/inspection.js | 4 +- src/components/CustomDatetimePicker.vue | 114 ++++----- src/utils/request.js | 3 +- src/views/Inspection/InspectionForm.vue | 10 +- src/views/Inspection/index.vue | 20 +- src/views/layout/vueLayout.vue | 308 ++++++++++++++++++------ 7 files changed, 366 insertions(+), 170 deletions(-) diff --git a/deploy-gy.sh b/deploy-gy.sh index 65dbb50..2b20f4c 100644 --- a/deploy-gy.sh +++ b/deploy-gy.sh @@ -1,5 +1,6 @@ #!/bin/bash - +# 使用后端本地调用api方式部署 + # 加载配置 if [ -f "./deploy.config.sh" ]; then source ./deploy.config.sh @@ -7,63 +8,89 @@ else echo "配置文件 deploy.config.sh 不存在" exit 1 fi - + echo "开始远程部署 - $(date)" - + echo "开始部署您的项目..." - + # 1. 克隆项目代码 # echo "1. 克隆项目代码..." # git clone https://git.zhouxhere.com/wonderzhao/cola-web.git - + # 2. 进入项目目录 # echo "2. 进入项目目录..." # cd cola-web - + # 3. 安装依赖 # echo "3. 安装依赖..." # npm install - + # 4. 构建项目 echo "4. 构建项目..." npm run build - + # 5. 构建 Docker 镜像 echo "5. 构建 Docker 镜像..." docker build -t ${DOCKER_IMAGE_NAME} . - + # 6. 保存镜像为 tar 文件 echo "6. 保存 Docker 镜像..." docker save ${DOCKER_IMAGE_NAME} > ${DOCKER_IMAGE_NAME}.tar - -# 7. 传输文件到服务器 -echo "7. 传输文件到服务器..." -# ssh -p 22 owner@192.168.1.199 + +# 7. 创建 nginx 配置文件 +echo "7. 创建 nginx 配置文件..." +cat > nginx.conf << 'NGINX_EOF' +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + location /api { + proxy_pass http://192.168.1.199:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} +NGINX_EOF + +# 8. 传输文件到服务器 +echo "8. 传输文件到服务器..." scp -v -P ${REMOTE_PORT} ${DOCKER_IMAGE_NAME}.tar ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/ - -# 8. 在远程服务器上执行部署 -echo "8. 在远程服务器上执行部署..." +scp -v -P ${REMOTE_PORT} nginx.conf ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/ + +# 9. 在远程服务器上执行部署 +echo "9. 在远程服务器上执行部署..." ssh -p ${REMOTE_PORT} ${REMOTE_USER}@${REMOTE_HOST} << EOF set -e # 遇到错误立即退出 - + echo "===== 开始执行远程部署 =====" cd ${REMOTE_PATH} docker load < ${DOCKER_IMAGE_NAME}.tar docker stop ${DOCKER_CONTAINER_NAME} 2>/dev/null || true docker rm ${DOCKER_CONTAINER_NAME} 2>/dev/null || true - docker run -d \ - --name ${DOCKER_CONTAINER_NAME} \ - -p ${APP_PORT}:80 \ - --restart unless-stopped \ + docker run -d \\ + --name ${DOCKER_CONTAINER_NAME} \\ + -p ${APP_PORT}:80 \\ + -v ${REMOTE_PATH}/nginx.conf:/etc/nginx/conf.d/default.conf \\ + --restart unless-stopped \\ ${DOCKER_IMAGE_NAME} EOF - + echo "部署完成!" -# echo "部署完成!" - + +# 清理本地临时文件 +rm -f nginx.conf +rm -f ${DOCKER_IMAGE_NAME}.tar + # 10. 检查部署状态 # echo "10. 检查部署状态..." # ssh owner@192.168.1.199 "docker ps | grep cola-web" - + # 在另一个终端窗口查看日志 # tail -f deploy.log \ No newline at end of file diff --git a/src/api/inspection.js b/src/api/inspection.js index 5f02b6a..d65f58f 100644 --- a/src/api/inspection.js +++ b/src/api/inspection.js @@ -3,7 +3,7 @@ import request from '@/utils/request'; // 获取点检页面当前值 export function getInspectionCurrent(deviceId, inputTime) { return request({ - url: `/Check/currunt?deviceId=${deviceId}&inputTime=${inputTime}`, + url: `/Check/currunt?deviceTypeId=${deviceId}&inputTime=${inputTime}`, method: 'get' }); } @@ -11,7 +11,7 @@ export function getInspectionCurrent(deviceId, inputTime) { // 获取点检页面整点数值 export function getInspectionData(deviceId, inputTime, shift) { return request({ - url: `/Check/sharp?deviceId=${deviceId}&inputTime=${inputTime}&shift=${shift}`, + url: `/Check/sharp?deviceTypeId=${deviceId}&inputTime=${inputTime}&shift=${shift}`, method: 'get' }); } diff --git a/src/components/CustomDatetimePicker.vue b/src/components/CustomDatetimePicker.vue index ae5b0d6..3abc12c 100644 --- a/src/components/CustomDatetimePicker.vue +++ b/src/components/CustomDatetimePicker.vue @@ -1,66 +1,72 @@ - - + \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js index dbb0743..b252789 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,7 +2,8 @@ import axios from 'axios'; const service = axios.create({ // baseURL: 'http://192.168.1.199:8080/api', // 办公室测试接口 - baseURL: 'http://39.105.9.124:8090/api', // 家用测试接口 + // baseURL: 'http://39.105.9.124:8090/api', // 家用测试接口 + baseURL: '/api', timeout: 5000, // 请求超时时间 headers: { "Access-Control-Allow-Origin": "*", diff --git a/src/views/Inspection/InspectionForm.vue b/src/views/Inspection/InspectionForm.vue index 99ab210..e5794aa 100644 --- a/src/views/Inspection/InspectionForm.vue +++ b/src/views/Inspection/InspectionForm.vue @@ -27,7 +27,7 @@ \ No newline at end of file