index.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" />-->
  6. <link rel="stylesheet" href="src/assets/iconfont/iconfont.css" />
  7. <meta
  8. name="viewport"
  9. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
  10. />
  11. <title>h5</title>
  12. </head>
  13. <body>
  14. <div id="app"></div>
  15. <script type="module">
  16. if (import.meta.env.MODE === 'development' || import.meta.env.MODE === 'sit') {
  17. // 异步加载 eruda
  18. const script = document.createElement('script');
  19. script.src = 'https://cdn.bootcdn.net/ajax/libs/eruda/2.3.3/eruda.min.js';
  20. script.onload = () => {
  21. eruda.init();
  22. };
  23. document.head.appendChild(script);
  24. }
  25. </script>
  26. <script type="module" src="/src/main.ts"></script>
  27. <script>
  28. function getBrowserInfo() {
  29. const userAgent = navigator.userAgent
  30. let browserName = 'Unknown'
  31. let browserVersion = 'Unknown'
  32. // 检查浏览器类型及版本
  33. if (userAgent.includes('Chrome')) {
  34. browserName = 'Chrome';
  35. // 提取 Chrome 版本
  36. const match = userAgent.match(/Chrome\/([0-9]+)/);
  37. if (match) {
  38. browserVersion = match[1];
  39. }
  40. } else if (userAgent.includes("Firefox")) {
  41. browserName = "Firefox";
  42. // 提取 Firefox 版本
  43. const match = userAgent.match(/Firefox\/([0-9]+)/);
  44. if (match) {
  45. browserVersion = match[1];
  46. }
  47. } else if (userAgent.includes("MSIE") || userAgent.includes("Trident")) {
  48. browserName = "Internet Explorer";
  49. // 提取 IE 版本
  50. const match = userAgent.match(/(?:MSIE |rv:)([0-9]+)/);
  51. if (match) {
  52. browserVersion = match[1];
  53. }
  54. } else if (userAgent.includes("Edge")) {
  55. browserName = "Edge";
  56. // 提取 Edge 版本
  57. const match = userAgent.match(/Edge\/([0-9]+)/);
  58. if (match) {
  59. browserVersion = match[1];
  60. }
  61. } else if (userAgent.includes("Safari")) {
  62. browserName = "Safari";
  63. // 提取 Safari 版本
  64. const match = userAgent.match(/Version\/([0-9]+)/);
  65. if (match) {
  66. browserVersion = match[1];
  67. }
  68. }
  69. return {
  70. browserName,
  71. browserVersion,
  72. };
  73. }
  74. // const browserInfo = getBrowserInfo();
  75. // console.log(`Browser: ${browserInfo.browserName}, Version: ${browserInfo.browserVersion}`);
  76. </script>
  77. </body>
  78. </html>