pwa fixes
This commit is contained in:
parent
6b41eafc55
commit
9bbc8cd0b3
2 changed files with 127 additions and 118 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { login } from '$lib/api/auth';
|
import { login } from "$lib/api/auth";
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from "$app/navigation";
|
||||||
import { auth } from '$lib/auth/store.svelte';
|
import { auth } from "$lib/auth/store.svelte";
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from "svelte";
|
||||||
import { today } from '$lib/utils/date';
|
import { today } from "$lib/utils/date";
|
||||||
|
|
||||||
let username = $state('');
|
let username = $state("");
|
||||||
let password = $state('');
|
let password = $state("");
|
||||||
let error = $state('');
|
let error = $state("");
|
||||||
let loading = $state(false);
|
let loading = $state(false);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
async function handleSubmit(e: SubmitEvent) {
|
async function handleSubmit(e: SubmitEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
error = '';
|
error = "";
|
||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
await login(username, password);
|
await login(username, password);
|
||||||
goto(`/diary/${today()}`);
|
goto(`/diary/${today()}`);
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
error = 'Invalid username or password';
|
error = "Invalid username or password";
|
||||||
} finally {
|
} finally {
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,10 @@
|
||||||
|
|
||||||
<form onsubmit={handleSubmit} class="space-y-4">
|
<form onsubmit={handleSubmit} class="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label for="username" class="block text-sm font-medium text-zinc-400 mb-1">Username</label>
|
<label
|
||||||
|
for="username"
|
||||||
|
class="block text-sm font-medium text-zinc-400 mb-1">Username</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
id="username"
|
id="username"
|
||||||
type="text"
|
type="text"
|
||||||
|
|
@ -47,7 +50,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="password" class="block text-sm font-medium text-zinc-400 mb-1">Password</label>
|
<label
|
||||||
|
for="password"
|
||||||
|
class="block text-sm font-medium text-zinc-400 mb-1">Password</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
id="password"
|
id="password"
|
||||||
type="password"
|
type="password"
|
||||||
|
|
@ -67,13 +73,15 @@
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
class="w-full bg-green-600 hover:bg-green-500 disabled:opacity-50 rounded-xl py-3 font-semibold transition-colors"
|
class="w-full bg-green-600 hover:bg-green-500 disabled:opacity-50 rounded-xl py-3 font-semibold transition-colors"
|
||||||
>
|
>
|
||||||
{loading ? 'Signing in…' : 'Sign in'}
|
{loading ? "Signing in…" : "Sign in"}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p class="text-center mt-6 text-zinc-500 text-sm">
|
<p class="text-center mt-6 text-zinc-500 text-sm">
|
||||||
No account?
|
No account?
|
||||||
<a href="/register" class="text-green-500 hover:text-green-400">Register</a>
|
<a href="/register" class="text-green-500 hover:text-green-400"
|
||||||
|
>Register</a
|
||||||
|
>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ export default defineConfig({
|
||||||
display: 'standalone',
|
display: 'standalone',
|
||||||
orientation: 'portrait',
|
orientation: 'portrait',
|
||||||
start_url: '/diary/today',
|
start_url: '/diary/today',
|
||||||
|
scope: '/',
|
||||||
id: '/',
|
id: '/',
|
||||||
categories: ['health', 'food'],
|
categories: ['health', 'food'],
|
||||||
icons: [
|
icons: [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue