用户禁用后踢出

dev_2022-04-07
yujialong 3 years ago
parent 3c255df977
commit 396b48fd04
  1. 1
      src/api/index.js
  2. 31
      src/plugins/requests/index.js
  3. 2
      src/setting.js

@ -51,6 +51,7 @@ export default {
isClient: `/users/users/user/isClient`, isClient: `/users/users/user/isClient`,
deleteProfile: `/users/users/userInfo/deleteProfile`, deleteProfile: `/users/users/userInfo/deleteProfile`,
checkEmailOrPhone: `/occupationlab/architecture/checkEmailOrPhone`, checkEmailOrPhone: `/occupationlab/architecture/checkEmailOrPhone`,
accountIsDisabled: `/users/users/user/accountIsDisabled`,
userTemplate: `http://39.108.250.202/template/%E6%95%B0%E6%8D%AE%E5%B9%B3%E5%8F%B0%E7%94%A8%E6%88%B7%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`, userTemplate: `http://39.108.250.202/template/%E6%95%B0%E6%8D%AE%E5%B9%B3%E5%8F%B0%E7%94%A8%E6%88%B7%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`,
// 角色管理 // 角色管理

@ -3,14 +3,38 @@ import util from '@/libs/util'
import router from '@/router/index' import router from '@/router/index'
import Setting from '@/setting' import Setting from '@/setting'
import store from '@/store' import store from '@/store'
import api from '@/api'
const baseURL = Setting.apiBaseURL
const service = axios.create({ const service = axios.create({
baseURL: Setting.apiBaseURL, baseURL,
timeout: 10000000 timeout: 10000000
}) })
// post请求头 // post请求头
service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8' service.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
let check = true
let checkTimer = null
// 检测账号是否被禁用,如果禁用则提示并退出登录
function checkDisabled () {
const token = util.local.get(Setting.tokenKey)
if (!token) return false
check = false
axios.get(baseURL + api.accountIsDisabled + '?token=' + token, {
token: util.local.get(Setting.tokenKey),
headers: {
token
}
}).then(res => {
console.log(11, res.data)
if (res.data) {
util.errorMsg('当前账号无权限,请重新登录!')
setTimeout(() => {
store.dispatch('user/logout')
}, 1500)
}
}).catch(res => {})
}
// 请求拦截器 // 请求拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
let token = util.local.get(Setting.tokenKey) let token = util.local.get(Setting.tokenKey)
@ -20,6 +44,11 @@ service.interceptors.request.use(config => {
if(routeSchoolId) routeSchoolId = atob(decodeURI(routeSchoolId)) if(routeSchoolId) routeSchoolId = atob(decodeURI(routeSchoolId))
// 如果store里没有schoolId,则取url里的schoolId,从用户跳转到后台的时候因为加载顺序的问题会出现这个情况,所以要做这个处理 // 如果store里没有schoolId,则取url里的schoolId,从用户跳转到后台的时候因为加载顺序的问题会出现这个情况,所以要做这个处理
if(storeSchoolId || routeSchoolId) config.headers.schoolId = storeSchoolId ? storeSchoolId : routeSchoolId if(storeSchoolId || routeSchoolId) config.headers.schoolId = storeSchoolId ? storeSchoolId : routeSchoolId
clearTimeout(checkTimer)
check && checkDisabled()
checkTimer = setTimeout(() => {
check = true
}, 2000)
return config return config
},err => { },err => {
util.errorMsg({ util.errorMsg({

@ -25,7 +25,7 @@ const Setting = {
* 正式http://www.dataforward.cn:9000 * 正式http://www.dataforward.cn:9000
* */ * */
// apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://39.108.250.202:9000', // apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://39.108.250.202:9000',
apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : `${location.origin}:9000`, apiBaseURL: env === 'development' ? 'http://39.108.250.202:9000' : `${location.origin}:9000`,
// 接口请求返回错误时,弹窗的持续时间,单位:秒 // 接口请求返回错误时,弹窗的持续时间,单位:秒
modalDuration: 3, modalDuration: 3,
// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice

Loading…
Cancel
Save