找回密码
 立即注册
搜索
查看: 18|回复: 2

音画贴源码 转自马黑教程专版

[复制链接]

1657

主题

3461

回帖

1万

积分

管理员

积分
14050
发表于 昨天 01:40 | 显示全部楼层 |阅读模式
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8" />
  <title>音画帖快手</title>
  <meta name="author" content="mhh" />
  <meta name="keywords" content="tzmaker2026,lrc" />
  <meta name="description" content="快速制作音画帖" />
</head>
<body style="background: #666; color: white;">

<style>
  .mainBox { --xx: 0px; margin: 30px 0; left: calc(50% - var(--xx)); transform: translateX(-50%); width: 98vw; height: 86vh; background: white; color: black; padding: 0 20px; border-radius: 8px; box-sizing: border-box; display: flex; flex-direction: row; gap: 5px; position: relative; }
  .item { flex-grow: 1; box-sizing: border-box; padding: 10px; display: flex; gap: 10px; flex-direction: column;  }
  .item div { flex-grow: 0; font-size: 18px; display: flex; gap: 10px; }
  .item div:nth-of-type(2) { flex-grow: 2; background: #ccc; }
  .item div:nth-of-type(2) textarea { flex-grow: 1; box-sizing: border-box; resize: none; overflow: auto; padding: 10px; font: normal 16px/1.2 monospace; background: beige; color: black; }
  .mainBox button { outline: none; border: none; box-shadow: 0 0 2px gray; border-radius: 16px; padding: 6px 20px; }
  .mainBox button:hover { color: red; box-shadow: 1px 1px 8px gray; }
  #previewBox { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(255,255,255,.99); display: none; padding: 0; overflow: hidden; z-index: 1000; margin: 0; }
  #previewBox::after { position: absolute; content: '关闭预览'; top: 20px; right: 20px; padding: 0 4px; width: 80px; height: 30px; line-height: 30px; text-align: center; border: 1px solid #efe; border-radius: 6px; background: #eee; color: red; font-size: 14px; box-shadow: 2px 2px 6px rgba(0,0,0,.25); cursor: pointer; }
  #previewBox iframe { position: relative; width: 100%; height: 100%; border: none; outline: none; box-sizing: border-box; margin: 0; }
  #copyMsg { position: fixed; top: 50%; right: 50%; background: #333; color: #fff; padding: 10px 15px; border-radius: 4px; opacity: 0; display: none; transition: opacity 0.3s; }
  .wrapper { position: absolute; transform: translate(0, -30px); border-radius: 8px 8px 0 0; background: white; padding: 5px 16px 5px 8px; }
  .grow2 { flex-grow: 2; }
  .tMid { text-align: center; }

</style>

<h2 class="tMid">音画帖快手</h2>
<div class="mainBox">
  <div class="wrapper" title="点击切换单曲/专辑&#10注意:代码会重置!">
    <input type="checkbox" id="mMusic" name="mMusic">
    <label for="mMusic" >专辑</label>
  </div>
  <div class="item">
    <div><span>CSS代码</span></div>
    <div><textarea></textarea></div>
    <div>
      <button value="0">重置CSS代码</button>
    </div>
  </div>
  <div class="item">
    <div>html代码</div>
    <div><textarea></textarea></div>
    <div>
      <button value="1">重置HTML代码</button>
    </div>
  </div>
  <div class="item">
    <div>
      <span>JS代码</span>
      <span class="grow2"></span>
      <button value="3">预览帖子效果</button>
    </div>
    <div><textarea></textarea></div>
    <div>
      <button value="2">重置JS代码</button>
      <span class="grow2"></span>
      <button value="4">复制帖子代码</button>
    </div>
  </div>
</div>
<div id="previewBox"></div>
<div id="copyMsg">showToast</div>

<script>
  const tzBasicCodes = [`<style>
  @import 'https://638183.freep.cn/638183/tzmaker/tz2026.css';
  .pa { --bg: url('背景图片') no-repeat center/cover; }
  .player { bottom: 50px; width: 120px; height: 120px; }
  .bgprog { bottom: 20px; }
  .btnFs { left: 30px; top: 30px; color: lightblue; }
  /* .lrc { top: 30px; } */
</style>`,
  `<div class="pa">
  <audio src="https://music.163.com/song/media/outer/url?id=歌曲ID" autoplay loop></audio>
  <!--<video class="pd-vid" src="熊猫视频" autoplay loop muted></video>-->
  <!--<div class="lrc">LRC</div>-->
  <img src="小播图片" class="player rotate" title="Alt+X" alt="">
  <div class="bgprog"></div>
  <div class="btnFs" title="F11"></div>
</div>`,
  `\<script\>
/* lrc歌词同步
  var gc = \`
[00:01.300]歌词
[00:04.260]歌词\`;
*/
  loadJs('https://638183.freep.cn/638183/tzmaker/tz2026.min.js');

  function loadJs(url, callback) {
    const script = document.createElement('script');
    script.charset = 'utf-8';
    script.src = url;
    script.defer = true;
    script.onload = () => {
      var tz = TZ('pa');
      tz.start(); // tz.start(gc);
    };
    document.head.appendChild(script);
  }
\</script\>`];

const mtzBasicCodes = [`<style>
  @import 'https://638183.freep.cn/638183/tzmaker/tz2026m.css';
  .pa { --bg: url('背景图片') no-repeat center/cover; }
  .mlist { left: 30px; top: 20px; }
  .player { bottom: 50px; }
  .bgprog { bottom: 20px; }
  .btnFs { right: 30px; top: 30px; color: lightblue; }
</style>`,
  `<div class="pa">
  <audio></audio>
  <!--<video class="pd-vid" src="熊猫视频" autoplay loop muted></video>-->
  <ol class="mlist"></ol>
  <img class="player rotate" title="Alt+X" alt="">
  <div class="bgprog"></div>
  <div class="btnFs" title="F11"></div>
</div>`,
  `\<script\>
  var musics = [
    ['https://music.163.com/song/media/outer/url?id=歌曲ID', '曲名'],
    ['https://music.163.com/song/media/outer/url?id=歌曲ID', '曲名'],
  ];

  loadJs('https://638183.freep.cn/638183/tzmaker/tz2026m.js', tzInit);

  function loadJs(url, callback) {
    var script = document.createElement('script');
    script.charset = 'utf-8';
    script.src = url;
    script.defer = true;
    script.onload = callback;
    document.head.appendChild(script);
  }

  function tzInit() {
    var tz = TZ('pa', musics);
    tz.start();
  }
\</script\>`];
</script>

<script>
  const btns = document.querySelectorAll('.mainBox button');
  const tboxes = document.querySelectorAll('.mainBox textarea');
  const mMusic = document.getElementById('mMusic');
  let codeAr = [];

  // 按钮单击函数
  function handleBtnClick(ar) {
    btns.forEach(btn => btn.onclick = () => {
      switch (btn.value) {
        // 重置代码
        case "0":
        case "1":
        case "2":
          const k = btn.value * 1;
          tboxes[k].value = ar[k];
          tboxes[k].focus();
          break;
        // 预览
        case "3":
          preView(getCodes(), previewBox);
          break;
        // 复制代码
        default:
          xCopy(getCodes());
      }
    });
  }

  // 预览
  function preView(htmlCode, targetBox) {
    if (targetBox.innerHTML) return;
    const iframe = document.createElement('iframe');
    htmlCode = htmlCode + '\n<style>body {margin: 0; }</style>\n';
    iframe.srcdoc = htmlCode;
    targetBox.appendChild(iframe);
    targetBox.style.display = 'block';
    targetBox.onclick = () => {
      targetBox.innerHTML = '';
      targetBox.style.display = 'none';
    }
  }

  // 整合代码
  function getCodes() {
    return tboxes[0].value.trim() + '\n\n' + tboxes[1].value.trim() + '\n\n' + tboxes[2].value.trim() + '\n';
  }

  // 复制
  function xCopy(content) {
    if (!content) return;
    if (navigator.clipboard && window.isSecureContext) {
      return navigator.clipboard.writeText(content)
        .then(() => {
          showToast('复制成功');
        })
        .catch(err => {
          console.error('复制失败:', err);
          showToast('复制失败');
        });
    } else {
      return new Promise((resolve) => {
        let successful = false;
        const body = document.body;
        if (!body) {
          showToast('复制失败');
          resolve(false);
          return;
        }
        const textarea = document.createElement('textarea');
        textarea.style.position = 'fixed';
        textarea.style.opacity = '0';
        textarea.value = content;
        body.appendChild(textarea);
        textarea.select();
        try {
          successful = document.execCommand('copy');
        } catch (err) {
          successful = false;
        }
        body.removeChild(textarea);
        if (successful) {
          showToast('复制成功');
          resolve(true);
        } else {
          console.error('execCommand 复制失败');
          showToast('复制失败');
          resolve(false);
        }
      });
    }
  }

  // 复制交互
  function showToast(message, duration = 2000) {
    const toast = document.getElementById('copyMsg');
    toast.textContent = message;
    toast.style.display = 'block';
    toast.style.opacity = '1';
    clearTimeout(toast.timeout);
    toast.timeout = setTimeout(() => {
      toast.style.display = 'none';
      toast.style.opacity = '0';
    }, duration);
  }

  // 单曲或专辑
  function selectCode() {
    codeAr = mMusic.checked ? mtzBasicCodes : tzBasicCodes;
    tboxes.forEach((tbox, k) => tbox.value = codeAr[k]);
  }

  // 专辑复选按钮
  mMusic.onclick = () => selectCode();

  //初始化页面
  selectCode();
  handleBtnClick(codeAr);
</script>

</body>
</html>

1657

主题

3461

回帖

1万

积分

管理员

积分
14050
 楼主| 发表于 昨天 01:41 | 显示全部楼层
基于 tz2026 插件,支持单曲、专辑制作。源码存为本地 .html 文档即可运行(2026年3月27日更新):

1657

主题

3461

回帖

1万

积分

管理员

积分
14050
 楼主| 发表于 昨天 01:42 | 显示全部楼层

  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.   <meta charset="utf-8" />
  5.   <title>音画帖快手</title>
  6.   <meta name="author" content="mhh" />
  7.   <meta name="keywords" content="tzmaker2026,lrc" />
  8.   <meta name="description" content="快速制作音画帖" />
  9. </head>
  10. <body style="background: #666; color: white;">

  11. <style>
  12.   .mainBox { --xx: 0px; margin: 30px 0; left: calc(50% - var(--xx)); transform: translateX(-50%); width: 98vw; height: 86vh; background: white; color: black; padding: 0 20px; border-radius: 8px; box-sizing: border-box; display: flex; flex-direction: row; gap: 5px; position: relative; }
  13.   .item { flex-grow: 1; box-sizing: border-box; padding: 10px; display: flex; gap: 10px; flex-direction: column;  }
  14.   .item div { flex-grow: 0; font-size: 18px; display: flex; gap: 10px; }
  15.   .item div:nth-of-type(2) { flex-grow: 2; background: #ccc; }
  16.   .item div:nth-of-type(2) textarea { flex-grow: 1; box-sizing: border-box; resize: none; overflow: auto; padding: 10px; font: normal 16px/1.2 monospace; background: beige; color: black; }
  17.   .mainBox button { outline: none; border: none; box-shadow: 0 0 2px gray; border-radius: 16px; padding: 6px 20px; }
  18.   .mainBox button:hover { color: red; box-shadow: 1px 1px 8px gray; }
  19.   #previewBox { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(255,255,255,.99); display: none; padding: 0; overflow: hidden; z-index: 1000; margin: 0; }
  20.   #previewBox::after { position: absolute; content: '关闭预览'; top: 20px; right: 20px; padding: 0 4px; width: 80px; height: 30px; line-height: 30px; text-align: center; border: 1px solid #efe; border-radius: 6px; background: #eee; color: red; font-size: 14px; box-shadow: 2px 2px 6px rgba(0,0,0,.25); cursor: pointer; }
  21.   #previewBox iframe { position: relative; width: 100%; height: 100%; border: none; outline: none; box-sizing: border-box; margin: 0; }
  22.   #copyMsg { position: fixed; top: 50%; right: 50%; background: #333; color: #fff; padding: 10px 15px; border-radius: 4px; opacity: 0; display: none; transition: opacity 0.3s; }
  23.   .wrapper { position: absolute; transform: translate(0, -30px); border-radius: 8px 8px 0 0; background: white; padding: 5px 16px 5px 8px; }
  24.   .grow2 { flex-grow: 2; }
  25.   .tMid { text-align: center; }

  26. </style>

  27. <h2 class="tMid">音画帖快手</h2>
  28. <div class="mainBox">
  29.   <div class="wrapper" title="点击切换单曲/专辑&#10注意:代码会重置!">
  30.     <input type="checkbox" id="mMusic" name="mMusic">
  31.     <label for="mMusic" >专辑</label>
  32.   </div>
  33.   <div class="item">
  34.     <div><span>CSS代码</span></div>
  35.     <div><textarea></textarea></div>
  36.     <div>
  37.       <button value="0">重置CSS代码</button>
  38.     </div>
  39.   </div>
  40.   <div class="item">
  41.     <div>html代码</div>
  42.     <div><textarea></textarea></div>
  43.     <div>
  44.       <button value="1">重置HTML代码</button>
  45.     </div>
  46.   </div>
  47.   <div class="item">
  48.     <div>
  49.       <span>JS代码</span>
  50.       <span class="grow2"></span>
  51.       <button value="3">预览帖子效果</button>
  52.     </div>
  53.     <div><textarea></textarea></div>
  54.     <div>
  55.       <button value="2">重置JS代码</button>
  56.       <span class="grow2"></span>
  57.       <button value="4">复制帖子代码</button>
  58.     </div>
  59.   </div>
  60. </div>
  61. <div id="previewBox"></div>
  62. <div id="copyMsg">showToast</div>

  63. <script>
  64.   const tzBasicCodes = [`<style>
  65.   @import 'https://638183.freep.cn/638183/tzmaker/tz2026.css';
  66.   .pa { --bg: url('背景图片') no-repeat center/cover; }
  67.   .player { bottom: 50px; width: 120px; height: 120px; }
  68.   .bgprog { bottom: 20px; }
  69.   .btnFs { left: 30px; top: 30px; color: lightblue; }
  70.   /* .lrc { top: 30px; } */
  71. </style>`,
  72.   `<div class="pa">
  73.   <audio src="https://music.163.com/song/media/outer/url?id=歌曲ID" autoplay loop></audio>
  74.   <!--<video class="pd-vid" src="熊猫视频" autoplay loop muted></video>-->
  75.   <!--<div class="lrc">LRC</div>-->
  76.   <img src="小播图片" class="player rotate" title="Alt+X" alt="">
  77.   <div class="bgprog"></div>
  78.   <div class="btnFs" title="F11"></div>
  79. </div>`,
  80.   `\<script\>
  81. /* lrc歌词同步
  82.   var gc = \`
  83. [00:01.300]歌词
  84. [00:04.260]歌词\`;
  85. */
  86.   loadJs('https://638183.freep.cn/638183/tzmaker/tz2026.min.js');

  87.   function loadJs(url, callback) {
  88.     const script = document.createElement('script');
  89.     script.charset = 'utf-8';
  90.     script.src = url;
  91.     script.defer = true;
  92.     script.onload = () => {
  93.       var tz = TZ('pa');
  94.       tz.start(); // tz.start(gc);
  95.     };
  96.     document.head.appendChild(script);
  97.   }
  98. \</script\>`];

  99. const mtzBasicCodes = [`<style>
  100.   @import 'https://638183.freep.cn/638183/tzmaker/tz2026m.css';
  101.   .pa { --bg: url('背景图片') no-repeat center/cover; }
  102.   .mlist { left: 30px; top: 20px; }
  103.   .player { bottom: 50px; }
  104.   .bgprog { bottom: 20px; }
  105.   .btnFs { right: 30px; top: 30px; color: lightblue; }
  106. </style>`,
  107.   `<div class="pa">
  108.   <audio></audio>
  109.   <!--<video class="pd-vid" src="熊猫视频" autoplay loop muted></video>-->
  110.   <ol class="mlist"></ol>
  111.   <img class="player rotate" title="Alt+X" alt="">
  112.   <div class="bgprog"></div>
  113.   <div class="btnFs" title="F11"></div>
  114. </div>`,
  115.   `\<script\>
  116.   var musics = [
  117.     ['https://music.163.com/song/media/outer/url?id=歌曲ID', '曲名'],
  118.     ['https://music.163.com/song/media/outer/url?id=歌曲ID', '曲名'],
  119.   ];

  120.   loadJs('https://638183.freep.cn/638183/tzmaker/tz2026m.js', tzInit);

  121.   function loadJs(url, callback) {
  122.     var script = document.createElement('script');
  123.     script.charset = 'utf-8';
  124.     script.src = url;
  125.     script.defer = true;
  126.     script.onload = callback;
  127.     document.head.appendChild(script);
  128.   }

  129.   function tzInit() {
  130.     var tz = TZ('pa', musics);
  131.     tz.start();
  132.   }
  133. \</script\>`];
  134. </script>

  135. <script>
  136.   const btns = document.querySelectorAll('.mainBox button');
  137.   const tboxes = document.querySelectorAll('.mainBox textarea');
  138.   const mMusic = document.getElementById('mMusic');
  139.   let codeAr = [];

  140.   // 按钮单击函数
  141.   function handleBtnClick(ar) {
  142.     btns.forEach(btn => btn.onclick = () => {
  143.       switch (btn.value) {
  144.         // 重置代码
  145.         case "0":
  146.         case "1":
  147.         case "2":
  148.           const k = btn.value * 1;
  149.           tboxes[k].value = ar[k];
  150.           tboxes[k].focus();
  151.           break;
  152.         // 预览
  153.         case "3":
  154.           preView(getCodes(), previewBox);
  155.           break;
  156.         // 复制代码
  157.         default:
  158.           xCopy(getCodes());
  159.       }
  160.     });
  161.   }

  162.   // 预览
  163.   function preView(htmlCode, targetBox) {
  164.     if (targetBox.innerHTML) return;
  165.     const iframe = document.createElement('iframe');
  166.     htmlCode = htmlCode + '\n<style>body {margin: 0; }</style>\n';
  167.     iframe.srcdoc = htmlCode;
  168.     targetBox.appendChild(iframe);
  169.     targetBox.style.display = 'block';
  170.     targetBox.onclick = () => {
  171.       targetBox.innerHTML = '';
  172.       targetBox.style.display = 'none';
  173.     }
  174.   }

  175.   // 整合代码
  176.   function getCodes() {
  177.     return tboxes[0].value.trim() + '\n\n' + tboxes[1].value.trim() + '\n\n' + tboxes[2].value.trim() + '\n';
  178.   }

  179.   // 复制
  180.   function xCopy(content) {
  181.     if (!content) return;
  182.     if (navigator.clipboard && window.isSecureContext) {
  183.       return navigator.clipboard.writeText(content)
  184.         .then(() => {
  185.           showToast('复制成功');
  186.         })
  187.         .catch(err => {
  188.           console.error('复制失败:', err);
  189.           showToast('复制失败');
  190.         });
  191.     } else {
  192.       return new Promise((resolve) => {
  193.         let successful = false;
  194.         const body = document.body;
  195.         if (!body) {
  196.           showToast('复制失败');
  197.           resolve(false);
  198.           return;
  199.         }
  200.         const textarea = document.createElement('textarea');
  201.         textarea.style.position = 'fixed';
  202.         textarea.style.opacity = '0';
  203.         textarea.value = content;
  204.         body.appendChild(textarea);
  205.         textarea.select();
  206.         try {
  207.           successful = document.execCommand('copy');
  208.         } catch (err) {
  209.           successful = false;
  210.         }
  211.         body.removeChild(textarea);
  212.         if (successful) {
  213.           showToast('复制成功');
  214.           resolve(true);
  215.         } else {
  216.           console.error('execCommand 复制失败');
  217.           showToast('复制失败');
  218.           resolve(false);
  219.         }
  220.       });
  221.     }
  222.   }

  223.   // 复制交互
  224.   function showToast(message, duration = 2000) {
  225.     const toast = document.getElementById('copyMsg');
  226.     toast.textContent = message;
  227.     toast.style.display = 'block';
  228.     toast.style.opacity = '1';
  229.     clearTimeout(toast.timeout);
  230.     toast.timeout = setTimeout(() => {
  231.       toast.style.display = 'none';
  232.       toast.style.opacity = '0';
  233.     }, duration);
  234.   }

  235.   // 单曲或专辑
  236.   function selectCode() {
  237.     codeAr = mMusic.checked ? mtzBasicCodes : tzBasicCodes;
  238.     tboxes.forEach((tbox, k) => tbox.value = codeAr[k]);
  239.   }

  240.   // 专辑复选按钮
  241.   mMusic.onclick = () => selectCode();

  242.   //初始化页面
  243.   selectCode();
  244.   handleBtnClick(codeAr);
  245. </script>

  246. </body>
  247. </html>
复制代码


返回列表 发新帖
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

协同嘉业科技有限公司 ( 京ICP备2024053108号-1 )

GMT+8, 2026-11-7 02:06 , Processed in 0.087747 second(s), 28 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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