🎅挂件馆🌟铭牌馆✨️靓标库🧚‍♂️名人堂🦄宝可梦🍎水果机🥊猜拳🏧黑市🏧银行💹抽奖
   🎁
返回列表 发布新帖
查看: 228|回复: 0

[代码技巧] 子比主题 – PC右下角显示网易云热评(三款)

[复制链接]
飞流 00001
起源之星
任务·年会员
累计签到LV.3
摩羯座
+1
社区贡献
346 216 24292
等级头衔
Icon组别 : 管理员
Icon等级 :

积分成就
   钻石 : 175 颗
   贡献 : 14431 点
   金币 : 4 枚
Icon在线时间 : 1952 小时
Icon注册时间 : 2024-11-22
Icon最后登录 : 2026-8-16
送礼物:3 收礼物:1
FLLTCN 实名认证 特邀大神 诚信商家 信誉担保 精华作者+ 官方团队 vip vip-year 发表于 2025-10-8 22:46:25 | 查看全部 |阅读模式 浙江金华

交易无需等待,成交就是现在,全面资源整合网络大咖云集,让你轻松玩转互联网!

您需要 登录 才可以下载或查看,没有账号?立即注册

×
给子比主题PC端右下角加一个显示网易云热评的美化样式,这个功能还是不错的,给自己的网站加上动态的网易云热评,一共是三款,喜欢的自行部署吧!

第一款



tengfei_down (50).webp

第二款


tengfei_down (51).webp

第三款


tengfei_down (52).webp

代码部署


喜欢哪一款放到:WP后台–>>外观–小工具–>>自定义HTML,建议放到:所有页面-底部全宽度
第一款代码
  1. <div id="wniui-popup-window" class="wniui-show-popup-window">
  2.   <div class="wniui-popup-header">
  3.       <div class="wniui-popup-window-title">网易云热评</div>
  4.       <span id="wniui-popup-username"></span>
  5.       <a id="music-link" href="" target="_blank" style="position: absolute; top: 8px; right: 10px;">
  6.           <svg style="transition: .3s;height:30px;width:30px;" t="1740280523955" class="icon" viewbox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22033"
  7.               xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30">
  8.               <path
  9.                   d="M512.1 137.8c-206.4 0-373.7 167.3-373.7 373.7s167.3 373.7 373.7 373.7 373.7-167.3 373.7-373.7-167.3-373.7-373.7-373.7zM721 508.5L589.2 647c-9.9 10.4-27.4 3.4-27.4-11v-90.9h-1.4c-130.9 0-239.1 58.4-259.2 134.7h-2.3c12.8-133.2 125-237.4 261.5-237.4 0.5 0 0.9 0.1 1.4 0.1V359c0-14.4 17.5-21.4 27.4-11L721 486.6c5.8 6.2 5.8 15.8 0 21.9z"
  10.                   fill="#231815" p-id="22034"></path>
  11.           </svg>
  12.       </a>
  13.   </div>
  14.   <div class="wniui-popup-window-divider"></div>
  15.   <div class="wniui-popup-window-content">
  16.   </div>
  17. </div>

  18. <style>
  19.   #music-link:hover svg path {
  20.   fill: #425AEF;
  21.   transition: .3s;
  22. }

  23.   #wniui-popup-window {
  24.       min-width: 300px;
  25.       max-width: 500px;
  26.       bottom: 20px;
  27.       right: 20px;
  28.       position: fixed;
  29.       z-index: 1002;
  30.       color: #363636;
  31.       padding: 8px 16px;
  32.       border-radius: 12px;
  33.       transition: opacity 0.3s ease, transform 0.3s ease;
  34.       background-color: rgba(255, 255, 255, 0.85);
  35.       border: 1px solid #e3e8f7;
  36.       max-height: 300px;
  37.       opacity: 0;
  38.       transform: translateY(20px);
  39.       display: flex;
  40.       flex-direction: column;
  41.       justify-content: flex-start;
  42.   }

  43.   #wniui-popup-window.wniui-show {
  44.       opacity: 1;
  45.       transform: translateY(0);
  46.   }

  47.   #wniui-popup-header {
  48.       display: flex;
  49.       align-items: center;
  50.       gap: 8px;
  51.       position: relative;
  52.   }

  53.   #wniui-popup-window .wniui-popup-window-title {
  54.       font-size: 12px;
  55.       font-weight: 700;
  56.       color: #fff;
  57.       line-height: 1;
  58.       background: #363636;
  59.       padding: 4px;
  60.       border-radius: 4px;
  61.       display: inline-block;
  62.   }

  63.   #wniui-popup-username {
  64.       font-size: 12px;
  65.       color: #666;
  66.       line-height: 1;
  67.       margin: 0;
  68.       white-space: nowrap;
  69.   }

  70.   #wniui-popup-window .wniui-popup-window-divider {
  71.       width: 100%;
  72.       margin-top: 6px;
  73.       border: 1px solid #e3e8f7;
  74.   }

  75.   #wniui-popup-window .wniui-popup-window-content {
  76.       font-size: 15px;
  77.       display: flex;
  78.       justify-content: space-around;
  79.       word-wrap: break-word;
  80.       max-width: 450px;
  81.       margin-top: 5px;
  82.       overflow: auto;
  83.   }

  84.   #wniui-popup-window .wniui-popup-image {
  85.       width: 50px;
  86.       height: 50px;
  87.       border-radius: 50%;
  88.       margin-right: 10px !important;
  89.   }

  90.   #wniui-popup-window .wniui-popup-window-content p {
  91.       margin: 0;
  92.       display: -webkit-box;
  93.       -webkit-box-orient: vertical;
  94.       overflow: hidden;
  95.       -webkit-line-clamp: 2;
  96.       text-overflow: ellipsis;
  97.   }

  98.   #wniui-popup-window:hover {
  99.       border: 1px solid #425AEF;
  100.   }

  101.   #wniui-popup-window .wniui-popup-window-title:hover {
  102.       background-color: #425AEF;
  103.   }
  104. </style>

  105. <script>
  106. async function fetchPopupContent() {
  107.   if (window.innerWidth <= 768) {
  108.       document.getElementById("wniui-popup-window").style.display = "none";
  109.       return;
  110.   } else {
  111.       document.getElementById("wniui-popup-window").style.display = "flex";
  112.   }

  113.   try {
  114.       const response = await fetch("https://www.wniui.com/api/music/index.php");
  115.       const data = await response.json();
  116.       const { musicLink, comments } = data;
  117.       const { nickname, avatarUrl, content } = getRandomComment(comments);

  118.       const popup = document.getElementById("wniui-popup-window");

  119.       popup.classList.remove("wniui-show");

  120.       setTimeout(() => {
  121.           document.getElementById("wniui-popup-username").textContent = `- ${nickname}`;
  122.           document.querySelector(".wniui-popup-window-content").innerHTML = `
  123.               <div style="display: flex; align-items: center;">
  124.                   
  125.                   <div><p>${content}</p></div>
  126.               </div>
  127.           `;

  128.           const musicLinkElement = document.getElementById("music-link");
  129.           musicLinkElement.href = musicLink;
  130.           popup.classList.add("wniui-show");
  131.       }, 300);

  132.   } catch (error) {
  133.       console.error("获取数据失败:", error);
  134.   }
  135. }

  136. // 每 4 秒更新一次
  137. fetchPopupContent();
  138. setInterval(fetchPopupContent, 4000);

  139. function getRandomComment(comments) {
  140.   return comments[Math.floor(Math.random() * comments.length)];
  141. }

  142. </script>
复制代码


第二款代码
  1. <div id="wniui-popup-window" class="wniui-show-popup-window">
  2.     <div class="wniui-popup-header">
  3.         <div class="wniui-popup-window-title">网易云热评</div>
  4.         <a id="music-link" href="" target="_blank" style="position: absolute; top: 4px; right: 10px;">
  5.             <svg style="transition: .3s;height:30px;width:30px;" t="1740280523955" class="icon" viewbox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22033"
  6.                 xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30">
  7.                 <path
  8.                     d="M512.1 137.8c-206.4 0-373.7 167.3-373.7 373.7s167.3 373.7 373.7 373.7 373.7-167.3 373.7-373.7-167.3-373.7-373.7-373.7zM721 508.5L589.2 647c-9.9 10.4-27.4 3.4-27.4-11v-90.9h-1.4c-130.9 0-239.1 58.4-259.2 134.7h-2.3c12.8-133.2 125-237.4 261.5-237.4 0.5 0 0.9 0.1 1.4 0.1V359c0-14.4 17.5-21.4 27.4-11L721 486.6c5.8 6.2 5.8 15.8 0 21.9z"
  9.                     fill="#231815" p-id="22034"></path>
  10.             </svg>
  11.         </a>
  12.     </div>
  13.     <div class="wniui-popup-window-divider"></div>
  14.     <div class="wniui-popup-window-content">
  15.     </div>
  16.   </div>
  17.   
  18.   <style>
  19.     #music-link:hover svg path {
  20.     fill: #425AEF;
  21.     transition: .3s;
  22.   }
  23.   
  24.     #wniui-popup-window {
  25.         min-width: 300px;
  26.         max-width: 500px;
  27.         bottom: 20px;
  28.         right: 20px;
  29.         position: fixed;
  30.         z-index: 1002;
  31.         color: #363636;
  32.         padding: 8px 16px;
  33.         border-radius: 12px;
  34.         transition: opacity 0.3s ease, transform 0.3s ease;
  35.         background-color: rgba(255, 255, 255, 0.85);
  36.         border: 1px solid #e3e8f7;
  37.         max-height: 300px;
  38.         opacity: 0;
  39.         transform: translateY(20px);
  40.         display: flex;
  41.         flex-direction: column;
  42.         justify-content: flex-start;
  43.     }
  44.   
  45.     #wniui-popup-window.wniui-show {
  46.         opacity: 1;
  47.         transform: translateY(0);
  48.     }
  49.   
  50.     #wniui-popup-header {
  51.         display: flex;
  52.         align-items: center;
  53.         gap: 8px;
  54.         position: relative;
  55.     }
  56.   
  57.     #wniui-popup-window .wniui-popup-window-title {
  58.         font-size: 12px;
  59.         font-weight: 700;
  60.         color: #fff;
  61.         line-height: 1;
  62.         background: #363636;
  63.         padding: 4px;
  64.         border-radius: 4px;
  65.         display: inline-block;
  66.     }
  67.   
  68.     #wniui-popup-username {
  69.         font-size: 12px;
  70.         color: #666;
  71.         line-height: 1;
  72.         margin: 0;
  73.         white-space: nowrap;
  74.     }
  75.   
  76.     #wniui-popup-window .wniui-popup-window-divider {
  77.         width: 100%;
  78.         margin-top: 6px;
  79.         border: 1px solid #e3e8f7;
  80.     }
  81.   
  82.     #wniui-popup-window .wniui-popup-window-content {
  83.         font-size: 15px;
  84.         display: flex;
  85.         justify-content: space-around;
  86.         word-wrap: break-word;
  87.         max-width: 450px;
  88.         margin-top: 5px;
  89.         overflow: auto;
  90.     }
  91.   
  92.     #wniui-popup-window .wniui-popup-image {
  93.         width: 50px;
  94.         height: 50px;
  95.         border-radius: 50%;
  96.         margin-right: 10px !important;
  97.     }
  98.   
  99.     #wniui-popup-window .wniui-popup-window-content p {
  100.         margin: 0;
  101.         display: -webkit-box;
  102.         -webkit-box-orient: vertical;
  103.         overflow: hidden;
  104.         -webkit-line-clamp: 2;
  105.         text-overflow: ellipsis;
  106.     }
  107.   
  108.     #wniui-popup-window:hover {
  109.         border: 1px solid #425AEF;
  110.     }
  111.   
  112.     #wniui-popup-window .wniui-popup-window-title:hover {
  113.         background-color: #425AEF;
  114.     }
  115.   </style>
  116.   
  117.   <script>
  118.   async function fetchPopupContent() {
  119.     if (window.innerWidth <= 768) {
  120.         document.getElementById("wniui-popup-window").style.display = "none";
  121.         return;
  122.     } else {
  123.         document.getElementById("wniui-popup-window").style.display = "flex";
  124.     }
  125.   
  126.     try {
  127.         const response = await fetch("https://www.wniui.com/api/music/index.php");
  128.         const data = await response.json();
  129.         const { musicLink, comments, songName } = data;
  130.         const { content } = getRandomComment(comments);
  131.   
  132.         const popup = document.getElementById("wniui-popup-window");
  133.   
  134.         popup.classList.remove("wniui-show");
  135.   
  136.         setTimeout(() => {
  137.             document.querySelector(".wniui-popup-window-content").innerHTML = `
  138.                 <div>
  139.                     <p>${content} —— 网易云热评《${songName}》</p>
  140.                 </div>
  141.             `;
  142.   
  143.             const musicLinkElement = document.getElementById("music-link");
  144.             musicLinkElement.href = musicLink;
  145.             popup.classList.add("wniui-show");
  146.         }, 300);
  147.   
  148.     } catch (error) {
  149.         console.error("获取数据失败:", error);
  150.     }
  151.   }
  152.   
  153.   // 每 4 秒更新一次
  154.   fetchPopupContent();
  155.   setInterval(fetchPopupContent, 4000);
  156.   
  157.   function getRandomComment(comments) {
  158.     return comments[Math.floor(Math.random() * comments.length)];
  159.   }
  160.   
  161.   </script>
复制代码

第三款代码
  1. <div id="wniui-popup-window" class="wniui-show-popup-window">
  2.   <div class="wniui-popup-header">
  3.       <div style="display: flex; justify-content: space-between; width: 100%; align-items: center;">
  4.           <div id="wniui-user-info" style="display: flex; align-items: center; gap: 8px;">
  5.               <span id="wniui-popup-username"></span>
  6.           </div>
  7.           <a id="wniui-popup-link" href="#" target="_blank" class="wniui-popup-window-title">网易云热评</a>
  8.       </div>
  9.   </div>
  10.   <div class="wniui-popup-window-divider"></div>
  11.   <div class="wniui-popup-window-content">
  12.       <div class="wniui-popup-tip">加载中...</div>
  13.   </div>
  14. </div>

  15. <style>
  16. #wniui-popup-window {
  17.       min-width: 300px;
  18.       max-width: 500px;
  19.       bottom: 20px;
  20.       right: 20px;
  21.       position: fixed;
  22.       z-index: 1002;
  23.       color: #363636;
  24.       padding: 8px 16px;
  25.       border-radius: 12px;
  26.       transition: opacity 0.3s ease, transform 0.3s ease;
  27.       background-color: rgba(255, 255, 255, 0.85);
  28.       border: 1px solid #e3e8f7;
  29.       max-height: 300px;
  30.       opacity: 0;
  31.       transform: translateY(20px);
  32.       display: flex;
  33.       flex-direction: column;
  34.       justify-content: flex-start;
  35.   }

  36.   #wniui-popup-window.wniui-show {
  37.       opacity: 1;
  38.       transform: translateY(0);
  39.   }

  40.   #wniui-popup-header {
  41.       display: flex;
  42.       justify-content: space-between;
  43.       align-items: center;
  44.   }

  45.   .wniui-popup-window-title {
  46.       font-size: 14px;
  47.       font-weight: 700;
  48.       color: #fff;
  49.       line-height: 1;
  50.       background: #363636;
  51.       padding: 4px;
  52.       border-radius: 4px;
  53.       display: inline-block;
  54.       transition: .3s;
  55.   }
  56. .wniui-popup-window-title:hover{
  57.   background-color: #425AEF;
  58.   transition: .3s;
  59. }
  60.   #wniui-user-info {
  61.       background-color: rgba(255, 255, 255, 0.5);
  62.       padding: 4px 8px;
  63.       border-radius: 8px;
  64.       font-size: 12px;
  65.       display: flex;
  66.       align-items: center;
  67.   }

  68.   #wniui-popup-avatar {
  69.       width: 30px;
  70.       height: 30px;
  71.       border-radius: 50%;
  72.       object-fit: cover;
  73.   }

  74.   #wniui-popup-username {
  75.       color: #666;
  76.       font-weight: 500;
  77.   }

  78.   #wniui-popup-window .wniui-popup-window-divider {
  79.       width: 100%;
  80.       margin-top: 6px;
  81.       border: 1px solid #e3e8f7;
  82.   }

  83.   #wniui-popup-window .wniui-popup-window-content {
  84.       font-size: 15px;
  85.       display: flex;
  86.       justify-content: space-around;
  87.       align-items: center;
  88.       word-wrap: break-word;
  89.       max-width: 450px;
  90.       margin-top: 5px;
  91.       overflow: auto;
  92.   }

  93.   #wniui-popup-window:hover {
  94.       border: 1px solid #425AEF;
  95.       transition: 0.4s;
  96.   }

  97.   .wniui-popup-window-content p {
  98.       margin: 0;
  99.   }
  100. </style>

  101. <script>
  102.   let popupTimer;

  103.   function checkWindowWidth() {
  104.       const popup = document.getElementById("wniui-popup-window");
  105.       if (window.innerWidth < 768) {
  106.           popup.classList.remove("wniui-show");
  107.           clearTimeout(popupTimer);
  108.       } else {
  109.           fetchPopupContent();
  110.       }
  111.   }

  112.   function fetchPopupContent() {
  113.       fetch("https://www.wniui.com/api/music/index.php")
  114.           .then(response => response.json())
  115.           .then(data => {
  116.               // 随机选择一个评论
  117.               const randomIndex = Math.floor(Math.random() * data.comments.length);
  118.               const userData = data.comments[randomIndex];
  119.               const content = userData.content || "没有更多的内容";

  120.               const avatarElement = document.getElementById("wniui-popup-avatar");
  121.               avatarElement.src = userData.avatarUrl;

  122.               const usernameElement = document.getElementById("wniui-popup-username");
  123.               usernameElement.textContent = `${userData.nickname}`;

  124.               const musicLink = data.musicLink;

  125.               const titleLinkElement = document.getElementById("wniui-popup-link");
  126.               titleLinkElement.href = musicLink;

  127.               const message = `
  128.                   <div>
  129.                       <p>${content}</p>
  130.                   </div>
  131.               `;
  132.               const popup = document.getElementById("wniui-popup-window");

  133.               popup.classList.remove("wniui-show");
  134.               clearTimeout(popupTimer);

  135.               setTimeout(() => {
  136.                   document.querySelector(".wniui-popup-window-content").innerHTML = message;
  137.                   popup.classList.add("wniui-show");

  138.                   popupTimer = setTimeout(() => {
  139.                       popup.classList.remove("wniui-show");
  140.                       fetchPopupContent();
  141.                   }, 5000);
  142.               }, 300);
  143.           })
  144.           .catch(() => {
  145.               fetchPopupContent();
  146.           });
  147.   }

  148.   checkWindowWidth();
  149.   window.addEventListener("resize", checkWindowWidth);
  150. </script>
复制代码


本帖被以下淘专辑推荐:

路虽远,行则将至;事虽难,做则必成。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

飞流广播+ 发布

07-23 18:52
飞流这论坛到底有没有资本给我投资一下啊!
07-20 22:07
系统消息:飞流安卓客户端APP已上线,请在QQ群(123129)群文件内获取下载。
02-21 02:22
01-24 12:40
站内通告

📢 六月份后均不在线,请悉知

提供资源交易、信息共享、靓号交流、技术变现、学习问答、兴趣娱乐等全面服务。

1.丰富功能系统,扩展社区特色玩法,打造最好的互联网聚集圈子。

2.准确信息真实交易,安全快捷又方便,让虚拟交易面对面。

3. 天上不会掉馅饼,话术骗术迷人心,切勿脱离平台线下交易,被骗与平台无关!

4. 欺诈骗钱,违规违法将视情受到警告&禁言&封号甚至检举至👮🏻‍♀️处理!

官方Q群:1003810038钉推群:BAYR2383 站长QQ:3388700000

飞流论坛(FLLT.CN),一个专注于资源信息发布、虚拟网络交易、技术学习与娱乐社交的交流平台。
  • 钉钉新帖推送群
  • 官方交流QQ群
  • 站长唯一微信号

💥客户端|🧿小黑屋|📴手机页|飞流网 |网站地图

GMT+8, 2026-8-17 08:51 , Processed in 0.069288 second(s), 68 queries, MemCached On , Gzip On.

飞流论坛 HanAnalytics icp

Copyright © 2024-2026 飞流网 版权所有 All Rights Reserved. X3.5

快速回复 返回顶部 返回列表