This commit is contained in:
2026-08-26 11:49:01 +08:00
parent dd80d265ac
commit 1659a0b79d
8 changed files with 300 additions and 28 deletions
+145 -27
View File
@@ -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; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", sans-serif; background: #f0f4f8; color: #333; }
@@ -18,14 +18,22 @@
.login-box button:hover { background: #40a9ff; }
.login-err { color: #e64340; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
/* 主页面 */
/* 顶栏 */
header { background: #fff; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
header h1 { font-size: 18px; color: #1890ff; }
header .ops { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #666; }
header button { padding: 6px 14px; border: 1px solid #d9d9d9; background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }
header button:hover { border-color: #1890ff; color: #1890ff; }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
/* 左菜单 + 右内容布局 */
.layout { display: flex; max-width: 1200px; margin: 24px auto; padding: 0 16px; gap: 16px; align-items: flex-start; }
aside { width: 170px; flex-shrink: 0; background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.05); overflow: hidden; }
aside .menu-item { display: block; padding: 14px 20px; font-size: 14px; color: #555; cursor: pointer; border-left: 3px solid transparent; }
aside .menu-item:hover { background: #f7fbff; }
aside .menu-item.active { background: #e8f4ff; color: #1890ff; border-left-color: #1890ff; font-weight: 600; }
.content { flex: 1; min-width: 0; }
/* 今日数据 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 10px; padding: 18px 22px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.stat-card .num { font-size: 30px; font-weight: 700; }
@@ -40,8 +48,21 @@
.badge.chat, .badge.deliver { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.badge.skipped { background: #fff7e6; color: #faad14; border: 1px solid #ffd591; }
.score-high { color: #52c41a; font-weight: 700; } .score-mid { color: #faad14; font-weight: 700; } .score-low { color: #e64340; font-weight: 700; }
.remark { color: #999; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remark { color: #999; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 40px; color: #999; }
/* 快捷拉黑按钮 */
.bl-btn { border: 1px solid #ffd6d6; background: #fff; color: #e64340; border-radius: 4px; font-size: 12px; padding: 1px 8px; cursor: pointer; margin-left: 6px; }
.bl-btn:hover { background: #fff1f0; }
/* 黑名单页 */
.bl-add { display: flex; gap: 10px; background: #fff; border-radius: 10px; padding: 16px 18px; box-shadow: 0 2px 8px rgba(0,0,0,.05); margin-bottom: 16px; }
.bl-add input { flex: 1; padding: 9px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; }
.bl-add button { padding: 9px 22px; background: #e64340; color: #fff; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; }
.bl-add button:hover { background: #f06e6b; }
.bl-tip { font-size: 12px; color: #999; margin: 0 4px 12px; }
.bl-remove { border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; font-size: 12px; padding: 2px 10px; cursor: pointer; }
.bl-remove:hover { border-color: #e64340; color: #e64340; }
</style>
</head>
<body>
@@ -49,7 +70,7 @@
<!-- 登录 -->
<div class="login-wrap" id="loginView">
<div class="login-box">
<h1>今日投递数据 · 登录</h1>
<h1>投递数据中心 · 登录</h1>
<div class="login-err" id="loginErr"></div>
<input type="text" id="username" placeholder="用户名" autocomplete="username">
<input type="password" id="password" placeholder="密码" autocomplete="current-password">
@@ -60,33 +81,60 @@
<!-- 数据 -->
<div id="dataView" class="hidden">
<header>
<h1>今日投递数据</h1>
<h1>投递数据中心</h1>
<div class="ops">
<span id="who"></span>
<span id="updatedAt"></span>
<button id="btnRefresh">刷新</button>
<button id="btnLogout">退出</button>
</div>
</header>
<main>
<div class="stats">
<div class="stat-card"><div class="num green" id="stApplied">0</div><div class="label">今日已投递</div></div>
<div class="stat-card"><div class="num orange" id="stSkipped">0</div><div class="label">今日已跳过</div></div>
<div class="stat-card"><div class="num blue" id="stTotal">0</div><div class="label">今日处理总数</div></div>
<div class="layout">
<!-- 左侧菜单 -->
<aside>
<div class="menu-item active" data-page="today">今日投递数据</div>
<div class="menu-item" data-page="blacklist">公司黑名单</div>
</aside>
<!-- 右侧内容 -->
<div class="content">
<!-- 今日投递数据 -->
<div id="pageToday">
<div class="stats">
<div class="stat-card"><div class="num green" id="stApplied">0</div><div class="label">今日已投递</div></div>
<div class="stat-card"><div class="num orange" id="stSkipped">0</div><div class="label">今日已跳过</div></div>
<div class="stat-card"><div class="num blue" id="stTotal">0</div><div class="label">今日处理总数</div></div>
</div>
<table>
<thead><tr>
<th>时间</th><th>职位</th><th>公司</th><th>薪资</th><th>结果</th><th>AI评分</th><th>备注</th>
</tr></thead>
<tbody id="tbody"></tbody>
</table>
<div class="empty hidden" id="empty">今天还没有投递记录</div>
</div>
<!-- 公司黑名单 -->
<div id="pageBlacklist" class="hidden">
<div class="bl-add">
<input type="text" id="blCompany" placeholder="输入公司名,如:某某科技有限公司" maxlength="128">
<button id="btnBlAdd">拉黑</button>
</div>
<div class="bl-tip">拉黑后,投递任务将自动跳过该公司的所有职位;在「今日投递数据」的公司列也可快捷拉黑。</div>
<table>
<thead><tr><th style="width:60px">#</th><th>公司名</th><th style="width:170px">拉黑时间</th><th style="width:90px">操作</th></tr></thead>
<tbody id="blTbody"></tbody>
</table>
<div class="empty hidden" id="blEmpty">黑名单为空</div>
</div>
</div>
<table>
<thead><tr>
<th>时间</th><th>职位</th><th>公司</th><th>薪资</th><th>结果</th><th>AI评分</th><th>备注</th>
</tr></thead>
<tbody id="tbody"></tbody>
</table>
<div class="empty hidden" id="empty">今天还没有投递记录</div>
</main>
</div>
</div>
<script>
const TOKEN_KEY = 'view_token';
const token = () => localStorage.getItem(TOKEN_KEY);
let blSet = new Set(); // 当前黑名单公司名集合,用于今日表格快捷拉黑按钮状态
async function api(path, opts = {}) {
const resp = await fetch(path, {
@@ -135,6 +183,7 @@ function esc(s) {
return div.innerHTML;
}
/* ---------- 今日投递数据 ---------- */
async function load() {
try {
const [me, d] = await Promise.all([api('/api/auth/me'), api('/api/jobs/today')]);
@@ -153,7 +202,11 @@ async function load() {
const score = r.ai_score == null || r.ai_score < 0 ? '-'
: '<span class="' + (r.ai_score >= 80 ? 'score-high' : r.ai_score >= 60 ? 'score-mid' : 'score-low') + '">' + r.ai_score + '</span>';
const remark = r.apply_type === 'skipped' ? (r.skip_reason || '') : (r.ai_reason || '');
return '<tr><td>' + esc(r.applied_at) + '</td><td>' + esc(r.job_title) + '</td><td>' + esc(r.company) +
// 公司列:未拉黑时显示快捷拉黑按钮
const company = r.company || '';
const blBtn = (company && !blSet.has(company))
? '<button class="bl-btn" data-company="' + esc(company) + '">拉黑</button>' : '';
return '<tr><td>' + esc(r.applied_at) + '</td><td>' + esc(r.job_title) + '</td><td>' + esc(company) + blBtn +
'</td><td>' + esc(r.salary) + '</td><td>' + type + '</td><td>' + score +
'</td><td class="remark" title="' + esc(remark) + '">' + esc(remark) + '</td></tr>';
}).join('');
@@ -161,18 +214,83 @@ async function load() {
} catch (e) { /* 401 已在 api 内处理 */ }
}
/* ---------- 公司黑名单 ---------- */
async function loadBlacklist() {
try {
const items = await api('/api/blacklist');
blSet = new Set(items.map(i => i.company));
const tbody = document.getElementById('blTbody');
tbody.innerHTML = items.map((i, idx) =>
'<tr><td>' + (idx + 1) + '</td><td>' + esc(i.company) + '</td><td>' + esc(i.created_at) +
'</td><td><button class="bl-remove" data-id="' + i.id + '">移除</button></td></tr>'
).join('');
document.getElementById('blEmpty').classList.toggle('hidden', items.length > 0);
} catch (e) { /* 401 已在 api 内处理 */ }
}
async function addBlacklist(company) {
company = (company || '').trim();
if (!company) return;
try {
await api('/api/blacklist', { method: 'POST', body: JSON.stringify({ company }) });
await loadBlacklist();
await load(); // 刷新快捷拉黑按钮状态
alert('已拉黑:' + company + ',后续不再投递该公司');
} catch (e) { alert('拉黑失败:' + (e.message || '')); }
}
async function removeBlacklist(id) {
try {
await api('/api/blacklist/' + id, { method: 'DELETE' });
await loadBlacklist();
} catch (e) { alert('移除失败:' + (e.message || '')); }
}
/* ---------- 页面切换 ---------- */
function switchPage(page) {
document.querySelectorAll('aside .menu-item').forEach(el =>
el.classList.toggle('active', el.dataset.page === page));
document.getElementById('pageToday').classList.toggle('hidden', page !== 'today');
document.getElementById('pageBlacklist').classList.toggle('hidden', page !== 'blacklist');
if (page === 'today') load(); else loadBlacklist();
}
/* ---------- 事件绑定 ---------- */
document.getElementById('btnLogin').onclick = login;
document.getElementById('password').addEventListener('keydown', e => { if (e.key === 'Enter') login(); });
document.getElementById('btnLogout').onclick = logout;
document.querySelectorAll('aside .menu-item').forEach(el =>
el.addEventListener('click', () => switchPage(el.dataset.page)));
document.getElementById('btnBlAdd').onclick = () => {
const input = document.getElementById('blCompany');
addBlacklist(input.value);
input.value = '';
};
document.getElementById('blCompany').addEventListener('keydown', e => {
if (e.key === 'Enter') document.getElementById('btnBlAdd').click();
});
// 黑名单列表「移除」/ 今日表格快捷「拉黑」(事件委托)
document.getElementById('blTbody').addEventListener('click', e => {
const btn = e.target.closest('.bl-remove');
if (btn) removeBlacklist(btn.dataset.id);
});
document.getElementById('tbody').addEventListener('click', e => {
const btn = e.target.closest('.bl-btn');
if (btn && confirm('确认拉黑公司「' + btn.dataset.company + '」?拉黑后将不再投递该公司。')) {
addBlacklist(btn.dataset.company);
}
});
async function enter() {
showData();
await loadBlacklist();
await load();
}
document.getElementById('btnLogin').onclick = login;
document.getElementById('password').addEventListener('keydown', e => { if (e.key === 'Enter') login(); });
document.getElementById('btnRefresh').onclick = load;
document.getElementById('btnLogout').onclick = logout;
if (token()) enter(); else showLogin();
setInterval(() => { if (token() && !document.getElementById('dataView').classList.contains('hidden')) load(); }, 30000);
setInterval(() => {
if (token() && !document.getElementById('dataView').classList.contains('hidden')) load();
}, 30000);
</script>
</body>
</html>