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