index.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = false</script>
  11. <script>
  12. // 获取URL参数中的app值
  13. function getAppParam() {
  14. const urlParams = new URLSearchParams(window.location.search);
  15. return urlParams.get('app');
  16. }
  17. // 根据app参数设置favicon
  18. function setFavicon() {
  19. const appParam = getAppParam();
  20. // 获取基础路径
  21. const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
  22. let faviconPath = basePath + 'favicon.ico'; // 默认图标
  23. console.log(appParam, basePath, 6666)
  24. if (appParam == '1') {
  25. faviconPath = basePath + 'fire.ico';
  26. } else if (appParam == '2') {
  27. faviconPath = basePath + 'police.ico';
  28. }
  29. // 查找现有的favicon链接元素
  30. let link = document.querySelector("link[rel~='icon']");
  31. // 如果没有找到,创建一个新的
  32. if (!link) {
  33. link = document.createElement('link');
  34. link.rel = 'icon';
  35. document.head.appendChild(link);
  36. }
  37. // 设置favicon路径
  38. link.href = faviconPath;
  39. }
  40. // 页面加载时设置favicon
  41. window.addEventListener('load', setFavicon);
  42. // 当URL通过History API变化时也更新favicon
  43. window.addEventListener('popstate', setFavicon);
  44. </script>
  45. </head>
  46. <body>
  47. <div id="app"></div>
  48. <script type="module" src="/src/main.ts"></script>
  49. </body>
  50. </html>