diff --git a/vps/owrt-remote-hub.py b/vps/owrt-remote-hub.py
index 7940fae..f01ed21 100644
--- a/vps/owrt-remote-hub.py
+++ b/vps/owrt-remote-hub.py
@@ -779,13 +779,47 @@ def web_manifest_json():
"background_color": "#10081c",
"theme_color": "#7c3aed",
"description": "Удаленный доступ к OpenWrt через свой VPS",
- "icons": [],
+ "icons": [
+ {
+ "src": "/favicon.svg",
+ "sizes": "any",
+ "type": "image/svg+xml",
+ "purpose": "any maskable",
+ }
+ ],
},
ensure_ascii=False,
separators=(",", ":"),
)
+def favicon_svg():
+ return """
+
+""".strip() + "\n"
+
+
def run_quiet(args, timeout=2.5):
try:
return subprocess.run(
@@ -1585,6 +1619,7 @@ def dashboard_html(routers, username, sessions=None, notifications=None):
+
{APP_NAME}
@@ -2225,12 +2260,29 @@ function isStandalonePwa() {{
return !!(window.navigator.standalone || (window.matchMedia && window.matchMedia('(display-mode: standalone)').matches));
}}
+function webPushSupportInfo() {{
+ const secure = !!window.isSecureContext;
+ const hasServiceWorker = 'serviceWorker' in navigator;
+ const hasPushManager = 'PushManager' in window;
+ const hasNotification = 'Notification' in window;
+ let reason = '';
+ if (!secure) reason = 'https';
+ else if (!hasServiceWorker) reason = 'serviceWorker';
+ else if (!hasPushManager) reason = 'pushManager';
+ else if (!hasNotification) reason = 'notification';
+ if (isIOSDevice() && !isStandalonePwa()) reason = 'ios-home-screen';
+ return {{secure, hasServiceWorker, hasPushManager, hasNotification, reason}};
+}}
+
function webPushSupported() {{
- return 'serviceWorker' in navigator && 'PushManager' in window && 'Notification' in window;
+ const support = webPushSupportInfo();
+ return support.secure && support.hasServiceWorker && support.hasPushManager && support.hasNotification;
}}
function notificationPermissionText() {{
+ const support = webPushSupportInfo();
if (!webPushSupported()) {{
+ if (support.reason === 'https') return 'Push: нужен HTTPS';
if (isIOSDevice()) return isStandalonePwa() ? 'Push недоступен' : 'iOS: добавь на экран';
return 'Push недоступен';
}}
@@ -2284,6 +2336,11 @@ async function enableNotifications() {{
localStorage.setItem('owrtNotifyEnabled', '0');
localStorage.setItem('owrtPushEnabled', '0');
updateNotifyButton();
+ const support = webPushSupportInfo();
+ if (support.reason === 'https') {{
+ showRouterMsg('Web Push работает только по HTTPS. Сейчас Hub открыт по обычному HTTP, поэтому Chrome не даёт service worker и push-подписку.', false);
+ return;
+ }}
const message = isIOSDevice()
? (isStandalonePwa()
? 'Этот iOS-браузер не дал Push API. Проверь iOS 16.4+, разрешения уведомлений для веб-приложений и открой Hub именно с экрана Домой.'
@@ -2437,6 +2494,7 @@ def ssh_terminal_html(row, ws_token):
+
SSH {safe_name}