Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
878 B

<script>
import { onMount, setContext } from "svelte"
import Router from "svelte-spa-router"
import { routeStore, screenStore, styleable } from "@budibase/component-sdk"
import Screen from "./Screen.svelte"
export let styles
let routes
onMount(() => {
initialiseRouter()
})
const initialiseRouter = async () => {
await routeStore.actions.fetchRoutes()
await screenStore.actions.fetchScreens()
routes = {}
$routeStore.routes.forEach(route => {
routes[route.path] = Screen
})
// Add catch-all route so that we serve the Screen component always
routes["*"] = Screen
}
function onRouteLoading({ detail }) {
routeStore.actions.setActiveRoute(detail.route)
}
setContext("test", 123)
</script>
{#if routes}
<div use:styleable={styles}>
<Router on:routeLoading={onRouteLoading} {routes} />
</div>
{/if}