saving token

This commit is contained in:
2026-06-15 09:39:33 +03:00
parent 933e56207e
commit ace3e89033
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -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;
+1 -1
View File
@@ -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'],