From ccf8482af8782957eefbf0a3c2d41d83db773424 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Wed, 17 Jul 2024 10:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A7=E5=B1=8F=E7=9A=84?= =?UTF-8?q?=E6=89=93=E5=8C=85=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgzb-screen/config/index.js | 2 +- sgzb-screen/config/prod.env.js | 2 +- sgzb-screen/src/api/index.js | 22 ++- .../src/components/home/centerBottom.vue | 137 ++++++++++-------- sgzb-screen/src/router/index.js | 10 +- sgzb-screen/src/views/layout.vue | 12 +- sgzb-screen/src/views/login/index.vue | 68 +++++---- 7 files changed, 140 insertions(+), 113 deletions(-) diff --git a/sgzb-screen/config/index.js b/sgzb-screen/config/index.js index 17a35939..bbbb5562 100644 --- a/sgzb-screen/config/index.js +++ b/sgzb-screen/config/index.js @@ -36,7 +36,7 @@ var proxyUrl = // Paths assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static01', - assetsPublicPath: '/bigScrap', + assetsPublicPath: '/bigScrap/', productionSourceMap: false, devtool: '#source-map', productionGzip: false, diff --git a/sgzb-screen/config/prod.env.js b/sgzb-screen/config/prod.env.js index 172a0d7e..6e3c1f48 100644 --- a/sgzb-screen/config/prod.env.js +++ b/sgzb-screen/config/prod.env.js @@ -6,5 +6,5 @@ module.exports = { NODE_ENV: '"production"', //post用当前域名 // API_ROOT: '"http://' + testUrl + '/iot"' - // API_ROOT: '/', + // API_ROOT: '/sgzbgl-api/', } diff --git a/sgzb-screen/src/api/index.js b/sgzb-screen/src/api/index.js index f02e2bb0..1e400086 100644 --- a/sgzb-screen/src/api/index.js +++ b/sgzb-screen/src/api/index.js @@ -2,12 +2,18 @@ * axios全局配置 */ import axios from 'axios'; -axios.defaults.timeout = 30000 +// axios.defaults.timeout = 30000 // 默认配置 -axios.defaults.baseURL = process.env.API_ROOT; +// axios.defaults.baseURL = process.env.API_ROOT; +// axios.defaults.baseURL = '/sgzbgl-api/'; -axios.interceptors.request.use( + +const axiosService = axios.create({ + baseURL: "http://192.168.8.163:21624/sgzbgl-api/",// you can use "process.env.VUE_APP_BASE_API" too + timeout: 30000 +}) +axiosService.interceptors.request.use( config => { let token = localStorage.getItem('token') if (token) { @@ -22,7 +28,7 @@ axios.interceptors.request.use( ); // 添加一个请求拦截器 -axios.interceptors.response.use( +axiosService.interceptors.response.use( response => { if (response.data) { if (response.data.code === 401) { @@ -45,19 +51,21 @@ axios.interceptors.response.use( // 通用POST方法 export const POST = (url, params) => { - return axios.post(`${url}`, params).then(response => response); + return axiosService.post(`${url}`, params).then(response => response); }; // 通用POST_JSON方法 export const POST_JSON = (url, json, params) => { - return axios.post(`${url}`, json, { + return axiosService.post(`${url}`, json, { params: params }).then(response => response); }; // 通用GET方法 export const GET = (url, params) => { - return axios.get(`${url}`, { + return axiosService.get(`${url}`, { params: params }).then(response => response); }; + + diff --git a/sgzb-screen/src/components/home/centerBottom.vue b/sgzb-screen/src/components/home/centerBottom.vue index 9adf65fb..eb81af9b 100644 --- a/sgzb-screen/src/components/home/centerBottom.vue +++ b/sgzb-screen/src/components/home/centerBottom.vue @@ -12,54 +12,61 @@ diff --git a/sgzb-screen/src/router/index.js b/sgzb-screen/src/router/index.js index 8a1a6f2e..fa06dcb5 100644 --- a/sgzb-screen/src/router/index.js +++ b/sgzb-screen/src/router/index.js @@ -70,16 +70,20 @@ router.beforeEach(async (to, from, next) => { if (to.path === '/login/index') { return next(); } - const token = localStorage.getItem('token'); + + + if (to.query.token) { + localStorage.setItem('token', to.query.token) + } + const token = to.query.token || localStorage.getItem('token') || null; if (!token) { - next('/login/index'); // 跳转到登录页 + next('/bigScrap/login/index'); // 跳转到登录页 } else { next(); // 放行 } }); - // if (to.matched.some(r => r.meta.requireLoginAuth)) { // next(); // } else { diff --git a/sgzb-screen/src/views/layout.vue b/sgzb-screen/src/views/layout.vue index c6ddb203..ba309482 100644 --- a/sgzb-screen/src/views/layout.vue +++ b/sgzb-screen/src/views/layout.vue @@ -7,22 +7,18 @@ diff --git a/sgzb-screen/src/views/login/index.vue b/sgzb-screen/src/views/login/index.vue index 97cfef77..a8d480d9 100644 --- a/sgzb-screen/src/views/login/index.vue +++ b/sgzb-screen/src/views/login/index.vue @@ -107,20 +107,25 @@