1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import { formatDate } from './tools'
|
||||
|
||||
|
||||
class Http {
|
||||
constructor() {
|
||||
this.config = {
|
||||
@@ -71,8 +72,15 @@ class Http {
|
||||
if (this.store) {
|
||||
this.store.commit('user/setToken', '')
|
||||
}
|
||||
if (window.rootVue && window.rootVue.$router) {
|
||||
window.rootVue.$router.push({ path: '/login' }) // 使用 path 而不是 name
|
||||
// 使用框架的 router 实例跳转到登录页
|
||||
try {
|
||||
if (window.framework && window.framework.router) {
|
||||
window.framework.router.push({ path: '/login' })
|
||||
} else if (window.location) {
|
||||
window.location.href = '#/login'
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('跳转登录页失败:', err)
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
@@ -106,8 +114,17 @@ class Http {
|
||||
}
|
||||
|
||||
showError(msg) {
|
||||
if (window.rootVue && window.rootVue.$Message) {
|
||||
window.rootVue.$Message.error({ content: msg, duration: 3 })
|
||||
// 优先使用框架的 ViewUI 实例,如果不存在则使用全局的 $Message
|
||||
try {
|
||||
if (window.framework && window.framework.ViewUI && window.framework.ViewUI.Message) {
|
||||
window.framework.ViewUI.Message.error({ content: msg, duration: 3 })
|
||||
} else if (window.$Message) {
|
||||
window.$Message.error({ content: msg, duration: 3 })
|
||||
} else {
|
||||
console.error('[HTTP Error]', msg)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[HTTP Error]', msg, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user