PC端
This commit is contained in:
@@ -160,6 +160,8 @@ class Applicant:
|
|||||||
self._tab: dict | None = None
|
self._tab: dict | None = None
|
||||||
self._sess: CDPSession | None = None
|
self._sess: CDPSession | None = None
|
||||||
self._salary_by_id: dict[str, str] = {}
|
self._salary_by_id: dict[str, str] = {}
|
||||||
|
# 公司黑名单(每次任务开始时从云端拉取)
|
||||||
|
self._blacklist: set[str] = set()
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# 启停控制
|
# 启停控制
|
||||||
@@ -249,6 +251,15 @@ class Applicant:
|
|||||||
logger.info("已达当日投递上限,任务直接结束")
|
logger.info("已达当日投递上限,任务直接结束")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 公司黑名单:拉黑过的公司直接跳过(任务开始时拉取一次)
|
||||||
|
try:
|
||||||
|
self._blacklist = set(self.server.list_blacklist())
|
||||||
|
if self._blacklist:
|
||||||
|
logger.info(f"已加载 {len(self._blacklist)} 家黑名单公司")
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"获取公司黑名单失败,黑名单过滤跳过:{e}")
|
||||||
|
self._blacklist = set()
|
||||||
|
|
||||||
city_name = CITY_NAMES.get(str(city_code), "")
|
city_name = CITY_NAMES.get(str(city_code), "")
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
if self._should_stop():
|
if self._should_stop():
|
||||||
@@ -383,6 +394,11 @@ class Applicant:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# 黑名单过滤:拉黑过的公司全部职位直接跳过
|
||||||
|
if card.company and card.company in self._blacklist:
|
||||||
|
self._report_skip(card, "公司已拉黑")
|
||||||
|
return 0
|
||||||
|
|
||||||
self.stats["current"] = f"评估:{card.company} - {card.title}"
|
self.stats["current"] = f"评估:{card.company} - {card.title}"
|
||||||
logger.debug(f"开始处理卡片:{card.company} - {card.title}"
|
logger.debug(f"开始处理卡片:{card.company} - {card.title}"
|
||||||
f" | 薪资={card.salary or '未知'} | Boss在线={card.boss_online}")
|
f" | 薪资={card.salary or '未知'} | Boss在线={card.boss_online}")
|
||||||
|
|||||||
@@ -246,6 +246,13 @@ class ServerAPI:
|
|||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.json().get("applied", False)
|
return resp.json().get("applied", False)
|
||||||
|
|
||||||
|
def list_blacklist(self) -> list[str]:
|
||||||
|
"""公司黑名单名单(公司名列表,拉黑后不再投递该公司)"""
|
||||||
|
resp = self._req("get", f"{self.base_url}/api/blacklist",
|
||||||
|
headers=self._headers(), timeout=15)
|
||||||
|
resp.raise_for_status()
|
||||||
|
return [i["company"] for i in resp.json()]
|
||||||
|
|
||||||
def get_stats(self) -> dict:
|
def get_stats(self) -> dict:
|
||||||
resp = self._req("get", f"{self.base_url}/api/jobs/stats", headers=self._headers(), timeout=15)
|
resp = self._req("get", f"{self.base_url}/api/jobs/stats", headers=self._headers(), timeout=15)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
|
|||||||
@@ -105,9 +105,36 @@ CREATE TABLE IF NOT EXISTS job_applications (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||||
COMMENT='投递记录';
|
COMMENT='投递记录';
|
||||||
|
|
||||||
|
-- ------------------------------------------------------------
|
||||||
|
-- 5. 公司黑名单(拉黑后 RPA 不再投递该公司)
|
||||||
|
-- ------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS company_blacklist (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
user_id INT NOT NULL,
|
||||||
|
company VARCHAR(128) NOT NULL COMMENT '公司名(与投递记录 company 精确匹配)',
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '拉黑时间',
|
||||||
|
UNIQUE KEY uq_user_company (user_id, company),
|
||||||
|
KEY ix_blacklist_user_id (user_id),
|
||||||
|
CONSTRAINT fk_blacklist_user FOREIGN KEY (user_id)
|
||||||
|
REFERENCES users (id) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||||
|
COMMENT='公司黑名单';
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- 附:老库升级脚本(已建过表、缺少新增字段时执行)
|
-- 附:老库升级脚本(已建过表、缺少新增字段时执行)
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- ALTER TABLE job_applications
|
-- ALTER TABLE job_applications
|
||||||
-- ADD COLUMN jd_text TEXT NULL COMMENT '职位JD全文',
|
-- ADD COLUMN jd_text TEXT NULL COMMENT '职位JD全文',
|
||||||
-- ADD COLUMN greeting VARCHAR(500) NULL COMMENT '实际发送的打招呼语';
|
-- ADD COLUMN greeting VARCHAR(500) NULL COMMENT '实际发送的打招呼语';
|
||||||
|
--
|
||||||
|
-- 老库新增公司黑名单表:
|
||||||
|
-- CREATE TABLE IF NOT EXISTS company_blacklist (
|
||||||
|
-- id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
-- user_id INT NOT NULL,
|
||||||
|
-- company VARCHAR(128) NOT NULL,
|
||||||
|
-- created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
-- UNIQUE KEY uq_user_company (user_id, company),
|
||||||
|
-- KEY ix_blacklist_user_id (user_id),
|
||||||
|
-- CONSTRAINT fk_blacklist_user FOREIGN KEY (user_id)
|
||||||
|
-- REFERENCES users (id) ON DELETE CASCADE
|
||||||
|
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|||||||
+2
-1
@@ -14,7 +14,7 @@ from loguru import logger
|
|||||||
|
|
||||||
from .config import settings
|
from .config import settings
|
||||||
from .database import engine
|
from .database import engine
|
||||||
from .routers import register, resumes, sessions, jobs
|
from .routers import register, resumes, sessions, jobs, blacklist
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
@@ -48,6 +48,7 @@ app.include_router(register.router)
|
|||||||
app.include_router(resumes.router)
|
app.include_router(resumes.router)
|
||||||
app.include_router(sessions.router)
|
app.include_router(sessions.router)
|
||||||
app.include_router(jobs.router)
|
app.include_router(jobs.router)
|
||||||
|
app.include_router(blacklist.router)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/", tags=["健康检查"])
|
@app.get("/", tags=["健康检查"])
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class User(Base):
|
|||||||
resumes = relationship("Resume", back_populates="user", cascade="all, delete-orphan")
|
resumes = relationship("Resume", back_populates="user", cascade="all, delete-orphan")
|
||||||
applications = relationship("JobApplication", back_populates="user", cascade="all, delete-orphan")
|
applications = relationship("JobApplication", back_populates="user", cascade="all, delete-orphan")
|
||||||
sessions = relationship("ApplySession", back_populates="user", cascade="all, delete-orphan")
|
sessions = relationship("ApplySession", back_populates="user", cascade="all, delete-orphan")
|
||||||
|
blacklist = relationship("CompanyBlacklist", back_populates="user", cascade="all, delete-orphan")
|
||||||
|
|
||||||
|
|
||||||
class Resume(Base):
|
class Resume(Base):
|
||||||
@@ -135,3 +136,23 @@ class JobApplication(Base):
|
|||||||
|
|
||||||
user = relationship("User", back_populates="applications")
|
user = relationship("User", back_populates="applications")
|
||||||
session = relationship("ApplySession", back_populates="applications")
|
session = relationship("ApplySession", back_populates="applications")
|
||||||
|
|
||||||
|
|
||||||
|
class CompanyBlacklist(Base):
|
||||||
|
"""
|
||||||
|
公司黑名单
|
||||||
|
拉黑后 RPA 不再投递该公司的任何职位
|
||||||
|
"""
|
||||||
|
__tablename__ = "company_blacklist"
|
||||||
|
__table_args__ = (
|
||||||
|
# 同一用户不重复拉黑同一公司
|
||||||
|
UniqueConstraint("user_id", "company", name="uq_user_company"),
|
||||||
|
)
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||||
|
# 公司名(与投递记录中的 company 精确匹配)
|
||||||
|
company = Column(String(128), nullable=False)
|
||||||
|
created_at = Column(DateTime, default=utcnow, nullable=False)
|
||||||
|
|
||||||
|
user = relationship("User", back_populates="blacklist")
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
"""
|
||||||
|
公司黑名单路由:拉黑后 RPA 不再投递该公司的任何职位
|
||||||
|
"""
|
||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from ..auth import get_current_user
|
||||||
|
from ..database import get_db
|
||||||
|
from ..models import User, CompanyBlacklist
|
||||||
|
from ..schemas import BlacklistIn, BlacklistOut, Message
|
||||||
|
|
||||||
|
router = APIRouter(prefix="/api/blacklist", tags=["公司黑名单"])
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("", response_model=list[BlacklistOut])
|
||||||
|
def list_blacklist(
|
||||||
|
current_user: User = Depends(get_current_user),
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
):
|
||||||
|
"""查询当前用户的黑名单列表(按拉黑时间倒序)"""
|
||||||
|
return db.query(CompanyBlacklist).filter(
|
||||||
|
CompanyBlacklist.user_id == current_user.id,
|
||||||
|
).order_by(CompanyBlacklist.created_at.desc()).all()
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("", response_model=BlacklistOut)
|
||||||
|
def add_blacklist(
|
||||||
|
req: BlacklistIn,
|
||||||
|
current_user: User = Depends(get_current_user),
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
):
|
||||||
|
"""拉黑一家公司(重复拉黑幂等返回已有记录)"""
|
||||||
|
company = req.company.strip()
|
||||||
|
if not company:
|
||||||
|
raise HTTPException(status_code=422, detail="公司名不能为空")
|
||||||
|
|
||||||
|
existing = db.query(CompanyBlacklist).filter(
|
||||||
|
CompanyBlacklist.user_id == current_user.id,
|
||||||
|
CompanyBlacklist.company == company,
|
||||||
|
).first()
|
||||||
|
if existing:
|
||||||
|
return existing
|
||||||
|
|
||||||
|
item = CompanyBlacklist(user_id=current_user.id, company=company)
|
||||||
|
db.add(item)
|
||||||
|
db.commit()
|
||||||
|
db.refresh(item)
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
@router.delete("/{item_id}", response_model=Message)
|
||||||
|
def remove_blacklist(
|
||||||
|
item_id: int,
|
||||||
|
current_user: User = Depends(get_current_user),
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
):
|
||||||
|
"""移除一条黑名单记录"""
|
||||||
|
item = db.query(CompanyBlacklist).filter(
|
||||||
|
CompanyBlacklist.id == item_id,
|
||||||
|
CompanyBlacklist.user_id == current_user.id,
|
||||||
|
).first()
|
||||||
|
if not item:
|
||||||
|
raise HTTPException(status_code=404, detail="黑名单记录不存在")
|
||||||
|
db.delete(item)
|
||||||
|
db.commit()
|
||||||
|
return Message(msg="已移除")
|
||||||
@@ -156,6 +156,22 @@ class ApplicationOut(BaseModel):
|
|||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
|
# =======================================================
|
||||||
|
# 公司黑名单
|
||||||
|
# =======================================================
|
||||||
|
class BlacklistIn(BaseModel):
|
||||||
|
company: str = Field(..., min_length=1, max_length=128, description="公司名")
|
||||||
|
|
||||||
|
|
||||||
|
class BlacklistOut(BaseModel):
|
||||||
|
id: int
|
||||||
|
company: str
|
||||||
|
created_at: datetime
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
from_attributes = True
|
||||||
|
|
||||||
|
|
||||||
# =======================================================
|
# =======================================================
|
||||||
# 通用
|
# 通用
|
||||||
# =======================================================
|
# =======================================================
|
||||||
|
|||||||
+145
-27
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>今日投递数据</title>
|
<title>投递数据中心</title>
|
||||||
<style>
|
<style>
|
||||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
body { font-family: "Microsoft YaHei", sans-serif; background: #f0f4f8; color: #333; }
|
body { font-family: "Microsoft YaHei", sans-serif; background: #f0f4f8; color: #333; }
|
||||||
@@ -18,14 +18,22 @@
|
|||||||
.login-box button:hover { background: #40a9ff; }
|
.login-box button:hover { background: #40a9ff; }
|
||||||
.login-err { color: #e64340; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
|
.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 { 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 h1 { font-size: 18px; color: #1890ff; }
|
||||||
header .ops { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #666; }
|
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 { 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; }
|
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; }
|
.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 { 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 .num { font-size: 30px; font-weight: 700; }
|
||||||
@@ -40,8 +48,21 @@
|
|||||||
.badge.chat, .badge.deliver { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
.badge.chat, .badge.deliver { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
||||||
.badge.skipped { background: #fff7e6; color: #faad14; border: 1px solid #ffd591; }
|
.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; }
|
.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; }
|
.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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -49,7 +70,7 @@
|
|||||||
<!-- 登录 -->
|
<!-- 登录 -->
|
||||||
<div class="login-wrap" id="loginView">
|
<div class="login-wrap" id="loginView">
|
||||||
<div class="login-box">
|
<div class="login-box">
|
||||||
<h1>今日投递数据 · 登录</h1>
|
<h1>投递数据中心 · 登录</h1>
|
||||||
<div class="login-err" id="loginErr"></div>
|
<div class="login-err" id="loginErr"></div>
|
||||||
<input type="text" id="username" placeholder="用户名" autocomplete="username">
|
<input type="text" id="username" placeholder="用户名" autocomplete="username">
|
||||||
<input type="password" id="password" placeholder="密码" autocomplete="current-password">
|
<input type="password" id="password" placeholder="密码" autocomplete="current-password">
|
||||||
@@ -60,33 +81,60 @@
|
|||||||
<!-- 数据 -->
|
<!-- 数据 -->
|
||||||
<div id="dataView" class="hidden">
|
<div id="dataView" class="hidden">
|
||||||
<header>
|
<header>
|
||||||
<h1>今日投递数据</h1>
|
<h1>投递数据中心</h1>
|
||||||
<div class="ops">
|
<div class="ops">
|
||||||
<span id="who"></span>
|
<span id="who"></span>
|
||||||
<span id="updatedAt"></span>
|
<span id="updatedAt"></span>
|
||||||
<button id="btnRefresh">刷新</button>
|
|
||||||
<button id="btnLogout">退出</button>
|
<button id="btnLogout">退出</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
|
||||||
<div class="stats">
|
<div class="layout">
|
||||||
<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>
|
<aside>
|
||||||
<div class="stat-card"><div class="num blue" id="stTotal">0</div><div class="label">今日处理总数</div></div>
|
<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>
|
</div>
|
||||||
<table>
|
</div>
|
||||||
<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>
|
<script>
|
||||||
const TOKEN_KEY = 'view_token';
|
const TOKEN_KEY = 'view_token';
|
||||||
const token = () => localStorage.getItem(TOKEN_KEY);
|
const token = () => localStorage.getItem(TOKEN_KEY);
|
||||||
|
let blSet = new Set(); // 当前黑名单公司名集合,用于今日表格快捷拉黑按钮状态
|
||||||
|
|
||||||
async function api(path, opts = {}) {
|
async function api(path, opts = {}) {
|
||||||
const resp = await fetch(path, {
|
const resp = await fetch(path, {
|
||||||
@@ -135,6 +183,7 @@ function esc(s) {
|
|||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- 今日投递数据 ---------- */
|
||||||
async function load() {
|
async function load() {
|
||||||
try {
|
try {
|
||||||
const [me, d] = await Promise.all([api('/api/auth/me'), api('/api/jobs/today')]);
|
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 ? '-'
|
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>';
|
: '<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 || '');
|
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>' + esc(r.salary) + '</td><td>' + type + '</td><td>' + score +
|
||||||
'</td><td class="remark" title="' + esc(remark) + '">' + esc(remark) + '</td></tr>';
|
'</td><td class="remark" title="' + esc(remark) + '">' + esc(remark) + '</td></tr>';
|
||||||
}).join('');
|
}).join('');
|
||||||
@@ -161,18 +214,83 @@ async function load() {
|
|||||||
} catch (e) { /* 401 已在 api 内处理 */ }
|
} 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() {
|
async function enter() {
|
||||||
showData();
|
showData();
|
||||||
|
await loadBlacklist();
|
||||||
await load();
|
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();
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user