offline.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>案件信息</title>
  8. <link rel="stylesheet" type="text/css" href="./lib/Cesium/Widgets/CesiumWidget/CesiumWidget.css">
  9. <link rel="stylesheet" type="text/css" href="./lib/Cesium/Widgets/CesiumWidget/lighter.css">
  10. <script>window.offline = true</script>
  11. </head>
  12. <script>
  13. // 获取URL参数中的app值
  14. function getAppParam() {
  15. const urlParams = new URLSearchParams(window.location.search);
  16. return {app: urlParams.get('app'), isSample: urlParams.get('isSample')};
  17. }
  18. // 根据app参数设置favicon
  19. function setFavicon() {
  20. const appParam = getAppParam();
  21. // 获取基础路径
  22. const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
  23. let faviconPath = basePath + 'favicon.ico'; // 默认图标
  24. console.log(appParam, basePath, 6666)
  25. if (appParam.app == '1') {
  26. faviconPath = basePath + 'fire.ico';
  27. } else if (appParam.app == '2' && appParam.isSample == '1') {
  28. faviconPath = basePath + 'police.ico';
  29. } else if (appParam.app == '3') {
  30. faviconPath = basePath + 'jmlogo.png';
  31. } else if (appParam.app == '2' && appParam.isSample == '0') {
  32. faviconPath = basePath + 'logo_big.ico';
  33. }
  34. // 查找现有的favicon链接元素
  35. let link = document.querySelector("link[rel~='icon']");
  36. // 如果没有找到,创建一个新的
  37. if (!link) {
  38. link = document.createElement('link');
  39. link.rel = 'icon';
  40. document.head.appendChild(link);
  41. }
  42. // 设置favicon路径
  43. link.href = faviconPath;
  44. }
  45. // 页面加载时设置favicon
  46. window.addEventListener('load', setFavicon);
  47. // 当URL通过History API变化时也更新favicon
  48. window.addEventListener('popstate', setFavicon);
  49. </script>
  50. <body>
  51. <div id="app"></div>
  52. <script type="module" src="/src/main.ts"></script>
  53. </body>
  54. </html>