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:
45
app.js
45
app.js
@@ -56,6 +56,17 @@ function serviceSearchText(service) {
|
|||||||
].join(' ');
|
].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) {
|
function createServiceCard(service) {
|
||||||
const category = categoryById.get(service.category);
|
const category = categoryById.get(service.category);
|
||||||
const card = document.createElement('a');
|
const card = document.createElement('a');
|
||||||
@@ -81,22 +92,28 @@ function createServiceCard(service) {
|
|||||||
<span class="card-domain">${service.domain}</span>
|
<span class="card-domain">${service.domain}</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
if (service.mobileUrl) {
|
const mobileUrl = getMobileUrl(service);
|
||||||
|
if (mobileUrl) {
|
||||||
card.addEventListener('click', (e) => {
|
card.addEventListener('click', (e) => {
|
||||||
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
if (!isMobileDevice()) return;
|
||||||
if (isMobile) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const start = Date.now();
|
|
||||||
// Versuch, die mobile App über ihr registriertes Custom URL-Schema zu öffnen
|
if (/^https?:\/\//i.test(mobileUrl)) {
|
||||||
window.location.href = service.mobileUrl;
|
window.location.href = mobileUrl;
|
||||||
|
return;
|
||||||
// Web-Fallback nach 800ms, falls die App nicht installiert ist
|
|
||||||
setTimeout(() => {
|
|
||||||
if (Date.now() - start < 1500) {
|
|
||||||
window.open(service.url, '_blank');
|
|
||||||
}
|
|
||||||
}, 800);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/app.js?v=27" defer></script>
|
<script src="/app.js?v=28" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
"description": "Cloud-Speicher",
|
"description": "Cloud-Speicher",
|
||||||
"domain": "drive.mischlabs.de",
|
"domain": "drive.mischlabs.de",
|
||||||
"url": "https://drive.mischlabs.de",
|
"url": "https://drive.mischlabs.de",
|
||||||
"mobileUrl": "nextcloud://",
|
"mobileUrl": "https://drive.mischlabs.de/index.php/login/flow",
|
||||||
"category": "media",
|
"category": "media",
|
||||||
"accent": "#60a5fa",
|
"accent": "#60a5fa",
|
||||||
"icon": "folder",
|
"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 = [
|
const APP_SHELL = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
'/offline.html',
|
'/offline.html',
|
||||||
'/style.css?v=20',
|
'/style.css?v=27',
|
||||||
'/app.js?v=6',
|
'/app.js?v=28',
|
||||||
'/services.json?v=1',
|
'/services.json?v=1',
|
||||||
'/manifest.webmanifest?v=3',
|
'/manifest.webmanifest?v=3',
|
||||||
'/icons/icon-192.png',
|
'/icons/icon-192.png',
|
||||||
|
|||||||
Reference in New Issue
Block a user