179 lines
8.1 KiB
HTML
179 lines
8.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>今日投递数据</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { font-family: "Microsoft YaHei", sans-serif; background: #f0f4f8; color: #333; }
|
|
.hidden { display: none !important; }
|
|
|
|
/* 登录页 */
|
|
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
|
|
.login-box { background: #fff; padding: 36px 40px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.08); width: 360px; }
|
|
.login-box h1 { font-size: 20px; text-align: center; margin-bottom: 24px; color: #1890ff; }
|
|
.login-box input { width: 100%; padding: 10px 12px; margin-bottom: 14px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; }
|
|
.login-box button { width: 100%; padding: 11px; background: #1890ff; color: #fff; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; }
|
|
.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; }
|
|
.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; }
|
|
.stat-card .label { font-size: 13px; color: #888; margin-top: 4px; }
|
|
.num.green { color: #52c41a; } .num.orange { color: #faad14; } .num.blue { color: #1890ff; }
|
|
|
|
table { width: 100%; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.05); border-collapse: collapse; font-size: 13px; }
|
|
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; }
|
|
th { background: #fafafa; color: #666; font-weight: 600; }
|
|
tr:hover td { background: #f7fbff; }
|
|
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; }
|
|
.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; }
|
|
.empty { text-align: center; padding: 40px; color: #999; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- 登录 -->
|
|
<div class="login-wrap" id="loginView">
|
|
<div class="login-box">
|
|
<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">
|
|
<button id="btnLogin">登 录</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 数据 -->
|
|
<div id="dataView" class="hidden">
|
|
<header>
|
|
<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>
|
|
<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>
|
|
|
|
<script>
|
|
const TOKEN_KEY = 'view_token';
|
|
const token = () => localStorage.getItem(TOKEN_KEY);
|
|
|
|
async function api(path, opts = {}) {
|
|
const resp = await fetch(path, {
|
|
...opts,
|
|
headers: { 'Content-Type': 'application/json',
|
|
...(token() ? { Authorization: 'Bearer ' + token() } : {}),
|
|
...(opts.headers || {}) },
|
|
});
|
|
if (resp.status === 401) { logout(); throw new Error('未登录'); }
|
|
if (!resp.ok) { const d = await resp.json().catch(() => ({})); throw new Error(d.detail || resp.status); }
|
|
return resp.json();
|
|
}
|
|
|
|
function showLogin() {
|
|
document.getElementById('loginView').classList.remove('hidden');
|
|
document.getElementById('dataView').classList.add('hidden');
|
|
}
|
|
function showData() {
|
|
document.getElementById('loginView').classList.add('hidden');
|
|
document.getElementById('dataView').classList.remove('hidden');
|
|
}
|
|
function logout() {
|
|
localStorage.removeItem(TOKEN_KEY);
|
|
showLogin();
|
|
}
|
|
|
|
async function login() {
|
|
const errEl = document.getElementById('loginErr');
|
|
errEl.textContent = '';
|
|
try {
|
|
const d = await api('/api/auth/login', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
username: document.getElementById('username').value.trim(),
|
|
password: document.getElementById('password').value,
|
|
}),
|
|
});
|
|
localStorage.setItem(TOKEN_KEY, d.token);
|
|
enter();
|
|
} catch (e) { errEl.textContent = e.message || '登录失败'; }
|
|
}
|
|
|
|
function esc(s) {
|
|
const div = document.createElement('div');
|
|
div.textContent = s == null ? '' : String(s);
|
|
return div.innerHTML;
|
|
}
|
|
|
|
async function load() {
|
|
try {
|
|
const [me, d] = await Promise.all([api('/api/auth/me'), api('/api/jobs/today')]);
|
|
document.getElementById('who').textContent = me.nickname || me.username;
|
|
document.getElementById('stApplied').textContent = d.applied;
|
|
document.getElementById('stSkipped').textContent = d.skipped;
|
|
document.getElementById('stTotal').textContent = d.total;
|
|
document.getElementById('updatedAt').textContent =
|
|
'更新于 ' + new Date().toLocaleTimeString('zh-CN', { hour12: false });
|
|
|
|
const tbody = document.getElementById('tbody');
|
|
tbody.innerHTML = (d.items || []).map(r => {
|
|
const type = r.apply_type === 'skipped'
|
|
? '<span class="badge skipped">跳过</span>'
|
|
: '<span class="badge ' + r.apply_type + '">' + (r.apply_type === 'chat' ? '已沟通' : '已投递') + '</span>';
|
|
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) +
|
|
'</td><td>' + esc(r.salary) + '</td><td>' + type + '</td><td>' + score +
|
|
'</td><td class="remark" title="' + esc(remark) + '">' + esc(remark) + '</td></tr>';
|
|
}).join('');
|
|
document.getElementById('empty').classList.toggle('hidden', (d.items || []).length > 0);
|
|
} catch (e) { /* 401 已在 api 内处理 */ }
|
|
}
|
|
|
|
async function enter() {
|
|
showData();
|
|
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);
|
|
</script>
|
|
</body>
|
|
</html>
|