index.html 2.2 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 = false</script>
  11. <script>
  12. // 获取URL参数中的app值
  13. function getAppParam() {
  14. const urlParams = new URLSearchParams(window.location.search);
  15. return {app: urlParams.get('app'), isSample: urlParams.get('isSample')};
  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.app == '1') {
  25. faviconPath = basePath + 'fire.ico';
  26. } else if (appParam.app == '2' && appParam.isSample == '1') {
  27. faviconPath = basePath + 'police.ico';
  28. } else if (appParam.app == '3') {
  29. faviconPath = basePath + 'jmlogo.png';
  30. } else if (appParam.app == '2' && appParam.isSample == '0') {
  31. faviconPath = basePath + 'logo_big.ico';
  32. }
  33. // 查找现有的favicon链接元素
  34. let link = document.querySelector("link[rel~='icon']");
  35. // 如果没有找到,创建一个新的
  36. if (!link) {
  37. link = document.createElement('link');
  38. link.rel = 'icon';
  39. document.head.appendChild(link);
  40. }
  41. // 设置favicon路径
  42. link.href = faviconPath;
  43. }
  44. // 页面加载时设置favicon
  45. window.addEventListener('load', setFavicon);
  46. // 当URL通过History API变化时也更新favicon
  47. window.addEventListener('popstate', setFavicon);
  48. </script>
  49. </head>
  50. <body>
  51. <div id="app"></div>
  52. <script type="module" src="/src/main.ts"></script>
  53. </body>
  54. </html>