|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <html lang="zh"> |
3 | 3 | <head> |
4 | | - <meta charset="UTF-8" /> |
5 | | - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 4 | + <meta charset="UTF-8"/> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> |
6 | 6 | <title>Cookie管理</title> |
7 | | - <link rel="stylesheet" href="./static/css/style.css" /> |
8 | | - <link rel="stylesheet" href="./static/css/daisyui.min.css" /> |
| 7 | + <link rel="stylesheet" href="./static/css/style.css"/> |
| 8 | + <link rel="stylesheet" href="./static/css/daisyui.min.css"/> |
9 | 9 | <script src="./static/js/tailwindcss.min.js"></script> |
10 | 10 | <script src="./static/js/axios.min.js"></script> |
11 | 11 | <script src="./static/js/qrcode.min.js"></script> |
|
24 | 24 |
|
25 | 25 | <!-- QR Code --> |
26 | 26 | <div class="qrcode-container text-center mb-4"> |
27 | | - <img id="qrcode" src="./static/img/qrcode_expired.jpg" alt="二维码" class="mx-auto" /> |
| 27 | + <img id="qrcode" src="./static/img/qrcode_expired.jpg" alt="二维码" class="mx-auto"/> |
28 | 28 | </div> |
29 | 29 |
|
30 | 30 | <!-- Divider --> |
|
35 | 35 | id="cookie-res" |
36 | 36 | 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" |
37 | 37 | placeholder="扫码确认后将在此处展示cookie" |
38 | | - readonly |
39 | 38 | ></textarea> |
40 | 39 |
|
41 | 40 | <!-- Buttons with improved design --> |
|
85 | 84 |
|
86 | 85 | // Store cookie (just an alert for now) |
87 | 86 | function storeCookie() { |
88 | | - alert("入库功能暂未实现!"); |
| 87 | + // 获取当前激活的 li |
| 88 | + const activeLi = document.querySelector("ul.menu a.active"); |
| 89 | + if (activeLi) { |
| 90 | + const textValue = document.getElementById("cookie-res").value || ''; |
| 91 | + const active_name = activeLi.textContent.trim(); |
| 92 | + const active_key = activeLi.getAttribute('data-platform').trim() + '_cookie'; |
| 93 | + console.log(`准备入库cookie:${active_name} ${active_key},值为:${textValue}`); |
| 94 | + |
| 95 | + const cookie_auth_code = prompt('cookie入库功能需要管理员授权码,请你正确输入后继续'); |
| 96 | + if (cookie_auth_code) { |
| 97 | + // 使用 axios 发送 POST 请求 |
| 98 | + axios.post('/admin/cookie-set', { |
| 99 | + cookie_auth_code: cookie_auth_code, |
| 100 | + key: active_key, |
| 101 | + value: textValue |
| 102 | + }) |
| 103 | + .then(response => { |
| 104 | + if (response.data.success) { |
| 105 | + alert(`Cookie 入库成功:${active_name} (${active_key})`); |
| 106 | + } else { |
| 107 | + alert(`入库失败:${response.data.message}`); |
| 108 | + } |
| 109 | + }) |
| 110 | + .catch(error => { |
| 111 | + console.error('请求失败:', error); |
| 112 | + alert(`入库失败,服务器出现问题,请稍后再试。\n${error.response.data.message}`); |
| 113 | + }); |
| 114 | + } |
| 115 | + } else { |
| 116 | + alert('至少选中一个cookie入库项目'); |
| 117 | + } |
89 | 118 | } |
90 | 119 |
|
| 120 | + |
91 | 121 | // Initialize the page |
92 | 122 | initializePage(); |
93 | 123 | </script> |
|
0 commit comments