@@ -182,8 +182,6 @@ initFrontedAPI()
182182
183183createHead ()
184184const sideBarOpen = ref (false );
185- const defaultLayout = ref (true );
186- const headerOnlyLayout = ref (false );
187185const route = useRoute ();
188186const router = useRouter ();
189187const publicConfigLoaded = ref (false );
@@ -197,6 +195,14 @@ const isSidebarIconOnly = ref(localStorage.getItem('afIconOnlySidebar') === 'tru
197195
198196const loggedIn = computed (() => !! coreStore ?.adminUser );
199197
198+ const defaultLayout = computed (() => {
199+ return route .meta ?.sidebarAndHeader !== ' none' ;
200+ });
201+
202+ const headerOnlyLayout = computed (() => {
203+ return route .meta ?.sidebarAndHeader === ' headerOnly' ;
204+ });
205+
200206const expandedWidth = computed (() => coreStore .config ?.iconOnlySidebar ?.expandedSidebarWidth || ' 16.5rem' );
201207
202208const theme = ref (' light' );
@@ -308,19 +314,6 @@ async function loadMenu() {
308314 loginRedirectCheckIsReady .value = true ;
309315}
310316
311- function handleCustomLayout() {
312- if (route .meta ?.sidebarAndHeader === ' none' ) {
313- defaultLayout .value = false ;
314- } else if (route .meta ?.sidebarAndHeader === ' preferIconOnly' ) {
315- defaultLayout .value = true ;
316- isSidebarIconOnly .value = true ;
317- } else if (route .meta ?.sidebarAndHeader === ' headerOnly' ) {
318- headerOnlyLayout .value = true ;
319- } else {
320- defaultLayout .value = true ;
321- }
322- }
323-
324317function humanizeSnake(str : string ): string {
325318 if (! str ) {
326319 return ' ' ;
@@ -345,10 +338,11 @@ watch(title, (title) => {
345338 document .title = title ;
346339})
347340
348- watch ([route , () => coreStore .resourceById , () => coreStore .config ], async () => {
349- handleCustomLayout ()
350- await new Promise ((resolve ) => setTimeout (resolve , 0 ));
351-
341+ watch (route , () => {
342+ // Handle preferIconOnly layout
343+ if (route .meta ?.sidebarAndHeader === ' preferIconOnly' ) {
344+ isSidebarIconOnly .value = true ;
345+ }
352346});
353347
354348
@@ -376,7 +370,6 @@ onMounted(async () => {
376370 loadPublicConfig (); // and this
377371 // before init flowbite we have to wait router initialized because it affects dom(our v-ifs) and fetch menu
378372 await initRouter ();
379- handleCustomLayout ();
380373
381374 adminforth .menu .refreshMenuBadges = async () => {
382375 await coreStore .fetchMenuBadges ();
0 commit comments