feat(offline): add offline mode link to login screen

- Add "Start in offline mode" link below login form
- Enable offline mode without authentication
- Navigate directly to local library when starting offline
- Add i18n strings for offline start link (en/es)
This commit is contained in:
vicrodh committed 2026-01-15 22:59:30 -06:00
1 parent 6bcb1fc7a6
commit 6e0d7486b0
4 files changed
+59 -4

No files matched your search

+42 -1
View File
@@ -1,6 +1,8 @@
<script lang="ts">
import { invoke } from '@tauri-apps/api/core';
import TitleBar from '../TitleBar.svelte';
import { t } from '$lib/i18n';
import { setManualOffline } from '$lib/stores/offlineStore';
interface UserInfo {
userName: string;
@@ -9,9 +11,10 @@
interface Props {
onLoginSuccess: (userInfo: UserInfo) => void;
onStartOffline?: () => void;
}
let { onLoginSuccess }: Props = $props();
let { onLoginSuccess, onStartOffline }: Props = $props();
let email = $state('');
let password = $state('');
@@ -128,6 +131,16 @@
isLoading = false;
}
}
async function handleStartOffline() {
try {
await setManualOffline(true);
onStartOffline?.();
} catch (err) {
console.error('Failed to enable offline mode:', err);
error = String(err);
}
}
</script>
<div class="login-wrapper">
@@ -203,6 +216,14 @@
QBZ requires an active Qobuz subscription.
Your credentials are sent directly to Qobuz and stored securely in your system's keyring.
</p>
<p class="offline-link">
<small>
<button type="button" class="link-button" onclick={handleStartOffline}>
{$t('offline.startWithoutLogin')}
</button>
</small>
</p>
{/if}
</div>
</div>
@@ -411,6 +432,26 @@
line-height: 1.5;
}
.offline-link {
margin-top: 16px;
text-align: center;
}
.link-button {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
text-decoration: underline;
font-size: inherit;
padding: 0;
transition: color 150ms ease;
}
.link-button:hover {
color: var(--accent-primary);
}
.spinner {
width: 32px;
height: 32px;