hookehuyr

fix(图标): 修复并优化favicon处理逻辑

移除课程卡片中重复的订阅信息显示
恢复默认favicon并添加时间戳避免缓存问题
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 <html lang="en"> 2 <html lang="en">
3 <head> 3 <head>
4 <meta charset="UTF-8" /> 4 <meta charset="UTF-8" />
5 - <!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> --> 5 + <link rel="icon" type="image/svg+xml" href="/vite.jpg" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" /> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
7 <title>美乐爱觉</title> 7 <title>美乐爱觉</title>
8 </head> 8 </head>
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
36 {{ course.buy_count }}人订阅 36 {{ course.buy_count }}人订阅
37 </div> 37 </div>
38 </div> 38 </div>
39 - <div class="text-gray-400 text-xs"> 39 + <!-- <div class="text-gray-400 text-xs">
40 已更新{{ course.count }}期 | {{ course.buy_count }}人订阅 40 已更新{{ course.count }}期 | {{ course.buy_count }}人订阅
41 - </div> 41 + </div> -->
42 </div> 42 </div>
43 </router-link> 43 </router-link>
44 </template> 44 </template>
......
...@@ -409,6 +409,28 @@ function remove_favicon() { ...@@ -409,6 +409,28 @@ function remove_favicon() {
409 if (link && link.parentNode) { 409 if (link && link.parentNode) {
410 link.parentNode.removeChild(link); 410 link.parentNode.removeChild(link);
411 } 411 }
412 + // 移除后恢复默认图标,避免浏览器继续沿用上一次缓存的图标
413 + set_default_favicon();
414 +}
415 +
416 +/**
417 + * @function set_default_favicon
418 + * @description 设置默认 favicon 为 /vite.svg,并通过时间戳参数避免缓存导致图标不更新。
419 + */
420 +function set_default_favicon() {
421 + const head = document.head || document.getElementsByTagName('head')[0];
422 + if (!head) return;
423 + const default_id = 'default-favicon';
424 + let link = document.querySelector('link#' + default_id);
425 + if (!link) {
426 + link = document.createElement('link');
427 + link.setAttribute('rel', 'icon');
428 + link.setAttribute('type', 'image/svg+xml');
429 + link.setAttribute('id', default_id);
430 + head.appendChild(link);
431 + }
432 + // 加上时间戳,确保浏览器立即刷新图标而非使用旧缓存
433 + link.setAttribute('href', `/vite.jpg?_ts=${Date.now()}`);
412 } 434 }
413 435
414 const $route = useRoute(); 436 const $route = useRoute();
......