mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
refactor(views/login): add getDeviceType function
This commit is contained in:
parent
5a3a31ff1c
commit
b44397a6bf
@ -43,20 +43,8 @@
|
|||||||
// Required for correct loading of scripts in Electron
|
// Required for correct loading of scripts in Electron
|
||||||
if (typeof module === 'object') {window.module = module; module = undefined;}
|
if (typeof module === 'object') {window.module = module; module = undefined;}
|
||||||
|
|
||||||
let device;
|
const device = getDeviceType()
|
||||||
|
|
||||||
if (window.location.search === '?desktop') {
|
|
||||||
device = "desktop";
|
|
||||||
}
|
|
||||||
else if (window.location.search === '?mobile') {
|
|
||||||
device = "mobile";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
device = isMobile() ? "mobile" : "desktop";
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Setting device cookie to:", device);
|
console.log("Setting device cookie to:", device);
|
||||||
|
|
||||||
setCookie("trilium-device", device);
|
setCookie("trilium-device", device);
|
||||||
|
|
||||||
function setCookie(name, value) {
|
function setCookie(name, value) {
|
||||||
@ -66,6 +54,12 @@
|
|||||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDeviceType() {
|
||||||
|
if (window.location.search === '?desktop') return "desktop";
|
||||||
|
if (window.location.search === '?mobile') return "mobile";
|
||||||
|
return isMobile() ? "mobile" : "desktop";
|
||||||
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/73731646/944162
|
// https://stackoverflow.com/a/73731646/944162
|
||||||
function isMobile() {
|
function isMobile() {
|
||||||
const mQ = matchMedia?.('(pointer:coarse)');
|
const mQ = matchMedia?.('(pointer:coarse)');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user