index.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. <meta
  7. name="viewport"
  8. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
  9. />
  10. <title>h5</title>
  11. <style>
  12. #splash {
  13. position: fixed;
  14. top: 0;
  15. left: 0;
  16. width: 100%;
  17. height: 100%;
  18. background: #fff url('src/assets/img.png') no-repeat center center;
  19. background-size: contain;
  20. z-index: 9999;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div id="app"></div>
  26. <div id="splash"></div>
  27. <script type="module" src="/src/main.ts"></script>
  28. <script>
  29. window.onload = function() {
  30. document.getElementById('splash').style.display = 'none'; // 隐藏启动页
  31. }
  32. function getBrowserInfo() {
  33. const userAgent = navigator.userAgent;
  34. let browserName = "Unknown";
  35. let browserVersion = "Unknown";
  36. // 检查浏览器类型及版本
  37. if (userAgent.includes("Chrome")) {
  38. browserName = "Chrome";
  39. // 提取 Chrome 版本
  40. const match = userAgent.match(/Chrome\/([0-9]+)/);
  41. if (match) {
  42. browserVersion = match[1];
  43. }
  44. } else if (userAgent.includes("Firefox")) {
  45. browserName = "Firefox";
  46. // 提取 Firefox 版本
  47. const match = userAgent.match(/Firefox\/([0-9]+)/);
  48. if (match) {
  49. browserVersion = match[1];
  50. }
  51. } else if (userAgent.includes("MSIE") || userAgent.includes("Trident")) {
  52. browserName = "Internet Explorer";
  53. // 提取 IE 版本
  54. const match = userAgent.match(/(?:MSIE |rv:)([0-9]+)/);
  55. if (match) {
  56. browserVersion = match[1];
  57. }
  58. } else if (userAgent.includes("Edge")) {
  59. browserName = "Edge";
  60. // 提取 Edge 版本
  61. const match = userAgent.match(/Edge\/([0-9]+)/);
  62. if (match) {
  63. browserVersion = match[1];
  64. }
  65. } else if (userAgent.includes("Safari")) {
  66. browserName = "Safari";
  67. // 提取 Safari 版本
  68. const match = userAgent.match(/Version\/([0-9]+)/);
  69. if (match) {
  70. browserVersion = match[1];
  71. }
  72. }
  73. return {
  74. browserName,
  75. browserVersion,
  76. };
  77. }
  78. // const browserInfo = getBrowserInfo();
  79. // console.log(`Browser: ${browserInfo.browserName}, Version: ${browserInfo.browserVersion}`);
  80. </script>
  81. </body>
  82. </html>