mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 15:58:19 +08:00
28 lines
689 B
TypeScript
Executable File
28 lines
689 B
TypeScript
Executable File
export function useAppMenu() {
|
|
const router = useRouter()
|
|
|
|
const appSettingsStore = useAppSettingsStore()
|
|
const appMenuStore = useAppMenuStore()
|
|
|
|
function generateTitle(title: string | (() => any) = '[ 无标题 ]') {
|
|
return typeof title === 'function'
|
|
? title()
|
|
: title
|
|
}
|
|
|
|
function switchTo(index: number) {
|
|
appMenuStore.setActived(index)
|
|
if (
|
|
appSettingsStore.settings.menu.mainMenuClickMode === 'jump'
|
|
|| (appSettingsStore.settings.menu.mainMenuClickMode === 'smart' && appMenuStore.sidebarMenusHasOnlyMenu)
|
|
) {
|
|
router.push(appMenuStore.sidebarMenusFirstDeepestPath)
|
|
}
|
|
}
|
|
|
|
return {
|
|
generateTitle,
|
|
switchTo,
|
|
}
|
|
}
|