reset:还原

This commit is contained in:
迷和油
2025-06-19 11:50:22 +08:00
parent f683dfbe26
commit 2ded94976a
2 changed files with 0 additions and 135 deletions

View File

@@ -107,73 +107,5 @@
$('.top-country .close-icon').click(function(){
$(".mask,.action-sheet").hide();
})
// 缓存检测结果
let _deviceType = null;
/**
* 检测当前设备类型
* @returns {'mobile'|'tablet'|'desktop'}
*/
function detectDevice() {
if (_deviceType) return _deviceType;
const isTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
const screenWidth = window.innerWidth || document.documentElement.clientWidth;
const userAgent = navigator.userAgent.toLowerCase();
const isTablet =
userAgent.includes('tablet') ||
(userAgent.includes('android') && !userAgent.includes('mobile')) ||
userAgent.includes('ipad') ||
userAgent.includes('kindle');
_deviceType =
isTouch && (screenWidth < 768 || !isTablet) ? 'mobile' :
isTouch && screenWidth >= 768 ? 'tablet' : 'desktop';
return _deviceType;
}
/**
* 显示设备类型提示
*/
function showDeviceAlert() {
const device = detectDevice();
const message = `您正在使用${
device === 'mobile' ? '手机' :
device === 'tablet' ? '平板' : '电脑'
}访问本页面`;
// 使用原生alert
alert(message);
// 或者使用自定义样式的提示需要引入相关CSS
/*
$('<div class="device-alert">' + message + '</div>')
.css({
position: 'fixed',
top: '10px',
right: '10px',
padding: '10px 15px',
background: '#333',
color: 'white',
borderRadius: '5px',
zIndex: '9999'
})
.appendTo('body')
.fadeIn()
.delay(3000)
.fadeOut(function() {
$(this).remove();
});
*/
}
// 页面加载完成后自动检测并提示
$(document).ready(showDeviceAlert);
// 暴露检测方法供外部使用
$.detectDevice = detectDevice;
})
</script>

View File

@@ -201,72 +201,5 @@
$('.closecountrybt').click(function () {
$('#top-country').hide();
});
// 缓存检测结果
let _deviceType = null;
/**
* 检测当前设备类型
* @returns {'mobile'|'tablet'|'desktop'}
*/
function detectDevice() {
if (_deviceType) return _deviceType;
const isTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
const screenWidth = window.innerWidth || document.documentElement.clientWidth;
const userAgent = navigator.userAgent.toLowerCase();
const isTablet =
userAgent.includes('tablet') ||
(userAgent.includes('android') && !userAgent.includes('mobile')) ||
userAgent.includes('ipad') ||
userAgent.includes('kindle');
_deviceType =
isTouch && (screenWidth < 768 || !isTablet) ? 'mobile' :
isTouch && screenWidth >= 768 ? 'tablet' : 'desktop';
return _deviceType;
}
/**
* 显示设备类型提示
*/
function showDeviceAlert() {
const device = detectDevice();
const message = `您正在使用${
device === 'mobile' ? '手机' :
device === 'tablet' ? '平板' : '电脑'
}访问本页面`;
// 使用原生alert
alert(message);
// 或者使用自定义样式的提示需要引入相关CSS
/*
$('<div class="device-alert">' + message + '</div>')
.css({
position: 'fixed',
top: '10px',
right: '10px',
padding: '10px 15px',
background: '#333',
color: 'white',
borderRadius: '5px',
zIndex: '9999'
})
.appendTo('body')
.fadeIn()
.delay(3000)
.fadeOut(function() {
$(this).remove();
});
*/
}
// 页面加载完成后自动检测并提示
$(document).ready(showDeviceAlert);
// 暴露检测方法供外部使用
$.detectDevice = detectDevice;
});
</script>