diff --git a/.env b/.env
index adb4ec7..0e9349d 100644
--- a/.env
+++ b/.env
@@ -1,14 +1,12 @@
-NODE_ENV=development
+# process.env.VUE_APP_API_ROOT
-VUE_APP_ENV=development
+# VUE_APP_API_ROOT_USER=https://smapitest.malls.iformall.com/C
-# VUE_APP_API_ROOT=http://192.168.0.89:8392
-# VUE_APP_API_ROOT=http://192.168.0.165:8392
-#lsf新版接口路径
-# VUE_APP_API_ROOT=http://192.168.0.46:48080
-VUE_APP_API_ROOT=http://192.168.0.89:48080
-# 图片代理接口地址
-VUE_APP_API_ROOT_IMAGE=http://192.168.0.89:8096
-# 登录
-VUE_APP_API_ROOT_USER=http://192.168.0.89:8393
-# VUE_APP_API_ROOT_USER=http://192.168.0.89:8391
\ No newline at end of file
+# 开发
+NODE_ENV=development
+VUE_APP_ENV=development
+VUE_APP_API_ROOT=https://smapitest.malls.iformall.com/C
+# 正式
+# NODE_ENV=production
+# VUE_APP_ENV=production
+# VUE_APP_API_ROOT=http://m.metavatar.cc/C
diff --git a/.env.development b/.env.development
index 9b3b50f..21cb26a 100644
--- a/.env.development
+++ b/.env.development
@@ -1,9 +1,4 @@
-# just a flag
-ENV = 'development'
-# base api
-VUE_APP_BASE_API = '/api'
-
-# environment env 环境
-
-VUE_APP_MONEY = 1000
+# NODE_ENV=development
+# VUE_APP_ENV=development
+# VUE_APP_API_ROOT=https://smapitest.malls.iformall.com/C
diff --git a/.env.production b/.env.production
index 189abfd..b86c8df 100644
--- a/.env.production
+++ b/.env.production
@@ -1,5 +1,4 @@
-NODE_ENV=production
-VUE_APP_ENV=production
-
-VUE_APP_API_ROOT=http://xxxx.com/api
\ No newline at end of file
+# NODE_ENV=production
+# VUE_APP_ENV=production
+# VUE_APP_API_ROOT=http://m.metavatar.cc/C
\ No newline at end of file
diff --git a/public/index.html b/public/index.html
index 0418178..c4fcea4 100644
--- a/public/index.html
+++ b/public/index.html
@@ -12,17 +12,25 @@
-
-
-
-
+
<%= htmlWebpackPlugin.options.title %>
+
+
+
+ <% for(var css of htmlWebpackPlugin.options.cdn.css) { %>
+
+ <% } %>
+
+
+ <% for(var js of htmlWebpackPlugin.options.cdn.js) { %>
+
+ <% } %>
diff --git a/src/api/login.js b/src/api/login.js
index c4a4551..c67a2a5 100644
--- a/src/api/login.js
+++ b/src/api/login.js
@@ -123,7 +123,9 @@ export function doLoginOut() {
* @description 获取图形验证码
* @returns data
*/
-export const doCodeImg =
- 'https://smapitest.malls.iformall.com/C/api/user/captcha.jpg'
- // export const doCodeImg =
- // 'http://m.metavatar.cc/C/api/user/captcha.jpg'
\ No newline at end of file
+// export const doCodeImg =
+// 'https://smapitest.malls.iformall.com/C/api/user/captcha.jpg'
+// export const doCodeImg =
+// 'http://m.metavatar.cc/C/api/user/captcha.jpg'
+
+export const doCodeImg =process.env.VUE_APP_API_ROOT+'/api/user/captcha.jpg'
\ No newline at end of file
diff --git a/src/components/CutImg.vue b/src/components/CutImg.vue
index ae26933..da259c6 100644
--- a/src/components/CutImg.vue
+++ b/src/components/CutImg.vue
@@ -173,8 +173,9 @@ export default {
that
.$axios({
method: 'post',
- url: `https://smapitest.malls.iformall.com/C/api/upload/awsImgUpload`,
+ // url: `https://smapitest.malls.iformall.com/C/api/upload/awsImgUpload`,
// url: `http://m.metavatar.cc/C/api/upload/awsImgUpload`,
+ url: process.env.VUE_APP_API_ROOT + `/api/upload/awsImgUpload`,
headers: {
'content-type': 'multipart/form-data',
token: AccessToken,
diff --git a/src/components/home/home.vue b/src/components/home/home.vue
index e5f4c70..101400a 100644
--- a/src/components/home/home.vue
+++ b/src/components/home/home.vue
@@ -543,8 +543,9 @@ export default {
if (AccessToken) {
this.$axios({
method: 'get',
- url: `https://smapitest.malls.iformall.com/C/api/userVideo/list?pageNum=1&pageSize=3`,
+ // url: `https://smapitest.malls.iformall.com/C/api/userVideo/list?pageNum=1&pageSize=3`,
// url: `http://m.metavatar.cc/C/api/userVideo/list?pageNum=1&pageSize=3`,
+ url: process.env.VUE_APP_API_ROOT + `/api/userVideo/list?pageNum=1&pageSize=3`,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
token: AccessToken
diff --git a/src/utils/request.js b/src/utils/request.js
index e16fce7..f38f3a8 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -3,9 +3,10 @@ import router from '@/router'
import { Toast } from 'vant'
// 基础地址
-const baseURL = 'https://smapitest.malls.iformall.com/C' //测试环境
+// const baseURL = 'https://smapitest.malls.iformall.com/C' //测试环境
// const baseURL = 'http://m.metavatar.cc/C' //正式环境
+const baseURL = process.env.VUE_APP_API_ROOT //测试环境
/**
* @description:发送Axios请求
*/
diff --git a/src/views/myPage/myPage.vue b/src/views/myPage/myPage.vue
index f2f0dff..12f2159 100644
--- a/src/views/myPage/myPage.vue
+++ b/src/views/myPage/myPage.vue
@@ -359,6 +359,8 @@ export default {
},
mounted() {
+ console.log(process.env.NODE_ENV);
+ console.log(process.env.VUE_APP_ENV);
this.inPage = true;
scrollToID('top');
},
diff --git a/vue.config.js b/vue.config.js
index c6e1a89..eea82db 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,12 +1,41 @@
// const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const path = require('path');
+
+let externals = {}
+let cdn = { css: [], js: [] }
+const isProduction = process.env.VUE_APP_ENV == 'production' // 判断是否是生产环境
+if (isProduction) {
+ externals = {
+ /**
+ * externals 对象属性解析:
+ * '包名' : '在项目中引入的名字'
+ */
+ 'vue': 'Vue',
+ 'element-ui': 'ELEMENT',
+ 'xlsx': 'XLSX'
+ }
+ cdn = {
+ css: [
+ 'https://unpkg.com/element-ui/lib/theme-chalk/index.css' // element-ui css 样式表
+ ],
+ js: [
+ // vue must at first!
+ 'https://unpkg.com/vue@2.6.12/dist/vue.js', // vuejs
+ 'https://unpkg.com/element-ui/lib/index.js', // element-ui js
+ 'https://cdn.jsdelivr.net/npm/xlsx@0.16.6/dist/xlsx.full.min.js' // xlsx
+ ]
+ }
+}
+
+
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
- }
+ },
+ externals
},
css: {
loaderOptions: {
@@ -39,7 +68,8 @@ module.exports = {
},
proxy: {
'/api': {
- target: 'https://smapitestmalls,iformall.com/C/api',
+ // target: 'https://smapitestmalls,iformall.com/C/api',
+ target: process.env.VUE_APP_API_ROOT+'/api',
changeOrigin: true,
pathRewrite: {
'^/api': ''
@@ -56,6 +86,17 @@ module.exports = {
args[0].favicon = './public/favicon.ico';
return args;
});
+
+ // 注入cdn变量 (打包时会执行)
+ config.plugin('html').tap(args => {
+ args[0].cdn = cdn // 配置cdn给插件
+ return args
+ })
+
+
+
+
+
}
// configureWebpack: {
// plugins: [