990cb4a68d
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 15s
CI / ui (pull_request) Failing after 11s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Failing after 0s
CI / deploy (pull_request) Has been skipped
Make the web SPA an installable PWA and surface it to users: - manifest.webmanifest + an install-only service worker + 192/512/maskable icons (ui/public); PWA head tags in index.html; the .webmanifest MIME type registered in the gateway (the distroless image has no /etc/mime.types). - Platform-adaptive install CTA (components/InstallApp.svelte + lib/pwa): one-tap on Chromium, manual Add-to-Home-Screen instructions on iOS Safari, hidden elsewhere / once installed / inside a Mini App. Shown under the logged-out login card and at the bottom of Settings. - The landing gains a third entry linking /app/ (the brand tile), with a caption under all three (Telegram / VK / Веб-версия). The service worker is navigation-only (network-first, cached-shell fallback); hashed assets and the Connect stream are untouched. It exists to satisfy Chromium's installability requirement and is the single growth point for a future opt-in offline mode. Tests: pwa.ts unit tests; a webui probe (manifest/sw.js content-type + the SPA-fallback-to-HTML trap); e2e for the one-tap CTA, the iOS instructions modal and the landing web entry. Docs: ARCHITECTURE §13, FUNCTIONAL (+ru), gateway README.
139 lines
3.3 KiB
Svelte
139 lines
3.3 KiB
Svelte
<script lang="ts">
|
|
import { loginEmail, loginGuest, requestEmailCode } from '../lib/app.svelte';
|
|
import { t } from '../lib/i18n/index.svelte';
|
|
import InstallApp from '../components/InstallApp.svelte';
|
|
|
|
let email = $state('');
|
|
let code = $state('');
|
|
let stage = $state<'choose' | 'code'>('choose');
|
|
let busy = $state(false);
|
|
|
|
async function sendCode() {
|
|
if (!email.trim()) return;
|
|
busy = true;
|
|
const ok = await requestEmailCode(email.trim());
|
|
busy = false;
|
|
if (ok) stage = 'code';
|
|
}
|
|
|
|
async function signIn() {
|
|
busy = true;
|
|
await loginEmail(email.trim(), code.trim());
|
|
busy = false;
|
|
}
|
|
</script>
|
|
|
|
<main class="login">
|
|
<div class="card">
|
|
<h1>{t('app.title')}</h1>
|
|
|
|
<button class="primary" disabled={busy} onclick={() => loginGuest()}>
|
|
{t('login.guest')}
|
|
</button>
|
|
|
|
<div class="divider"><span>{t('login.email')}</span></div>
|
|
|
|
{#if stage === 'choose'}
|
|
<input
|
|
type="email"
|
|
autocomplete="email"
|
|
placeholder={t('login.emailPlaceholder')}
|
|
bind:value={email}
|
|
/>
|
|
<button class="secondary" disabled={busy || !email.trim()} onclick={sendCode}>
|
|
{t('login.sendCode')}
|
|
</button>
|
|
{:else}
|
|
<p class="muted">{t('login.codeSent', { email })}</p>
|
|
<input
|
|
inputmode="numeric"
|
|
autocomplete="one-time-code"
|
|
placeholder={t('login.codePlaceholder')}
|
|
bind:value={code}
|
|
/>
|
|
<button class="secondary" disabled={busy || !code.trim()} onclick={signIn}>
|
|
{t('login.signIn')}
|
|
</button>
|
|
{/if}
|
|
</div>
|
|
<!-- Web-only install call-to-action, under the login card. Renders nothing unless the app is
|
|
installable here (see components/InstallApp.svelte / lib/pwa). -->
|
|
<div class="promo"><InstallApp /></div>
|
|
</main>
|
|
|
|
<style>
|
|
.login {
|
|
height: 100%;
|
|
display: grid;
|
|
place-items: center;
|
|
/* Centre the card + install promo as a group, with a gap between them. */
|
|
align-content: center;
|
|
gap: 16px;
|
|
padding: 16px;
|
|
}
|
|
/* Match the card width so the install CTA lines up under it. */
|
|
.promo {
|
|
width: min(94vw, 360px);
|
|
}
|
|
.card {
|
|
width: min(94vw, 360px);
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
box-shadow: var(--shadow);
|
|
padding: 24px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
h1 {
|
|
margin: 0 0 8px;
|
|
text-align: center;
|
|
}
|
|
input {
|
|
padding: 11px;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font-size: 1rem;
|
|
}
|
|
button {
|
|
padding: 12px;
|
|
border-radius: var(--radius-sm);
|
|
border: 1px solid var(--border);
|
|
font-weight: 600;
|
|
}
|
|
.primary {
|
|
background: var(--accent);
|
|
color: var(--accent-text);
|
|
border-color: var(--accent);
|
|
}
|
|
.secondary {
|
|
background: var(--surface);
|
|
color: var(--text);
|
|
}
|
|
button:disabled {
|
|
opacity: 0.5;
|
|
}
|
|
.divider {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
color: var(--text-muted);
|
|
font-size: 0.85rem;
|
|
}
|
|
.divider::before,
|
|
.divider::after {
|
|
content: '';
|
|
flex: 1;
|
|
height: 1px;
|
|
background: var(--border);
|
|
}
|
|
.muted {
|
|
color: var(--text-muted);
|
|
font-size: 0.9rem;
|
|
margin: 0;
|
|
}
|
|
</style>
|