1
This commit is contained in:
@@ -138,6 +138,8 @@ class AdminFramework {
|
||||
Vue.prototype.$http = http
|
||||
Vue.prototype.$tools = tools
|
||||
Vue.prototype.$uiTool = uiTool
|
||||
Vue.prototype.$funTool = funTool
|
||||
Vue.prototype.$framework = this
|
||||
|
||||
this.registerGlobalComponents(Vue)
|
||||
|
||||
@@ -328,6 +330,11 @@ class AdminFramework {
|
||||
|
||||
const framework = new AdminFramework()
|
||||
|
||||
// 【关键】框架实例创建后立即暴露到全局,确保在任何地方都能访问
|
||||
if (typeof window !== 'undefined') {
|
||||
window.framework = framework
|
||||
}
|
||||
|
||||
export default framework
|
||||
|
||||
export {
|
||||
|
||||
@@ -71,16 +71,10 @@ class Http {
|
||||
if (error && error.response && error.response.status === 401) {
|
||||
if (this.store) {
|
||||
this.store.commit('user/setToken', '')
|
||||
}
|
||||
// 使用框架的 router 实例跳转到登录页
|
||||
try {
|
||||
// 使用 store 中的 router 实例跳转
|
||||
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)
|
||||
}
|
||||
@@ -114,17 +108,13 @@ class Http {
|
||||
}
|
||||
|
||||
showError(msg) {
|
||||
// 优先使用框架的 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)
|
||||
// 使用框架存储的 ViewUI 实例
|
||||
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(msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,24 +110,15 @@ export default class uiTool {
|
||||
}
|
||||
|
||||
static delConfirm(callback) {
|
||||
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('你确定删除吗?')) {
|
||||
const Modal = (window.framework && window.framework.ViewUI && window.framework.ViewUI.Modal) || window.$Modal
|
||||
if (Modal) {
|
||||
Modal.confirm({
|
||||
title: '温馨提示',
|
||||
content: '<p>你确定删除吗?</p>',
|
||||
onOk: () => {
|
||||
callback && callback()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('delConfirm error:', error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user