mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 05:56:03 +08:00
use more precise detection of a mobile browser, fixes #3680
This commit is contained in:
parent
f541bf186c
commit
03897c5c9d
2 changed files with 16 additions and 4 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.58.8",
|
"version": "0.59.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.58.8",
|
"version": "0.59.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -52,8 +52,7 @@
|
||||||
device = "mobile";
|
device = "mobile";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// mobile device detection based on https://stackoverflow.com/a/24600597/944162
|
device = isMobile() ? "mobile" : "desktop";
|
||||||
device = /Mobi/.test(navigator.userAgent) ? "mobile" : "desktop";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Setting device cookie to:", device);
|
console.log("Setting device cookie to:", device);
|
||||||
|
@ -66,6 +65,19 @@
|
||||||
|
|
||||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/73731646/944162
|
||||||
|
function isMobile() {
|
||||||
|
if ('maxTouchPoints' in navigator) return navigator.maxTouchPoints > 0;
|
||||||
|
|
||||||
|
const mQ = matchMedia?.('(pointer:coarse)');
|
||||||
|
if (mQ?.media === '(pointer:coarse)') return !!mQ.matches;
|
||||||
|
|
||||||
|
if ('orientation' in window) return true;
|
||||||
|
|
||||||
|
return /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(navigator.userAgent) ||
|
||||||
|
/\b(Android|Windows Phone|iPad|iPod)\b/i.test(navigator.userAgent);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<link href="<%= assetPath %>/libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
<link href="<%= assetPath %>/libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
Loading…
Reference in a new issue