index.html 4.9 KB

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