完善请求头

This commit is contained in:
杨志
2026-01-20 15:18:09 +08:00
parent 7aa5ce365a
commit 929547657c
3 changed files with 44 additions and 39 deletions

View File

@@ -246,19 +246,13 @@
<div class="form-group">
<label for="cookie-jsessionid">JSESSIONID</label>
<input type="text" id="cookie-jsessionid" placeholder="示例9E592C9CC752F8552F0D746D91958475">
<small>推荐直接填写避免粘贴JSON出错</small>
<small>从浏览器开发者工具中复制JSESSIONID的值</small>
</div>
<div class="form-group">
<label for="cookie-serverid">SERVERID</label>
<input type="text" id="cookie-serverid" placeholder="示例546762930bd4e5dda968e40edd43fb6a|1768878822|1768878621">
<small>推荐直接填写避免粘贴JSON出错</small>
</div>
<div class="form-group">
<label for="cookies">Cookie数据JSON格式</label>
<textarea id="cookies" placeholder='{"请求 Cookie": {"JSESSIONID": "xxx", "SERVERID": "xxx"}}'></textarea>
<small>可选若上面已填写两个字段此处可留空否则请按JSON格式填写完整Cookie</small>
<small>从浏览器开发者工具中复制SERVERID的值</small>
</div>
<div class="form-group">
@@ -447,42 +441,22 @@
});
}
// 组装Cookie数据支持单独填写和JSON
// 组装Cookie数据
function buildCookiesPayload(messageContainerId) {
const raw = document.getElementById('cookies').value.trim();
const jsessionid = document.getElementById('cookie-jsessionid').value.trim();
const serverid = document.getElementById('cookie-serverid').value.trim();
let cookies = { "请求 Cookie": {} };
if (raw) {
try {
const parsed = JSON.parse(raw);
cookies = parsed;
} catch (e) {
showMessage(messageContainerId, 'Cookie数据格式错误请检查JSON格式', 'error');
return null;
}
}
// 确保存在“请求 Cookie”层级
if (!cookies['请求 Cookie'] || typeof cookies['请求 Cookie'] !== 'object') {
cookies['请求 Cookie'] = {};
}
if (jsessionid) {
cookies['请求 Cookie']['JSESSIONID'] = jsessionid;
}
if (serverid) {
cookies['请求 Cookie']['SERVERID'] = serverid;
}
if (Object.keys(cookies['请求 Cookie']).length === 0) {
showMessage(messageContainerId, '请填写Cookie数据', 'error');
if (!jsessionid || !serverid) {
showMessage(messageContainerId, '请填写JSESSIONID和SERVERID', 'error');
return null;
}
return cookies;
return {
"请求 Cookie": {
"JSESSIONID": jsessionid,
"SERVERID": serverid
}
};
}
// 全选/取消全选