- Добавлены новые мета-теги и улучшены существующие для поддержки PWA. - Обновлен manifest.json с новыми полями для совместимости с Brave. - Улучшен Service Worker для кэширования манифеста и обработки ошибок. - Обновлены инструкции по тестированию PWA, включая новую тестовую страницу для Brave. - Оптимизирован код для обработки установки PWA на мобильных устройствах и в Brave.
212 lines
7.4 KiB
HTML
212 lines
7.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Вход в систему заметок</title>
|
||
|
||
<!-- PWA Meta Tags -->
|
||
<meta
|
||
name="description"
|
||
content="NoteJS - современная система заметок с поддержкой Markdown, изображений, тегов и календаря"
|
||
/>
|
||
<meta name="theme-color" content="#007bff" />
|
||
<meta name="mobile-web-app-capable" content="yes" />
|
||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||
<meta
|
||
name="apple-mobile-web-app-status-bar-style"
|
||
content="black-translucent"
|
||
/>
|
||
<meta name="apple-mobile-web-app-title" content="NoteJS" />
|
||
<meta name="apple-touch-fullscreen" content="yes" />
|
||
<meta name="msapplication-TileColor" content="#007bff" />
|
||
<meta name="msapplication-config" content="/browserconfig.xml" />
|
||
<meta name="msapplication-TileImage" content="/icons/icon-144x144.png" />
|
||
<meta name="application-name" content="NoteJS" />
|
||
<meta name="format-detection" content="telephone=no" />
|
||
|
||
<!-- Icons -->
|
||
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
|
||
<link
|
||
rel="icon"
|
||
type="image/png"
|
||
sizes="32x32"
|
||
href="/icons/icon-32x32.png"
|
||
/>
|
||
<link
|
||
rel="icon"
|
||
type="image/png"
|
||
sizes="16x16"
|
||
href="/icons/icon-16x16.png"
|
||
/>
|
||
<link rel="apple-touch-icon" sizes="57x57" href="/icons/icon-48x48.png" />
|
||
<link rel="apple-touch-icon" sizes="60x60" href="/icons/icon-48x48.png" />
|
||
<link rel="apple-touch-icon" sizes="72x72" href="/icons/icon-72x72.png" />
|
||
<link rel="apple-touch-icon" sizes="76x76" href="/icons/icon-72x72.png" />
|
||
<link
|
||
rel="apple-touch-icon"
|
||
sizes="114x114"
|
||
href="/icons/icon-128x128.png"
|
||
/>
|
||
<link
|
||
rel="apple-touch-icon"
|
||
sizes="120x120"
|
||
href="/icons/icon-128x128.png"
|
||
/>
|
||
<link
|
||
rel="apple-touch-icon"
|
||
sizes="144x144"
|
||
href="/icons/icon-144x144.png"
|
||
/>
|
||
<link
|
||
rel="apple-touch-icon"
|
||
sizes="152x152"
|
||
href="/icons/icon-152x152.png"
|
||
/>
|
||
<link
|
||
rel="apple-touch-icon"
|
||
sizes="180x180"
|
||
href="/icons/icon-192x192.png"
|
||
/>
|
||
<link rel="mask-icon" href="/icon.svg" color="#007bff" />
|
||
|
||
<!-- Manifest -->
|
||
<link rel="manifest" href="/manifest.json" />
|
||
|
||
<!-- Styles -->
|
||
<link rel="stylesheet" href="/style.css" />
|
||
|
||
<!-- Scripts -->
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/iconify/2.0.0/iconify.min.js"></script>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<header>
|
||
<span class="iconify" data-icon="mdi:login"></span> Вход в систему
|
||
</header>
|
||
<div class="login-form">
|
||
<form id="loginForm">
|
||
<div class="form-group">
|
||
<label for="username">Логин:</label>
|
||
<input
|
||
type="text"
|
||
id="username"
|
||
name="username"
|
||
required
|
||
placeholder="Введите ваш логин"
|
||
/>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="password">Пароль:</label>
|
||
<input
|
||
type="password"
|
||
id="password"
|
||
name="password"
|
||
required
|
||
placeholder="Введите пароль"
|
||
/>
|
||
</div>
|
||
<button type="submit" class="btnSave">Войти</button>
|
||
</form>
|
||
<div
|
||
id="errorMessage"
|
||
class="error-message"
|
||
style="display: none"
|
||
></div>
|
||
<p class="auth-link">
|
||
Нет аккаунта? <a href="/register">Зарегистрируйтесь</a>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
<div class="footer">
|
||
<p>Создатель: <span>Fovway</span></p>
|
||
</div>
|
||
<script src="/login.js"></script>
|
||
|
||
<!-- PWA Service Worker Registration -->
|
||
<script>
|
||
if ("serviceWorker" in navigator) {
|
||
window.addEventListener("load", () => {
|
||
navigator.serviceWorker
|
||
.register("/sw.js")
|
||
.then((registration) => {
|
||
console.log("SW зарегистрирован успешно:", registration.scope);
|
||
|
||
// Проверяем обновления
|
||
registration.addEventListener("updatefound", () => {
|
||
const newWorker = registration.installing;
|
||
newWorker.addEventListener("statechange", () => {
|
||
if (
|
||
newWorker.state === "installed" &&
|
||
navigator.serviceWorker.controller
|
||
) {
|
||
// Новый контент доступен, можно показать уведомление
|
||
if (
|
||
confirm("Доступна новая версия приложения. Обновить?")
|
||
) {
|
||
newWorker.postMessage({ type: "SKIP_WAITING" });
|
||
window.location.reload();
|
||
}
|
||
}
|
||
});
|
||
});
|
||
})
|
||
.catch((error) => {
|
||
console.log("Ошибка регистрации SW:", error);
|
||
});
|
||
});
|
||
}
|
||
|
||
// Обработка установки PWA
|
||
let deferredPrompt;
|
||
window.addEventListener("beforeinstallprompt", (e) => {
|
||
console.log("beforeinstallprompt event fired");
|
||
|
||
// Определяем браузер
|
||
const isBrave = navigator.userAgent.includes('Brave') ||
|
||
(navigator.brave && await navigator.brave.isBrave());
|
||
const isMobile =
|
||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||
navigator.userAgent
|
||
) ||
|
||
(navigator.maxTouchPoints && navigator.maxTouchPoints > 2) ||
|
||
window.matchMedia("(max-width: 768px)").matches;
|
||
|
||
// Для Brave на мобильных устройствах не предотвращаем стандартное поведение
|
||
if (!isMobile && !isBrave) {
|
||
e.preventDefault();
|
||
}
|
||
deferredPrompt = e;
|
||
|
||
// Показываем кнопку установки на мобильных устройствах или в Brave
|
||
if (isMobile || isBrave) {
|
||
const installButton = document.createElement("button");
|
||
installButton.textContent = "Установить приложение";
|
||
installButton.className = "btnSave";
|
||
installButton.style.marginTop = "10px";
|
||
installButton.style.width = "100%";
|
||
|
||
installButton.addEventListener("click", async () => {
|
||
if (deferredPrompt) {
|
||
deferredPrompt.prompt();
|
||
const choiceResult = await deferredPrompt.userChoice;
|
||
if (choiceResult.outcome === "accepted") {
|
||
console.log("Пользователь установил приложение");
|
||
}
|
||
deferredPrompt = null;
|
||
installButton.remove();
|
||
}
|
||
});
|
||
|
||
document.querySelector(".auth-link").appendChild(installButton);
|
||
}
|
||
});
|
||
|
||
// Обработка успешной установки
|
||
window.addEventListener("appinstalled", () => {
|
||
console.log("PWA установлено успешно");
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|