base.html 15.2 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>{% block title %}WeChat Viewer{% endblock %}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f0f2f5; color: #333; height: 100vh; overflow: hidden; }

/* Top bar */
.topbar { background: #2c3e50; color: white; height: 48px; display: flex; align-items: center; padding: 0 12px; gap: 12px; position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
.topbar .menu-btn { background: none; border: none; color: white; font-size: 22px; cursor: pointer; padding: 4px 8px; line-height: 1; }
.topbar .brand { font-size: 15px; font-weight: bold; }
.topbar .brand-sub { font-size: 12px; color: #95a5a6; margin-left: 4px; }
.topbar .spacer { flex: 1; }
.topbar select { padding: 3px 8px; border: 1px solid #555; border-radius: 4px; background: #2c3e50; color: white; font-size: 11px; max-width: 120px; }

/* Drawer overlay */
.overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 200; }
.overlay.show { display: block; }

/* Drawer */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; background: #2c3e50; z-index: 201; transform: translateX(-100%); transition: transform 0.25s ease; display: flex; flex-direction: column; overflow-y: auto; }
.drawer.open { transform: translateX(0); }
.drawer .drawer-header { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.drawer .drawer-header .d-brand { font-size: 18px; font-weight: bold; color: white; }
.drawer .drawer-header .d-sub { font-size: 11px; color: #7f8c8d; margin-top: 4px; }
.drawer .drawer-nav { flex: 1; padding: 8px 0; }
.drawer .drawer-nav a { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: #bbb; text-decoration: none; font-size: 14px; transition: .15s; }
.drawer .drawer-nav a:hover { background: rgba(255,255,255,0.05); color: white; }
.drawer .drawer-nav a.active { background: rgba(255,255,255,0.1); color: white; font-weight: bold; border-left: 3px solid #3498db; padding-left: 17px; }
.drawer .drawer-nav a .icon { font-size: 16px; width: 22px; text-align: center; }
.drawer .drawer-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.drawer .drawer-footer select { width: 100%; padding: 6px 8px; border: 1px solid #555; border-radius: 4px; background: #34495e; color: white; font-size: 12px; }

/* Main content */
.main { height: 100vh; padding-top: 48px; overflow-y: auto; background: #f0f2f5; }

/* Shared components (unchanged from original) */
/* Session list */
.sidebar { width: 320px; background: white; border-right: 1px solid #e0e0e0; overflow-y: auto; flex-shrink: 0; }
.layout { display: flex; height: 100%; }
.search-box { padding: 12px; border-bottom: 1px solid #eee; position: sticky; top: 0; background: white; z-index: 10; }
.search-box input { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; outline: none; }
.search-box input:focus { border-color: #3498db; }
.session-item { padding: 14px 16px; border-bottom: 1px solid #f5f5f5; cursor: pointer; transition: .15s; display: flex; gap: 10px; }
.session-item:hover { background: #f5f7fa; }
.session-item.active { background: #e8f0fe; }
.session-item .avatar { width: 40px; height: 40px; border-radius: 4px; background: #3498db; color: white; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: bold; flex-shrink: 0; }
.session-item .avatar.group { background: #27ae60; }
.session-item .avatar.official { background: #e67e22; }
.session-item .info { flex: 1; min-width: 0; }
.session-item .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .preview { font-size: 12px; color: #999; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .time { font-size: 11px; color: #bbb; margin-top: 4px; }

/* Messages */
.messages { padding: 20px; max-width: 800px; margin: 0 auto; }
.msg-header { background: white; padding: 16px 20px; border-radius: 8px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.msg-header h2 { font-size: 18px; }
.msg-header .sub { font-size: 12px; color: #999; margin-top: 4px; }
.msg-bubble { margin-bottom: 12px; display: flex; }
.msg-bubble.sent { justify-content: flex-end; }
.msg-bubble .bubble { max-width: 70%; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5; word-break: break-all; position: relative; }
.msg-bubble.received .bubble { background: white; color: #333; }
.msg-bubble.sent .bubble { background: #95EC69; color: #333; }
.msg-bubble .time-sub { font-size: 11px; color: #999; margin-top: 4px; text-align: right; }
.msg-bubble img { max-width: 240px; border-radius: 4px; cursor: pointer; }
.msg-bubble video { max-width: 240px; border-radius: 4px; }
.msg-bubble audio { margin-top: 6px; }
.msg-bubble .msg-type-badge { font-size: 10px; color: #999; background: #f0f0f0; padding: 2px 6px; border-radius: 3px; margin-right: 6px; }
.msg-bubble a { color: #3498db; }
.empty-state { text-align: center; padding: 60px 20px; color: #999; }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* Shared page styles */
.circle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 20px; }
.circle-card { background: white; border-radius: 8px; padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.circle-card h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.circle-card .count { font-size: 12px; color: #999; background: #f0f0f0; padding: 2px 8px; border-radius: 10px; }
.stats-bar { padding: 20px; display: flex; gap: 20px; }
.stat-item { background: white; padding: 16px 24px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); text-align: center; flex: 1; }
.stat-item .num { font-size: 28px; font-weight: bold; color: #2c3e50; }
.stat-item .label { font-size: 12px; color: #999; margin-top: 4px; }
.list-table { width: 100%; border-collapse: collapse; }
.list-table th, .list-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.list-table th { color: #999; font-weight: 500; font-size: 12px; }
.list-table .tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.list-table .tag.pending { background: #fff3cd; color: #856404; }
.list-table .tag.read { background: #d4edda; color: #155724; }

.loading { text-align: center; padding: 40px; color: #999; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid #ddd; border-top-color: #3498db; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; top: 60px; right: 20px; background: #333; color: white; padding: 10px 20px; border-radius: 6px; font-size: 13px; z-index: 1000; opacity: 0; transition: .3s; }
.toast.show { opacity: 1; }

.article-card { background: white; border-radius: 8px; padding: 12px; margin: 4px 0; border: 1px solid #e8e8e8; cursor: pointer; transition: .15s; display: flex; gap: 10px; text-decoration: none; color: inherit; }
.article-card:hover { background: #f8f9fa; }
.article-card .card-thumb { width: 60px; height: 60px; border-radius: 4px; object-fit: cover; flex-shrink: 0; background: #f0f0f0; }
.article-card .card-body { flex: 1; min-width: 0; }
.article-card .card-title { font-size: 13px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-card .card-desc { font-size: 11px; color: #999; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.article-card .card-source { font-size: 10px; color: #bbb; margin-top: 4px; }

.finder-card { background: white; border-radius: 8px; overflow: hidden; margin: 4px 0; border: 1px solid #e8e8e8; cursor: pointer; }
.finder-card .finder-cover { position: relative; width: 100%; aspect-ratio: 9/16; max-height: 280px; background: #000; overflow: hidden; }
.finder-card .finder-cover img { width: 100%; height: 100%; object-fit: cover; }
.finder-card .finder-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 48px; height: 48px; background: rgba(0,0,0,0.6); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.finder-card .finder-play::after { content: ''; border-left: 14px solid white; border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 4px; }
.finder-card .finder-dur { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.7); color: white; font-size: 11px; padding: 2px 6px; border-radius: 3px; }
.finder-card .finder-info { padding: 10px 12px; display: flex; gap: 8px; align-items: flex-start; }
.finder-card .finder-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.finder-card .finder-body { flex: 1; min-width: 0; }
.finder-card .finder-nick { font-size: 12px; font-weight: 600; color: #576b95; }
.finder-card .finder-desc { font-size: 12px; color: #333; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.msg-image-wrap { position: relative; display: inline-block; max-width: 300px; }
.msg-image-wrap img { width: 100%; border-radius: 6px; cursor: pointer; }
.msg-image-wrap .dl-hint { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,0.6); color: white; font-size: 10px; padding: 2px 6px; border-radius: 3px; opacity: 0; transition: .2s; }
.msg-image-wrap:hover .dl-hint { opacity: 1; }

.img-modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); z-index: 999; align-items: center; justify-content: center; flex-direction: column; }
.img-modal img { max-width: 95%; max-height: 80%; border-radius: 4px; }
.img-modal .dl-btn { margin-top: 12px; padding: 8px 20px; background: #3498db; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; }
.img-modal .dl-btn:hover { background: #2980b9; }

@media (max-width: 768px) {
  .sidebar { width: 100%; height: 40%; }
  .main { height: 60%; }
  .layout { flex-direction: column; }
  .circle-grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>

<!-- Top bar -->
<div class="topbar">
  <button class="menu-btn" onclick="toggleDrawer()" aria-label="菜单">☰</button>
  <span class="brand">📱 微信管理</span>
  <span class="brand-sub">{% block page_title %}{% endblock %}</span>
  {% block topbar_extra %}{% endblock %}
  <span class="spacer"></span>
  <select id="accountSwitcher" onchange="switchAccount(this.value)">
    <option value="">加载中...</option>
  </select>
</div>

<!-- Overlay -->
<div class="overlay" id="overlay" onclick="closeDrawer()"></div>

<!-- Drawer -->
<div class="drawer" id="drawer">
  <div class="drawer-header">
    <div class="d-brand">📱 微信管理</div>
    <div class="d-sub">WeChat Viewer</div>
  </div>
  <div class="drawer-nav">
    {% if session.get('role') != 'boss' %}
    <a href="/dashboard" class="{% if request.path == '/dashboard' %}active{% endif %}">
      <span class="icon">📊</span> 数据看板
    </a>
    <a href="/chat" class="{% if request.path == '/chat' %}active{% endif %}">
      <span class="icon">🤖</span> AI 对话
    </a>
    <a href="/" class="{% if request.path == '/' %}active{% endif %}">
      <span class="icon">💬</span> 消息
    </a>
    <a href="/articles" class="{% if request.path == '/articles' %}active{% endif %}">
      <span class="icon">📰</span> 文章列表
    </a>
    <a href="/reports" class="{% if request.path == '/reports' %}active{% endif %}">
      <span class="icon">📋</span> 日报列表
    </a>
    <a href="/report-images" class="{% if request.path == '/report-images' %}active{% endif %}">
      <span class="icon">🖼</span> 日报图片
    </a>
    <a href="/jobs" class="{% if request.path.startswith('/job') %}active{% endif %}">
      <span class="icon">🔧</span> 任务监控
    </a>
    <a href="/learn" class="{% if request.path == '/learn' %}active{% endif %}">
      <span class="icon">📚</span> 学习管线
    </a>
    <a href="/skills" class="{% if request.path.startswith('/skill') %}active{% endif %}">
      <span class="icon">🧩</span> Skills
    </a>
    <a href="/agents" class="{% if request.path.startswith('/agent') %}active{% endif %}">
      <span class="icon">🤖</span> Agents
    </a>
    <a href="/approvals" class="{% if request.path.startswith('/approval') %}active{% endif %}">
      <span class="icon">✅</span> 自动回复审批
    </a>
    <a href="/whitelist" class="{% if request.path.startswith('/whitelist') %}active{% endif %}">
      <span class="icon">⭐</span> 回复白名单
    </a>
    <a href="/cron" class="{% if request.path.startswith('/cron') %}active{% endif %}">
      <span class="icon">⏱</span> Cron 管理
    </a>
    <a href="/ops" class="{% if request.path.startswith('/ops') %}active{% endif %}">
      <span class="icon">🛠</span> 后台监管
    </a>
    {% endif %}
    <a href="/boss-jobs" class="{% if request.path.startswith('/boss-job') or request.path == '/boss-jobs' %}active{% endif %}">
      <span class="icon">🏢</span> BOSS 岗位
    </a>
    <a href="/resumes" class="{% if request.path.startswith('/resume') %}active{% endif %}">
      <span class="icon">📄</span> 简历筛选
    </a>
  </div>
  <div class="drawer-footer">
    <select id="drawerAccountSwitcher" onchange="switchAccount(this.value)">
      <option value="">加载中...</option>
    </select>
  </div>
</div>

<script>
function toggleDrawer() {
  var d = document.getElementById('drawer');
  var o = document.getElementById('overlay');
  if (d.classList.contains('open')) { closeDrawer(); }
  else { d.classList.add('open'); o.classList.add('show'); }
}
function closeDrawer() {
  document.getElementById('drawer').classList.remove('open');
  document.getElementById('overlay').classList.remove('show');
}

async function loadAccounts(){
  try{var r=await fetch('/api/accounts');var j=await r.json();
    if(j.ok){
      var opts='';
      for(var i=0;i<j.data.accounts.length;i++){var a=j.data.accounts[i];
        opts+='<option value="'+a.id+'"'+(a.id===j.data.current?' selected':'')+'>'+escHtml(a.name)+'</option>';
      }
      document.getElementById('accountSwitcher').innerHTML=opts;
      document.getElementById('drawerAccountSwitcher').innerHTML=opts;
    }
  }catch(e){}
}
async function switchAccount(id){
  try{await fetch('/api/accounts/switch',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({account_id:id})});
    location.reload();
  }catch(e){}
}
function escHtml(s){return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');}

loadAccounts();

// Close drawer on swipe-right (mobile)
var touchStartX=0;
document.addEventListener('touchstart',function(e){touchStartX=e.touches[0].clientX});
document.addEventListener('touchend',function(e){
  var dx=e.changedTouches[0].clientX-touchStartX;
  if(dx>80&&touchStartX<30)closeDrawer();
});
</script>

<div class="main">
{% block body %}{% endblock %}
</div>

</body>
</html>