1
This commit is contained in:
16
src/index.js
16
src/index.js
@@ -117,13 +117,12 @@ class AdminFramework {
|
||||
* @param {Object} options.VueRouter - VueRouter 实例(可选)
|
||||
* @param {Object} options.Vuex - Vuex 实例(可选)
|
||||
* @param {Function} options.createPersistedState - vuex-persistedstate(可选)
|
||||
* @param {Object} options.homeRoute - 自定义 home 路由配置(可选,用于覆盖默认 home)
|
||||
*/
|
||||
install(Vue, options = {}) {
|
||||
if (this.installed) return
|
||||
this.installed = true
|
||||
|
||||
const { config = {}, ViewUI, VueRouter, Vuex, createPersistedState, homeRoute } = options
|
||||
const { config = {}, ViewUI, VueRouter, Vuex, createPersistedState } = options
|
||||
this.config = config
|
||||
|
||||
// 自动注册 ViewUI
|
||||
@@ -161,18 +160,7 @@ class AdminFramework {
|
||||
if (VueRouter && !this.router) {
|
||||
// 获取主路由配置(包含 home)
|
||||
const mainRoute = this.getRoutes({ Main, ParentView, Page404 })
|
||||
|
||||
// 如果外部提供了自定义 homeRoute,合并到主路由的 children 中
|
||||
if (homeRoute && mainRoute && mainRoute.children) {
|
||||
// 查找并替换默认的 home 路由
|
||||
const homeIndex = mainRoute.children.findIndex(route => route.name === 'home')
|
||||
if (homeIndex !== -1) {
|
||||
mainRoute.children[homeIndex] = homeRoute
|
||||
} else {
|
||||
// 如果没找到,添加到开头
|
||||
mainRoute.children.unshift(homeRoute)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.router = this.createRouter(VueRouter, {
|
||||
Main,
|
||||
|
||||
Reference in New Issue
Block a user