Add a launcher context provider
This commit is contained in:
3 files changed
+34
-15
No files matched your search
+18
-15
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import '@/styles/globals.css'
|
import '@/styles/globals.css'
|
||||||
import { Roboto } from 'next/font/google'
|
import { Roboto } from 'next/font/google'
|
||||||
|
import LauncherContext from '@/context/LauncherContext'
|
||||||
|
|
||||||
import Sidebar from '@/componets/Sidebar'
|
import Sidebar from '@/componets/Sidebar'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
@@ -56,25 +57,27 @@ export default function RootLayout ({
|
|||||||
|
|
||||||
setLoading(3)
|
setLoading(3)
|
||||||
})()
|
})()
|
||||||
})
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang='en' className={roboto.className}>
|
<html lang='en' className={roboto.className}>
|
||||||
<body className='relative dark-theme'>
|
<body className='relative dark-theme'>
|
||||||
{loading == 3 ? (
|
<LauncherContext.Provider value={{ launcherManifest }}>
|
||||||
<>
|
{loading == 3 ? (
|
||||||
<Sidebar />
|
<>
|
||||||
<main>{children}</main>
|
<Sidebar />
|
||||||
</>
|
<main>{children}</main>
|
||||||
) : (
|
</>
|
||||||
<p className='flex justify-center items-center h-screen w-screen text-6xl'>
|
) : (
|
||||||
{loading == 0
|
<p className='flex justify-center items-center h-screen w-screen text-6xl'>
|
||||||
? 'Loading'
|
{loading == 0
|
||||||
: loading == 1
|
? 'Loading'
|
||||||
? 'Failed to load launcher'
|
: loading == 1
|
||||||
: 'Outdated launcher!'}
|
? 'Failed to load launcher'
|
||||||
</p>
|
: 'Outdated launcher!'}
|
||||||
)}
|
</p>
|
||||||
|
)}
|
||||||
|
</LauncherContext.Provider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
export default function Home () {
|
export default function Home () {
|
||||||
return <div></div>
|
return <div></div>
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { createContext, useContext } from 'react'
|
||||||
|
import type LauncherManifest from '@/types/LauncherManifest'
|
||||||
|
|
||||||
|
type LauncherContextType = {
|
||||||
|
launcherManifest: LauncherManifest | null
|
||||||
|
}
|
||||||
|
|
||||||
|
const LauncherContext = createContext<LauncherContextType | null>(null)
|
||||||
|
|
||||||
|
export const useLauncher = () => useContext(LauncherContext)
|
||||||
|
|
||||||
|
export default LauncherContext
|
||||||
Reference in new issue
Block a user