too many changes

This commit is contained in:
2026-10-07 02:17:30 +04:00
parent 0c7f3bce90
commit bcf985c17d
74 changed files with 4048 additions and 78 deletions
+91
View File
@@ -0,0 +1,91 @@
<script>
import { onMount } from 'svelte'
import { jwt, isAuthed } from './stores/auth.js'
import { api } from './lib/api.js'
import { initData, applyTheme } from './lib/telegram.js'
import MediaPage from './pages/MediaPage.svelte'
import CollectionsPage from './pages/CollectionsPage.svelte'
let tab = 'media' // 'media' | 'collections'
let authError = null
let authing = true
function devTokenFromHash() {
if (!import.meta.env.DEV) return null
const params = new URLSearchParams(window.location.hash.slice(1))
return params.get('token') ?? null
}
onMount(async () => {
applyTheme()
// Dev-режим: #token=<jwt> в URL — пропускаем обмен initData
const devToken = devTokenFromHash()
if (devToken) {
jwt.set(devToken)
authing = false
return
}
try {
const { token } = await api.auth(initData)
jwt.set(token)
} catch (e) {
authError = e.message
} finally {
authing = false
}
})
</script>
<main>
{#if authing}
<div class="splash">Загрузка…</div>
{:else if authError}
<div class="splash error">Ошибка авторизации:<br/>{authError}</div>
{:else if $isAuthed}
<nav>
<button class:active={tab === 'media'} on:click={() => (tab = 'media')}>Медиа</button>
<button class:active={tab === 'collections'} on:click={() => (tab = 'collections')}>Коллекции</button>
</nav>
{#if tab === 'media'}
<MediaPage />
{:else}
<CollectionsPage />
{/if}
{/if}
</main>
<style>
:global(*) { box-sizing: border-box; margin: 0; padding: 0; }
:global(body) {
background: var(--tg-bg, #fff);
color: var(--tg-text, #000);
font-family: system-ui, -apple-system, sans-serif;
min-height: 100vh;
}
main { display: flex; flex-direction: column; height: 100vh; }
.splash {
display: flex; align-items: center; justify-content: center;
height: 100vh; color: var(--tg-hint, #888); font-size: 16px; text-align: center; padding: 24px;
}
.error { color: #e53935; }
nav {
display: flex; border-bottom: 1px solid var(--tg-hint, #ccc);
background: var(--tg-bg, #fff); position: sticky; top: 0; z-index: 10;
}
nav button {
flex: 1; padding: 12px; border: none; background: none;
color: var(--tg-hint, #888); font-size: 15px; cursor: pointer;
border-bottom: 2px solid transparent;
}
nav button.active {
color: var(--tg-button, #2196f3);
border-bottom-color: var(--tg-button, #2196f3);
font-weight: 600;
}
</style>