up
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>账号管理 - 职位信息爬虫工具</title>
|
||||
<title>系统管理 - 职位信息爬虫工具</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1000px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
@@ -162,13 +162,25 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>账号管理</h1>
|
||||
<h1>系统管理</h1>
|
||||
<div class="nav-links">
|
||||
<a href="/crawler">爬虫工具</a>
|
||||
<a href="/auth/logout">退出登录</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BASE_URL配置 -->
|
||||
<div class="form-section">
|
||||
<h2>BASE_URL配置</h2>
|
||||
<div id="baseurl-message"></div>
|
||||
<div class="form-group">
|
||||
<label for="base-url">BASE_URL(域名和端口):</label>
|
||||
<input type="text" id="base-url" placeholder="例如:http://gzrsks.oumakspt.com:62">
|
||||
<small style="color: #666; margin-top: 5px; display: block;">这是爬虫目标网站的基础URL(不含路径)</small>
|
||||
</div>
|
||||
<button class="btn" onclick="saveBaseUrl()">保存配置</button>
|
||||
</div>
|
||||
|
||||
<!-- 添加账号 -->
|
||||
<div class="form-section">
|
||||
<h2>添加账号</h2>
|
||||
@@ -208,14 +220,65 @@
|
||||
<script>
|
||||
const API_BASE_URL = '';
|
||||
|
||||
// 页面加载时获取账号列表
|
||||
// 页面加载时获取配置和账号列表
|
||||
window.onload = function() {
|
||||
loadBaseUrl();
|
||||
loadUsers();
|
||||
};
|
||||
|
||||
// 加载BASE_URL配置
|
||||
function loadBaseUrl() {
|
||||
fetch(API_BASE_URL + '/admin/getBaseUrl', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
document.getElementById('base-url').value = data.data.base_url || '';
|
||||
} else {
|
||||
showMessage('baseurl-message', data.msg || '获取失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage('baseurl-message', '请求失败: ' + error.message, 'error');
|
||||
});
|
||||
}
|
||||
|
||||
// 保存BASE_URL配置
|
||||
function saveBaseUrl() {
|
||||
const baseUrl = document.getElementById('base-url').value.trim();
|
||||
|
||||
if (!baseUrl) {
|
||||
showMessage('baseurl-message', 'BASE_URL不能为空', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(API_BASE_URL + '/admin/setBaseUrl', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `base_url=${encodeURIComponent(baseUrl)}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
showMessage('baseurl-message', data.msg || '保存成功', 'success');
|
||||
} else {
|
||||
showMessage('baseurl-message', data.msg || '保存失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage('baseurl-message', '请求失败: ' + error.message, 'error');
|
||||
});
|
||||
}
|
||||
|
||||
// 加载账号列表
|
||||
function loadUsers() {
|
||||
fetch(API_BASE_URL + '/user/getUsers', {
|
||||
fetch(API_BASE_URL + '/admin/getUsers', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -278,7 +341,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(API_BASE_URL + '/user/add', {
|
||||
fetch(API_BASE_URL + '/admin/addUser', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
@@ -307,7 +370,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(API_BASE_URL + '/user/delete', {
|
||||
fetch(API_BASE_URL + '/admin/deleteUser', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
@@ -157,7 +157,12 @@
|
||||
if (data.code === 1) {
|
||||
showMessage('登录成功,正在跳转...', 'success');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/crawler';
|
||||
// 根据账号类型跳转到不同页面
|
||||
if (data.data && data.data.is_admin) {
|
||||
window.location.href = '/admin';
|
||||
} else {
|
||||
window.location.href = '/crawler';
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
showMessage(data.msg || '登录失败', 'error');
|
||||
|
||||
@@ -240,7 +240,6 @@
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
||||
<h1 style="margin: 0;">职位信息爬虫工具</h1>
|
||||
<div style="display: flex; gap: 15px;">
|
||||
<a href="/user" style="color: #2196F3; text-decoration: none; padding: 8px 15px; border-radius: 4px; background: #e3f2fd;">账号管理</a>
|
||||
<a href="/auth/logout" style="color: #f44336; text-decoration: none; padding: 8px 15px; border-radius: 4px; background: #ffebee;">退出登录</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user