Compare commits

...

1 Commits

Author SHA1 Message Date
longchao d7da84838c 本地访问配置 1 month ago
  1. 4
      .env.development
  2. 13451
      package-lock.json
  3. 2
      src/main.js
  4. 21
      src/utils/login.js
  5. 2
      src/utils/request.js
  6. 10
      vue.config.js

4
.env.development

@ -1,2 +1,2 @@
VUE_APP_BASE_API=http://agentnew.pengda.checkcopy.com/api
VUE_APP_HOST=//agentnew.pengda.checkcopy.com
VUE_APP_BASE_API=http://agent.pengda.checkcopy.com/api
VUE_APP_HOST=//agent.pengda.checkcopy.com

13451
package-lock.json

File diff suppressed because it is too large

2
src/main.js

@ -92,5 +92,5 @@ autoLoginByToken().then(() => {
}).$mount('#app')
}).catch((e) => {
console.log(e)
window.location.href = process.env.VUE_APP_HOST;
// window.location.href = process.env.VUE_APP_HOST;
});

21
src/utils/login.js

@ -35,16 +35,17 @@ export async function autoLoginByToken(timeout = 10000) {
if(res.data.data.menu_list !== undefined) localStorage.setItem('menu_list', JSON.stringify(res.data.data.menu_list))
}
const res = await axiosWithTimeout(
axios.post(
process.env.VUE_APP_BASE_API+'/agentnew/check_login',{}, // 保证和 x-www-form-urlencoded 匹配
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
),
timeout
);
if(!res.data.status){
throw new Error('您还未登陆');
}
// const res = await axiosWithTimeout(
// axios.post(
// process.env.VUE_APP_BASE_API+'/agentnew/check_login',{}, // 保证和 x-www-form-urlencoded 匹配
// { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
// ),
// timeout
// );
// res.data.status = true
// if(!res.data.status){
// throw new Error('您还未登陆');
// }
const access_token = localStorage.getItem('token')
if(!access_token){

2
src/utils/request.js

@ -5,7 +5,7 @@ import { logout } from '@/utils/logout';
// 创建 axios 实例
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // 从环境变量中读取 API 基础地址
baseURL: 'http://agentnew.checkcopy.com/api', // 从环境变量中读取 API 基础地址
timeout: 60000, // 请求超时时间
headers: {
'Content-Type': 'application/x-www-form-urlencoded'

10
vue.config.js

@ -3,16 +3,22 @@ const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
// publicPath: '/new/',
devServer: {
port:80,
proxy: {
'/supernew': {
target: 'http://adminnew.pengda.checkcopy.com/',
target: 'http://agent.pengda.checkcopy.com/',
changeOrigin: true,
},
'/api/': {
target: 'http://agent.pengda.checkcopy.com/api/',
changeOrigin: true,
},
'/agentnew': {
target: 'http://kuaile.checkcopy.com',
changeOrigin: true,
}
}
},
allowedHosts: 'all'
},
configureWebpack: {
module: {

Loading…
Cancel
Save