1
This commit is contained in:
@@ -51,7 +51,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
actionUrl: window.rootVue.$config.apiUrl + 'sys_file/upload_oos_img',
|
||||
actionUrl: this.config.apiUrl + 'sys_file/upload_oos_img',
|
||||
cropper: null,
|
||||
insideSrc: '',
|
||||
file: null,
|
||||
@@ -81,7 +81,7 @@ export default {
|
||||
reader.onload = async (event) => {
|
||||
this.getSize(event.srcElement.result).then(({ width, height }) => {
|
||||
if (width < 500 || height < 500) {
|
||||
rootVue.$Message.error('图片尺寸小于 500*500 ,请更换图片')
|
||||
this.$Message.error('图片尺寸小于 500*500 ,请更换图片')
|
||||
return false
|
||||
}
|
||||
this.insideSrc = event.srcElement.result
|
||||
|
||||
@@ -25,7 +25,7 @@ export default {
|
||||
this.editor = new WangEditor(domId)
|
||||
this.editor.config.uploadImgShowBase64 = true
|
||||
|
||||
this.editor.config.uploadImgServer = window.rootVue.$config.apiUrl + 'sys_file/upload_oos_img'
|
||||
this.editor.config.uploadImgServer =this.config.apiUrl + 'sys_file/upload_oos_img'
|
||||
this.editor.config.uploadImgHooks = {
|
||||
customInsert: (insertImg, result, editor) => {
|
||||
var url = result.data.path
|
||||
|
||||
@@ -37,7 +37,7 @@ export default {
|
||||
return {
|
||||
headers,
|
||||
uploadList: [],
|
||||
actionUrl: window.rootVue.$config.apiUrl + 'sys_file/upload_oos_img',
|
||||
actionUrl:this.config.apiUrl + 'sys_file/upload_oos_img',
|
||||
imgSrc: '',
|
||||
visible: false,
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
headers,
|
||||
actionUrl: window.rootVue.$config.apiUrl + 'sys_file/upload_oos_img',
|
||||
actionUrl: this.config.apiUrl + 'sys_file/upload_oos_img',
|
||||
imgUrl: '',
|
||||
visible: false,
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const funTool = {
|
||||
|
||||
import storeModules, { userModule, appModule } from './store'
|
||||
|
||||
import routerConfig, { createBaseRoutes, setupRouterGuards } from './router'
|
||||
import { createBaseRoutes, setupRouterGuards } from './router'
|
||||
|
||||
import HomePage from './views/home/index.vue'
|
||||
|
||||
@@ -75,6 +75,7 @@ class AdminFramework {
|
||||
this.config = {}
|
||||
this.store = null
|
||||
this.router = null
|
||||
this.ViewUI = null
|
||||
|
||||
this.tools = tools
|
||||
this.uiTool = uiTool
|
||||
@@ -119,6 +120,7 @@ class AdminFramework {
|
||||
|
||||
const { config = {}, ViewUI, VueRouter, Vuex, createPersistedState, componentMap } = options
|
||||
this.config = config
|
||||
this.ViewUI = ViewUI
|
||||
|
||||
if (ViewUI) {
|
||||
Vue.use(ViewUI)
|
||||
|
||||
@@ -104,9 +104,8 @@ export default {
|
||||
commit('setMenuList', mainMenu.children)
|
||||
|
||||
// 动态添加路由(重要!解决登录后点击菜单空白的问题)
|
||||
if (window.rootVue && window.rootVue.$router) {
|
||||
const router = window.rootVue.$router
|
||||
const routes = router.options.routes
|
||||
if (this.router) {
|
||||
const routes =this.router.options.routes
|
||||
|
||||
// 查找并移除旧的主路由
|
||||
const mainRouteIndex = routes.findIndex(r => r.path === '/')
|
||||
|
||||
@@ -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: () => {
|
||||
|
||||
@@ -75,7 +75,7 @@ export default {
|
||||
|
||||
this.$refs.editModal.addShow({}, async (row) => {
|
||||
await paramSetupServer.add(row)
|
||||
rootVue.$Message.success('新增成功!')
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
@@ -88,7 +88,7 @@ export default {
|
||||
this.gridOption.editRow = row
|
||||
this.$refs.editModal.editShow(row, async (newRow) => {
|
||||
await paramSetupServer.edit(newRow)
|
||||
rootVue.$Message.success('修改成功!')
|
||||
this.$Message.success('修改成功!')
|
||||
|
||||
this.init()
|
||||
})
|
||||
@@ -96,7 +96,7 @@ export default {
|
||||
async delConfirm(row) {
|
||||
uiTool.delConfirm(async () => {
|
||||
await paramSetupServer.del(row)
|
||||
rootVue.$Message.success('删除成功!')
|
||||
this.$Message.success('删除成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
|
||||
@@ -82,21 +82,21 @@ export default {
|
||||
this.$refs.editModal.addShow({}, async (row) => {
|
||||
await roleServer.add(row)
|
||||
this.init()
|
||||
await rootVue.$Message.success('新增成功!')
|
||||
await this.$Message.success('新增成功!')
|
||||
})
|
||||
},
|
||||
showEditWarp(row) {
|
||||
this.$refs.editModal.editShow(row, async (newRow) => {
|
||||
await roleServer.edit(newRow)
|
||||
await this.init()
|
||||
rootVue.$Message.success('修改成功!')
|
||||
this.$Message.success('修改成功!')
|
||||
})
|
||||
},
|
||||
async delConfirm(row) {
|
||||
uiTool.delConfirm(async () => {
|
||||
await roleServer.del(row)
|
||||
await this.init()
|
||||
rootVue.$Message.success('删除成功!')
|
||||
this.$Message.success('删除成功!')
|
||||
})
|
||||
},
|
||||
async submitPermission() {
|
||||
@@ -110,7 +110,7 @@ export default {
|
||||
|
||||
await roleServer.edit(param)
|
||||
await this.init()
|
||||
rootVue.$Message.success('权限修改成功!')
|
||||
this.$Message.success('权限修改成功!')
|
||||
|
||||
this.isShowPermission = false
|
||||
},
|
||||
|
||||
@@ -112,21 +112,21 @@ export default {
|
||||
showAddWarp() {
|
||||
this.$refs.editModal.addShow({}, async (newRow) => {
|
||||
await userServer.add(newRow)
|
||||
rootVue.$Message.success('新增成功!')
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
showEditWarp(row) {
|
||||
this.$refs.editModal.editShow(row, async (newRow) => {
|
||||
await userServer.edit(newRow)
|
||||
rootVue.$Message.success('修改成功!')
|
||||
this.$Message.success('修改成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
async delConfirm(row) {
|
||||
uiTool.delConfirm(async () => {
|
||||
await userServer.del(row)
|
||||
rootVue.$Message.success('删除成功!')
|
||||
this.$Message.success('删除成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
|
||||
@@ -119,7 +119,7 @@ export default {
|
||||
async showAddWarp() {
|
||||
this.$refs.editModal.addShow({}, async (newRow) => {
|
||||
let res = await sysControlTypeServer.add(newRow)
|
||||
rootVue.$Message.success('新增成功!')
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
let valid = await this.$refs['editModal'].$refs['From'].validate()
|
||||
if (valid) {
|
||||
let res = await sysControlTypeServer.edit(newRow)
|
||||
rootVue.$Message.success('修改成功!')
|
||||
this.$Message.success('修改成功!')
|
||||
this.init()
|
||||
}
|
||||
})
|
||||
@@ -137,7 +137,7 @@ export default {
|
||||
async delConfirm(row) {
|
||||
uiTool.delConfirm(async () => {
|
||||
await sysControlTypeServer.del(row)
|
||||
rootVue.$Message.success('删除成功!')
|
||||
this.$Message.success('删除成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
|
||||
@@ -317,7 +317,7 @@ export default {
|
||||
this.$refs.editModal.editShow(this.editRow, async (newRow) => {
|
||||
let param = Object.assign({}, this.editRow, newRow)
|
||||
await menuServer.edit(param)
|
||||
rootVue.$Message.success('修改成功!')
|
||||
this.$Message.success('修改成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
@@ -335,7 +335,7 @@ export default {
|
||||
this.$refs.editModal.addShow(this.editRow, async (newRow) => {
|
||||
let param = Object.assign({}, newRow)
|
||||
await menuServer.add(param)
|
||||
rootVue.$Message.success('新增成功!')
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
@@ -354,14 +354,14 @@ export default {
|
||||
this.$refs.editModal.addShow(this.editRow, async (newRow) => {
|
||||
let param = Object.assign({}, newRow)
|
||||
await menuServer.add(param)
|
||||
rootVue.$Message.success('新增成功!')
|
||||
this.$Message.success('新增成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
async delConfirm(row) {
|
||||
uiTool.delConfirm(async () => {
|
||||
await menuServer.del(row)
|
||||
rootVue.$Message.success('删除成功!')
|
||||
this.$Message.success('删除成功!')
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
@@ -372,7 +372,7 @@ export default {
|
||||
},
|
||||
async () => {
|
||||
let res = await menuServer.generate(row)
|
||||
rootVue.$Message.success('生成成功!')
|
||||
this.$Message.success('生成成功!')
|
||||
this.init()
|
||||
}
|
||||
)
|
||||
@@ -384,7 +384,7 @@ export default {
|
||||
},
|
||||
async () => {
|
||||
let res = await menuServer.generateModel(row)
|
||||
rootVue.$Message.success('生成成功!')
|
||||
this.$Message.success('生成成功!')
|
||||
this.init()
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user