feat: propagate client screen size to web runtime

This commit is contained in:
2026-04-24 18:26:11 +00:00
parent 627910f07b
commit 8863943d79
3 changed files with 128 additions and 12 deletions
+26
View File
@@ -100,6 +100,32 @@
banner.style.display = 'none';
});
})();
(function () {
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function currentScreenParams() {
const width = clamp(window.innerWidth || document.documentElement.clientWidth || 1280, 320, 7680);
const height = clamp(window.innerHeight || document.documentElement.clientHeight || 720, 240, 4320);
const sp = new URLSearchParams();
sp.set('sw', String(width));
sp.set('sh', String(height));
return sp;
}
document.querySelectorAll('a.tile[href^="/go/"]').forEach(function (link) {
link.addEventListener('click', function () {
try {
const url = new URL(link.getAttribute('href'), window.location.origin);
const params = currentScreenParams();
url.search = params.toString();
link.setAttribute('href', url.pathname + '?' + url.searchParams.toString());
} catch (e) {}
}, { capture: true });
});
})();
</script>
</body>
</html>