test route
This commit is contained in:
parent
4c9af83342
commit
86d1984095
42
index.html
42
index.html
@ -7,24 +7,58 @@
|
||||
</head>
|
||||
<body class="bg-neutral-50">
|
||||
|
||||
<onzer></onzer>
|
||||
<div id="app"></div>
|
||||
|
||||
<script src="https://unpkg.com/animore/animore.js"></script>
|
||||
<script src="https://unpkg.com/riot@9/riot+compiler.min.js"></script>
|
||||
<script src="https://unpkg.com/@riotjs/route@6/route.umd.js"></script>
|
||||
|
||||
<!-- Composant Onzer -->
|
||||
<script type="riot" src="./onzer.riot"></script>
|
||||
|
||||
<!-- Composant Playlists -->
|
||||
<script type="riot">
|
||||
<playlists>
|
||||
<h1>Playlists Page</h1>
|
||||
<p>This is the playlists page. It is currently empty.</p>
|
||||
<script>
|
||||
export default {
|
||||
// Your component logic here
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
/* Your style here */
|
||||
</style>
|
||||
</playlists>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
async function fetch_data() {
|
||||
return fetch("https://dwarves.iut-fbleau.fr/~fauvet/api/albums").then(response => {
|
||||
return response.json();
|
||||
});
|
||||
return fetch("https://dwarves.iut-fbleau.fr/~fauvet/api/albums").then(response => response.json());
|
||||
}
|
||||
|
||||
function mountComponent(component) {
|
||||
const app = document.getElementById('app');
|
||||
app.innerHTML = '';
|
||||
riot.mount(app, component);
|
||||
}
|
||||
|
||||
riot.compile().then(async () => {
|
||||
const data = await fetch_data();
|
||||
|
||||
// Définir les routes
|
||||
route('/', () => {
|
||||
riot.mount('onzer', { items: data });
|
||||
});
|
||||
|
||||
route('/playlists', () => {
|
||||
riot.mount('playlists');
|
||||
});
|
||||
|
||||
// Démarrer le routeur
|
||||
router.start();
|
||||
router.exec();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div class="flex flex-row items-baseline">
|
||||
<input class="flex-grow-1 border-solid border bg-emerald-100 w-half rounded-lg border-emerald-300 h-20 pl-6 grow"
|
||||
placeholder={state.placeholder} onkeyup={edit} />
|
||||
<input type="button" value="Playlists"
|
||||
<input type="button" value="Playlists" onclick={navigateToPlaylists}
|
||||
class="ml-2 border-solid bg-emerald-300 border rounded-lg border-emerald-600 mb-4 h-20 w-48 mt-2" />
|
||||
</div>
|
||||
</form>
|
||||
@ -96,6 +96,9 @@
|
||||
computeHttpRequest = `${baseHttpRequest}${table}`;
|
||||
}
|
||||
return fetch(computeHttpRequest).then(response => response.json());
|
||||
},
|
||||
navigateToPlaylists() {
|
||||
route('/playlists');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
14
playlists.riot
Normal file
14
playlists.riot
Normal file
@ -0,0 +1,14 @@
|
||||
<playlists>
|
||||
<h1>Playlists Page</h1>
|
||||
<p>This is the playlists page. It is currently empty.</p>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
// Votre code de composant ici (si nécessaire)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Votre style ici (si nécessaire) */
|
||||
</style>
|
||||
</playlists>
|
Loading…
Reference in New Issue
Block a user