Browse Source

本地访问配置

dev_test
longchao 1 month ago
parent
commit
d7da84838c
  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_BASE_API=http://agent.pengda.checkcopy.com/api
VUE_APP_HOST=//agentnew.pengda.checkcopy.com 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') }).$mount('#app')
}).catch((e) => { }).catch((e) => {
console.log(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)) if(res.data.data.menu_list !== undefined) localStorage.setItem('menu_list', JSON.stringify(res.data.data.menu_list))
} }
const res = await axiosWithTimeout( // const res = await axiosWithTimeout(
axios.post( // axios.post(
process.env.VUE_APP_BASE_API+'/agentnew/check_login',{}, // 保证和 x-www-form-urlencoded 匹配 // process.env.VUE_APP_BASE_API+'/agentnew/check_login',{}, // 保证和 x-www-form-urlencoded 匹配
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } } // { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
), // ),
timeout // timeout
); // );
if(!res.data.status){ // res.data.status = true
throw new Error('您还未登陆'); // if(!res.data.status){
} // throw new Error('您还未登陆');
// }
const access_token = localStorage.getItem('token') const access_token = localStorage.getItem('token')
if(!access_token){ if(!access_token){

2
src/utils/request.js

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

10
vue.config.js

@ -3,16 +3,22 @@ const TerserPlugin = require('terser-webpack-plugin');
module.exports = { module.exports = {
// publicPath: '/new/', // publicPath: '/new/',
devServer: { devServer: {
port:80,
proxy: { proxy: {
'/supernew': { '/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, changeOrigin: true,
}, },
'/agentnew': { '/agentnew': {
target: 'http://kuaile.checkcopy.com', target: 'http://kuaile.checkcopy.com',
changeOrigin: true, changeOrigin: true,
} }
} },
allowedHosts: 'all'
}, },
configureWebpack: { configureWebpack: {
module: { module: {

Loading…
Cancel
Save