From 882793e794a071e443215b0c8d32d4004cd43f3d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 11 Jan 2026 18:29:47 +0200 Subject: [PATCH] chore(client-standalone): basic support for mobile --- apps/client/src/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts index 795adc8cf..0d0ebd9e0 100644 --- a/apps/client/src/index.ts +++ b/apps/client/src/index.ts @@ -25,10 +25,24 @@ async function setupGlob() { window.global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */ window.glob = { ...json, - activeDialog: null + activeDialog: null, + device: getDevice() }; } +function getDevice() { + // Respect user's manual override via URL. + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.has("desktop")) { + return "desktop"; + } else if (urlParams.has("mobile")) { + return "mobile"; + } + + const deviceCookie = document.cookie.split("; ").find(row => row.startsWith("trilium-device="))?.split("=")[1]; + return deviceCookie ?? "desktop"; +} + async function loadBootstrapCss() { // We have to selectively import Bootstrap CSS based on text direction. if (glob.isRtl) {