From 91baf4185eb512cd05f8e864a9bbe0449c0d6172 Mon Sep 17 00:00:00 2001 From: weir <1261174789@qq.com> Date: Tue, 27 Jul 2021 21:42:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-ui/.env.production | 4 ++++ yudao-admin-ui/Jenkinsfile | 12 ++++++------ yudao-admin-ui/src/router/index.js | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/yudao-admin-ui/.env.production b/yudao-admin-ui/.env.production index 59e977414..5c64ef413 100644 --- a/yudao-admin-ui/.env.production +++ b/yudao-admin-ui/.env.production @@ -3,4 +3,8 @@ ENV = 'production' # 芋道管理系统/生产环境 VUE_APP_BASE_API = '/prod-api' +# 根据服务器或域名修改 +PUBLIC_PATH = 'http://you_ip.cn/yudao-admin/' +# 二级部署路径 +VUE_APP_APP_NAME ='yudao-admin' diff --git a/yudao-admin-ui/Jenkinsfile b/yudao-admin-ui/Jenkinsfile index cd20133e1..65d18d449 100644 --- a/yudao-admin-ui/Jenkinsfile +++ b/yudao-admin-ui/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { environment { APP_NAME = 'yudao-admin' - APP_PACKAGE='yudao-admin-ui' + PROJECT_DIR='yudao-admin-ui' NGINX_WORKDIR = '/home/pi/mydata/nginx/html/' } @@ -25,8 +25,8 @@ pipeline { stage('构建') { steps { - sh 'cnpm --prefix '+ "${env.APP_PACKAGE}" +' install' - sh 'cnpm --prefix '+ "${env.APP_PACKAGE}" +' run build:prod' + sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' install' + sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' run build:prod' } } @@ -34,9 +34,9 @@ pipeline { steps { sh 'rm -f ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz' sh 'mkdir -p ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" - sh 'cp -rf ' + "${env.APP_PACKAGE}" + '/dist/. ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" - sh 'tar -zcvf ' + "${env.APP_PACKAGE}" + '/'+ "${env.APP_PACKAGE}" + '.tar.gz ' + "${env.APP_PACKAGE}" + '/dist/' - archiveArtifacts "${env.APP_PACKAGE}" + '/'+ "${env.APP_PACKAGE}" + '.tar.gz' + sh 'cp -rf ' + "${env.PROJECT_DIR}" + '/dist/. ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" + sh 'tar -zcvf ' + "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz ' + "${env.PROJECT_DIR}" + '/dist/' + archiveArtifacts "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz' //TODO 考虑刷新缓存的问题 } } diff --git a/yudao-admin-ui/src/router/index.js b/yudao-admin-ui/src/router/index.js index a4f676306..82a304551 100644 --- a/yudao-admin-ui/src/router/index.js +++ b/yudao-admin-ui/src/router/index.js @@ -122,6 +122,7 @@ export const constantRoutes = [ ] export default new Router({ + base: process.env.VUE_APP_APP_NAME ? process.env.VUE_APP_APP_NAME : "/", mode: 'history', // 去掉url中的# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes