From ace3e890338664908956d2cb8b8db034eef5cdfe Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Mon, 15 Jun 2026 09:39:33 +0300 Subject: [PATCH] saving token --- src/main.ts | 14 ++++++++++++++ vite.config.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index d4a3eea..e31c61d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,6 +10,7 @@ import type { WordItem } from './training.ts'; // ----- Конфигурация ----- const API_BASE_URL = 'https://learning.micialware.ru'; +const SYNC_ID_STORAGE_KEY = 'japlearn_sync_id'; // ----- Элементы UI ----- const container = document.getElementById('page-container') as HTMLElement; @@ -39,9 +40,19 @@ function getSyncId(): string { const input = document.getElementById('syncId') as HTMLInputElement | null; const id = input?.value.trim(); if (!id) throw new Error('Введите ID синхронизации'); + // Сохраняем в localStorage + localStorage.setItem(SYNC_ID_STORAGE_KEY, id); return id; } +function restoreSyncId(): void { + const saved = localStorage.getItem(SYNC_ID_STORAGE_KEY); + if (saved) { + const input = document.getElementById('syncId') as HTMLInputElement | null; + if (input) input.value = saved; + } +} + // ----- Рендеринг страниц ----- function renderWordsPage() { @@ -360,6 +371,9 @@ async function main() { // Стартовая страница switchPage('words'); + // Восстанавливаем сохранённый ID синхронизации + restoreSyncId(); + // Глобальные обработчики container.addEventListener('click', async (e) => { const target = e.target as HTMLElement; diff --git a/vite.config.ts b/vite.config.ts index af06c59..544da56 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,7 +4,7 @@ import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig({ plugins: [ - // basicSsl(), + basicSsl(), VitePWA({ registerType: 'autoUpdate', includeAssets: ['favicon.svg', 'icon-192.png', 'icon-512.png'],