frontend: add svelte frontend
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import Cover from './Cover.svelte';
|
||||
import { fetchApps } from './apps';
|
||||
|
||||
interface App {
|
||||
title: string;
|
||||
id: number;
|
||||
hdr_supported: boolean;
|
||||
}
|
||||
|
||||
interface AppsResponse {
|
||||
apps: Record<string, App[]>;
|
||||
}
|
||||
|
||||
let appsPromise: Promise<AppsResponse>;
|
||||
|
||||
//async function fetchApps() {
|
||||
// console.log('apps');
|
||||
// const response = await fetch('/api/apps');
|
||||
// console.log(response);
|
||||
// const data = (await response.json()) as AppsResponse;
|
||||
// console.log(data);
|
||||
// return data;
|
||||
//}
|
||||
|
||||
appsPromise = fetchApps();
|
||||
</script>
|
||||
|
||||
{#await appsPromise}
|
||||
<p>Loading...</p>
|
||||
{:then resp}
|
||||
<div class="apps-container">
|
||||
{#each Object.entries(resp.apps) as [server_name, apps]}
|
||||
{#each apps as app}
|
||||
<Cover {app} {server_name}></Cover>
|
||||
{/each}
|
||||
{/each}
|
||||
</div>
|
||||
{:catch error}
|
||||
<p>Error: {error.message}</p>
|
||||
{/await}
|
||||
|
||||
<style>
|
||||
.apps-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user