index.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8"/>
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  6. <title>Cookie管理</title>
  7. <link rel="stylesheet" href="./static/css/style.css"/>
  8. <link rel="stylesheet" href="./static/css/daisyui.min.css"/>
  9. <script src="./static/js/tailwindcss.min.js"></script>
  10. <script src="./static/js/axios.min.js"></script>
  11. <script src="./static/js/qrcode.min.js"></script>
  12. <script src="./static/js/crypto-js.min.js"></script>
  13. <script src="./static/js/core.js"></script>
  14. <script src="./static/js/cookie.js"></script>
  15. </head>
  16. <body class="bg-gray-100 font-sans">
  17. <div class="artboard phone-2 box p-4">
  18. <!-- Navigation Menu -->
  19. <ul class="menu menu-horizontal lg:menu-horizontal bg-base-200 rounded-box mb-4">
  20. <li><a class="btn-scan" data-platform="ali">阿里</a></li>
  21. <li><a class="btn-scan" data-platform="quark">夸克</a></li>
  22. <li><a class="btn-scan" data-platform="uc">UC</a></li>
  23. <li><a class="btn-scan" data-platform="uc_token">UC_TOKEN</a></li>
  24. <li><a class="btn-scan" data-platform="bili">哔哩哔哩</a></li>
  25. </ul>
  26. <!-- QR Code -->
  27. <div class="qrcode-container text-center mb-4">
  28. <img id="qrcode" src="./static/img/qrcode_expired.jpg" alt="二维码" class="mx-auto"/>
  29. </div>
  30. <!-- Divider -->
  31. <div class="divider divider-neutral mb-4">请使用手机APP扫码登录</div>
  32. <!-- Textarea with improved styling -->
  33. <textarea
  34. id="cookie-res"
  35. class="textarea textarea-bordered w-full h-40 p-4 bg-white border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
  36. placeholder="扫码确认后将在此处展示cookie"
  37. ></textarea>
  38. <!-- Buttons with improved design -->
  39. <div class="flex justify-center gap-4 mt-4">
  40. <button
  41. id="copy-btn"
  42. class="btn btn-primary w-28 py-2 rounded-lg text-white shadow-lg transform transition-all duration-200 hover:bg-blue-600 hover:scale-105"
  43. onclick="copyToClipboard()"
  44. >
  45. 复制
  46. </button>
  47. <button
  48. id="store-btn"
  49. class="btn btn-success w-28 py-2 rounded-lg text-white shadow-lg transform transition-all duration-200 hover:bg-green-600 hover:scale-105"
  50. onclick="storeCookie()"
  51. >
  52. 入库
  53. </button>
  54. </div>
  55. </div>
  56. <!-- Toast notification -->
  57. <div class="toast toast-top toast-end">
  58. <div class="toast-content" id="toast" style="display: none;">
  59. <span id="toast-content"></span>
  60. </div>
  61. </div>
  62. <script>
  63. // Copy text to clipboard
  64. function copyToClipboard() {
  65. const textArea = document.getElementById("cookie-res");
  66. textArea.select();
  67. document.execCommand("copy");
  68. // Show success message
  69. const toast = document.getElementById("toast");
  70. const toastContent = document.getElementById("toast-content");
  71. toastContent.textContent = "内容已复制到剪切板";
  72. toast.style.display = "block";
  73. // Hide toast after 2 seconds
  74. setTimeout(() => {
  75. toast.style.display = "none";
  76. }, 2000);
  77. }
  78. // Store cookie (just an alert for now)
  79. function storeCookie() {
  80. // 获取当前激活的 li
  81. const activeLi = document.querySelector("ul.menu a.active");
  82. if (activeLi) {
  83. const textValue = document.getElementById("cookie-res").value || '';
  84. const active_name = activeLi.textContent.trim();
  85. const active_key = activeLi.getAttribute('data-platform').trim();
  86. const save_key = active_key === 'ali' ? active_key + '_token' : active_key + '_cookie';
  87. console.log(`准备入库cookie:${active_name} ${save_key},值为:${textValue}`);
  88. const cookie_auth_code = prompt('cookie入库功能需要管理员授权码,请你正确输入后继续');
  89. if (cookie_auth_code) {
  90. // 使用 axios 发送 POST 请求
  91. axios.post('/admin/cookie-set', {
  92. cookie_auth_code: cookie_auth_code,
  93. key: save_key,
  94. value: textValue.trim().replaceAll('\n', '')
  95. })
  96. .then(response => {
  97. if (response.data.success) {
  98. alert(`Cookie 入库成功:${active_name} (${save_key})`);
  99. } else {
  100. alert(`入库失败:${response.data.message}`);
  101. }
  102. })
  103. .catch(error => {
  104. console.error('请求失败:', error);
  105. alert(`入库失败,服务器出现问题,请稍后再试。\n${error.response.data.message}`);
  106. });
  107. }
  108. } else {
  109. alert('至少选中一个cookie入库项目');
  110. }
  111. }
  112. // Initialize the page
  113. initializePage();
  114. </script>
  115. </body>
  116. </html>