开启辅助访问     
收藏本站

站内搜索

搜索

Minecraft(我的世界)苦力怕论坛

[其他] 针对@星空晶体的“KLPTID”工具的UI美化和代码结构优化

 发表于 2025-1-15 20:54:43 来自手机|显示全部楼层|阅读模式 IP:湖南省
本帖最后由 林梦泽 于 2025-1-15 20:57 编辑

未获得开发者授权,帖子内已@

首先,样式我基于TailwindCSS2.2.19+新拟态设计进行美化。
其次,他这JavaScript代码实在是太...硬编码和getid太多了,我这边使用function对js进行了优化,功能区使用js动态加载,代码从前400余行优化到200余行。(本人不太爱写注释哈)
对了,等我忙完自己项目会用vue+ts对整个项目重构开源 望作者同意
@星空晶体

代码如下:
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">

  3. <head>
  4.   <meta charset="UTF-8">
  5.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.   <title>苦力怕TID跳转器</title>
  7.   <link href="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/tailwindcss/2.2.19/tailwind.min.css" type="text/css" rel="stylesheet" />
  8.   <style>
  9.     .neumorphic-box {
  10.       background: #f0f0f3;
  11.       border-radius: 16px;
  12.       box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
  13.       text-align: center;
  14.       padding: 16px;
  15.       font-size: 14px;
  16.       cursor: pointer;
  17.       transition: transform 0.2s, box-shadow 0.2s;
  18.     }

  19.     .neumorphic-box:hover {
  20.       transform: translateY(-4px);
  21.       box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  22.     }

  23.     .neumorphic-input {
  24.       width: 100%;
  25.       padding: 12px;
  26.       border-radius: 8px;
  27.       box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
  28.       border: none;
  29.       margin-bottom: 16px;
  30.       outline: none;
  31.     }

  32.     .neumorphic-btn {
  33.       width: 100%;
  34.       padding: 12px;
  35.       border-radius: 8px;
  36.       background: #f0f0f3;
  37.       box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  38.       border: none;
  39.       cursor: pointer;
  40.       font-weight: bold;
  41.       transition: transform 0.2s, box-shadow 0.2s;
  42.     }

  43.     .neumorphic-btn:hover {
  44.       transform: translateY(-4px);
  45.       box-shadow: 2px 2px 4px #d1d9e6, -2px -2px 4px #ffffff;
  46.     }
  47.   </style>
  48. </head>

  49. <body class="bg-gray-100 flex flex-col items-center justify-center min-h-screen p-4">
  50.   <!-- 标题 -->
  51.   <div class="text-center mb-6">
  52.     <p class="text-4xl font-bold text-gray-800 mb-2">KLPTID4.1</p>
  53.     <p class="text-lg text-gray-500">↓点击切换模式↓</p>
  54.   </div>

  55.   <!-- 功能选择 -->
  56.   <div class="grid grid-cols-3 gap-4 w-full max-w-3xl mb-8">
  57.     <button class="neumorphic-box" onclick="showFunction(1)">[基础]TID跳转</button>
  58.     <button class="neumorphic-box" onclick="showFunction(2)">[高级]TID跳转</button>
  59.     <button class="neumorphic-box" onclick="showFunction(3)">[基础]页面跳转</button>
  60.     <button class="neumorphic-box" onclick="showFunction(4)">[高级]页面跳转</button>
  61.     <button class="neumorphic-box" onclick="showFunction(5)">用户UID跳转</button>
  62.     <button class="neumorphic-box" onclick="showFunction(6)">查看警告记录</button>
  63.     <button class="neumorphic-box" onclick="showFunction(7)">查看点赞人</button>
  64.     <button class="neumorphic-box" onclick="showFunction(8)">查看帖子</button>
  65.     <button class="neumorphic-box" onclick="showFunction(9)">查看回复</button>
  66.   </div>

  67.   <!-- 功能区 -->
  68.   <div id="function-area" class="w-full max-w-xl p-6 rounded-xl bg-gray-200 shadow-xl hidden space-y-6">
  69.     <!-- 功能内容会动态更新 -->
  70.   </div>

  71.   <!-- 关于 -->
  72.   <p class="text-center text-gray-500 underline cursor-pointer mt-6" onclick="showAbout()">关于[可点]</p>

  73.   <!-- 关于弹窗 -->
  74.   <div id="about-window" class="hidden fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-6 bg-gray-100 rounded-xl shadow-xl w-full max-w-lg z-50">
  75.     <p class="text-xl font-semibold text-gray-700 mb-4">关于 About</p>
  76.     <p class="text-sm text-gray-600">
  77.       更新日志:美化 UI 和功能补充<br>
  78.       版本:4.1 最终版<br>
  79.       作者:KLPBBS星空晶体<br>
  80.       Github 仓库地址:<a href="#" class="text-blue-500">点此查看</a><br>
  81.       <span class="text-red-500 font-bold">声明:本工具由苦力怕论坛用户制作,非官方工具。</span><br />
  82.       <span class="text-red-500 font-bold">新UI由@YShenZe(github.com/YShenZe)制作</span>
  83.     </p>
  84.     <button onclick="closeAbout()" class="neumorphic-btn mt-4">关闭</button>
  85.   </div>

  86.   <script>
  87.     function showFunction(id) {
  88.       const functionArea = document.getElementById("function-area");
  89.       functionArea.classList.remove("hidden");

  90.       let content = "";
  91.       switch (id) {
  92.         case 1:
  93.           content = `
  94.                         <p class="text-xl font-semibold text-gray-700">TID跳转 - 基础版</p>
  95.                         <input type="text" id="tid1" placeholder="请输入TID" class="neumorphic-input">
  96.                         <button onclick="jumpToTID('tid1')" class="neumorphic-btn">跳转</button>`;
  97.           break;
  98.         case 2:
  99.           content = `
  100.                         <p class="text-xl font-semibold text-gray-700">TID跳转 - 高级版</p>
  101.                         <input type="text" id="tid2" placeholder="请输入TID" class="neumorphic-input">
  102.                         <input type="text" id="mode2" placeholder="请输入模式 (2 或 no)" class="neumorphic-input mt-4">
  103.                         <button onclick="jumpToTIDAdvanced()" class="neumorphic-btn">跳转</button>`;
  104.           break;
  105.         case 3:
  106.           content = `
  107.                         <p class="text-xl font-semibold text-gray-700">页面跳转 - 基础版</p>
  108.                         <input type="text" id="url3" placeholder="请输入URL" class="neumorphic-input">
  109.                         <button onclick="jumpToPage('url3')" class="neumorphic-btn">跳转</button>`;
  110.           break;
  111.         case 4:
  112.           content = `
  113.                         <p class="text-xl font-semibold text-gray-700">页面跳转 - 高级版</p>
  114.                         <input type="text" id="url4" placeholder="请输入URL" class="neumorphic-input">
  115.                         <input type="text" id="mode4" placeholder="请输入模式" class="neumorphic-input mt-4">
  116.                         <button onclick="jumpToPageAdvanced()" class="neumorphic-btn">跳转</button>`;
  117.           break;
  118.         case 5:
  119.           content = `
  120.                         <p class="text-xl font-semibold text-gray-700">用户UID跳转</p>
  121.                         <input type="text" id="uid" placeholder="请输入UID" class="neumorphic-input">
  122.                         <button onclick="jumpToUID()" class="neumorphic-btn">跳转</button>`;
  123.           break;
  124.         case 6:
  125.           content = `
  126.                         <p class="text-xl font-semibold text-gray-700">查看某用户警告记录</p>
  127.                         <input type="text" id="uidWarning" placeholder="请输入UID" class="neumorphic-input">
  128.                         <button onclick="checkWarning()" class="neumorphic-btn">查看</button>`;
  129.           break;
  130.         case 7:
  131.           content = `
  132.                         <p class="text-xl font-semibold text-gray-700">查看某主题的点赞人</p>
  133.                         <input type="text" id="tidLike" placeholder="请输入TID" class="neumorphic-input">
  134.                         <button onclick="checkLikes()" class="neumorphic-btn">查看</button>`;
  135.           break;
  136.         case 8:
  137.           content = `
  138.                         <p class="text-xl font-semibold text-gray-700">查看某用户空间的帖子</p>
  139.                         <input type="text" id="uidPosts" placeholder="请输入UID" class="neumorphic-input">
  140.                         <button onclick="checkPosts()" class="neumorphic-btn">查看</button>`;
  141.           break;
  142.         case 9:
  143.           content = `
  144.                         <p class="text-xl font-semibold text-gray-700">查看某用户空间的回复</p>
  145.                         <input type="text" id="uidReplies" placeholder="请输入UID" class="neumorphic-input">
  146.                         <button onclick="checkReplies()" class="neumorphic-btn">查看</button>`;
  147.           break;
  148.         default:
  149.           break;
  150.       }

  151.       functionArea.innerHTML = content;
  152.     }

  153.     function showAbout() {
  154.       document.getElementById("about-window").classList.remove("hidden");
  155.     }

  156.     function closeAbout() {
  157.       document.getElementById("about-window").classList.add("hidden");
  158.     }

  159.     function jumpToTID(inputId) {
  160.       const tid = document.getElementById(inputId).value;
  161.       window.location.href = `https://klpbbs.com/thread-${tid}-1-1.html`;
  162.     }

  163.     function jumpToTIDAdvanced() {
  164.       const tid = document.getElementById("tid2").value;
  165.       const mode = document.getElementById("mode2").value;
  166.       const url = mode === "no" ? `https://klpbbs.com/thread-${tid}-1-1-no.html` : `https://klpbbs.com/thread-${tid}-1-1.html`;
  167.       window.location.href = url;
  168.     }

  169.     function jumpToPage(inputId) {
  170.       const url = document.getElementById(inputId).value;
  171.       window.location.href = url;
  172.     }

  173.     function jumpToPageAdvanced() {
  174.       const url = document.getElementById("url4").value;
  175.       const mode = document.getElementById("mode4").value;
  176.       const finalUrl = `${url}?mode=${mode}`;
  177.       window.location.href = finalUrl;
  178.     }

  179.     function jumpToUID() {
  180.       const uid = document.getElementById("uid").value;
  181.       window.location.href = `https://klpbbs.com/space-uid-${uid}.html`;
  182.     }

  183.     function checkWarning() {
  184.       const uid = document.getElementById("uidWarning").value;
  185.       window.location.href = `https://klpbbs.com/warnings?uid=${uid}`;
  186.     }

  187.     function checkLikes() {
  188.       const tid = document.getElementById("tidLike").value;
  189.       window.location.href = `https://klpbbs.com/thread-${tid}-likes.html`;
  190.     }

  191.     function checkPosts() {
  192.       const uid = document.getElementById("uidPosts").value;
  193.       window.location.href = `https://klpbbs.com/space-uid-${uid}-posts.html`;
  194.     }

  195.     function checkReplies() {
  196.       const uid = document.getElementById("uidReplies").value;
  197.       window.location.href = `https://klpbbs.com/space-uid-${uid}-replies.html`;
  198.     }
  199.   </script>
  200. </body>

  201. </html>
复制代码
苦力怕论坛,感谢有您~
评论区暂时隐藏审核中...

本版积分规则

本站
关于我们
联系我们
坛史纲要
官方
哔哩哔哩
技术博客
下载
网易版
安卓版
JAVA
反馈
意见建议
教程中心
更多
捐助本站
QQ群
QQ群

QQ群

访问手机版

访问手机版

手机版|小黑屋|系统状态|klpbbs.com

粤公网安备 44200002445329号 | 由 木韩网络 提供支持 | GMT+8, 2025-4-2 23:51

声明:本站与Mojang以及微软公司没有从属关系

Powered by Discuz! X3.4 粤ICP备2023071842号-3