diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..73c4a95 --- /dev/null +++ b/.env.development @@ -0,0 +1,5 @@ +NODE_ENV='development' +# 请求域名前缀 +VUE_APP_URL='https://swsz.api.js-dyyj.com' +# 打包后输出目录 +VUE_APP_OUTPUTDIR='dist_dev' \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..8808c55 --- /dev/null +++ b/.env.production @@ -0,0 +1,5 @@ +NODE_ENV='production' +# 请求域名前缀 +VUE_APP_URL='https://api.sutenong.com' +# 打包后输出目录 +VUE_APP_OUTPUTDIR='dist' \ No newline at end of file diff --git a/src/libs/axios.js b/src/libs/axios.js index 728d487..d7fc7af 100644 --- a/src/libs/axios.js +++ b/src/libs/axios.js @@ -17,7 +17,7 @@ http.interceptors.request.use((config) => { config.baseURL = process.env.VUE_APP_URL; } - const token = store.state.user.userInfo.token; + const token = store.state.user?.userInfo?.token || ''; config.headers['token'] = token config.headers['Content-Type'] = 'application/json;charset=UTF-8'; @@ -84,7 +84,7 @@ http.interceptors.response.use(response => { }); // 请求方法挂载 -Vue.prototype.get = (params, url, loading = true) => { +Vue.prototype.get = (params, url, loading = false) => { return new Promise((resolve, reject) => { http.get(url, { params, @@ -99,7 +99,7 @@ Vue.prototype.get = (params, url, loading = true) => { }) } -Vue.prototype.post = (data, url, loading = true) => { +Vue.prototype.post = (data, url, loading = false) => { return new Promise((resolve, reject) => { http.post(url, data, { loading // 传递加载状态参数 diff --git a/src/views/Home.vue b/src/views/Home.vue index d0d2430..906682c 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,27 +1,27 @@