feat: open Nextcloud login flow on mobile
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 11s
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 11s
This commit is contained in:
35
app.js
35
app.js
@@ -56,6 +56,17 @@ function serviceSearchText(service) {
|
||||
].join(' ');
|
||||
}
|
||||
|
||||
function isMobileDevice() {
|
||||
return /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
function getMobileUrl(service) {
|
||||
if (service.id === 'drive') {
|
||||
return 'https://drive.mischlabs.de/index.php/login/flow';
|
||||
}
|
||||
return service.mobileUrl;
|
||||
}
|
||||
|
||||
function createServiceCard(service) {
|
||||
const category = categoryById.get(service.category);
|
||||
const card = document.createElement('a');
|
||||
@@ -81,22 +92,28 @@ function createServiceCard(service) {
|
||||
<span class="card-domain">${service.domain}</span>
|
||||
`;
|
||||
|
||||
if (service.mobileUrl) {
|
||||
const mobileUrl = getMobileUrl(service);
|
||||
if (mobileUrl) {
|
||||
card.addEventListener('click', (e) => {
|
||||
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||
if (isMobile) {
|
||||
e.preventDefault();
|
||||
const start = Date.now();
|
||||
// Versuch, die mobile App über ihr registriertes Custom URL-Schema zu öffnen
|
||||
window.location.href = service.mobileUrl;
|
||||
if (!isMobileDevice()) return;
|
||||
|
||||
// Web-Fallback nach 800ms, falls die App nicht installiert ist
|
||||
e.preventDefault();
|
||||
|
||||
if (/^https?:\/\//i.test(mobileUrl)) {
|
||||
window.location.href = mobileUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
// Try to open the native mobile app through its registered URL scheme.
|
||||
window.location.href = mobileUrl;
|
||||
|
||||
// Web fallback if the app is not installed or the scheme is not handled.
|
||||
setTimeout(() => {
|
||||
if (Date.now() - start < 1500) {
|
||||
window.open(service.url, '_blank');
|
||||
}
|
||||
}, 800);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,6 @@
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<script src="/app.js?v=27" defer></script>
|
||||
<script src="/app.js?v=28" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"description": "Cloud-Speicher",
|
||||
"domain": "drive.mischlabs.de",
|
||||
"url": "https://drive.mischlabs.de",
|
||||
"mobileUrl": "nextcloud://",
|
||||
"mobileUrl": "https://drive.mischlabs.de/index.php/login/flow",
|
||||
"category": "media",
|
||||
"accent": "#60a5fa",
|
||||
"icon": "folder",
|
||||
|
||||
6
sw.js
6
sw.js
@@ -1,10 +1,10 @@
|
||||
const CACHE_NAME = 'mischlabs-pwa-v9';
|
||||
const CACHE_NAME = 'mischlabs-pwa-v10';
|
||||
const APP_SHELL = [
|
||||
'/',
|
||||
'/index.html',
|
||||
'/offline.html',
|
||||
'/style.css?v=20',
|
||||
'/app.js?v=6',
|
||||
'/style.css?v=27',
|
||||
'/app.js?v=28',
|
||||
'/services.json?v=1',
|
||||
'/manifest.webmanifest?v=3',
|
||||
'/icons/icon-192.png',
|
||||
|
||||
Reference in New Issue
Block a user