前端测试pad和pc
This commit is contained in:
@@ -1,39 +1,89 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
{block name="title"}<title>{$basic_config['website_seo_title']['value']}</title>{/block}
|
{block name="title"}<title>{$basic_config['website_seo_title']['value']}</title>{/block}
|
||||||
{block name="seo"}
|
{block name="seo"}
|
||||||
<meta name="keywords" content="{$basic_config['website_seo_keyword']['value']}" />
|
<meta name="keywords" content="{$basic_config['website_seo_keyword']['value']}" />
|
||||||
<meta name="description" content="{$basic_config['website_seo_description']['value']}" />
|
<meta name="description" content="{$basic_config['website_seo_description']['value']}" />
|
||||||
{/block}
|
{/block}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" type="text/css" href="__CSS__/public.css" />
|
<link rel="stylesheet" type="text/css" href="__CSS__/public.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="__CSS__/fonts.css" />
|
<link rel="stylesheet" type="text/css" href="__CSS__/fonts.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="__CSS__/orico_header.css" />
|
<link rel="stylesheet" type="text/css" href="__CSS__/orico_header.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="__CSS__/orico_footer.css" />
|
<link rel="stylesheet" type="text/css" href="__CSS__/orico_footer.css" />
|
||||||
{block name="style"}{/block}
|
{block name="style"}{/block}
|
||||||
<link rel="stylesheet" href="https://unpkg.com/swiper@9/swiper-bundle.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/swiper@9/swiper-bundle.min.css">
|
||||||
<script type="text/javascript" src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
|
<script type="text/javascript" src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
|
||||||
<script type="text/javascript" src="https://unpkg.com/swiper@9.4.1/swiper-bundle.min.js"></script>
|
<script type="text/javascript" src="https://unpkg.com/swiper@9.4.1/swiper-bundle.min.js"></script>
|
||||||
<script type="text/javascript" src="__JS__/before-after.min.js"></script>
|
<script type="text/javascript" src="__JS__/before-after.min.js"></script>
|
||||||
<script type="text/javascript" src="__JS__/large.js"></script>
|
<script type="text/javascript" src="__JS__/large.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(window).ready(function() {
|
function detectDeviceByResolution() {
|
||||||
if ($(window).width() < 1024) {
|
// 获取屏幕信息
|
||||||
window.location.href = '?mtpl=1';
|
const screenWidth = window.screen.width;
|
||||||
}
|
const screenHeight = window.screen.height;
|
||||||
})
|
const aspectRatio = screenWidth / screenHeight;
|
||||||
</script>
|
const pixelDensity = window.devicePixelRatio || 1;
|
||||||
</head>
|
|
||||||
<body>
|
// 计算物理屏幕尺寸(对角线英寸数)
|
||||||
{block name="header"}
|
// 注意:此计算依赖浏览器提供准确的 devicePixelRatio
|
||||||
{include file="public/header"/}
|
const diagonalPixels = Math.sqrt(
|
||||||
{/block}
|
Math.pow(screenWidth, 2) + Math.pow(screenHeight, 2)
|
||||||
{block name="main"}{/block}
|
);
|
||||||
{block name="footer"}
|
const diagonalInches = diagonalPixels / pixelDensity / 96;
|
||||||
{include file="public/footer"/}
|
|
||||||
{/block}
|
// 设备类型判断阈值
|
||||||
{block name="script"}{/block}
|
const isTabletSize = diagonalInches >= 7 && diagonalInches <= 13;
|
||||||
</body>
|
const isLaptopSize = diagonalInches > 13 && diagonalInches <= 17;
|
||||||
|
const isDesktopSize = diagonalInches > 17;
|
||||||
|
|
||||||
|
// 常见平板分辨率模式(非绝对标准)
|
||||||
|
const isTabletResolution = (
|
||||||
|
(screenWidth >= 768 && screenWidth <= 1100 && aspectRatio <= 1.7) || // 竖屏或方屏平板
|
||||||
|
(screenHeight >= 768 && screenHeight <= 1100 && aspectRatio >= 1.5) // 横屏平板
|
||||||
|
);
|
||||||
|
|
||||||
|
// 常见PC/笔记本分辨率模式
|
||||||
|
const isPcResolution = (
|
||||||
|
(screenWidth >= 1280 && aspectRatio >= 1.6) || // 宽屏笔记本/桌面
|
||||||
|
(screenWidth >= 1920) // 高分辨率桌面
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isTabletSize && isTabletResolution) {
|
||||||
|
return 'tablet';
|
||||||
|
} else if (isLaptopSize && isPcResolution) {
|
||||||
|
return 'laptop';
|
||||||
|
} else if (isDesktopSize && isPcResolution) {
|
||||||
|
return 'desktop';
|
||||||
|
} else {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(window).ready(function () {
|
||||||
|
const deviceType = detectDeviceByResolution();
|
||||||
|
if (deviceType=='tablet') {
|
||||||
|
window.location.href = '?mtpl=1';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// $(window).ready(function () {
|
||||||
|
// if ($(window).width() < 1024) {
|
||||||
|
// window.location.href = '?mtpl=1';
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{block name="header"}
|
||||||
|
{include file="public/header"/}
|
||||||
|
{/block}
|
||||||
|
{block name="main"}{/block}
|
||||||
|
{block name="footer"}
|
||||||
|
{include file="public/footer"/}
|
||||||
|
{/block}
|
||||||
|
{block name="script"}{/block}
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user