mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-15 18:25:37 +02:00
try to work with capacitor
This commit is contained in:
79
packages/play-standalone/src/pages/index.astro
Normal file
79
packages/play-standalone/src/pages/index.astro
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
import { ClientRouter } from "astro:transitions";
|
||||
import { navigate } from "astro:transitions/client";
|
||||
---
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Nestri Play</title>
|
||||
<ClientRouter />
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 2rem;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
}
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
label {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
input {
|
||||
padding: 0.5rem;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
button {
|
||||
padding: 0.75rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form id="join-form">
|
||||
<h1>Nestri Play</h1>
|
||||
<div>
|
||||
<label for="room">Room</label>
|
||||
<input type="text" id="room" name="room" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="peerURL">peerURL</label>
|
||||
<input type="text" id="peerURL" name="peerURL" required>
|
||||
</div>
|
||||
<button type="submit">Join</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
import { navigate } from "astro:transitions/client";
|
||||
document.getElementById('join-form').addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
const room = (document.getElementById('room') as HTMLInputElement).value;
|
||||
const peerURL = (document.getElementById('peerURL') as HTMLInputElement).value;
|
||||
if (room && peerURL) {
|
||||
navigate(`/play/index.html?peerURL=${encodeURIComponent(peerURL)}#${room}`);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
import DefaultLayout from "../layouts/DefaultLayout.astro";
|
||||
const { room } = Astro.params;
|
||||
|
||||
// Passing of environment variables to the client side
|
||||
// gotta love node and it's ecosystem..
|
||||
@@ -19,7 +18,7 @@ if (envs_map.size > 0) {
|
||||
<DefaultLayout>
|
||||
<h1 id="offlineText" class="offline">Offline</h1>
|
||||
<h1 id="loadingText" class="loading">Warming up the GPU...</h1>
|
||||
<canvas id="playCanvas" class="playCanvas" data-room={room}></canvas>
|
||||
<canvas id="playCanvas" class="playCanvas"></canvas>
|
||||
<div id="ENVS" data-envs={envs}></div>
|
||||
</DefaultLayout>
|
||||
|
||||
@@ -37,9 +36,9 @@ if (envs_map.size > 0) {
|
||||
const offlineText = document.getElementById("offlineText")! as HTMLHeadingElement;
|
||||
const loadingText = document.getElementById("loadingText")! as HTMLHeadingElement;
|
||||
|
||||
const room = canvas.dataset.room;
|
||||
const room = window.location.hash.substring(1);
|
||||
if (!room || room.length <= 0) {
|
||||
throw new Error("Room parameter is required");
|
||||
throw new Error("Room parameter is required in URL hash");
|
||||
}
|
||||
|
||||
offlineText.style.display = "flex";
|
||||
Reference in New Issue
Block a user