漏洞问题修复
This commit is contained in:
parent
6065429c25
commit
be300522e2
|
|
@ -5,7 +5,7 @@ VITE_BUILD_MODE = 'prod'
|
|||
# 线上环境接口地址
|
||||
# VITE_API_URL = 'https://production.com'
|
||||
# VITE_API_URL = 'https://test-rental.zhgkxt.com/proxy'
|
||||
VITE_API_URL = 'https://z.csgmall.com.cn/proxy'
|
||||
VITE_API_URL = 'https://test-rental.zhgkxt.com/proxy'
|
||||
# VITE_API_URL = 'http://localhost:8080/proxy'
|
||||
# 百度地图key
|
||||
VITE_AK = "cClgLBaLgGUdQDilX9dGvieL"
|
||||
|
|
|
|||
3062
pnpm-lock.yaml
3062
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -3,6 +3,7 @@
|
|||
import axios from 'axios'
|
||||
import NProgress from 'nprogress'
|
||||
import { useStore } from 'store/main'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const store = useStore()
|
||||
// const CancelToken = axios.CancelToken
|
||||
// const source = CancelToken.source()
|
||||
|
|
@ -15,7 +16,11 @@ const service = axios.create({
|
|||
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
config.headers['Authorization'] = store.token
|
||||
const jdCloud = JSON.parse(localStorage.getItem('jdcloud')).token
|
||||
if (jdCloud) {
|
||||
config.headers['Authorization'] = jdCloud
|
||||
}
|
||||
|
||||
return config
|
||||
},
|
||||
(error) => {
|
||||
|
|
@ -25,7 +30,19 @@ service.interceptors.request.use(
|
|||
// 响应拦截
|
||||
service.interceptors.response.use(
|
||||
(res) => {
|
||||
const code = res.data.code || 200
|
||||
if (code === 401) {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '登录状态已过期请重新登录',
|
||||
type: 'error',
|
||||
})
|
||||
window.location.href = 'https://test-rental.zhgkxt.com/mall-view/'
|
||||
} else {
|
||||
return res.data
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
(error) => {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import ElementPlus from 'element-plus';
|
||||
import 'element-plus/dist/index.css'
|
||||
import locale from 'element-plus/dist/locale/zh-cn.mjs'
|
||||
|
||||
import App from './App.vue'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import test from './module/test'
|
||||
import myInfo from './module/myInfo'
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
|
|
@ -48,4 +49,22 @@ const router = createRouter({
|
|||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const jdCloud = JSON.parse(localStorage.getItem('jdcloud')).token
|
||||
|
||||
// console.log('jdCloud', jdCloud)
|
||||
if (jdCloud) {
|
||||
next()
|
||||
} else {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '当前未登录,请登录..',
|
||||
type: 'error',
|
||||
})
|
||||
setTimeout(() => {
|
||||
window.location.href = 'https://test-rental.zhgkxt.com/mall-view/'
|
||||
}, 1500)
|
||||
|
||||
}
|
||||
})
|
||||
export default router
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export const useStore = defineStore('main', {
|
|||
state: () => {
|
||||
return {
|
||||
loadingFlag: false, //loading控制,
|
||||
token: 'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjVkNjVlMDI1LWVlY2MtNDBiOS1hNGNjLTQ3OTc4ZDQwMzExMiIsInVzZXJuYW1lIjoiYWRtaW4ifQ.npryPWEmJwBaGgfyZ-oQW8oDxDzitAf8v5XUvsokRvu6f1vSOGTer89C9GJ-ER2bZuvO9iAOYCieDV4INVQCvA'
|
||||
token: ''
|
||||
}
|
||||
},
|
||||
getters: {},
|
||||
|
|
|
|||
Loading…
Reference in New Issue