From c272ea4814dab7815a6068627b9865efa5eb8ee5 Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Wed, 17 May 2023 11:12:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.test | 3 +++ package.json | 4 ++-- src/config/app.js | 12 +++++++----- src/main.js | 12 ++++++++---- vue.config.js | 3 ++- 5 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 .env.test diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..3b67466 --- /dev/null +++ b/.env.test @@ -0,0 +1,3 @@ +VUE_APP_API_BASE=http://192.168.31.140:9998 +template=./public/index-dev.html +outputDir=serve diff --git a/package.json b/package.json index ecc71e5..ec9f319 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "file-saver": "^2.0.2", "js-cookie": "^2.2.0", "mockjs": "^1.0.1-beta3", - "node-sass": "^6.0.1", + "sass": "^1.32.8", "nprogress": "^0.2.0", "pinyin": "^2.10.2", "useless-files-webpack-plugin": "^1.0.1", @@ -38,7 +38,7 @@ "@vue/test-utils": "^1.0.0-beta.16", "babel-core": "7.0.0-bridge.0", "babel-jest": "^23.0.1", - "sass-loader": "^7.0.1", + "sass-loader": "^8.0.2", "vue-template-compiler": "2.5.16" }, "browserslist": [ diff --git a/src/config/app.js b/src/config/app.js index f233274..855f9f2 100644 --- a/src/config/app.js +++ b/src/config/app.js @@ -11,16 +11,18 @@ import "../../public/config.json"; import axios from "axios"; import myReq from "@/utils/axios"; -let BASE_URL = ""; +// let BASE_URL = ""; +let BASE_URL = process.env.VUE_APP_API_BASE; let SERVER_IP = ""; let ROUTER_MODE = ""; let IMG_BASE_URL = BASE_URL; export {BASE_URL, ROUTER_MODE, IMG_BASE_URL, SERVER_IP}; -axios.get('./config.json').then((res) => { +let url = process.env.VUE_APP_API_BASE; +// axios.get('./config.json').then((res) => { // 基础地址 - BASE_URL = res.data.BASE_URL; - SERVER_IP = res.data.SERVER_IP; + // BASE_URL = res.data.BASE_URL; + // SERVER_IP = res.data.SERVER_IP; myReq.defaults.baseURL = BASE_URL; -}); +// }); diff --git a/src/main.js b/src/main.js index d5de5e6..0c2f1a1 100644 --- a/src/main.js +++ b/src/main.js @@ -19,7 +19,7 @@ import {addDateRange,selectDictLabel} from '@/utils/tools'; import "./assets/icons/iconfont"; import IconSvg from "./components/common/IconSvg.vue"; // svg组件 -import { BASE_URL } from "./config/app" +// import { BASE_URL } from "./config/app" import axios from "axios"; import "../public/config.json"; import myReq from "./utils/axios" @@ -37,18 +37,22 @@ Vue.config.silent = true; Vue.config.productionTip = false; Vue.prototype.selectDictLabel = selectDictLabel; let getUrl = ""; +let url = process.env.VUE_APP_API_BASE; let startApp = function () { - axios.get('./config.json').then((res) => { + // axios.get('./config.json').then((res) => { // 基础地址 - getUrl = res.data.BASE_URL; + getUrl = url; myReq.defaults.baseURL = getUrl; + // // 基础地址 + // getUrl = res.data.BASE_URL; + // myReq.defaults.baseURL = getUrl; new Vue({ router, store, render: h => h(App) }).$mount("#app"); - }); + // }); }; startApp(); diff --git a/vue.config.js b/vue.config.js index 3eec51b..0301cff 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,7 +1,8 @@ const UselessFile = require('useless-files-webpack-plugin'); module.exports = { - baseUrl: process.env.NODE_ENV === "production" ? "./" : "/", + lintOnSave:false, + baseUrl: process.env.NODE_ENV === "production"|| "test" ? "./" : "/", outputDir: process.env.outputDir, configureWebpack: config => { if (process.env.NODE_ENV === "production") {