子比首页添加macgf导航条和前往弹窗

效果显示

图片[1]-子比首页添加macgf导航条和前往弹窗 - 程序猿-程序猿

js代码

// 判断存在jq资源
try {
  if($ || jQuery) {
    tipsFun();
  }
} catch(e) {
  let script=document.createElement("script");
  script.type="text/javascript";
  script.src="https://cdn.mac89.com/common/static/jquery.min.js";

  document.getElementsByTagName('head')[0].appendChild(script);

  script.onload = tipsFun;
}


function tipsFun() {
  // 判断用户是否是windows
  if((navigator.platform == "Win32") || (navigator.platform == "Windows")) {
    // let hostName = location.hostname;
    // if(hostName === 'mac.mac89.com') return;

    let curTime = new Date().getTime();
    if(!window.localStorage.hasTips || ((curTime - window.localStorage.hasTips) >= 86400000)) {
      setTimeout(()=> {
        $(document).ready(function(){
          let tipHtml = `
            <div class="tip-box" id="tip-box" style="position: fixed; z-index: 9999; width: 740px; height: 150px; background-color: #fff; border-radius: 0 0 20px 20px; text-align: center; font-size: 16px; top: 0; left: 50%; margin-left: -370px; box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.2); display: none; transform: translateY(-100%); transition: all .6s;">
              <p class="tip" style="font-size: 18px; line-height: 1; margin: 38px 0 22px;">如果您当前使用的电脑是MacOS操作系统,请前往MacOS下载资源站点。</p>
              <button class="nomore" style="width: 120px; cursor: pointer; height: 40px; border: 1px solid #ddd; outline: none; border-radius: 5px; margin-right: 40px;">不再提醒</button>
              <button class="cancel" style="background-color: #333; color: #fff; width: 120px; cursor: pointer; height: 40px; border: none; outline: none; border-radius: 5px; margin-right: 40px;">继续浏览</button>
              <button class="sure" style="height: 40px; padding: 0 30px; background-color: #1B78F5; cursor: pointer; color: #fff; border-radius: 5px; outline: none; border: none;">立即前往 (10秒)</button>
            </div>`;

          $('body').append(tipHtml);

          const $tipBox = $('#tip-box');
          $tipBox.show().css('transform', 'translateY(0)');

          $tipBox.on('click', '.cancel', ()=> {
            removeTip();
          }).on('click', '.sure', ()=> {
            window.open("https://www.macw.com/");
          }).on('click', '.nomore', ()=> {
            removeTip();
            window.localStorage.hasTips = curTime;
          })

          let time = 10, timer;

          timer = setInterval(()=> {
            time--;
            $tipBox.find('.sure').text('立即前往 ('+ time +'秒)')
            if(time < 1) {
              removeTip();
            }
          }, 1000)

          function removeTip() {
            $tipBox.css('transform', 'translateY(-100%)');
            clearInterval(timer);
            setTimeout(function() {
              $tipBox.remove();
            }, 600)
          }
        });
      }, 1000);
    }
  }


  // pd广告地址
  let hostName = location.hostname;
  let pdAdress = "https://shop.macsc.com/pd19";

  // if(hostName === 'mac.macxf.com' || hostName === 'mac.orsoon.com') return; 

  let curTime = new Date().getTime();


  // 底部商城广告
  let shopHtml = `<div class="shop-box {class}" id="shop-box" style="position: fixed; box-sizing: border-box; z-index: 199; width: 100%; height: 120px; left: 0; bottom: {bot}; transition: all .2s; padding: 25px 0;">
  <div class="flex jse flex-row gutters-5 flex-col-sm-2">
    <div class="flex1">
      <div class="icon-cover-card flex ac zib-widget">
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=%E8%AE%BF%E8%BE%BE&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Finder.png" alt="访达" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=CleanMyMac+X&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/CleanMyMac%20X.png" alt="CleanMyMac"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=After%20Effects&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Adobe%20After%20Effects%202024.png"
            alt="After Effects" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Photoshop&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Adobe%20Photoshop%202024.png" alt="Photoshop"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Premiere%20Pro&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Adobe%20Premiere%20Pro%202024.png" alt="Premiere Pro"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Sketch&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Sketch.png" alt="Sketch" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Downie&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Downie%204.png" alt="Downie" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=DaVinci%20Resolve&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/DaVinci%20Resolve.png" alt="DaVinci Resolve"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Cinema%204D&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Cinema%204D.png" alt="Cinema 4D"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=WeChat&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/WeChat.png" alt="WeChat" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Parallels%20Desktop&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Parallels%20Desktop.png" alt="Parallels Desktop"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=Office&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/Office.png" alt="Office" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=AlDente&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/AlDente.png" alt="AlDente" style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=VMware%20Fusion&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/VMware%20Fusion.png" alt="VMware Fusion"
            style="width: 60px; height: 60px;">
          </div>
        </a>
        <a class="main-color" target="_blank" href="https://www.macgf.com/?s=AutoCAD&amp;type=post">
          <div class="icon-cover-icon" style="font-size: 25px;">
            <img src="/xzk/img/AutoCAD%202024.png" alt="AutoCAD"
            style="width: 60px; height: 60px;">
          </div>
        </a>
      </div>
    </div>
  </div>
</div>`;

//<div class="chat-gpt" style="display:none; position: fixed;z-index: 2;bottom: 220px;left: 30px;width: 100px;height: 100px;box-sizing: border-box;box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.1);border-radius: 15px;padding: 16px;line-height: 40px;text-align: center;margin: 0 10px;background: linear-gradient(135deg, #9D4EFF, #2C52F4);">
//  <a href="https://chat.macjz.com/" target="_blank" style="display: block;color: #fff;">
//    <img src="https://cdn.mac89.com/images/gpt.png" height="40"  style="display: inline-block;vertical-align: middle;">
//    <p>Chat GPT</p>
//  </a>
//</div>

//<div class="item gpt" style="width: 200px;height: 70px;box-sizing: border-box;box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.1);border-radius: 15px;padding: 15px 18px;line-height: 40px;margin: 0 10px;background: linear-gradient(135deg, #9D4EFF, #2C52F4);">
//  <a href="https://chat.macjz.com/" target="_blank" style="display: block;color: #fff;">
//    <img src="https://cdn.mac89.com/images/gpt.png" height="30"  style="display: inline-block;vertical-align: middle;">
//    <span style="margin-left: 10px;">Chat GPT人工智能</span>
//  </a>
//</div>

  let hasHide = window.localStorage.hideShop || '';
  if(hasHide === 'hide') {
    shopHtml = shopHtml.replace('{bot}', '-117px').replace('{class}', 'bot').replace('{rotate}', 'transform: rotate(180deg);')
  }  else {
    shopHtml = shopHtml.replace('{bot}', '0').replace('{class}', '').replace('{rotate}', '');
  }

  $('body').append(shopHtml);

  if(hostName === 'mac.mac89.com') {
    $('#shop-box').find('.gpt').hide();
  }

   $('#shop-box').on('click', '.close', function() {
    let $box = $('#shop-box')
     if($box.hasClass('bot')) {
       $box.css({'bottom': '0'})
       $(this).css({'transform': 'rotate(0)'})
       window.localStorage.hideShop = '';
     } else {
      $box.css({'bottom': '-117px'})
      $(this).css({'transform': 'rotate(180deg)'})
      window.localStorage.hideShop = 'hide';
     }

     $box.toggleClass('bot');
   })
}

css代码

.flex .flex1 {
  flex: initial;
  overflow: hidden;
}
.icon-cover-icon:hover::after {
  content: ''; /* 必须要有内容,否则伪元素不会显示 */
  position: absolute; /* 相对于.icon-cover-icon定位 */
  bottom: -5px; /* 位于图标下方 */
  left: 50%; /* 居中 */
  transform: translateX(-50%); /* 水平居中 */
  width: 3.5px; /* 小黑点宽度 */
  height: 3.5px; /* 小黑点高度 */
  background-color: #00000080; /* 小黑点颜色 */
  border-radius: 50%; /* 小黑点为圆形 */
}
.icon-cover-card {
  display: flex;
  justify-content: center;
  position: relative;
  min-width: 60px; /* 设置容器的最小宽度为图标的宽度 */
  margin: 0 auto;
  background: rgb(255 255 255 / 50%);
}
.icon-cover-icon {
  margin: 0 5px; /* 调整图标之间的间距 */
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.13, 1.34), margin-top 0.3s cubic-bezier(0.25, 0.1, 0.13, 1.34); /* 添加放大效果的过渡 */
  z-index: 1; /* 确保图标位于最上层 */
  max-width: 100%; /* 限制图标的最大宽度 */
  max-height: 100%; /* 限制图标的最大高度 */
}

.icon-cover-card:hover .icon-cover-icon:hover {
  transform: scale(1.2) translateY(-5px); /* 放大悬停的图标并向上移动10px */
  z-index: 2; /* 将悬停图标置于最上层 */
  margin-top: -20px; /* 为了保持布局稳定,调整上边距 */
}

 

© 版权声明
THE END
点赞18 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容