@ -71,7 +71,7 @@ export default {
@@ -71,7 +71,7 @@ export default {
for ( var item in router . children ) {
if ( router . children [ item ] . parentPath === undefined ) {
if ( router . path === "/" ) {
router . children [ item ] . path = "/redirect/ " + router . children [ item ] . path ;
router . children [ item ] . path = "/" + router . children [ item ] . path ;
} else {
if ( ! this . ishttp ( router . children [ item ] . path ) ) {
router . children [ item ] . path = router . path + "/" + router . children [ item ] . path ;
@ -87,22 +87,23 @@ export default {
@@ -87,22 +87,23 @@ export default {
/ / 默 认 激 活 的 菜 单
activeMenu ( ) {
const path = this . $route . path ;
let activePath = this . defaultRouter ( ) ;
let activePath = path ;
if ( path . lastIndexOf ( "/" ) > 0 ) {
const tmpPath = path . substring ( 1 , path . length ) ;
activePath = "/" + tmpPath . substring ( 0 , tmpPath . indexOf ( "/" ) ) ;
this . $store . dispatch ( 'app/toggleSideBarHide' , false ) ;
} else if ( "/index" == path || "" == path ) {
if ( ! this . isFrist ) {
this . isFrist = true ;
} else {
activePath = "index" ;
}
this . $store . dispatch ( 'app/toggleSideBarHide' , true ) ;
} else if ( ! this . $route . children ) {
activePath = path ;
this . $store . dispatch ( 'app/toggleSideBarHide' , true ) ;
}
var routes = this . activeRoutes ( activePath ) ;
if ( routes . length === 0 ) {
activePath = this . currentIndex || this . defaultRouter ( )
this . activeRoutes ( activePath ) ;
}
this . activeRoutes ( activePath ) ;
return activePath ;
} ,
} ,
@ -121,29 +122,21 @@ export default {
@@ -121,29 +122,21 @@ export default {
const width = document . body . getBoundingClientRect ( ) . width / 3 ;
this . visibleNumber = parseInt ( width / 85 ) ;
} ,
/ / 默 认 激 活 的 路 由
defaultRouter ( ) {
let router ;
Object . keys ( this . routers ) . some ( ( key ) => {
if ( ! this . routers [ key ] . hidden ) {
router = this . routers [ key ] . path ;
return true ;
}
} ) ;
return router ;
} ,
/ / 菜 单 选 择 事 件
handleSelect ( key , keyPath ) {
this . currentIndex = key ;
const route = this . routers . find ( item => item . path === key ) ;
if ( this . ishttp ( key ) ) {
/ / h t t p ( s ) : / / 路 径 新 窗 口 打 开
window . open ( key , "_blank" ) ;
} else if ( key . indexOf ( "/redirect" ) !== - 1 ) {
/ / / r e d i r e c t 路 径 内 部 打 开
this . $router . push ( { path : key . replace ( "/redirect" , "" ) } ) ;
} else if ( ! route || ! route . children ) {
/ / 没 有 子 路 由 路 径 内 部 打 开
this . $router . push ( { path : key } ) ;
this . $store . dispatch ( 'app/toggleSideBarHide' , true ) ;
} else {
/ / 显 示 左 侧 联 动 菜 单
this . activeRoutes ( key ) ;
this . $store . dispatch ( 'app/toggleSideBarHide' , false ) ;
}
} ,
/ / 当 前 激 活 的 路 由
@ -159,9 +152,8 @@ export default {
@@ -159,9 +152,8 @@ export default {
if ( routes . length > 0 ) {
this . $store . commit ( "SET_SIDEBAR_ROUTERS" , routes ) ;
}
return routes ;
} ,
ishttp ( url ) {
ishttp ( url ) {
return url . indexOf ( 'http://' ) !== - 1 || url . indexOf ( 'https://' ) !== - 1
}
} ,