refactor: ipd平台访问重定向为mobile view改为可配置

This commit is contained in:
2025-06-27 09:18:01 +08:00
parent c2b93bc290
commit fbeab9b7a0
5 changed files with 91 additions and 12 deletions

View File

@@ -28,5 +28,31 @@
{include file="public/footer"/}
{/block}
{block name="script"}{/block}
<script>
$(window).ready(function () {
// 为所有站内链接,添加标识
// 使用mtpl=1参数标识解决ipad访问站点时从pc重定向到mobile每次页面都会pc - mobile闪现问题
var LURL = new URL(window.location.href);
if (LURL.searchParams.get('mtpl') == 1) {
$('a').each(function () {
var href = $(this).attr('href');
if (href) {
var origin = LURL.origin;
if (href.indexOf('http') == -1) {
href = new URL(href, origin);
href.searchParams.set('mtpl', '1');
$(this).attr('href', href);
} else {
href = new URL(href);
if (href.origin == origin) {
href.searchParams.set('mtpl', '1');
$(this).attr('href', href);
}
}
}
})
}
})
</script>
</body>
</html>