index.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
  8. />
  9. <script>
  10. function isPC () {
  11. const ua = navigator.userAgent;
  12. const platform = navigator.platform;
  13. // 移动设备检测
  14. const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i;
  15. const isMobile = mobileRegex.test(ua);
  16. // 平板设备检测
  17. const tabletRegex = /iPad|Tablet|PlayBook|Silk|Kindle|(Android(?!.*Mobile))|(Windows(?!.*Phone))(.*Touch)/i;
  18. const isTablet = tabletRegex.test(ua);
  19. // 屏幕尺寸检测
  20. const isSmallScreen = window.innerWidth < 768;
  21. // 触摸支持检测
  22. const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
  23. // 如果是移动设备、平板设备、小屏幕设备,则不是PC
  24. if (isMobile || isTablet || isSmallScreen) {
  25. return false;
  26. }
  27. // 额外的PC特征检测
  28. const isWindows = /Win/i.test(platform);
  29. const isMac = /Mac/i.test(platform);
  30. const isLinux = /Linux/i.test(platform);
  31. return (isWindows || isMac || isLinux) && !hasTouch;
  32. }
  33. if (isPC()) {
  34. window.location.replace('https://callweb.wefanbot.com')
  35. }
  36. window.addEventListener('resize', function() {
  37. if (isPC()) {
  38. window.location.replace('https://callweb.wefanbot.com')
  39. }
  40. })
  41. </script>
  42. <title></title>
  43. <!--preload-links-->
  44. <!--app-context-->
  45. </head>
  46. <body>
  47. <div id="app"><!--app-html--></div>
  48. <script type="module" src="/main.js"></script>
  49. </body>
  50. </html>