盛夏云-星猫爱分享

通过腾讯云对象存储COS做静态网站跳转 防红引导页必备

希望把手段用在正当的地方,非常感谢!

74246567361448707514cc6d3feecd0864a4f94e212195df79d80980d5b5f39c.0

首先去腾讯云建一个COS存储桶-选择公有读私有写。

0aa491031554fcc4b85ebdf9da2c3ee1923265584d0641d43aae13302afb328d.0

进来之后,到基础配置-下来找到静态网站,开启下,默认是读取index.html文件。

5291424a473a62b3be7962b1af190644a8dfdd4a3f0eb371c11ea3ad84a15c63.0

在去设置域名选项-源站类型可以选择改成静态网站源站,也可以是默认的。

55ed8b0dc1e0843ef3567e91808e8a01c07d6c4a33c6713b1921eb2afcabc84a.0

然后自己新建一个index.html文件,把下面代码放进去。在把文件上传到腾讯云COS首页。记得把里面跳转的网址改成你的。

建议JS 图片本地化 以防止后期丢失

<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>网站名称标题</title>
</head>
<body>
  <div class="share_box">
    <!-- 头部 -->
    <div class="header_box">
      <img src="https://imgurl-ps-0.panbaidu.cn/2022/04/22/0515f57e7d698.png" class="bg">
      <div class="content">
        <p>点击右上角的 <img src="https://xxx.imgurl.ps/2022/04/22/e8410d32a43c1.png"> Safari打开</p>
        <p>可以继续浏览本站哦~</p>
      </div>
    </div>
    <!-- 按钮 -->
    <div class="footer_box">
      <p class="p_1">避免微信和QQ屏蔽本站网址,请理解支持!</p>
      <p class="p_2">点击右上角或复制网址自行打开</p>
      <div id="copyButton" class="button">点击复制本站网址</div>
    </div>
  </div>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    html {
      font-size: calc(100vw / 7.5);
    }
    html,
    body {
      width: 100%;
      height: 100%;
      overflow: hidden;
    }
    .share_box {
      position: relative;
      width: 100vw;
      height: 100vh;
      overflow: hidden;
    }
    .header_box {
      width: 100%;
      height: auto;
      overflow: hidden;
    }
    .header_box .bg {
      width: 100%;
      display: block;
    }
    .header_box .content {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      padding: 20px;
    }
    .header_box .content p {
      width: 100%;
      height: .6207rem;
      line-height: .6207rem;
      color: #fff;
      font-size: .3103rem;
    }
    .header_box .content p img {
      vertical-align: top;
      height: .4828rem;
      margin-top: .069rem;
    }
    .footer_box {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 20%;
    }
    .footer_box .p_1 {
      width: 100%;
      height: .4828rem;
      line-height: .4828rem;
      margin-bottom: .069rem;
      color: #000;
      font-size: .3103rem;
      text-align: center;
    }
    .footer_box .p_2 {
      position: relative;
      width: 100%;
      height: .4828rem;
      line-height: .4828rem;
      margin-bottom: .3793rem;
      color: #3764eb;
      font-size: .3103rem;
      text-align: center;
    }
    .footer_box .p_2::before,
    .footer_box .p_2::after {
      content: "";
      display: inline-block;
      vertical-align: top;
      width: .6897rem;
      height: .0138rem;
      margin-top: .2345rem;
      margin: .2345rem .2069rem;
      background-color: #3764eb;
    }
    .footer_box .button {
      width: 4.4483rem;
      height: .8414rem;
      line-height: .8414rem;
      margin: 0 auto;
      background-color: #3764eb;
      border-radius: .6897rem;
      color: #fff;
      font-size: .3448rem;
      font-weight: 500;
      text-align: center;
    }
  </style>
  <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/gh/iGaoWei/Dream-Msg/lib/dream-msg.min.js"></script>
  <script>
    /**
     * @description: 判断 - 环境 - 微信浏览器
     * @param {*}
     * @return {*}
     */
    // 是否是微信浏览器
    function isWeChatBrowser() {
      var ua = navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
      } else {
        return false;
      }
    }
    /**
     * @description: 判断 - 环境 - qq浏览器
     * @param {*}
     * @return {*}
     */
    function isQqInsideBrowser() {
      var sUserAgent = navigator.userAgent.toLowerCase();
      if (sUserAgent.match(/QQ/i) == 'qq') {
        return true
      } else {
        return false
      }
    }
    /**
     * @description: 封装 - 复制文本
     * @param {*} copuText
     * @return {*}
     */
    function copuText(copyText) {
      let input = document.createElement("input") // 创建一个input
      input.value = copyText // 赋值需要复制的内容
      document.body.appendChild(input) // 插入dom
      input.select()  // 选择对象
      document.execCommand("Copy") // 执行浏览器复制命令
      input.style.display = "none" // 隐藏
      document.body.removeChild(input) // 移除创建的input
    }
    if (isWeChatBrowser() || isQqInsideBrowser()) {
      alert("请点击右上角按钮, 点击使用浏览器打开");
    } else if (document.domain == "") {
      console.log("开发模式");
    } else {
      location.href = "你要跳转的网址";
    }
    $("#copyButton").click(function () {
      var copyUrl = location.href;
      copuText(copyUrl);
      Dreamer.success("复制成功", 2000);
    })
  </script>
</body>
</html>

嫌弃域名过长的,可以自己用一个没被拦截的域名,弄上301或者302跳转即可

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容