init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Web 控制面板包"""
|
||||
@@ -0,0 +1,273 @@
|
||||
"""
|
||||
本地 Web 控制面板
|
||||
FastAPI 应用:提供操作界面 + 编排浏览器自动化流程
|
||||
"""
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from fastapi import FastAPI, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from pydantic import BaseModel
|
||||
from loguru import logger
|
||||
|
||||
from ..config import client_settings
|
||||
from ..server_api import ServerAPI
|
||||
from ..ai import AIClient
|
||||
from ..fingerprint import generate_client_code, get_machine_summary
|
||||
from ..browser.manager import BrowserManager
|
||||
from ..browser.resume_scraper import ResumeScraper
|
||||
from ..browser.applicant import Applicant
|
||||
|
||||
WEB_DIR = Path(__file__).parent
|
||||
|
||||
app = FastAPI(title="Boss直聘投递控制面板")
|
||||
app.mount("/static", StaticFiles(directory=WEB_DIR / "static"), name="static")
|
||||
templates = Jinja2Templates(directory=str(WEB_DIR / "templates"))
|
||||
|
||||
|
||||
# =======================================================
|
||||
# 全局共享状态(整个客户端生命周期复用)
|
||||
# =======================================================
|
||||
class AppState:
|
||||
def __init__(self):
|
||||
self.server_api = ServerAPI()
|
||||
self.browser = BrowserManager()
|
||||
self.ai = AIClient()
|
||||
self.applicant: Applicant | None = None
|
||||
self.connected = False # 是否已注册/登录云端
|
||||
self.login_polling = False
|
||||
|
||||
def ensure_applicant(self) -> Applicant:
|
||||
if self.applicant is None:
|
||||
self.applicant = Applicant(self.browser, self.server_api, self.ai)
|
||||
return self.applicant
|
||||
|
||||
|
||||
state = AppState()
|
||||
|
||||
|
||||
# =======================================================
|
||||
# 请求模型
|
||||
# =======================================================
|
||||
class ConnectReq(BaseModel):
|
||||
nickname: str | None = None
|
||||
|
||||
|
||||
class StartApplyReq(BaseModel):
|
||||
keywords: list[str]
|
||||
city_code: str
|
||||
salary_min: int | None = None
|
||||
salary_max: int | None = None
|
||||
greeting: str = ""
|
||||
min_score: int = 65
|
||||
delay_min: int = 3
|
||||
delay_max: int = 8
|
||||
|
||||
|
||||
# =======================================================
|
||||
# 页面
|
||||
# =======================================================
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
def index(request: Request):
|
||||
return templates.TemplateResponse("index.html", {"request": request})
|
||||
|
||||
|
||||
# =======================================================
|
||||
# 基础状态
|
||||
# =======================================================
|
||||
@app.get("/api/status")
|
||||
def get_status():
|
||||
"""返回整体状态,供前端轮询"""
|
||||
result = {
|
||||
"client_code": generate_client_code()[:16] + "...",
|
||||
"machine": get_machine_summary(),
|
||||
"server_connected": state.connected,
|
||||
"server_reachable": state.server_api.ping(),
|
||||
"adspower_running": state.browser.is_adspower_running(),
|
||||
"ai_configured": state.ai.available(),
|
||||
"login_status": "unknown",
|
||||
"resume_count": 0,
|
||||
"has_primary": False,
|
||||
"applying": False,
|
||||
"apply_stats": None,
|
||||
}
|
||||
if state.connected:
|
||||
try:
|
||||
me = state.server_api.get_me()
|
||||
result["login_status"] = me.get("login_status", "unknown")
|
||||
result["boss_account"] = me.get("boss_account")
|
||||
resumes = state.server_api.list_resumes()
|
||||
result["resume_count"] = len(resumes)
|
||||
result["has_primary"] = any(r.get("is_primary") for r in resumes)
|
||||
except Exception as e:
|
||||
logger.debug(f"获取用户状态失败:{e}")
|
||||
if state.applicant and state.applicant.is_running:
|
||||
result["applying"] = True
|
||||
result["apply_stats"] = state.applicant.stats
|
||||
return result
|
||||
|
||||
|
||||
# =======================================================
|
||||
# Step 0: 连接云端服务端
|
||||
# =======================================================
|
||||
@app.post("/api/connect")
|
||||
def connect(req: ConnectReq):
|
||||
try:
|
||||
data = state.server_api.register(req.nickname)
|
||||
state.connected = True
|
||||
return {"ok": True, "user_id": data["user_id"], "is_new": data["is_new"]}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"连接服务端失败:{e}")
|
||||
|
||||
|
||||
# =======================================================
|
||||
# Step 1: 引导登录 Boss直聘
|
||||
# =======================================================
|
||||
@app.post("/api/start-login")
|
||||
def start_login():
|
||||
"""打开 AdsPower 浏览器并跳转到 Boss直聘,等待用户手动登录"""
|
||||
if not state.connected:
|
||||
raise HTTPException(status_code=400, detail="请先连接服务端")
|
||||
try:
|
||||
state.server_api.update_login_status("logging_in")
|
||||
page = state.browser.connect()
|
||||
page.goto("https://www.zhipin.com/", wait_until="domcontentloaded", timeout=30000)
|
||||
# 启动后台轮询检测登录
|
||||
threading.Thread(target=_poll_login, daemon=True).start()
|
||||
return {"ok": True, "msg": "浏览器已打开,请在浏览器中完成登录"}
|
||||
except Exception as e:
|
||||
state.server_api.update_login_status("not_login")
|
||||
raise HTTPException(status_code=500, detail=f"打开浏览器失败:{e}")
|
||||
|
||||
|
||||
def _poll_login():
|
||||
"""后台轮询检测登录状态,最长等待 5 分钟"""
|
||||
state.login_polling = True
|
||||
import time
|
||||
for _ in range(150): # 150 * 2s = 5 分钟
|
||||
time.sleep(2)
|
||||
try:
|
||||
if state.browser.check_boss_login():
|
||||
account = state.browser.get_boss_account_name()
|
||||
state.server_api.update_login_status("logged_in", account)
|
||||
logger.success(f"登录成功:{account}")
|
||||
break
|
||||
except Exception as e:
|
||||
logger.debug(f"登录轮询异常:{e}")
|
||||
state.login_polling = False
|
||||
|
||||
|
||||
@app.get("/api/login-status")
|
||||
def login_status():
|
||||
"""前端轮询登录状态"""
|
||||
if not state.connected:
|
||||
return {"status": "not_connected", "polling": False}
|
||||
try:
|
||||
me = state.server_api.get_me()
|
||||
return {
|
||||
"status": me.get("login_status", "not_login"),
|
||||
"boss_account": me.get("boss_account"),
|
||||
"polling": state.login_polling,
|
||||
}
|
||||
except Exception:
|
||||
return {"status": "unknown", "polling": state.login_polling}
|
||||
|
||||
|
||||
# =======================================================
|
||||
# Step 2: 抓取简历 + 选择主简历
|
||||
# =======================================================
|
||||
@app.post("/api/scrape-resumes")
|
||||
def scrape_resumes():
|
||||
"""AI 抓取账号内所有简历并上传到云端"""
|
||||
if not state.connected:
|
||||
raise HTTPException(status_code=400, detail="请先连接服务端")
|
||||
try:
|
||||
scraper = ResumeScraper(state.browser, state.ai)
|
||||
resumes = scraper.scrape_all()
|
||||
if not resumes:
|
||||
raise HTTPException(status_code=404, detail="未抓取到任何简历,请确认已登录")
|
||||
uploaded = state.server_api.upload_resumes(resumes)
|
||||
return {"ok": True, "count": len(uploaded), "resumes": uploaded}
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"抓取简历失败:{e}")
|
||||
|
||||
|
||||
@app.get("/api/resumes")
|
||||
def list_resumes():
|
||||
if not state.connected:
|
||||
return []
|
||||
return state.server_api.list_resumes()
|
||||
|
||||
|
||||
@app.post("/api/resumes/{resume_id}/primary")
|
||||
def set_primary(resume_id: int):
|
||||
return state.server_api.set_primary_resume(resume_id)
|
||||
|
||||
|
||||
# =======================================================
|
||||
# Step 3 & 4: 开始 / 结束投递
|
||||
# =======================================================
|
||||
@app.post("/api/start-apply")
|
||||
def start_apply(req: StartApplyReq):
|
||||
if not state.connected:
|
||||
raise HTTPException(status_code=400, detail="请先连接服务端")
|
||||
if not state.server_api.get_primary_resume():
|
||||
raise HTTPException(status_code=400, detail="请先设置主简历")
|
||||
if not state.browser.is_adspower_running():
|
||||
raise HTTPException(status_code=400, detail="AdsPower 未运行")
|
||||
|
||||
applicant = state.ensure_applicant()
|
||||
if applicant.is_running:
|
||||
raise HTTPException(status_code=400, detail="已有投递任务在运行")
|
||||
|
||||
applicant.start(
|
||||
keywords=req.keywords,
|
||||
city_code=req.city_code,
|
||||
salary_min=req.salary_min,
|
||||
salary_max=req.salary_max,
|
||||
greeting=req.greeting,
|
||||
min_score=req.min_score,
|
||||
delay_range=(req.delay_min, req.delay_max),
|
||||
)
|
||||
return {"ok": True, "session_id": applicant.session_id}
|
||||
|
||||
|
||||
@app.post("/api/stop-apply")
|
||||
def stop_apply():
|
||||
applicant = state.ensure_applicant()
|
||||
if not applicant.is_running:
|
||||
return {"ok": False, "msg": "当前没有运行中的投递任务"}
|
||||
applicant.stop()
|
||||
return {"ok": True, "msg": "正在停止投递任务..."}
|
||||
|
||||
|
||||
@app.get("/api/apply-status")
|
||||
def apply_status():
|
||||
applicant = state.applicant
|
||||
if applicant is None:
|
||||
return {"running": False, "stats": None}
|
||||
return {
|
||||
"running": applicant.is_running,
|
||||
"stats": applicant.stats,
|
||||
"session_id": applicant.session_id,
|
||||
}
|
||||
|
||||
|
||||
# =======================================================
|
||||
# 历史与统计
|
||||
# =======================================================
|
||||
@app.get("/api/history")
|
||||
def history(limit: int = 50, apply_type: str | None = None):
|
||||
if not state.connected:
|
||||
return []
|
||||
return state.server_api.get_history(limit=limit, apply_type=apply_type)
|
||||
|
||||
|
||||
@app.get("/api/stats")
|
||||
def stats():
|
||||
if not state.connected:
|
||||
return {}
|
||||
return state.server_api.get_stats()
|
||||
@@ -0,0 +1,310 @@
|
||||
// ==========================================================
|
||||
// Boss直聘 AI 投递 - 控制面板前端逻辑
|
||||
// ==========================================================
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
let currentStep = 1;
|
||||
let loginPollTimer = null;
|
||||
let applyPollTimer = null;
|
||||
|
||||
// ---------- Toast ----------
|
||||
function toast(msg, ms = 3000) {
|
||||
const t = $('toast');
|
||||
t.textContent = msg;
|
||||
t.classList.add('show');
|
||||
setTimeout(() => t.classList.remove('show'), ms);
|
||||
}
|
||||
|
||||
// ---------- 步骤切换 ----------
|
||||
function goToStep(step) {
|
||||
currentStep = step;
|
||||
document.querySelectorAll('.step').forEach(el => {
|
||||
el.classList.toggle('active', parseInt(el.dataset.step) === step);
|
||||
});
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
$(`panel-${i}`).classList.toggle('hidden', i !== step);
|
||||
}
|
||||
if (step === 5) loadHistory();
|
||||
if (step === 3) loadResumes();
|
||||
}
|
||||
document.querySelectorAll('.step').forEach(el => {
|
||||
el.addEventListener('click', () => goToStep(parseInt(el.dataset.step)));
|
||||
});
|
||||
|
||||
// ---------- 通用请求 ----------
|
||||
async function api(path, options = {}) {
|
||||
const res = await fetch(path, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
...options,
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
throw new Error(err.detail || `请求失败 ${res.status}`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// ---------- 徽章工具 ----------
|
||||
function badge(text, cls) {
|
||||
return `<span class="badge ${cls || ''}">${text}</span>`;
|
||||
}
|
||||
|
||||
// ---------- 初始化状态 ----------
|
||||
async function refreshStatus() {
|
||||
try {
|
||||
const s = await api('/api/status');
|
||||
$('clientCode').textContent = s.client_code;
|
||||
$('serverReachable').innerHTML = badge(
|
||||
s.server_reachable ? '可连接' : '无法连接',
|
||||
s.server_reachable ? 'ok' : 'err'
|
||||
);
|
||||
$('adspowerStatus').innerHTML = badge(
|
||||
s.adspower_running ? '运行中' : '未运行',
|
||||
s.adspower_running ? 'ok' : 'warn'
|
||||
);
|
||||
// 顶部徽章
|
||||
$('statusBadges').innerHTML =
|
||||
badge(s.server_connected ? '已连接' : '未连接', s.server_connected ? 'ok' : '') +
|
||||
badge(s.ai_configured ? 'AI已配置' : 'AI未配置', s.ai_configured ? 'ok' : 'warn');
|
||||
|
||||
if (s.server_connected) {
|
||||
updateLoginBadge(s.login_status, s.boss_account);
|
||||
}
|
||||
return s;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function updateLoginBadge(status, account) {
|
||||
const el = $('loginStatus');
|
||||
if (status === 'logged_in') {
|
||||
el.innerHTML = badge(`已登录 ${escapeHtml(account || '')}`, 'ok');
|
||||
} else if (status === 'logging_in') {
|
||||
el.innerHTML = badge('登录中...', 'warn');
|
||||
} else {
|
||||
el.innerHTML = badge('未登录', '');
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================================
|
||||
// Step 1: 连接服务端
|
||||
// ==========================================================
|
||||
$('btnConnect').addEventListener('click', async () => {
|
||||
const btn = $('btnConnect');
|
||||
btn.disabled = true;
|
||||
try {
|
||||
const data = await api('/api/connect', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ nickname: $('nickname').value || null }),
|
||||
});
|
||||
toast(data.is_new ? '注册成功!' : '登录成功!');
|
||||
await refreshStatus();
|
||||
goToStep(2);
|
||||
} catch (e) {
|
||||
toast('连接失败:' + e.message, 5000);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================================
|
||||
// Step 2: 登录 Boss直聘
|
||||
// ==========================================================
|
||||
$('btnStartLogin').addEventListener('click', async () => {
|
||||
const btn = $('btnStartLogin');
|
||||
btn.disabled = true;
|
||||
try {
|
||||
await api('/api/start-login', { method: 'POST' });
|
||||
toast('浏览器已打开,请在 AdsPower 浏览器中完成登录');
|
||||
$('loginSpinner').classList.remove('hidden');
|
||||
startLoginPoll();
|
||||
} catch (e) {
|
||||
toast('打开浏览器失败:' + e.message, 5000);
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
function startLoginPoll() {
|
||||
if (loginPollTimer) clearInterval(loginPollTimer);
|
||||
loginPollTimer = setInterval(async () => {
|
||||
try {
|
||||
const r = await api('/api/login-status');
|
||||
updateLoginBadge(r.status, r.boss_account);
|
||||
if (r.status === 'logged_in') {
|
||||
clearInterval(loginPollTimer);
|
||||
$('loginSpinner').classList.add('hidden');
|
||||
$('btnStartLogin').disabled = false;
|
||||
toast('登录成功!即将进入简历步骤');
|
||||
setTimeout(() => goToStep(3), 1200);
|
||||
}
|
||||
} catch (e) { /* 忽略 */ }
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
// ==========================================================
|
||||
// Step 3: 抓取简历
|
||||
// ==========================================================
|
||||
$('btnScrape').addEventListener('click', async () => {
|
||||
const btn = $('btnScrape');
|
||||
btn.disabled = true;
|
||||
btn.textContent = '正在抓取...';
|
||||
try {
|
||||
const data = await api('/api/scrape-resumes', { method: 'POST' });
|
||||
toast(`抓取到 ${data.count} 份简历`);
|
||||
loadResumes();
|
||||
} catch (e) {
|
||||
toast('抓取失败:' + e.message, 5000);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '开始抓取简历';
|
||||
}
|
||||
});
|
||||
|
||||
async function loadResumes() {
|
||||
try {
|
||||
const resumes = await api('/api/resumes');
|
||||
const list = $('resumeList');
|
||||
if (!resumes.length) {
|
||||
list.innerHTML = '<p class="hint">暂无简历,请先抓取。</p>';
|
||||
return;
|
||||
}
|
||||
list.innerHTML = resumes.map(r => `
|
||||
<div class="resume-item ${r.is_primary ? 'primary' : ''}" data-id="${r.id}">
|
||||
<div class="radio"></div>
|
||||
<div>
|
||||
<div class="r-title">${escapeHtml(r.title)}</div>
|
||||
<div class="r-pos">${escapeHtml(r.position || '未设置求职意向')}</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
list.querySelectorAll('.resume-item').forEach(el => {
|
||||
el.addEventListener('click', () => setPrimary(parseInt(el.dataset.id)));
|
||||
});
|
||||
} catch (e) { console.error(e); }
|
||||
}
|
||||
|
||||
async function setPrimary(id) {
|
||||
try {
|
||||
await api(`/api/resumes/${id}/primary`, { method: 'POST' });
|
||||
toast('已设为主简历');
|
||||
loadResumes();
|
||||
// 允许进入下一步
|
||||
setTimeout(() => { if (currentStep === 3) goToStep(4); }, 600);
|
||||
} catch (e) {
|
||||
toast('设置失败:' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================================
|
||||
// Step 4: 开始 / 结束投递
|
||||
// ==========================================================
|
||||
$('btnStartApply').addEventListener('click', async () => {
|
||||
const keywords = $('keywords').value.split(',').map(k => k.trim()).filter(Boolean);
|
||||
if (!keywords.length) { toast('请填写搜索关键词'); return; }
|
||||
|
||||
const btn = $('btnStartApply');
|
||||
btn.disabled = true;
|
||||
try {
|
||||
await api('/api/start-apply', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
keywords,
|
||||
city_code: $('cityCode').value,
|
||||
salary_min: parseInt($('salaryMin').value) || null,
|
||||
salary_max: parseInt($('salaryMax').value) || null,
|
||||
greeting: $('greeting').value,
|
||||
min_score: parseInt($('minScore').value) || 65,
|
||||
}),
|
||||
});
|
||||
toast('投递任务已启动');
|
||||
toggleApplyUI(true);
|
||||
startApplyPoll();
|
||||
} catch (e) {
|
||||
toast('启动失败:' + e.message, 5000);
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
$('btnStopApply').addEventListener('click', async () => {
|
||||
try {
|
||||
const r = await api('/api/stop-apply', { method: 'POST' });
|
||||
toast(r.msg);
|
||||
} catch (e) { toast('停止失败:' + e.message); }
|
||||
});
|
||||
|
||||
function toggleApplyUI(running) {
|
||||
$('btnStartApply').classList.toggle('hidden', running);
|
||||
$('btnStopApply').classList.toggle('hidden', !running);
|
||||
$('progressBox').classList.toggle('hidden', !running);
|
||||
$('btnStartApply').disabled = false;
|
||||
}
|
||||
|
||||
function startApplyPoll() {
|
||||
if (applyPollTimer) clearInterval(applyPollTimer);
|
||||
applyPollTimer = setInterval(async () => {
|
||||
try {
|
||||
const r = await api('/api/apply-status');
|
||||
if (r.stats) {
|
||||
$('progressCurrent').textContent = r.stats.current || '';
|
||||
$('statApplied').textContent = r.stats.applied || 0;
|
||||
$('statSkipped').textContent = r.stats.skipped || 0;
|
||||
}
|
||||
if (!r.running) {
|
||||
clearInterval(applyPollTimer);
|
||||
toggleApplyUI(false);
|
||||
toast('投递任务已结束');
|
||||
}
|
||||
} catch (e) { /* 忽略 */ }
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// ==========================================================
|
||||
// Step 5: 历史与统计
|
||||
// ==========================================================
|
||||
async function loadHistory() {
|
||||
try {
|
||||
const [stats, history] = await Promise.all([
|
||||
api('/api/stats'),
|
||||
api('/api/history?limit=50'),
|
||||
]);
|
||||
$('statsGrid').innerHTML = `
|
||||
<div class="stat-card"><div class="num">${stats.total_applied || 0}</div><div class="label">累计投递</div></div>
|
||||
<div class="stat-card"><div class="num">${stats.total_chat || 0}</div><div class="label">立即沟通</div></div>
|
||||
<div class="stat-card"><div class="num">${stats.total_deliver || 0}</div><div class="label">投递简历</div></div>
|
||||
<div class="stat-card"><div class="num">${stats.today_applied || 0}</div><div class="label">今日投递</div></div>
|
||||
`;
|
||||
$('historyBody').innerHTML = history.map(h => `
|
||||
<tr>
|
||||
<td>${escapeHtml(h.job_title || '-')}</td>
|
||||
<td>${escapeHtml(h.company || '-')}</td>
|
||||
<td>${escapeHtml(h.salary || '-')}</td>
|
||||
<td><span class="tag ${safeType(h.apply_type)}">${typeLabel(h.apply_type)}</span></td>
|
||||
<td>${h.ai_score >= 0 ? h.ai_score : '-'}</td>
|
||||
<td>${formatTime(h.applied_at)}</td>
|
||||
</tr>
|
||||
`).join('') || '<tr><td colspan="6" style="text-align:center;color:#999">暂无记录</td></tr>';
|
||||
} catch (e) { console.error(e); }
|
||||
}
|
||||
|
||||
function typeLabel(t) {
|
||||
return { chat: '沟通', deliver: '投递', skipped: '跳过' }[t] || t;
|
||||
}
|
||||
// apply_type 仅允许白名单值用作 CSS class,防止注入
|
||||
function safeType(t) {
|
||||
return ['chat', 'deliver', 'skipped'].includes(t) ? t : 'skipped';
|
||||
}
|
||||
function formatTime(s) {
|
||||
if (!s) return '-';
|
||||
return s.replace('T', ' ').substring(0, 16);
|
||||
}
|
||||
function escapeHtml(s) {
|
||||
if (!s) return '';
|
||||
return s.replace(/[&<>"']/g, c => ({
|
||||
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
||||
}[c]));
|
||||
}
|
||||
|
||||
// ---------- 启动 ----------
|
||||
refreshStatus();
|
||||
setInterval(refreshStatus, 8000);
|
||||
@@ -0,0 +1,259 @@
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
:root {
|
||||
--primary: #2f6fed;
|
||||
--primary-dark: #1e56c8;
|
||||
--success: #16a34a;
|
||||
--danger: #dc2626;
|
||||
--warning: #d97706;
|
||||
--bg: #f4f6fa;
|
||||
--card: #ffffff;
|
||||
--text: #1f2937;
|
||||
--text-light: #6b7280;
|
||||
--border: #e5e7eb;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 860px;
|
||||
margin: 0 auto;
|
||||
padding: 24px 16px 60px;
|
||||
}
|
||||
|
||||
/* ===== 顶部 ===== */
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.header h1 { font-size: 22px; }
|
||||
.status-badges { display: flex; gap: 8px; }
|
||||
|
||||
/* ===== 步骤导航 ===== */
|
||||
.steps {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.step {
|
||||
flex: 1;
|
||||
min-width: 100px;
|
||||
text-align: center;
|
||||
padding: 10px 8px;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: var(--text-light);
|
||||
transition: all .2s;
|
||||
}
|
||||
.step.active {
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
.step-num {
|
||||
display: inline-block;
|
||||
width: 20px; height: 20px;
|
||||
line-height: 20px;
|
||||
border-radius: 50%;
|
||||
background: rgba(0,0,0,.08);
|
||||
margin-right: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.step.active .step-num { background: rgba(255,255,255,.25); }
|
||||
|
||||
/* ===== 面板 ===== */
|
||||
.panel {
|
||||
background: var(--card);
|
||||
border-radius: 12px;
|
||||
padding: 28px;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,.06);
|
||||
}
|
||||
.panel h2 { font-size: 19px; margin-bottom: 8px; }
|
||||
.panel .hint { color: var(--text-light); font-size: 14px; margin-bottom: 18px; }
|
||||
.hidden { display: none !important; }
|
||||
|
||||
.info-box {
|
||||
background: var(--bg);
|
||||
border-radius: 8px;
|
||||
padding: 14px 16px;
|
||||
margin-bottom: 18px;
|
||||
font-size: 14px;
|
||||
line-height: 2;
|
||||
}
|
||||
.info-box code {
|
||||
background: #eef2ff;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* ===== 徽章 ===== */
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 3px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
background: var(--border);
|
||||
color: var(--text-light);
|
||||
}
|
||||
.badge.ok { background: #dcfce7; color: var(--success); }
|
||||
.badge.warn { background: #fef3c7; color: var(--warning); }
|
||||
.badge.err { background: #fee2e2; color: var(--danger); }
|
||||
|
||||
/* ===== 表单 ===== */
|
||||
.form-group { margin-bottom: 16px; }
|
||||
.form-row { display: flex; gap: 14px; }
|
||||
.form-row .form-group { flex: 1; }
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus,
|
||||
.form-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
/* ===== 按钮 ===== */
|
||||
.btn {
|
||||
padding: 11px 22px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
transition: all .2s;
|
||||
font-weight: 600;
|
||||
}
|
||||
.btn-primary { background: var(--primary); color: #fff; }
|
||||
.btn-primary:hover { background: var(--primary-dark); }
|
||||
.btn-success { background: var(--success); color: #fff; }
|
||||
.btn-success:hover { filter: brightness(1.1); }
|
||||
.btn-danger { background: var(--danger); color: #fff; }
|
||||
.btn-danger:hover { filter: brightness(1.1); }
|
||||
.btn:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.action-buttons { display: flex; gap: 12px; margin-top: 10px; }
|
||||
|
||||
/* ===== 加载 ===== */
|
||||
.spinner {
|
||||
margin-top: 16px;
|
||||
color: var(--primary);
|
||||
font-size: 14px;
|
||||
animation: pulse 1.5s infinite;
|
||||
}
|
||||
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
|
||||
|
||||
/* ===== 简历列表 ===== */
|
||||
.resume-list { margin-top: 18px; }
|
||||
.resume-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 10px;
|
||||
cursor: pointer;
|
||||
transition: all .2s;
|
||||
}
|
||||
.resume-item:hover { border-color: var(--primary); }
|
||||
.resume-item.primary {
|
||||
border-color: var(--success);
|
||||
background: #f0fdf4;
|
||||
}
|
||||
.resume-item .radio {
|
||||
width: 18px; height: 18px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.resume-item.primary .radio {
|
||||
border-color: var(--success);
|
||||
background: var(--success);
|
||||
}
|
||||
.resume-item .r-title { font-weight: 600; }
|
||||
.resume-item .r-pos { font-size: 13px; color: var(--text-light); }
|
||||
|
||||
/* ===== 进度 ===== */
|
||||
.progress-box {
|
||||
margin-top: 18px;
|
||||
padding: 16px;
|
||||
background: var(--bg);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.progress-current { font-size: 14px; margin-bottom: 10px; color: var(--primary); }
|
||||
.progress-stats { display: flex; gap: 24px; font-size: 14px; }
|
||||
|
||||
/* ===== 统计网格 ===== */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stat-card {
|
||||
background: var(--bg);
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
|
||||
.stat-card .label { font-size: 13px; color: var(--text-light); margin-top: 4px; }
|
||||
|
||||
/* ===== 历史表格 ===== */
|
||||
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
.history-table th, .history-table td {
|
||||
padding: 10px 8px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.history-table th { color: var(--text-light); font-weight: 600; }
|
||||
.history-table td .tag {
|
||||
padding: 2px 8px; border-radius: 10px; font-size: 12px;
|
||||
}
|
||||
.tag.chat { background: #dcfce7; color: var(--success); }
|
||||
.tag.deliver { background: #dbeafe; color: var(--primary); }
|
||||
.tag.skipped { background: #f3f4f6; color: var(--text-light); }
|
||||
|
||||
/* ===== Toast ===== */
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translateY(80px);
|
||||
background: #1f2937;
|
||||
color: #fff;
|
||||
padding: 12px 22px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
opacity: 0;
|
||||
transition: all .3s;
|
||||
z-index: 999;
|
||||
max-width: 80%;
|
||||
}
|
||||
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
|
||||
@@ -0,0 +1,134 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Boss直聘 AI 智能投递</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- 顶部标题栏 -->
|
||||
<header class="header">
|
||||
<h1>🎯 Boss直聘 AI 智能投递</h1>
|
||||
<div class="status-badges" id="statusBadges"></div>
|
||||
</header>
|
||||
|
||||
<!-- 步骤导航 -->
|
||||
<nav class="steps">
|
||||
<div class="step active" data-step="1"><span class="step-num">1</span> 连接</div>
|
||||
<div class="step" data-step="2"><span class="step-num">2</span> 登录</div>
|
||||
<div class="step" data-step="3"><span class="step-num">3</span> 简历</div>
|
||||
<div class="step" data-step="4"><span class="step-num">4</span> 投递</div>
|
||||
<div class="step" data-step="5"><span class="step-num">5</span> 记录</div>
|
||||
</nav>
|
||||
|
||||
<!-- Step 1: 连接服务端 -->
|
||||
<section class="panel" id="panel-1">
|
||||
<h2>连接云端服务端</h2>
|
||||
<p class="hint">使用本机硬件指纹作为唯一编码注册,数据将隔离存储在你的账号下。</p>
|
||||
<div class="info-box">
|
||||
<div><strong>机器指纹:</strong><code id="clientCode">加载中...</code></div>
|
||||
<div><strong>服务端状态:</strong><span id="serverReachable" class="badge">检测中</span></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>昵称(可选)</label>
|
||||
<input type="text" id="nickname" placeholder="给自己起个名字">
|
||||
</div>
|
||||
<button class="btn btn-primary" id="btnConnect">连接并注册</button>
|
||||
</section>
|
||||
|
||||
<!-- Step 2: 登录 Boss直聘 -->
|
||||
<section class="panel hidden" id="panel-2">
|
||||
<h2>登录 Boss直聘</h2>
|
||||
<p class="hint">点击下方按钮,将通过 AdsPower 指纹浏览器打开 Boss直聘,请在弹出的浏览器窗口中手动完成登录(扫码或账号密码)。</p>
|
||||
<div class="info-box">
|
||||
<div><strong>AdsPower 状态:</strong><span id="adspowerStatus" class="badge">检测中</span></div>
|
||||
<div><strong>登录状态:</strong><span id="loginStatus" class="badge">未登录</span></div>
|
||||
</div>
|
||||
<button class="btn btn-primary" id="btnStartLogin">打开浏览器登录</button>
|
||||
<div class="spinner hidden" id="loginSpinner">正在等待登录,请在浏览器中完成操作...</div>
|
||||
</section>
|
||||
|
||||
<!-- Step 3: 简历管理 -->
|
||||
<section class="panel hidden" id="panel-3">
|
||||
<h2>抓取并选择主简历</h2>
|
||||
<p class="hint">AI 将自动抓取你 Boss直聘 账号内的所有简历,请勾选一份作为主简历用于 JD 匹配。</p>
|
||||
<button class="btn btn-primary" id="btnScrape">开始抓取简历</button>
|
||||
<div class="resume-list" id="resumeList"></div>
|
||||
</section>
|
||||
|
||||
<!-- Step 4: 配置投递 -->
|
||||
<section class="panel hidden" id="panel-4">
|
||||
<h2>配置并开始投递</h2>
|
||||
<div class="form-group">
|
||||
<label>搜索关键词(多个用逗号分隔)</label>
|
||||
<input type="text" id="keywords" placeholder="如:Python开发,后端工程师" value="Python开发">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>城市</label>
|
||||
<select id="cityCode">
|
||||
<option value="101010100">北京</option>
|
||||
<option value="101020100">上海</option>
|
||||
<option value="101280100">广州</option>
|
||||
<option value="101280600">深圳</option>
|
||||
<option value="101210100">杭州</option>
|
||||
<option value="101190100">成都</option>
|
||||
<option value="101110100">西安</option>
|
||||
<option value="101120100">济南</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>AI 最低匹配分</label>
|
||||
<input type="number" id="minScore" value="65" min="0" max="100">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>最低薪资 (K)</label>
|
||||
<input type="number" id="salaryMin" value="15" min="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>最高薪资 (K)</label>
|
||||
<input type="number" id="salaryMax" value="40" min="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>打招呼语(留空使用默认)</label>
|
||||
<textarea id="greeting" rows="2" placeholder="您好,我对贵司岗位很感兴趣..."></textarea>
|
||||
</div>
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-success" id="btnStartApply">▶ 开始投递</button>
|
||||
<button class="btn btn-danger hidden" id="btnStopApply">■ 结束投递</button>
|
||||
</div>
|
||||
<div class="progress-box hidden" id="progressBox">
|
||||
<div class="progress-current" id="progressCurrent">准备中...</div>
|
||||
<div class="progress-stats">
|
||||
<span>已投递:<strong id="statApplied">0</strong></span>
|
||||
<span>已跳过:<strong id="statSkipped">0</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Step 5: 投递记录 -->
|
||||
<section class="panel hidden" id="panel-5">
|
||||
<h2>投递记录与统计</h2>
|
||||
<div class="stats-grid" id="statsGrid"></div>
|
||||
<table class="history-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>职位</th><th>公司</th><th>薪资</th><th>方式</th><th>AI评分</th><th>时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="historyBody"></tbody>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- Toast 提示 -->
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script src="/static/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user