正式环境加上登录校验

main
许宏杰 5 days ago
parent 5ced2804f7
commit 692c146649

@ -11,7 +11,7 @@
<link rel="icon" href="/favicon.ico" />
<title>若依管理系统</title>
<!--引入mars3d库lib 莱斯服务器-->
<!-- <link
<link
href="https://zwyth.ntgaj.cn:8008/map3d/Cesium/Widgets/widgets.css"
rel="stylesheet"
type="text/css"
@ -32,10 +32,10 @@
<script
src="https://zwyth.ntgaj.cn:8008/map3d/mars3d/mars3d.js"
type="text/javascript"
></script> -->
></script>
<!--引入mars3d库lib 官方服务-->
<!--
<link
href="https://registry.npmmirror.com/mars3d-cesium/latest/files/Build/Cesium/Widgets/widgets.css"
rel="stylesheet"
@ -54,7 +54,7 @@
<script
src="https://registry.npmmirror.com/mars3d/latest/files/mars3d.js"
type="text/javascript"
></script>
></script> -->
<!--[if lt IE 11
]><script>

@ -1,5 +1,17 @@
import request from "@/utils/request";
export function getToken(){
// 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDUzNzI5NTgsInVzZXJuYW1lIjoibGl4aWFvamlhbiJ9.tiM-Mv4SQdvpahfrgb7HGNNYN3_9f8634RltsbvO22k'
return request({
url: "/api/sys/userInfoByToken",
headers: {
'x-access-token':localStorage.getItem("X-Access-Token")
},
method: "get",
})
}
// 服务点位
export function getPointListByType(query) {
//轨道交通警务站type=13,巡防警务站ype=04
@ -12,8 +24,6 @@ export function getPointListByType(query) {
}
// 关键字搜索
export function getPointList(query) {

@ -1,5 +1,14 @@
import { createApp } from 'vue'
// location.href = `${location.origin}${process.env.VUE_APP_URL}/pharmaceuticals/singleSignOn/signOut`;
import Cookies from 'js-cookie'
import ElementPlus from 'element-plus'
@ -13,6 +22,14 @@ import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive
import { getToken } from '@/api/mapApi'
if(import.meta.env.VITE_APP_ENV === "production"){
getToken()
}
// 注册指令
import plugins from './plugins' // plugins
@ -55,6 +72,7 @@ app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels
// 全局组件挂载
app.component('DictTag', DictTag)
app.component('Pagination', Pagination)

@ -95,6 +95,7 @@ service.interceptors.response.use(res => {
}
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
ElMessage({ message: msg, type: 'error' })
return Promise.reject(new Error(msg))
} else if (code === 601) {
@ -108,14 +109,17 @@ service.interceptors.response.use(res => {
}
},
error => {
console.log('err' + error)
let { message } = error;
if (message == "Network Error") {
message = "后端接口连接异常";
} else if (message.includes("timeout")) {
message = "系统接口请求超时";
} else if (message.includes("Request failed with status code")) {
if(import.meta.env.VITE_APP_ENV === "production") location.href = `${location.origin}/login`
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
ElMessage({ message: message, type: 'error', duration: 5 * 1000 })
return Promise.reject(error)

Loading…
Cancel
Save