| 
									
										
										
										
											2021-07-31 14:00:28 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   <div /> | 
					
						
							| 
									
										
										
										
											2021-07-31 14:00:28 -08:00
										 |  |  | </template> | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  | import { useAsyncKey } from "~/composables/use-utils"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { AppInfo, AppStartupInfo } from "~/lib/api/types/admin"; | 
					
						
							| 
									
										
										
										
											2024-02-07 10:53:55 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     definePageMeta({ | 
					
						
							|  |  |  |       layout: "blank", | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const $auth = useMealieAuth(); | 
					
						
							|  |  |  |     const { $axios } = useNuxtApp(); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |     const router = useRouter(); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const groupSlug = computed(() => $auth.user.value?.groupSlug); | 
					
						
							| 
									
										
										
										
											2023-02-19 17:13:29 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-07 10:53:55 -06:00
										 |  |  |     async function redirectPublicUserToDefaultGroup() { | 
					
						
							|  |  |  |       const { data } = await $axios.get<AppInfo>("/api/app/about"); | 
					
						
							|  |  |  |       if (data?.defaultGroupSlug) { | 
					
						
							|  |  |  |         router.push(`/g/${data.defaultGroupSlug}`); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							| 
									
										
										
										
											2024-02-07 10:53:55 -06:00
										 |  |  |         router.push("/login"); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     useAsyncData(useAsyncKey(), async () => { | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |       if (groupSlug.value) { | 
					
						
							|  |  |  |         const data = await $axios.get<AppStartupInfo>("/api/app/about/startup-info"); | 
					
						
							|  |  |  |         const isDemo = data.data.isDemo; | 
					
						
							|  |  |  |         const isFirstLogin = data.data.isFirstLogin; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         if (!isDemo && isFirstLogin && $auth.user.value?.admin) { | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |           router.push("/admin/setup"); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |           router.push(`/g/${groupSlug.value}`); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |         redirectPublicUserToDefaultGroup(); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> |