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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,20 +110,31 @@ export default class uiTool {
|
||||
}
|
||||
|
||||
static delConfirm(callback) {
|
||||
if (window.rootVue && window.rootVue.$Modal) {
|
||||
window.rootVue.$Modal.confirm({
|
||||
title: '温馨提示',
|
||||
content: '<p>你确定删除吗?</p>',
|
||||
onOk: () => {
|
||||
try {
|
||||
const Modal = (window.framework && window.framework.ViewUI && window.framework.ViewUI.Modal) || window.$Modal
|
||||
if (Modal) {
|
||||
Modal.confirm({
|
||||
title: '温馨提示',
|
||||
content: '<p>你确定删除吗?</p>',
|
||||
onOk: () => {
|
||||
callback && callback()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 如果 Modal 不存在,使用原生确认框
|
||||
if (confirm('你确定删除吗?')) {
|
||||
callback && callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('delConfirm error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
static showConfirm({ title = '温馨提示', content = '内容' }, callback) {
|
||||
if (window.rootVue && window.rootVue.$Modal) {
|
||||
window.rootVue.$Modal.confirm({
|
||||
const Modal = (window.framework && window.framework.ViewUI && window.framework.ViewUI.Modal) || window.$Modal
|
||||
if (Modal) {
|
||||
Modal.confirm({
|
||||
title,
|
||||
content,
|
||||
onOk: () => {
|
||||
|
||||
Reference in New Issue
Block a user