|
|
@@ -21,19 +21,29 @@
|
|
|
<script>
|
|
|
(function () {
|
|
|
try {
|
|
|
- var iconEl = document.getElementById('app-icon');
|
|
|
- if (!iconEl) return;
|
|
|
-
|
|
|
- var params = new URL(window.location.href).searchParams;
|
|
|
- var fromRoute = (params.get('fromRoute') || '').toLowerCase();
|
|
|
+ var params = window.location.hash;
|
|
|
+ var query = params.indexOf('?') > -1 ? params.split('?')[1] : '';
|
|
|
+ var fromRoute = (new URLSearchParams(query).get('fromRoute') || '').toLowerCase();
|
|
|
var iconMap = {
|
|
|
criminal: '/criminal.ico',
|
|
|
xmfire: '/jmlogo.png',
|
|
|
cjzfire: '/logo_big.ico'
|
|
|
};
|
|
|
-
|
|
|
var href = iconMap[fromRoute] || '/favicon.ico';
|
|
|
- iconEl.setAttribute('href', href);
|
|
|
+ // 查找现有的favicon链接元素
|
|
|
+ let link = document.querySelector("link[rel~='icon']");
|
|
|
+ if (link) {
|
|
|
+ // 如果存在,更新href属性
|
|
|
+ link.href = href;
|
|
|
+ console.log('更新favicon为', href);
|
|
|
+ } else {
|
|
|
+ // 如果不存在,创建新的favicon链接元素
|
|
|
+ link = document.createElement('link');
|
|
|
+ link.rel = 'icon';
|
|
|
+ link.type = 'image/ico';
|
|
|
+ link.href = href;
|
|
|
+ document.head.appendChild(link);
|
|
|
+ }
|
|
|
} catch (e) {
|
|
|
// 容错,不影响页面加载
|
|
|
}
|