feat: web frontend with Alpine.js

This commit is contained in:
2026-08-26 23:36:27 +08:00
parent c59654fcaa
commit c24df57882
5 changed files with 121 additions and 5 deletions
+29 -1
View File
@@ -1,2 +1,30 @@
<!DOCTYPE html>
<html><head><title>Login</title></head><body><h1>Login</h1></body></html>
<html>
<head>
<meta charset="UTF-8">
<title>yDropbox Login</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="container">
<h1>yDropbox</h1>
<form id="loginForm">
<input type="password" id="token" placeholder="Access Token" required>
<button type="submit">Login</button>
</form>
</div>
<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const token = document.getElementById('token').value;
const res = await fetch('/api/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({token})
});
if (res.ok) window.location.href = '/';
else alert('Invalid token');
});
</script>
</body>
</html>