修改下载token失效的问题
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { axios } from '@/utils/request'
|
import { axios } from '@/utils/request'
|
||||||
|
import store from '@/store'
|
||||||
import JLoadingOne from '../components/jero/JLoadingOne'
|
import JLoadingOne from '../components/jero/JLoadingOne'
|
||||||
|
import { Modal } from 'ant-design-vue'
|
||||||
|
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
|
||||||
|
|
||||||
const showDrawer = {}
|
const showDrawer = {}
|
||||||
|
|
||||||
@@ -153,7 +156,36 @@ export function downloadFile(url, fileName, parameter, callback) {
|
|||||||
isTrue: isTrue
|
isTrue: isTrue
|
||||||
})
|
})
|
||||||
return downFile(url, parameter).then((data) => {
|
return downFile(url, parameter).then((data) => {
|
||||||
console.log(data)
|
let fileReader = new FileReader()
|
||||||
|
fileReader.onload = function(event) {
|
||||||
|
try {
|
||||||
|
let jsonData = JSON.parse(event.target.result)
|
||||||
|
if (jsonData.message.includes('token')) {
|
||||||
|
index.showDrawer({
|
||||||
|
loading: false,
|
||||||
|
isTrue: isTrue
|
||||||
|
})
|
||||||
|
Modal.error({
|
||||||
|
title: '登录已过期',
|
||||||
|
content: '很抱歉,登录已过期,请重新登录',
|
||||||
|
okText: '重新登录',
|
||||||
|
mask: false,
|
||||||
|
onOk: () => {
|
||||||
|
store.dispatch('Logout').then(() => {
|
||||||
|
Vue.ls.remove(ACCESS_TOKEN)
|
||||||
|
try {
|
||||||
|
let path = window.document.location.pathname
|
||||||
|
if (path != '/' && path.indexOf('/user/login') == -1) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
if (!data || data.size === 0) {
|
if (!data || data.size === 0) {
|
||||||
Vue.prototype['$message'].warning('文件下载失败')
|
Vue.prototype['$message'].warning('文件下载失败')
|
||||||
return
|
return
|
||||||
@@ -176,6 +208,9 @@ export function downloadFile(url, fileName, parameter, callback) {
|
|||||||
isTrue: isTrue
|
isTrue: isTrue
|
||||||
})
|
})
|
||||||
callback && callback()
|
callback && callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fileReader.readAsText(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user