1
This commit is contained in:
@@ -24,6 +24,9 @@ const config = {
|
||||
uploadUrl: 'http://localhost:9098/admin_api/upload' // 修改为你的上传地址
|
||||
}
|
||||
|
||||
// 提前暴露框架实例(确保工具类可以访问)
|
||||
window.framework = AdminFramework
|
||||
|
||||
// 初始化框架
|
||||
AdminFramework.install(Vue, {
|
||||
config: config,
|
||||
@@ -82,7 +85,6 @@ app.$mount('#app')
|
||||
// 全局暴露(方便调试)
|
||||
window.app = app
|
||||
window.rootVue = app
|
||||
window.framework = AdminFramework
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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({
|
||||
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()
|
||||
}
|
||||
)
|
||||
|
||||
362
temp_index.txt
362
temp_index.txt
@@ -1,362 +0,0 @@
|
||||
/**
|
||||
* Admin Framework - 閫氱敤鍚庡彴绠$悊绯荤粺妗嗘灦
|
||||
* 鐗堟湰: 1.0.0
|
||||
*
|
||||
* 鍔熻兘鍖呭惈:
|
||||
* - 绯荤粺绠$悊鍔熻兘 (sys_*)
|
||||
* - 鐢ㄦ埛鐧诲綍鍜屾潈闄愮鐞? * - 鍔ㄦ€佽矾鐢辩鐞? * - 涓诲竷灞€鍜岄〉闈㈠竷灞€
|
||||
* - 鍏ㄥ眬缁勪欢
|
||||
* - 宸ュ叿搴? * - Vuex 鐘舵€佺鐞? */
|
||||
|
||||
// ==================== 鏍峰紡鏂囦欢 ====================
|
||||
import './assets/css/animate.css'
|
||||
import './assets/css/base.less'
|
||||
import './assets/css/ivewExpand.less'
|
||||
import './assets/icons/iconfont.css'
|
||||
|
||||
// ==================== 宸ュ叿搴?====================
|
||||
import uiTool from './utils/uiTool'
|
||||
import http from './utils/http'
|
||||
import * as tools from './utils/tools'
|
||||
|
||||
// ==================== Store 妯″潡 ====================
|
||||
import storeModules, { userModule, appModule } from './store'
|
||||
|
||||
// ==================== 璺敱閰嶇疆 ====================
|
||||
import routerConfig, { createBaseRoutes, setupRouterGuards } from './router'
|
||||
|
||||
// ==================== 绯荤粺椤甸潰 ====================
|
||||
// 涓婚〉
|
||||
import HomePage from './views/home/index.vue'
|
||||
|
||||
// system 椤甸潰
|
||||
import SysLog from './views/system/sys_log.vue'
|
||||
import SysParamSetup from './views/system/sys_param_setup.vue'
|
||||
import SysRole from './views/system/sys_role.vue'
|
||||
import SysUser from './views/system/sys_user.vue'
|
||||
|
||||
// system_high 椤甸潰
|
||||
import SysControl from './views/system_high/sys_control.vue'
|
||||
import SysMenu from './views/system_high/sys_menu.vue'
|
||||
import SysTitle from './views/system_high/sys_title.vue'
|
||||
|
||||
// 鐧诲綍鍜岄敊璇〉闈?import LoginPage from './views/login/login.vue'
|
||||
import Page401 from './views/error-page/401.vue'
|
||||
import Page404 from './views/error-page/404.vue'
|
||||
import Page500 from './views/error-page/500.vue'
|
||||
|
||||
// 甯冨眬缁勪欢
|
||||
import Main from './components/main'
|
||||
import ParentView from './components/parent-view'
|
||||
|
||||
// ==================== 绯荤粺 API ====================
|
||||
// system API
|
||||
import * as systemApi from './api/system'
|
||||
// system_high API
|
||||
import * as systemHighApi from './api/system_high'
|
||||
|
||||
// ==================== 妗嗘灦绫?====================
|
||||
class AdminFramework {
|
||||
constructor() {
|
||||
this.version = '1.0.0'
|
||||
this.installed = false
|
||||
this.config = {}
|
||||
this.store = null
|
||||
this.router = null
|
||||
|
||||
// 瀵煎嚭宸ュ叿
|
||||
this.tools = tools
|
||||
this.uiTool = uiTool
|
||||
this.http = http
|
||||
|
||||
// 瀵煎嚭 Store 妯″潡
|
||||
this.storeModules = storeModules
|
||||
this.userModule = userModule
|
||||
this.appModule = appModule
|
||||
|
||||
// 瀵煎嚭璺敱閰嶇疆
|
||||
this.createBaseRoutes = createBaseRoutes
|
||||
this.setupRouterGuards = setupRouterGuards
|
||||
|
||||
// 瀵煎嚭缁勪欢
|
||||
this.Main = Main
|
||||
this.ParentView = ParentView
|
||||
this.LoginPage = LoginPage
|
||||
this.Page401 = Page401
|
||||
this.Page404 = Page404
|
||||
this.Page500 = Page500
|
||||
|
||||
// 瀵煎嚭绯荤粺椤甸潰
|
||||
this.HomePage = HomePage
|
||||
this.SysLog = SysLog
|
||||
this.SysParamSetup = SysParamSetup
|
||||
this.SysRole = SysRole
|
||||
this.SysUser = SysUser
|
||||
this.SysControl = SysControl
|
||||
this.SysMenu = SysMenu
|
||||
this.SysTitle = SysTitle
|
||||
|
||||
// 瀵煎嚭 API
|
||||
this.systemApi = systemApi
|
||||
this.systemHighApi = systemHighApi
|
||||
}
|
||||
|
||||
/**
|
||||
* Vue 鎻掍欢瀹夎鏂规硶 - 鑷姩瀹屾垚鎵€鏈夊垵濮嬪寲
|
||||
* @param {Object} Vue - Vue 瀹炰緥
|
||||
* @param {Object} options - 閰嶇疆閫夐」
|
||||
* @param {Object} options.config - 搴旂敤閰嶇疆
|
||||
* @param {Object} options.ViewUI - ViewUI 瀹炰緥锛堝彲閫夛紝妗嗘灦浼氳嚜鍔ㄥ鐞嗭級
|
||||
* @param {Object} options.VueRouter - VueRouter 瀹炰緥锛堝彲閫夛級
|
||||
* @param {Object} options.Vuex - Vuex 瀹炰緥锛堝彲閫夛級
|
||||
* @param {Function} options.createPersistedState - vuex-persistedstate锛堝彲閫夛級
|
||||
* @param {Object} options.componentMap - 鑷畾涔夌粍浠舵槧灏勮〃锛堝彲閫夛級
|
||||
*/
|
||||
install(Vue, options = {}) {
|
||||
if (this.installed) return
|
||||
this.installed = true
|
||||
|
||||
const { config = {}, ViewUI, VueRouter, Vuex, createPersistedState, componentMap } = options
|
||||
this.config = config
|
||||
|
||||
// 鑷姩娉ㄥ唽 ViewUI
|
||||
if (ViewUI) {
|
||||
Vue.use(ViewUI)
|
||||
}
|
||||
|
||||
// 鑷姩娉ㄥ唽 VueRouter
|
||||
if (VueRouter) {
|
||||
Vue.use(VueRouter)
|
||||
}
|
||||
|
||||
// 鑷姩娉ㄥ唽 Vuex
|
||||
if (Vuex) {
|
||||
Vue.use(Vuex)
|
||||
}
|
||||
|
||||
// 鎸傝浇鍏ㄥ眬閰嶇疆鍜屽伐鍏? Vue.prototype.$config = config
|
||||
Vue.prototype.$http = http
|
||||
Vue.prototype.$tools = tools
|
||||
Vue.prototype.$uiTool = uiTool
|
||||
|
||||
// 鑷姩娉ㄥ唽鍏ㄥ眬缁勪欢
|
||||
this.registerGlobalComponents(Vue)
|
||||
|
||||
// 鑷姩璁剧疆缁勪欢鏄犲皠琛紙鍖呭惈澶栭儴浼犲叆鐨勬槧灏勶級
|
||||
this.setupComponentMap(componentMap)
|
||||
|
||||
// 濡傛灉鎻愪緵浜?Vuex锛岃嚜鍔ㄥ垱寤?Store
|
||||
if (Vuex && !this.store) {
|
||||
this.store = this.createStore(Vuex, {}, createPersistedState)
|
||||
// 鑷姩鍒濆鍖?HTTP
|
||||
http.init(config, this.store)
|
||||
}
|
||||
|
||||
// 濡傛灉鎻愪緵浜?VueRouter锛岃嚜鍔ㄥ垱寤?Router
|
||||
if (VueRouter && !this.router) {
|
||||
// 鑾峰彇涓昏矾鐢遍厤缃紙浠庡悗绔潈闄愯彍鍗曠敓鎴愶級
|
||||
const mainRoute = this.getRoutes({ Main, ParentView, Page404 })
|
||||
|
||||
this.router = this.createRouter(VueRouter, {
|
||||
Main,
|
||||
ParentView,
|
||||
LoginPage,
|
||||
Page401,
|
||||
Page404,
|
||||
Page500
|
||||
}, mainRoute ? [mainRoute] : [], ViewUI)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 鑷姩娉ㄥ唽鍏ㄥ眬缁勪欢
|
||||
*/
|
||||
registerGlobalComponents(Vue) {
|
||||
// 娉ㄥ唽甯冨眬缁勪欢
|
||||
Vue.component('Main', Main)
|
||||
Vue.component('ParentView', ParentView)
|
||||
|
||||
// 娉ㄥ唽閿欒椤甸潰
|
||||
Vue.component('Page401', Page401)
|
||||
Vue.component('Page404', Page404)
|
||||
Vue.component('Page500', Page500)
|
||||
|
||||
// 娉ㄥ唽鐧诲綍椤甸潰
|
||||
Vue.component('LoginPage', LoginPage)
|
||||
}
|
||||
|
||||
/**
|
||||
* 璁剧疆缁勪欢鏄犲皠琛紙灏嗗悗绔繑鍥炵殑璺緞鏄犲皠鍒板疄闄呯粍浠讹級
|
||||
* @param {Object} customMap - 澶栭儴浼犲叆鐨勮嚜瀹氫箟缁勪欢鏄犲皠
|
||||
*/
|
||||
setupComponentMap(customMap = {}) {
|
||||
// 妗嗘灦鍐呯疆缁勪欢鍒楄〃锛氳矾寰?=> 缁勪欢
|
||||
const components = {
|
||||
'home/index': HomePage,
|
||||
'system/sys_log': SysLog,
|
||||
'system/sys_param_setup': SysParamSetup,
|
||||
'system/sys_role': SysRole,
|
||||
'system/sys_user': SysUser,
|
||||
'system_high/sys_control': SysControl,
|
||||
'system_high/sys_menu': SysMenu,
|
||||
'system_high/sys_title': SysTitle,
|
||||
// 鍚堝苟澶栭儴浼犲叆鐨勭粍浠舵槧灏? ...customMap
|
||||
}
|
||||
|
||||
// 鑷姩鐢熸垚甯?.vue 鍜屼笉甯?.vue 鐨勬槧灏? const map = {}
|
||||
Object.keys(components).forEach(path => {
|
||||
const cleanPath = path.replace(/\.vue$/, '')
|
||||
map[cleanPath] = components[path]
|
||||
map[cleanPath + '.vue'] = components[path]
|
||||
})
|
||||
|
||||
uiTool.setComponentMap(map)
|
||||
}
|
||||
|
||||
/**
|
||||
* 娣诲姞鑷畾涔夌粍浠舵槧灏? * @param {Object} customMap - 鑷畾涔夌粍浠舵槧灏勫璞? * @example
|
||||
* AdminFramework.addComponentMap({
|
||||
* 'ball/games.vue': GamesComponent,
|
||||
* 'order/pay_orders.vue': PayOrdersComponent
|
||||
* })
|
||||
*/
|
||||
addComponentMap(customMap) {
|
||||
uiTool.setComponentMap(customMap)
|
||||
}
|
||||
|
||||
/**
|
||||
* 鍒濆鍖?HTTP 閰嶇疆
|
||||
* @param {Object} config - HTTP 閰嶇疆
|
||||
* @param {Object} store - Vuex Store 瀹炰緥
|
||||
*/
|
||||
initHttp(config, store) {
|
||||
http.init(config, store)
|
||||
this.store = store
|
||||
}
|
||||
|
||||
/**
|
||||
* 鍒涘缓璺敱瀹炰緥
|
||||
* @param {Object} Router - VueRouter 绫? * @param {Object} components - 缁勪欢瀵硅薄
|
||||
* @param {Array} customRoutes - 鑷畾涔夎矾鐢? * @param {Object} ViewUI - ViewUI 瀹炰緥
|
||||
* @param {String} homeName - 棣栭〉鍚嶇О
|
||||
* @returns {Object} router 瀹炰緥
|
||||
*/
|
||||
createRouter(Router, components = {}, customRoutes = [], ViewUI, homeName = 'home') {
|
||||
const { LoginPage, Page401, Page404, Page500 } = components
|
||||
|
||||
if (!LoginPage || !Page401 || !Page404 || !Page500) {
|
||||
console.error('Missing required page components')
|
||||
return null
|
||||
}
|
||||
|
||||
const baseRoutes = createBaseRoutes(LoginPage, Page401, Page404, Page500)
|
||||
|
||||
const router = new Router({
|
||||
routes: [...baseRoutes, ...customRoutes],
|
||||
mode: 'hash'
|
||||
})
|
||||
|
||||
if (ViewUI) {
|
||||
setupRouterGuards(router, ViewUI, homeName)
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
/**
|
||||
* 鍒涘缓 Store 瀹炰緥
|
||||
* @param {Object} Vuex - Vuex 绫? * @param {Object} customModules - 鑷畾涔夋ā鍧? * @param {Object} createPersistedState - vuex-persistedstate 鎻掍欢
|
||||
* @returns {Object} store 瀹炰緥
|
||||
*/
|
||||
createStore(Vuex, customModules = {}, createPersistedState) {
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
user: userModule,
|
||||
app: appModule,
|
||||
...customModules
|
||||
},
|
||||
plugins: createPersistedState ? [
|
||||
createPersistedState({
|
||||
storage: window.localStorage
|
||||
})
|
||||
] : []
|
||||
})
|
||||
|
||||
this.store = store
|
||||
return store
|
||||
}
|
||||
|
||||
/**
|
||||
* 鑾峰彇鍔ㄦ€佽矾鐢? * @param {Object} components - 缁勪欢瀵硅薄
|
||||
* @returns {Object} 涓昏矾鐢遍厤缃? */
|
||||
getRoutes(components = {}) {
|
||||
const { Main, ParentView, Page404 } = components
|
||||
|
||||
if (!Main || !ParentView || !Page404) {
|
||||
console.error('Missing required layout components')
|
||||
return null
|
||||
}
|
||||
|
||||
return uiTool.getRoutes(Main, ParentView, Page404)
|
||||
}
|
||||
|
||||
/**
|
||||
* 娉ㄥ唽鍏ㄥ眬缁勪欢
|
||||
* @param {Object} Vue - Vue 瀹炰緥
|
||||
* @param {Object} components - 缁勪欢瀵硅薄
|
||||
*/
|
||||
registerComponents(Vue, components = {}) {
|
||||
Object.keys(components).forEach(name => {
|
||||
Vue.component(name, components[name])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 鍒涘缓瀹炰緥骞跺鍑?====================
|
||||
const framework = new AdminFramework()
|
||||
|
||||
// 榛樿瀵煎嚭妗嗘灦瀹炰緥
|
||||
export default framework
|
||||
|
||||
// 鎸夐渶瀵煎嚭
|
||||
export {
|
||||
// 宸ュ叿搴? tools,
|
||||
uiTool,
|
||||
http,
|
||||
|
||||
// Store 妯″潡
|
||||
storeModules,
|
||||
userModule,
|
||||
appModule,
|
||||
|
||||
// 璺敱閰嶇疆
|
||||
createBaseRoutes,
|
||||
setupRouterGuards,
|
||||
|
||||
// 绯荤粺椤甸潰
|
||||
HomePage,
|
||||
SysLog,
|
||||
SysParamSetup,
|
||||
SysRole,
|
||||
SysUser,
|
||||
SysControl,
|
||||
SysMenu,
|
||||
SysTitle,
|
||||
|
||||
// 鐧诲綍鍜岄敊璇〉闈? LoginPage,
|
||||
Page401,
|
||||
Page404,
|
||||
Page500,
|
||||
|
||||
// 甯冨眬缁勪欢
|
||||
Main,
|
||||
ParentView,
|
||||
|
||||
// 绯荤粺 API
|
||||
systemApi,
|
||||
systemHighApi,
|
||||
|
||||
// 妗嗘灦绫? AdminFramework
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user