1
This commit is contained in:
42
src/index.js
42
src/index.js
@@ -146,6 +146,9 @@ class AdminFramework {
|
||||
|
||||
// 自动注册全局组件
|
||||
this.registerGlobalComponents(Vue)
|
||||
|
||||
// 自动设置组件映射表
|
||||
this.setupComponentMap()
|
||||
|
||||
// 如果提供了 Vuex,自动创建 Store
|
||||
if (Vuex && !this.store) {
|
||||
@@ -186,6 +189,45 @@ class AdminFramework {
|
||||
// 注册登录页面
|
||||
Vue.component('LoginPage', LoginPage)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置组件映射表(将后端返回的路径映射到实际组件)
|
||||
*/
|
||||
setupComponentMap() {
|
||||
// 组件列表:路径 => 组件
|
||||
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
|
||||
}
|
||||
|
||||
// 自动生成带 .vue 和不带 .vue 的映射
|
||||
const map = {}
|
||||
Object.keys(components).forEach(path => {
|
||||
map[path] = components[path]
|
||||
map[path + '.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 配置
|
||||
|
||||
Reference in New Issue
Block a user