feat(config):
style(ui): 全面重构用户界面样式

- 引入新的配色方案和设计系统变量
- 更新字体家族,使用 Fira Sans 和 Noto Sans SC
- 重新设计页面布局和组件样式
- 添加响应式设计优化
- 改进按钮、表格、表单等UI元素的视觉效果

feat(tasks): 添加任务级别浏览器配置选项

- 在任务配置中增加独立的浏览器开启/关闭选项
- 支持任务继承全局浏览器设置
- 在任务列表中显示浏览器配置状态
- 实现任务级别的 useBrowser 字段管理
```
This commit is contained in:
2026-03-10 17:58:09 +08:00
parent 4f504447a1
commit b9270428db
6 changed files with 699 additions and 134 deletions

View File

@@ -1063,7 +1063,7 @@ async function generateCombinedReport() {
function displayCombinedReport(winningReport, bidReport, container) {
const html = `
<!-- 中标公示部分 -->
<div class="summary" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
<div class="summary" style="background: linear-gradient(135deg, #0f6ecd 0%, #0ea5a4 100%);">
<h2>中标公示报告</h2>
<div class="stat">
<div class="stat-label">总项目数</div>

View File

@@ -6,136 +6,365 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>公告抓取与分析工具</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&family=Fira+Code:wght@500;600&family=Noto+Sans+SC:wght@400;500;700&display=swap');
:root {
--primary: #0f6ecd;
--primary-hover: #0c5caf;
--secondary: #0ea5a4;
--accent: #f59e0b;
--success: #0f9d58;
--danger: #d94848;
--text: #10233a;
--muted: #4f647d;
--line: rgba(15, 35, 58, 0.14);
--surface: rgba(255, 255, 255, 0.64);
--surface-strong: rgba(255, 255, 255, 0.82);
--shadow: 0 24px 50px rgba(15, 42, 74, 0.18);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: 'Fira Sans', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
color: var(--text);
min-height: 100vh;
padding: 20px;
background:
radial-gradient(1200px 600px at -10% -10%, rgba(15, 110, 205, 0.20), transparent 60%),
radial-gradient(900px 500px at 110% -20%, rgba(14, 165, 164, 0.20), transparent 55%),
linear-gradient(145deg, #edf6ff 0%, #e8fbf6 48%, #f7fbff 100%);
}
.container {
max-width: 1100px;
max-width: 1140px;
margin: 0 auto;
background: white;
border-radius: 16px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
border-radius: 20px;
overflow: hidden;
border: 1px solid var(--line);
background: var(--surface);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
box-shadow: var(--shadow);
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 24px 30px;
padding: 26px 30px;
text-align: center;
color: #f6fbff;
background: linear-gradient(120deg, #0f6ecd 0%, #0e9ab2 68%, #10b981 100%);
border-bottom: 1px solid rgba(255, 255, 255, 0.28);
}
.header h1 { font-size: 24px; margin-bottom: 6px; }
.header p { opacity: 0.85; font-size: 13px; }
/* Tabs */
.tabs { display: flex; background: #f5f5f5; border-bottom: 2px solid #e0e0e0; }
.tab {
flex: 1; padding: 14px; text-align: center; cursor: pointer;
background: #f5f5f5; border: none; font-size: 15px; transition: all 0.2s;
.header h1 {
font-family: 'Fira Code', 'Noto Sans SC', sans-serif;
letter-spacing: 0.2px;
font-size: 24px;
margin-bottom: 6px;
}
.header p { opacity: 0.92; font-size: 13px; }
.tabs {
display: flex;
gap: 6px;
padding: 8px;
background: rgba(255, 255, 255, 0.36);
border-bottom: 1px solid var(--line);
}
.tab {
flex: 1;
padding: 12px;
text-align: center;
cursor: pointer;
border: 1px solid transparent;
background: transparent;
color: var(--muted);
border-radius: 10px;
font-size: 15px;
font-weight: 600;
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.tab:hover {
color: var(--text);
background: rgba(255, 255, 255, 0.56);
border-color: var(--line);
}
.tab.active {
color: var(--primary);
background: var(--surface-strong);
border-color: rgba(15, 110, 205, 0.30);
box-shadow: inset 0 0 0 1px rgba(15, 110, 205, 0.12);
}
.tab:hover { background: #e8e8e8; }
.tab.active { background: white; color: #667eea; font-weight: bold; border-bottom: 3px solid #667eea; }
.content { padding: 24px; }
.tab-content { display: none; }
.tab-content.active { display: block; }
/* Form elements */
label { display: block; font-weight: 600; margin-bottom: 6px; color: #333; font-size: 14px; }
input[type="text"], input[type="number"], input[type="password"], textarea, select {
width: 100%; padding: 10px 12px; border: 1px solid #d0d0d0; border-radius: 8px;
font-size: 14px; transition: border 0.2s;
label {
display: block;
font-weight: 600;
margin-bottom: 6px;
color: var(--text);
font-size: 14px;
}
input[type="text"], input[type="number"], input[type="password"], textarea, select {
width: 100%;
padding: 10px 12px;
border: 1px solid var(--line);
border-radius: 10px;
font-size: 14px;
background: rgba(255, 255, 255, 0.76);
color: var(--text);
transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
input:focus, textarea:focus, select:focus {
outline: none;
border-color: rgba(15, 110, 205, 0.55);
box-shadow: 0 0 0 3px rgba(15, 110, 205, 0.12);
background: #ffffff;
}
textarea {
resize: vertical;
min-height: 80px;
font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #667eea; }
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }
/* Buttons */
.btn {
padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer;
font-size: 14px; font-weight: 600; transition: all 0.2s; display: inline-flex;
align-items: center; gap: 6px;
padding: 10px 18px;
border: 1px solid transparent;
border-radius: 10px;
cursor: pointer;
font-size: 14px;
font-weight: 600;
transition: all 0.2s ease;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
}
.btn-primary { background: #667eea; color: white; }
.btn-primary:hover { background: #5a6fd6; }
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #218838; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }
.btn-primary {
color: #fff;
background: linear-gradient(120deg, var(--primary), #178ac2);
box-shadow: 0 8px 18px rgba(15, 110, 205, 0.25);
}
.btn-primary:hover { background: linear-gradient(120deg, var(--primary-hover), #1279aa); }
.btn-success {
color: #fff;
background: linear-gradient(120deg, #0f9d58, #14b46c);
box-shadow: 0 8px 16px rgba(15, 157, 88, 0.24);
}
.btn-success:hover { filter: brightness(0.96); }
.btn-danger {
color: #fff;
background: linear-gradient(120deg, #d94848, #e26a5f);
box-shadow: 0 8px 16px rgba(217, 72, 72, 0.22);
}
.btn-danger:hover { filter: brightness(0.96); }
.btn-secondary {
color: #1e3856;
background: rgba(255, 255, 255, 0.72);
border-color: var(--line);
}
.btn-secondary:hover { background: #ffffff; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; border-radius: 12px; overflow: hidden; }
/* Table */
table { width: 100%; border-collapse: collapse; }
th { background: #f8f9fa; padding: 12px; text-align: left; font-size: 13px; color: #555; border-bottom: 2px solid #e0e0e0; }
td { padding: 10px 12px; border-bottom: 1px solid #eee; font-size: 13px; vertical-align: top; }
tr:hover { background: #f8f9ff; }
th {
background: rgba(15, 110, 205, 0.12);
padding: 12px;
text-align: left;
font-size: 13px;
color: #19446f;
border-bottom: 1px solid rgba(15, 110, 205, 0.22);
}
.prompt-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td {
padding: 10px 12px;
border-bottom: 1px solid rgba(15, 35, 58, 0.08);
font-size: 13px;
color: #203a58;
vertical-align: top;
background: rgba(255, 255, 255, 0.42);
}
/* Tags */
.tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.tag-on { background: #d4edda; color: #155724; }
.tag-off { background: #f8d7da; color: #721c24; }
tr:hover td { background: rgba(255, 255, 255, 0.74); }
.prompt-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
display: inline-block;
padding: 2px 10px;
border-radius: 999px;
font-size: 12px;
font-weight: 700;
border: 1px solid transparent;
}
.tag-on { background: rgba(15, 157, 88, 0.12); color: #0b7f47; border-color: rgba(15, 157, 88, 0.24); }
.tag-off { background: rgba(217, 72, 72, 0.12); color: #b83b3b; border-color: rgba(217, 72, 72, 0.24); }
/* Modal */
.modal {
display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center;
display: none;
position: fixed;
inset: 0;
background: rgba(9, 20, 36, 0.34);
z-index: 1000;
justify-content: center;
align-items: center;
padding: 20px;
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
.modal.show { display: flex; }
.modal-body {
background: white; border-radius: 12px; padding: 28px; width: 600px; max-width: 90vw;
max-height: 85vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.3);
border-radius: 16px;
padding: 26px;
width: 620px;
max-width: 92vw;
max-height: 86vh;
overflow-y: auto;
background: rgba(255, 255, 255, 0.9);
border: 1px solid var(--line);
box-shadow: var(--shadow);
}
.modal-body h3 { margin-bottom: 20px; color: #333; }
/* Status / alerts */
.modal-body h3 { margin-bottom: 20px; color: var(--text); }
.status-box {
padding: 14px; border-radius: 8px; margin-top: 16px; font-size: 14px;
padding: 14px;
border-radius: 10px;
margin-top: 16px;
font-size: 14px;
border: 1px solid transparent;
}
.status-info { background: #e8f0fe; color: #1a56db; }
.status-success { background: #d4edda; color: #155724; }
.status-error { background: #f8d7da; color: #721c24; }
.empty-state { text-align: center; padding: 40px; color: #999; }
.status-info {
background: rgba(15, 110, 205, 0.10);
color: #0f5eab;
border-color: rgba(15, 110, 205, 0.24);
}
.status-success {
background: rgba(15, 157, 88, 0.10);
color: #0f7f4b;
border-color: rgba(15, 157, 88, 0.24);
}
.status-error {
background: rgba(217, 72, 72, 0.10);
color: #b43d3d;
border-color: rgba(217, 72, 72, 0.24);
}
.empty-state { text-align: center; padding: 42px; color: var(--muted); }
/* Result items */
.result-card {
border: 1px solid #e8e8e8; border-radius: 10px; padding: 16px; margin-bottom: 12px;
transition: box-shadow 0.2s;
border: 1px solid var(--line);
border-radius: 14px;
padding: 16px;
margin-bottom: 12px;
background: rgba(255, 255, 255, 0.6);
transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.result-card:hover {
border-color: rgba(15, 110, 205, 0.30);
box-shadow: 0 10px 26px rgba(15, 42, 74, 0.14);
}
.result-card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
gap: 12px;
}
.result-card-header h4 { font-size: 15px; color: #17395b; }
.result-card-header span { font-size: 12px; color: var(--muted); }
.result-item {
display: flex;
align-items: center;
padding: 8px 0;
border-bottom: 1px solid rgba(15, 35, 58, 0.08);
gap: 12px;
}
.result-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.result-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.result-card-header h4 { font-size: 15px; color: #333; }
.result-card-header span { font-size: 12px; color: #888; }
.result-item { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0; gap: 12px; }
.result-item:last-child { border-bottom: none; }
.result-item .type { min-width: 80px; font-weight: 600; color: #667eea; font-size: 13px; }
.result-item .name { flex: 1; font-size: 13px; }
.result-item .amount { min-width: 100px; text-align: right; font-weight: 600; color: #e74c3c; font-size: 13px; }
.result-item .date { min-width: 90px; text-align: center; color: #888; font-size: 12px; }
.result-item a { color: #667eea; text-decoration: none; font-size: 12px; }
.result-item .type { min-width: 80px; font-weight: 700; color: var(--primary); font-size: 13px; }
.result-item .name { flex: 1; font-size: 13px; color: #1f3957; }
.result-item .amount { min-width: 100px; text-align: right; font-weight: 700; color: #ad5b1a; font-size: 13px; }
.result-item .date { min-width: 90px; text-align: center; color: var(--muted); font-size: 12px; }
.result-item a { color: var(--primary); text-decoration: none; font-size: 12px; }
.result-item a:hover { text-decoration: underline; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
flex-wrap: wrap;
gap: 10px;
}
/* Agent config */
.config-section { background: #f9f9f9; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.config-section h3 { margin-bottom: 14px; font-size: 16px; color: #444; }
.config-section {
background: rgba(255, 255, 255, 0.58);
border: 1px solid var(--line);
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.config-section h3 {
margin-bottom: 14px;
font-size: 16px;
color: #19446f;
}
@media (max-width: 900px) {
body { padding: 12px; }
.content { padding: 14px; }
.form-row { flex-direction: column; gap: 10px; }
.header { padding: 20px 16px; }
.header h1 { font-size: 20px; }
.tabs { padding: 6px; }
.tab { font-size: 14px; padding: 10px 6px; }
.btn { padding: 9px 14px; }
}
@media (prefers-reduced-motion: reduce) {
* {
transition: none !important;
animation: none !important;
}
}
</style>
</head>
@@ -169,11 +398,12 @@
<th>城市</th>
<th>提示词</th>
<th>状态</th>
<th>浏览器</th>
<th>操作</th>
</tr>
</thead>
<tbody id="tasksTbody">
<tr><td colspan="4" class="empty-state">加载中...</td></tr>
<tr><td colspan="5" class="empty-state">加载中...</td></tr>
</tbody>
</table>
@@ -304,6 +534,11 @@
<input type="checkbox" id="taskEnabled" checked> 启用
</label>
</div>
<div class="form-group">
<label>
<input type="checkbox" id="taskUseBrowser"> 打开浏览器
</label>
</div>
<div style="display:flex;gap:10px;justify-content:flex-end;">
<button type="button" class="btn btn-secondary" onclick="closeTaskModal()">取消</button>
<button type="submit" class="btn btn-primary">保存</button>
@@ -346,7 +581,7 @@
document.getElementById('taskSummary').textContent = `${tasksList.length} 个任务,${enabled} 个启用`;
if (tasksList.length === 0) {
tbody.innerHTML = '<tr><td colspan="4" class="empty-state">暂无任务,点击「新增任务」添加</td></tr>';
tbody.innerHTML = '<tr><td colspan="5" class="empty-state">暂无任务,点击「新增任务」添加</td></tr>';
return;
}
@@ -355,6 +590,7 @@
<td><strong>${t.city || '-'}</strong></td>
<td class="prompt-cell" title="${(t.prompt || '').replace(/"/g, '&quot;')}">${t.prompt || '-'}</td>
<td><span class="tag ${t.enabled ? 'tag-on' : 'tag-off'}">${t.enabled ? '启用' : '禁用'}</span></td>
<td><span class="tag ${t.useBrowser === true ? 'tag-on' : (t.useBrowser === false ? 'tag-off' : '')}">${t.useBrowser === true ? '打开' : (t.useBrowser === false ? '关闭' : '继承全局')}</span></td>
<td>
<button class="btn btn-primary btn-sm" onclick="openTaskModal('${t.id}')">编辑</button>
<button class="btn btn-success btn-sm" onclick="runSingleTask('${t.id}', this)">运行</button>
@@ -367,11 +603,15 @@
function openTaskModal(id) {
const item = id ? tasksList.find(t => t.id === id) : null;
const globalUseBrowser = document.getElementById('cfgUseBrowser').value === 'true';
document.getElementById('taskModalTitle').textContent = item ? '编辑任务' : '新增任务';
document.getElementById('taskEditId').value = item ? item.id : '';
document.getElementById('taskCity').value = item ? item.city : '';
document.getElementById('taskPrompt').value = item ? item.prompt : '';
document.getElementById('taskEnabled').checked = item ? item.enabled : true;
document.getElementById('taskUseBrowser').checked = item
? (typeof item.useBrowser === 'boolean' ? item.useBrowser : globalUseBrowser)
: globalUseBrowser;
document.getElementById('taskModal').classList.add('show');
}
@@ -386,6 +626,7 @@
city: document.getElementById('taskCity').value.trim(),
prompt: document.getElementById('taskPrompt').value.trim(),
enabled: document.getElementById('taskEnabled').checked,
useBrowser: document.getElementById('taskUseBrowser').checked,
};
try {
const url = id ? `/api/tasks/${id}` : '/api/tasks';
@@ -736,6 +977,7 @@
// ===== 初始化 =====
loadTasks();
loadSettings();
</script>
</body>

View File

@@ -6,6 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>抓取结果查看 - 公告采集工具</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&family=Fira+Code:wght@500;600&family=Noto+Sans+SC:wght@400;500;700&display=swap');
* {
margin: 0;
padding: 0;
@@ -44,7 +46,7 @@
.topbar-logo {
width: 36px;
height: 36px;
background: linear-gradient(135deg, #667eea, #764ba2);
background: linear-gradient(135deg, #0f6ecd, #0ea5a4);
border-radius: 8px;
display: flex;
align-items: center;
@@ -79,8 +81,8 @@
}
.topbar-link.active {
background: rgba(102, 126, 234, 0.25);
color: #8fa8f8;
background: rgba(15, 110, 205, 0.25);
color: #5ea2e8;
}
/* ===== 主体内容 ===== */
@@ -128,7 +130,7 @@
.stat-card:hover {
background: rgba(255, 255, 255, 0.08);
border-color: rgba(102, 126, 234, 0.4);
border-color: rgba(15, 110, 205, 0.4);
}
.stat-card .label {
@@ -192,8 +194,8 @@
.filter-select:focus,
.filter-input:focus {
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
border-color: #0f6ecd;
box-shadow: 0 0 0 3px rgba(15, 110, 205, 0.15);
}
.filter-select option {
@@ -224,14 +226,14 @@
}
.btn-primary {
background: linear-gradient(135deg, #667eea, #764ba2);
background: linear-gradient(135deg, #0f6ecd, #0ea5a4);
color: #fff;
}
.btn-primary:hover {
opacity: 0.9;
transform: translateY(-1px);
box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
box-shadow: 0 4px 14px rgba(15, 110, 205, 0.4);
}
.btn-danger {
@@ -286,7 +288,7 @@
top: 0;
bottom: 0;
width: 4px;
background: linear-gradient(180deg, #667eea, #764ba2);
background: linear-gradient(180deg, #0f6ecd, #0ea5a4);
border-radius: 14px 0 0 14px;
}
@@ -296,7 +298,7 @@
.result-card:hover {
background: rgba(255, 255, 255, 0.07);
border-color: rgba(102, 126, 234, 0.3);
border-color: rgba(15, 110, 205, 0.3);
}
.result-card-header {
@@ -323,9 +325,9 @@
}
.tag-city {
background: rgba(102, 126, 234, 0.2);
color: #8fa8f8;
border: 1px solid rgba(102, 126, 234, 0.3);
background: rgba(15, 110, 205, 0.2);
color: #5ea2e8;
border: 1px solid rgba(15, 110, 205, 0.3);
}
.tag-section {
@@ -353,7 +355,7 @@
}
.result-url a {
color: #6fa3ff;
color: #3c88d6;
text-decoration: none;
font-size: 13px;
word-break: break-all;
@@ -437,8 +439,8 @@
}
.data-table th {
background: rgba(102, 126, 234, 0.15);
color: #8fa8f8;
background: rgba(15, 110, 205, 0.15);
color: #5ea2e8;
font-weight: 600;
white-space: nowrap;
}
@@ -452,7 +454,7 @@
}
.data-table td a {
color: #6fa3ff;
color: #3c88d6;
text-decoration: none;
}
@@ -519,15 +521,15 @@
}
.page-btn:hover:not(:disabled) {
background: rgba(102, 126, 234, 0.25);
color: #8fa8f8;
border-color: rgba(102, 126, 234, 0.4);
background: rgba(15, 110, 205, 0.25);
color: #5ea2e8;
border-color: rgba(15, 110, 205, 0.4);
}
.page-btn.active-page {
background: rgba(102, 126, 234, 0.3);
color: #8fa8f8;
border-color: rgba(102, 126, 234, 0.5);
background: rgba(15, 110, 205, 0.3);
color: #5ea2e8;
border-color: rgba(15, 110, 205, 0.5);
font-weight: 700;
}
@@ -580,8 +582,8 @@
display: inline-block;
width: 40px;
height: 40px;
border: 3px solid rgba(102, 126, 234, 0.2);
border-top-color: #667eea;
border: 3px solid rgba(15, 110, 205, 0.2);
border-top-color: #0f6ecd;
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin-bottom: 12px;
@@ -790,26 +792,330 @@
grid-template-columns: repeat(2, 1fr);
}
}
</style>
/* ===== Glass Theme Override (No Purple) ===== */
:root {
--primary: #0f6ecd;
--primary-soft: rgba(15, 110, 205, 0.18);
--secondary: #0ea5a4;
--accent: #f59e0b;
--text: #112941;
--muted: #536b86;
--line: rgba(17, 41, 65, 0.14);
--glass: rgba(255, 255, 255, 0.62);
--glass-strong: rgba(255, 255, 255, 0.82);
--danger: #d94848;
}
body {
font-family: 'Fira Sans', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
color: var(--text);
background:
radial-gradient(900px 500px at -5% -5%, rgba(15, 110, 205, 0.20), transparent 55%),
radial-gradient(900px 520px at 108% -10%, rgba(14, 165, 164, 0.18), transparent 52%),
linear-gradient(145deg, #edf6ff 0%, #e8fbf6 50%, #f6fbff 100%);
}
.topbar {
background: var(--glass);
border-bottom: 1px solid var(--line);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.topbar-logo {
background: linear-gradient(125deg, var(--primary), var(--secondary));
color: #fff;
font-family: 'Fira Code', sans-serif;
font-size: 14px;
font-weight: 700;
letter-spacing: 0.4px;
}
.topbar-title { color: #1a3f65; }
.topbar-link {
color: var(--muted);
border: 1px solid transparent;
}
.topbar-link:hover {
color: var(--text);
background: rgba(255, 255, 255, 0.7);
border-color: var(--line);
}
.topbar-link.active {
color: var(--primary);
background: rgba(15, 110, 205, 0.12);
border-color: rgba(15, 110, 205, 0.24);
}
.page-header h1 { color: #173d62; }
.page-header p { color: var(--muted); }
.stat-card,
.toolbar,
.result-card,
.dialog-box,
.detail-box {
background: var(--glass);
border-color: var(--line);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
box-shadow: 0 16px 36px rgba(15, 42, 74, 0.12);
}
.stat-card:hover,
.result-card:hover {
background: var(--glass-strong);
border-color: rgba(15, 110, 205, 0.26);
}
.stat-card .label,
.stat-card .sub,
.page-info,
.result-time,
.dialog-msg {
color: var(--muted);
}
.stat-card .value,
.detail-header h3,
.dialog-title,
.result-data-body h4,
.detail-body h4 {
color: #183f65;
}
.filter-group label { color: #304d6b; }
.filter-select,
.filter-input {
background: rgba(255, 255, 255, 0.76);
border-color: var(--line);
color: var(--text);
}
.filter-select:focus,
.filter-input:focus {
border-color: rgba(15, 110, 205, 0.5);
box-shadow: 0 0 0 3px rgba(15, 110, 205, 0.12);
}
.filter-select option {
background: #ffffff;
color: #1b3f62;
}
.btn {
border: 1px solid transparent;
transition: all 0.2s ease;
}
.btn-primary {
background: linear-gradient(125deg, var(--primary), #178ac2);
color: #fff;
box-shadow: 0 8px 16px rgba(15, 110, 205, 0.24);
}
.btn-primary:hover {
transform: translateY(-1px);
box-shadow: 0 12px 24px rgba(15, 110, 205, 0.26);
}
.btn-ghost {
color: #284867;
background: rgba(255, 255, 255, 0.76);
border-color: var(--line);
}
.btn-ghost:hover {
color: #163a60;
background: #ffffff;
}
.btn-danger {
color: #b73d3d;
background: rgba(217, 72, 72, 0.10);
border-color: rgba(217, 72, 72, 0.22);
}
.btn-danger:hover {
color: #fff;
background: linear-gradient(125deg, #d94848, #e36d61);
}
.result-card::before {
background: linear-gradient(180deg, var(--primary), var(--secondary));
}
.result-card.has-error::before {
background: linear-gradient(180deg, #d94848, #ed7a62);
}
.tag-city {
background: rgba(15, 110, 205, 0.12);
color: #0f5fae;
border-color: rgba(15, 110, 205, 0.24);
}
.tag-section {
background: rgba(14, 165, 164, 0.12);
color: #0b7a79;
border-color: rgba(14, 165, 164, 0.24);
}
.tag-type {
background: rgba(245, 158, 11, 0.16);
color: #b96f06;
border-color: rgba(245, 158, 11, 0.28);
}
.tag-error {
background: rgba(217, 72, 72, 0.14);
color: #bf3b3b;
border-color: rgba(217, 72, 72, 0.28);
}
.result-url a,
.data-table td a {
color: var(--primary);
}
.result-data {
background: rgba(255, 255, 255, 0.68);
border-color: var(--line);
}
.result-data-toggle {
color: #375677;
}
.result-data-toggle:hover {
color: #1b4168;
}
.result-data-body pre,
.detail-body pre {
color: #225068;
}
.data-table {
color: #1f3f5d;
}
.data-table th,
.data-table td {
border-color: rgba(17, 41, 65, 0.12);
}
.data-table th {
background: rgba(15, 110, 205, 0.12);
color: #185a9f;
}
.data-table tr:nth-child(even) {
background: rgba(255, 255, 255, 0.42);
}
.data-table tr:hover {
background: rgba(255, 255, 255, 0.72);
}
.result-card-footer {
border-top-color: rgba(17, 41, 65, 0.10);
}
.page-btn {
background: rgba(255, 255, 255, 0.72);
border-color: var(--line);
color: #2a4b6c;
}
.page-btn:hover:not(:disabled) {
background: rgba(15, 110, 205, 0.14);
color: var(--primary);
border-color: rgba(15, 110, 205, 0.25);
}
.page-btn.active-page {
background: rgba(15, 110, 205, 0.2);
color: #0f5fae;
border-color: rgba(15, 110, 205, 0.35);
}
.empty-state,
.empty-state h3,
.empty-state p {
color: #4a6481;
}
.spinner {
border-color: rgba(15, 110, 205, 0.18);
border-top-color: var(--primary);
}
.toast {
color: #fff;
box-shadow: 0 8px 24px rgba(17, 41, 65, 0.24);
}
.overlay,
.detail-overlay {
background: rgba(8, 20, 36, 0.34);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
.dialog-title,
.detail-header h3 {
font-family: 'Fira Code', 'Noto Sans SC', sans-serif;
}
.detail-header {
border-bottom-color: rgba(17, 41, 65, 0.10);
}
.close-btn {
background: rgba(255, 255, 255, 0.75);
color: #345777;
border: 1px solid var(--line);
}
.close-btn:hover {
background: #ffffff;
color: #1b4269;
}
@media (prefers-reduced-motion: reduce) {
* {
transition: none !important;
animation: none !important;
}
}
</style>
</head>
<body>
<!-- 顶部导航 -->
<div class="topbar">
<a href="/" class="topbar-brand">
<div class="topbar-logo">📋</div>
<div class="topbar-logo">AG</div>
<span class="topbar-title">公告采集工具</span>
</a>
<div class="topbar-nav">
<a href="/" class="topbar-link">⚙️ 配置管理</a>
<a href="/results.html" class="topbar-link active">📊 抓取结果</a>
<a href="/" class="topbar-link"> 配置管理</a>
<a href="/results.html" class="topbar-link active"> 抓取结果</a>
</div>
</div>
<div class="main">
<!-- 页头 -->
<div class="page-header">
<h1>📊 抓取结果</h1>
<h1> 抓取结果</h1>
<p>所有抓取来源的历史结果,按抓取时间倒序展示</p>
</div>
@@ -859,8 +1165,8 @@
</div>
<div class="toolbar-actions">
<button class="btn btn-ghost" onclick="resetFilters()">↺ 重置</button>
<button class="btn btn-primary" onclick="loadResults()">🔄 刷新</button>
<button class="btn btn-danger" onclick="confirmClearAll()">🗑 清空全部</button>
<button class="btn btn-primary" onclick="loadResults()"> 刷新</button>
<button class="btn btn-danger" onclick="confirmClearAll()"> 清空全部</button>
</div>
</div>
@@ -883,7 +1189,7 @@
<!-- 确认清空弹窗 -->
<div class="overlay" id="confirmOverlay">
<div class="dialog-box">
<div class="dialog-title">⚠️ 确认清空</div>
<div class="dialog-title"> 确认清空</div>
<div class="dialog-msg" id="confirmMsg">确定要清空所有抓取结果吗?此操作不可撤销。</div>
<div class="dialog-actions">
<button class="btn btn-ghost" onclick="closeConfirm()">取消</button>
@@ -993,7 +1299,7 @@
renderResults(json.data || []);
renderPagination(json.total, json.page, json.pageSize);
} catch (e) {
listEl.innerHTML = `<div class="empty-state"><div class="icon">⚠️</div><h3>加载失败</h3><p>${e.message}</p></div>`;
listEl.innerHTML = `<div class="empty-state"><div class="icon"></div><h3>加载失败</h3><p>${e.message}</p></div>`;
} finally {
maskEl.classList.remove('show');
}
@@ -1015,7 +1321,7 @@
if (data.length === 0) {
listEl.innerHTML = `
<div class="empty-state">
<div class="icon">🔍</div>
<div class="icon"></div>
<h3>暂无抓取记录</h3>
<p>运行抓取来源后,结果将自动保存在这里</p>
</div>`;
@@ -1029,13 +1335,13 @@
${r.city ? `<span class="tag tag-city">${r.city}</span>` : ''}
${r.section ? `<span class="tag tag-section">${r.section}${r.subsection ? ' · ' + r.subsection : ''}</span>` : ''}
${r.type ? `<span class="tag tag-type">${r.type}</span>` : ''}
${r.error ? `<span class="tag tag-error"> 失败</span>` : ''}
${r.error ? `<span class="tag tag-error"> 失败</span>` : ''}
</div>
<span class="result-time">${formatTime(r.scrapedAt)}</span>
</div>
<div class="result-url">
<a href="${r.url}" target="_blank" title="${r.url}">🔗 ${r.url}</a>
<a href="${r.url}" target="_blank" title="${r.url}"> ${r.url}</a>
</div>
${r.error ? `<div class="result-error">错误信息:${r.error}</div>` : ''}
@@ -1043,7 +1349,7 @@
${!r.error && r.data ? `
<div class="result-data">
<button class="result-data-toggle" onclick="toggleData(this)">
<span>📄 查看数据</span>
<span> 查看数据</span>
<span>▼</span>
</button>
<div class="result-data-body">
@@ -1052,7 +1358,7 @@
</div>` : ''}
<div class="result-card-footer">
${!r.error && r.data ? `<button class="btn btn-ghost btn-sm" onclick="openDetail('${r.id}')">🔎 全屏查看</button>` : ''}
${!r.error && r.data ? `<button class="btn btn-ghost btn-sm" onclick="openDetail('${r.id}')"> 全屏查看</button>` : ''}
<button class="btn btn-danger btn-sm" onclick="deleteResult('${r.id}')">删除</button>
</div>
</div>
@@ -1245,7 +1551,7 @@
else val = String(val);
if ((val.startsWith('http://') || val.startsWith('https://')) && !val.includes(' ')) {
html += `<td><a href="${escHtml(val)}" target="_blank" title="${escHtml(val)}">🔗 链接</a></td>`;
html += `<td><a href="${escHtml(val)}" target="_blank" title="${escHtml(val)}"> 链接</a></td>`;
} else {
html += `<td>${escHtml(val)}</td>`;
}
@@ -1270,4 +1576,4 @@
</script>
</body>
</html>
</html>

View File

@@ -767,23 +767,29 @@ function generateScraperResultsHtml(results) {
const failResults = results.filter(r => r.error);
const generatedAt = new Date().toLocaleString('zh-CN');
// 把所有成功来源的 items 展开,附带来源信息
// Flatten all successful source items into one table.
const allRows = [];
for (const r of successResults) {
const items = r.data?.result || [];
const items = r.data?.results || r.data?.result || [];
for (const item of items) {
const hasAmount = typeof item.amount_yuan === 'number' || !!item.amount;
const amountText =
typeof item.amount_yuan === 'number'
? `${item.amount_yuan.toLocaleString('zh-CN')} CNY`
: (item.amount || 'N/A');
allRows.push({
section: [r.section, r.subsection].filter(Boolean).join(' · ') || r.city || '-',
type: r.type || '-',
title: item.title || '-',
section: [r.section, r.subsection].filter(Boolean).join(' / ') || r.city || '-',
type: item.type || r.type || '-',
title: item.project_name || item.title || '-',
date: item.date || '-',
amount: item.amount || '未公开',
url: item.url || '',
amount: amountText,
hasAmount,
url: item.target_link || item.url || '',
});
}
}
// 按日期降序排列
allRows.sort((a, b) => {
if (a.date === b.date) return 0;
return a.date > b.date ? -1 : 1;
@@ -802,7 +808,7 @@ function generateScraperResultsHtml(results) {
</td>
<td style="padding:9px 12px;border-bottom:1px solid #eaecf5;font-size:13px;max-width:320px;">${row.title}</td>
<td style="padding:9px 12px;border-bottom:1px solid #eaecf5;white-space:nowrap;font-size:13px;color:#555;">${row.date}</td>
<td style="padding:9px 12px;border-bottom:1px solid #eaecf5;white-space:nowrap;font-size:13px;font-weight:600;color:${row.amount === '未公开' ? '#aaa' : '#e67e22'};">${row.amount}</td>
<td style="padding:9px 12px;border-bottom:1px solid #eaecf5;white-space:nowrap;font-size:13px;font-weight:600;color:${row.hasAmount ? '#e67e22' : '#aaa'};">${row.amount}</td>
<td style="padding:9px 12px;border-bottom:1px solid #eaecf5;text-align:center;">
${row.url
? `<a href="${row.url}" target="_blank" style="color:#667eea;font-size:12px;text-decoration:none;white-space:nowrap;">查看 →</a>`
@@ -851,7 +857,7 @@ function generateScraperResultsHtml(results) {
<div style="font-size:12px;color:#888;margin-top:2px;">成功来源</div>
</div>
<div style="flex:1;padding:16px 24px;text-align:center;border-right:1px solid #eaecf5;">
<div style="font-size:28px;font-weight:700;color:#e67e22;">${allRows.filter(r => r.amount && r.amount !== '未公开').length}</div>
<div style="font-size:28px;font-weight:700;color:#e67e22;">${allRows.filter(r => r.hasAmount).length}</div>
<div style="font-size:12px;color:#888;margin-top:2px;">有金额</div>
</div>
<div style="flex:1;padding:16px 24px;text-align:center;">

View File

@@ -46,10 +46,11 @@ function appendResult(result) {
// ========== 任务执行 ==========
async function runTask(task, agentCfg) {
const useBrowser = typeof task.useBrowser === 'boolean' ? task.useBrowser : agentCfg.useBrowser;
console.log(`[定时任务][Agent] ${task.city}:开始执行`);
const { results } = await runAgentTask(task.prompt, {
baseUrl: agentCfg.baseUrl,
useBrowser: agentCfg.useBrowser,
useBrowser,
pollInterval: agentCfg.pollInterval,
timeout: agentCfg.timeout,
logPrefix: `[定时任务][Agent][${task.city}]`,

View File

@@ -27,6 +27,10 @@ function saveConfig(cfg) {
writeFileSync(CONFIG_PATH, JSON.stringify(cfg, null, 2), 'utf-8');
}
function normalizeUseBrowser(value) {
return value === true || value === 'true';
}
// ========== 抓取结果存取 ==========
function readResults() {
@@ -130,6 +134,7 @@ app.post('/api/tasks', (req, res) => {
city: req.body.city || '',
prompt: req.body.prompt || '',
enabled: req.body.enabled !== false,
useBrowser: normalizeUseBrowser(req.body.useBrowser),
};
cfg.tasks.push(item);
saveConfig(cfg);
@@ -144,7 +149,11 @@ app.put('/api/tasks/:id', (req, res) => {
const cfg = readConfig();
const idx = (cfg.tasks || []).findIndex(t => t.id === req.params.id);
if (idx === -1) return res.status(404).json({ success: false, error: '未找到该配置' });
cfg.tasks[idx] = { ...cfg.tasks[idx], ...req.body, id: req.params.id };
const patch = { ...req.body };
if (Object.prototype.hasOwnProperty.call(patch, 'useBrowser')) {
patch.useBrowser = normalizeUseBrowser(patch.useBrowser);
}
cfg.tasks[idx] = { ...cfg.tasks[idx], ...patch, id: req.params.id };
saveConfig(cfg);
res.json({ success: true, data: cfg.tasks[idx] });
} catch (e) {
@@ -173,11 +182,12 @@ let runningStatus = null; // { taskId, city, startTime, current, total, finished
async function runTask(task) {
const cfg = readConfig();
const agentCfg = cfg.agent || {};
const useBrowser = typeof task.useBrowser === 'boolean' ? task.useBrowser : agentCfg.useBrowser;
console.log(`[Agent] ${task.city}:开始执行`);
const { results } = await runAgentTask(task.prompt, {
baseUrl: agentCfg.baseUrl,
useBrowser: agentCfg.useBrowser,
useBrowser,
pollInterval: agentCfg.pollInterval,
timeout: agentCfg.timeout,
logPrefix: `[Agent][${task.city}]`,