UP
This commit is contained in:
@@ -280,8 +280,10 @@
|
||||
</div>
|
||||
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-secondary" onclick="getDsdmOptions()">获取地区选项</button>
|
||||
<button class="btn btn-secondary" onclick="saveUserConfig()">保存配置</button>
|
||||
<button class="btn" onclick="getDsdmOptions()">获取地区选项</button>
|
||||
</div>
|
||||
<div id="config-message"></div>
|
||||
</div>
|
||||
|
||||
<!-- 第二步:选择地区并自动抓取 -->
|
||||
@@ -335,6 +337,69 @@
|
||||
let lastAa = '';
|
||||
let lastResults = [];
|
||||
let isCrawling = false; // 爬取状态标志
|
||||
|
||||
// 页面加载时自动加载用户配置
|
||||
window.onload = function() {
|
||||
loadUserConfig();
|
||||
};
|
||||
|
||||
// 加载用户配置
|
||||
function loadUserConfig() {
|
||||
fetch(API_BASE_URL + '/crawler/getUserConfig', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1 && data.data) {
|
||||
// 填充表单
|
||||
document.getElementById('cookie-jsessionid2').value = data.data.jsessionid1 || '';
|
||||
document.getElementById('cookie-jsessionid').value = data.data.jsessionid2 || '';
|
||||
document.getElementById('cookie-serverid').value = data.data.serverid || '';
|
||||
document.getElementById('examid').value = data.data.examid || '';
|
||||
document.getElementById('bmid').value = data.data.bmid || '';
|
||||
document.getElementById('userid').value = data.data.userid || '';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('加载配置失败:', error);
|
||||
});
|
||||
}
|
||||
|
||||
// 保存用户配置
|
||||
function saveUserConfig() {
|
||||
const config = {
|
||||
jsessionid1: document.getElementById('cookie-jsessionid2').value.trim(),
|
||||
jsessionid2: document.getElementById('cookie-jsessionid').value.trim(),
|
||||
serverid: document.getElementById('cookie-serverid').value.trim(),
|
||||
examid: document.getElementById('examid').value.trim(),
|
||||
bmid: document.getElementById('bmid').value.trim(),
|
||||
userid: document.getElementById('userid').value.trim(),
|
||||
};
|
||||
|
||||
fetch(API_BASE_URL + '/crawler/saveUserConfig', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
body: `jsessionid1=${encodeURIComponent(config.jsessionid1)}&jsessionid2=${encodeURIComponent(config.jsessionid2)}&serverid=${encodeURIComponent(config.serverid)}&examid=${encodeURIComponent(config.examid)}&bmid=${encodeURIComponent(config.bmid)}&userid=${encodeURIComponent(config.userid)}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
showMessage('config-message', data.msg || '保存成功', 'success');
|
||||
} else {
|
||||
showMessage('config-message', data.msg || '保存失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage('config-message', '请求失败: ' + error.message, 'error');
|
||||
});
|
||||
}
|
||||
|
||||
// 获取地区选项
|
||||
function getDsdmOptions() {
|
||||
|
||||
Reference in New Issue
Block a user