增加打包配置脚本 可执行npm run build:prod 构建生产环境,执行npm run build:test 构建测试环境 也可以打开bin目录下的.bat文件 双击执行对应的构建脚本

This commit is contained in:
BianLzhaoMin 2025-02-25 09:59:59 +08:00
parent 01cfdd1131
commit 2e20db58ce
7 changed files with 30 additions and 6 deletions

10
.env.testing Normal file
View File

@ -0,0 +1,10 @@
# 页面标题
VUE_APP_TITLE = 可视化管控平台
NODE_ENV = production
# 生产环境配置
ENV = 'testing'
# 博诺思管理系统/生产环境
VUE_APP_BASE_API = '/nxdt-api'

12
bin/build-test.bat Normal file
View File

@ -0,0 +1,12 @@
@echo off
echo.
echo [<5B><>Ϣ] <20><><EFBFBD>Web<65><62><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>dist<73>ļ<EFBFBD><C4BC><EFBFBD>
echo.
%~d0
cd %~dp0
cd ..
npm run build:test
pause

View File

@ -8,6 +8,7 @@
"dev": "vue-cli-service serve", "dev": "vue-cli-service serve",
"build:prod": "vue-cli-service build", "build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging", "build:stage": "vue-cli-service build --mode staging",
"build:test": "vue-cli-service build --mode testing",
"preview": "node build/index.js --preview", "preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src" "lint": "eslint --ext .js,.vue src"
}, },

View File

@ -214,7 +214,7 @@ export default {
}) })
}, },
openPage(type) { openPage(type) {
if (type === 1) window.open('/screen', '_blank') if (type === 1) window.open(process.env.ENV === 'testing' ? '/nxdt/screen' : '/screen', '_blank')
if (type === 2) this.$router.push({ path: '/notice/noticeAnnouncement' }) if (type === 2) this.$router.push({ path: '/notice/noticeAnnouncement' })
if (type === 3) this.$router.push({ path: '/myToDoList/myToDoList' }) if (type === 3) this.$router.push({ path: '/myToDoList/myToDoList' })
if (type === 4) this.$router.push({ path: '/takePhoto/takePhoto' }) if (type === 4) this.$router.push({ path: '/takePhoto/takePhoto' })
@ -230,7 +230,8 @@ export default {
}) })
.then(() => { .then(() => {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
location.href = '/index' // location.href = '/index'
location.href = process.env.ENV === 'testing' ? '/nxdt/index' : 'index'
}) })
}) })
.catch(() => {}) .catch(() => {})

View File

@ -787,7 +787,7 @@ const createRouter = () =>
mode: 'history', // 去掉url中的# mode: 'history', // 去掉url中的#
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes, routes: constantRoutes,
// base: '/nxdt', base: process.env.ENV === 'testing' ? '/nxdt' : '',
}) })
const router = createRouter() const router = createRouter()

View File

@ -18,7 +18,7 @@ module.exports = {
// 部署生产环境和开发环境下的URL。 // 部署生产环境和开发环境下的URL。
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.bonus.vip/。如果应用被部署在一个子路径上你就需要用这个选项指定这个子路径。例如如果你的应用npm被部署在 https://www.bonus.vip/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.bonus.vip/。如果应用被部署在一个子路径上你就需要用这个选项指定这个子路径。例如如果你的应用npm被部署在 https://www.bonus.vip/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.NODE_ENV === 'production' ? '/' : '/', publicPath: process.env.ENV === 'testing' ? '/nxdt' : '/',
// 在npm run build 或 yarn build 时 生成文件的目录名称要和baseUrl的生产环境路径一致默认dist // 在npm run build 或 yarn build 时 生成文件的目录名称要和baseUrl的生产环境路径一致默认dist
outputDir: 'dist', outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
@ -38,9 +38,9 @@ module.exports = {
// target: `http://localhost:18080`, // target: `http://localhost:18080`,
// target: 'http://192.168.0.176:18080', // target: 'http://192.168.0.176:18080',
// target: 'http://192.168.0.58:19090', // 杰 // target: 'http://192.168.0.58:19090', // 杰
//target: 'http://192.168.0.38:18080', // 测试环境 //target: 'http://192.168.0.38:18080', // 测试环境
// target: 'http://218.21.27.6:1999/prod-api', // 生产环境 // target: 'http://218.21.27.6:1999/prod-api', // 生产环境
target: 'http://192.168.0.14:38080', // 郝志权 target: 'http://192.168.0.14:38080', // 郝志权
// target: 'http://192.168.2.122:18080', // 梁超 // target: 'http://192.168.2.122:18080', // 梁超
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {