2251 lines
91 KiB
HTML
2251 lines
91 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||
<meta http-equiv="Pragma" content="no-cache" />
|
||
<meta http-equiv="Expires" content="0" />
|
||
<title>抖音自动续火花 · Douyin Cloud Streak</title>
|
||
<link rel="stylesheet" href="/static/vendor/element-plus.css" />
|
||
<style>
|
||
/* ==========================================================================
|
||
经典简约曜黑 / 现代极简移动端高保真设计体系 (Clean Black & White)
|
||
========================================================================== */
|
||
:root {
|
||
--bg-page: #f8fafc;
|
||
--bg-surface: #ffffff;
|
||
--bg-surface-subtle: #f1f5f9;
|
||
--bg-surface-hover: #e2e8f0;
|
||
|
||
--border-color: #e2e8f0;
|
||
--border-dark: #cbd5e1;
|
||
--border-focus: #0f172a;
|
||
|
||
--text-main: #0f172a;
|
||
--text-regular: #334155;
|
||
--text-muted: #64748b;
|
||
--text-light: #94a3b8;
|
||
|
||
--color-primary: #0f172a;
|
||
--color-fire: #ea580c;
|
||
--color-success: #16a34a;
|
||
--color-warning: #d97706;
|
||
--color-danger: #dc2626;
|
||
|
||
--font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", Roboto, "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
||
--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
||
|
||
--radius-sm: 6px;
|
||
--radius-md: 10px;
|
||
--radius-lg: 14px;
|
||
--radius-full: 9999px;
|
||
|
||
--shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
|
||
--transition: all 0.15s ease;
|
||
}
|
||
|
||
*, *::before, *::after {
|
||
box-sizing: border-box;
|
||
margin: 0;
|
||
padding: 0;
|
||
}
|
||
|
||
html, body {
|
||
width: 100%;
|
||
max-width: 100vw;
|
||
overflow-x: hidden;
|
||
background-color: var(--bg-page);
|
||
font-family: var(--font-family);
|
||
color: var(--text-main);
|
||
-webkit-font-smoothing: antialiased;
|
||
-moz-osx-font-smoothing: grayscale;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
/* 滚动条 */
|
||
::-webkit-scrollbar { width: 5px; height: 5px; }
|
||
::-webkit-scrollbar-track { background: transparent; }
|
||
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: var(--radius-full); }
|
||
|
||
/* ==========================================================================
|
||
顶部导航栏 (Compact Responsive Header)
|
||
========================================================================== */
|
||
.topbar {
|
||
position: sticky;
|
||
top: 0;
|
||
z-index: 100;
|
||
background: #ffffff;
|
||
border-bottom: 1px solid var(--border-color);
|
||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
|
||
width: 100%;
|
||
}
|
||
.topbar-inner {
|
||
max-width: 1200px;
|
||
margin: 0 auto;
|
||
padding: 0 16px;
|
||
height: 54px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 10px;
|
||
flex-wrap: nowrap;
|
||
}
|
||
.brand {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
flex-shrink: 0;
|
||
}
|
||
.brand-icon {
|
||
width: 30px;
|
||
height: 30px;
|
||
border-radius: 8px;
|
||
background: #0f172a;
|
||
color: #ea580c;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
.brand-title {
|
||
font-size: 15px;
|
||
font-weight: 700;
|
||
color: #0f172a;
|
||
letter-spacing: -0.01em;
|
||
white-space: nowrap;
|
||
}
|
||
.topbar-right {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
flex-shrink: 0;
|
||
}
|
||
.status-pill {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 5px;
|
||
padding: 3px 8px;
|
||
border-radius: 999px;
|
||
font-size: 11.5px;
|
||
font-weight: 500;
|
||
white-space: nowrap;
|
||
}
|
||
.status-pill.status-ok {
|
||
background: #dcfce7;
|
||
color: #166534;
|
||
}
|
||
.status-pill.status-bad {
|
||
background: #fee2e2;
|
||
color: #991b1b;
|
||
}
|
||
.status-dot {
|
||
width: 6px;
|
||
height: 6px;
|
||
border-radius: 50%;
|
||
background: currentColor;
|
||
}
|
||
.btn-icon-top {
|
||
width: 30px;
|
||
height: 30px;
|
||
border-radius: 6px;
|
||
border: 1px solid #e2e8f0;
|
||
background: #ffffff;
|
||
color: #334155;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
cursor: pointer;
|
||
padding: 0;
|
||
transition: all 0.15s ease;
|
||
-webkit-tap-highlight-color: transparent;
|
||
}
|
||
.btn-icon-top:active {
|
||
background: #f1f5f9;
|
||
}
|
||
|
||
/* ==========================================================================
|
||
页面主体布局
|
||
========================================================================== */
|
||
.app-container {
|
||
max-width: 1200px;
|
||
margin: 0 auto;
|
||
padding: 20px 16px 40px;
|
||
width: 100%;
|
||
}
|
||
.shell {
|
||
display: grid;
|
||
grid-template-columns: 200px 1fr;
|
||
gap: 18px;
|
||
align-items: start;
|
||
width: 100%;
|
||
}
|
||
|
||
/* 侧边导航 */
|
||
.side-nav {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 4px;
|
||
background: var(--bg-surface);
|
||
border: 1px solid var(--border-color);
|
||
border-radius: var(--radius-md);
|
||
padding: 8px;
|
||
box-shadow: var(--shadow-card);
|
||
}
|
||
.nav-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
padding: 10px 12px;
|
||
border-radius: var(--radius-sm);
|
||
border: 1px solid transparent;
|
||
background: transparent;
|
||
color: var(--text-regular);
|
||
font-size: 13.5px;
|
||
font-weight: 500;
|
||
cursor: pointer;
|
||
text-align: left;
|
||
transition: var(--transition);
|
||
white-space: nowrap;
|
||
user-select: none;
|
||
-webkit-tap-highlight-color: transparent;
|
||
}
|
||
.nav-btn:hover {
|
||
background: var(--bg-surface-subtle);
|
||
color: var(--text-main);
|
||
}
|
||
.nav-btn.active {
|
||
background: #0f172a;
|
||
color: #ffffff;
|
||
font-weight: 600;
|
||
}
|
||
.nav-btn .icon {
|
||
width: 17px;
|
||
height: 17px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* ==========================================================================
|
||
卡片容器 (Cards)
|
||
========================================================================== */
|
||
.main-view {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 16px;
|
||
width: 100%;
|
||
min-width: 0;
|
||
}
|
||
.card {
|
||
background: var(--bg-surface);
|
||
border: 1px solid var(--border-color);
|
||
border-radius: var(--radius-md);
|
||
box-shadow: var(--shadow-card);
|
||
padding: 20px 22px;
|
||
width: 100%;
|
||
}
|
||
.card-header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 16px;
|
||
padding-bottom: 12px;
|
||
border-bottom: 1px solid var(--border-color);
|
||
}
|
||
.card-title {
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
color: var(--text-main);
|
||
margin: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
.card-desc {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
margin: 3px 0 0;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
/* 数据指标看板 */
|
||
.stats-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(4, 1fr);
|
||
gap: 12px;
|
||
width: 100%;
|
||
}
|
||
.stat-box {
|
||
background: var(--bg-surface);
|
||
border: 1px solid var(--border-color);
|
||
border-radius: var(--radius-md);
|
||
padding: 14px 16px;
|
||
box-shadow: var(--shadow-card);
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 3px;
|
||
transition: var(--transition);
|
||
}
|
||
.stat-label {
|
||
font-size: 12px;
|
||
font-weight: 500;
|
||
color: var(--text-muted);
|
||
}
|
||
.stat-value {
|
||
font-size: 19px;
|
||
font-weight: 700;
|
||
font-variant-numeric: tabular-nums;
|
||
color: var(--text-main);
|
||
display: flex;
|
||
align-items: baseline;
|
||
gap: 5px;
|
||
}
|
||
|
||
/* 按钮体系 */
|
||
.btn-action-primary {
|
||
background: #0f172a !important;
|
||
color: #ffffff !important;
|
||
border: 1px solid #0f172a !important;
|
||
border-radius: var(--radius-sm) !important;
|
||
font-weight: 600 !important;
|
||
transition: var(--transition) !important;
|
||
}
|
||
.btn-action-primary:hover {
|
||
background: #1e293b !important;
|
||
border-color: #1e293b !important;
|
||
}
|
||
.btn-action-fire {
|
||
background: #ea580c !important;
|
||
color: #ffffff !important;
|
||
border: 1px solid #ea580c !important;
|
||
border-radius: var(--radius-sm) !important;
|
||
font-weight: 600 !important;
|
||
transition: var(--transition) !important;
|
||
}
|
||
.btn-action-fire:hover {
|
||
background: #c2410c !important;
|
||
border-color: #c2410c !important;
|
||
}
|
||
|
||
/* ==========================================================================
|
||
桌面端与手机端好友列表
|
||
========================================================================== */
|
||
.desktop-only-table { display: block; }
|
||
.mobile-only-cards { display: none; }
|
||
|
||
.table-box {
|
||
border: 1px solid var(--border-color);
|
||
border-radius: var(--radius-sm);
|
||
overflow: hidden;
|
||
background: #ffffff;
|
||
width: 100%;
|
||
}
|
||
.el-table {
|
||
--el-table-bg-color: #ffffff !important;
|
||
--el-table-tr-bg-color: #ffffff !important;
|
||
--el-table-header-bg-color: #f8fafc !important;
|
||
--el-table-row-hover-bg-color: #f1f5f9 !important;
|
||
--el-table-border-color: #f1f5f9 !important;
|
||
font-size: 13.5px;
|
||
}
|
||
|
||
/* 手机端精美卡片式好友列表项 */
|
||
.contact-card-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
background: #ffffff;
|
||
border: 1px solid #e2e8f0;
|
||
border-radius: 8px;
|
||
padding: 10px 12px;
|
||
transition: all 0.15s ease;
|
||
user-select: none;
|
||
-webkit-tap-highlight-color: transparent;
|
||
cursor: pointer;
|
||
width: 100%;
|
||
}
|
||
.contact-card-row:active {
|
||
background: #f8fafc;
|
||
}
|
||
.contact-card-row.is-selected {
|
||
border-color: #0f172a;
|
||
background: #f8fafc;
|
||
}
|
||
.chk-wrap {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
.avatar-badge {
|
||
width: 32px;
|
||
height: 32px;
|
||
border-radius: 50%;
|
||
background: #f1f5f9;
|
||
color: #0f172a;
|
||
font-weight: 700;
|
||
font-size: 13px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
border: 1px solid #e2e8f0;
|
||
}
|
||
.contact-avatar-img,
|
||
.table-avatar {
|
||
width: 36px;
|
||
height: 36px;
|
||
border-radius: 50%;
|
||
object-fit: cover;
|
||
flex-shrink: 0;
|
||
border: 1px solid #e2e8f0;
|
||
background: #f1f5f9;
|
||
}
|
||
.user-meta {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 2px;
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
.user-name {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: #0f172a;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.user-sub {
|
||
font-size: 11.5px;
|
||
color: #64748b;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.pill-group {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 5px;
|
||
flex-shrink: 0;
|
||
}
|
||
.spark-pill {
|
||
color: #ea580c;
|
||
background: #fff7ed;
|
||
border: 1px solid #fed7aa;
|
||
padding: 2px 6px;
|
||
border-radius: 12px;
|
||
font-size: 11.5px;
|
||
font-weight: 600;
|
||
white-space: nowrap;
|
||
}
|
||
.no-spark-pill {
|
||
color: #94a3b8;
|
||
background: #f8fafc;
|
||
border: 1px solid #e2e8f0;
|
||
padding: 2px 6px;
|
||
border-radius: 12px;
|
||
font-size: 11px;
|
||
white-space: nowrap;
|
||
}
|
||
.status-pill-sub {
|
||
font-size: 11px;
|
||
padding: 2px 6px;
|
||
border-radius: 4px;
|
||
font-weight: 500;
|
||
white-space: nowrap;
|
||
}
|
||
.status-pill-sub.success {
|
||
background: #dcfce7;
|
||
color: #15803d;
|
||
}
|
||
.status-pill-sub.failed {
|
||
background: #fee2e2;
|
||
color: #b91c1c;
|
||
}
|
||
.status-pill-sub.pending {
|
||
background: #f1f5f9;
|
||
color: #64748b;
|
||
}
|
||
|
||
/* 日志控制台 */
|
||
.terminal-box {
|
||
background: #0f172a;
|
||
border: 1px solid #1e293b;
|
||
border-radius: var(--radius-sm);
|
||
overflow: hidden;
|
||
width: 100%;
|
||
}
|
||
.terminal-header {
|
||
background: #1e293b;
|
||
padding: 8px 14px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
color: #94a3b8;
|
||
font-size: 12px;
|
||
font-family: var(--font-mono);
|
||
}
|
||
.terminal-body {
|
||
margin: 0;
|
||
padding: 14px;
|
||
font-family: var(--font-mono);
|
||
font-size: 12.5px;
|
||
line-height: 1.6;
|
||
color: #e2e8f0;
|
||
height: 380px;
|
||
overflow-y: auto;
|
||
white-space: pre-wrap;
|
||
word-break: break-all;
|
||
}
|
||
|
||
/* Element Plus 适配 */
|
||
.el-input__wrapper, .el-textarea__inner {
|
||
background-color: #ffffff !important;
|
||
border: 1px solid var(--border-color) !important;
|
||
box-shadow: none !important;
|
||
border-radius: var(--radius-sm) !important;
|
||
color: var(--text-main) !important;
|
||
font-size: 14px;
|
||
}
|
||
.el-form-item__label {
|
||
color: var(--text-main) !important;
|
||
font-weight: 500;
|
||
font-size: 13.5px;
|
||
}
|
||
.el-button {
|
||
border-radius: var(--radius-sm) !important;
|
||
font-weight: 500;
|
||
}
|
||
.icon-svg {
|
||
width: 15px;
|
||
height: 15px;
|
||
display: inline-block;
|
||
vertical-align: middle;
|
||
fill: currentColor;
|
||
}
|
||
|
||
/* ==========================================================================
|
||
📱 移动端针对性重构 (Mobile Optimization)
|
||
========================================================================== */
|
||
@media (max-width: 768px) {
|
||
.app-container {
|
||
padding: 12px 10px calc(76px + env(safe-area-inset-bottom)) 10px;
|
||
}
|
||
.shell {
|
||
grid-template-columns: 1fr;
|
||
gap: 12px;
|
||
}
|
||
|
||
/* 顶栏:手机端压缩 + 允许换行,防止右上角用户菜单溢出屏幕点不到 */
|
||
.topbar-inner {
|
||
height: auto;
|
||
min-height: 50px;
|
||
flex-wrap: wrap;
|
||
padding: 6px 10px;
|
||
row-gap: 6px;
|
||
}
|
||
.brand-icon {
|
||
width: 26px;
|
||
height: 26px;
|
||
border-radius: 7px;
|
||
}
|
||
.brand-title {
|
||
font-size: 13px;
|
||
}
|
||
.topbar-right {
|
||
gap: 5px;
|
||
min-width: 0;
|
||
}
|
||
.topbar-right .status-pill {
|
||
display: none; /* 概览页已有登录状态,顶栏省空间 */
|
||
}
|
||
.topbar-right .el-select {
|
||
width: 96px !important;
|
||
}
|
||
.topbar-right .btn-icon-top {
|
||
width: 28px;
|
||
height: 28px;
|
||
}
|
||
.topbar-right .el-button {
|
||
padding: 0 6px !important;
|
||
font-size: 11px !important;
|
||
}
|
||
.user-chip {
|
||
padding: 0 7px;
|
||
}
|
||
.user-chip .user-name {
|
||
max-width: 64px;
|
||
font-size: 11.5px;
|
||
}
|
||
|
||
/* 底部固定导航栏 */
|
||
.side-nav {
|
||
position: fixed !important;
|
||
bottom: 0 !important;
|
||
left: 0 !important;
|
||
right: 0 !important;
|
||
width: 100vw !important;
|
||
max-width: 100vw !important;
|
||
box-sizing: border-box !important;
|
||
z-index: 9999 !important;
|
||
border-radius: 0 !important;
|
||
border: none !important;
|
||
border-top: 1px solid var(--border-color) !important;
|
||
background: rgba(255, 255, 255, 0.96) !important;
|
||
backdrop-filter: blur(16px) !important;
|
||
-webkit-backdrop-filter: blur(16px) !important;
|
||
padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) 8px !important;
|
||
box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06) !important;
|
||
flex-direction: row !important;
|
||
justify-content: space-around !important;
|
||
gap: 4px !important;
|
||
transform: translateZ(0) !important;
|
||
}
|
||
.nav-btn {
|
||
flex-direction: column;
|
||
gap: 3px;
|
||
padding: 6px 2px;
|
||
font-size: 11px;
|
||
text-align: center;
|
||
align-items: center;
|
||
flex: 1;
|
||
border-radius: var(--radius-sm);
|
||
}
|
||
.nav-btn .icon {
|
||
width: 18px;
|
||
height: 18px;
|
||
}
|
||
.nav-btn.active {
|
||
background: #0f172a;
|
||
color: #ffffff;
|
||
}
|
||
|
||
/* 隐藏桌面大表格,显示手机端轻量卡片 */
|
||
.desktop-only-table {
|
||
display: none !important;
|
||
}
|
||
.mobile-only-cards {
|
||
display: flex !important;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
max-height: 480px;
|
||
overflow-y: auto;
|
||
-webkit-overflow-scrolling: touch;
|
||
padding-bottom: 6px;
|
||
}
|
||
|
||
/* 2x2 数据看板 */
|
||
.stats-grid {
|
||
grid-template-columns: repeat(2, 1fr);
|
||
gap: 8px;
|
||
}
|
||
.stat-box {
|
||
padding: 12px 12px;
|
||
}
|
||
.stat-label {
|
||
font-size: 11px;
|
||
}
|
||
.stat-value {
|
||
font-size: 17px;
|
||
}
|
||
|
||
/* 卡片与按钮组优化 */
|
||
.card {
|
||
padding: 14px 14px;
|
||
border-radius: var(--radius-sm);
|
||
}
|
||
.card-header {
|
||
flex-direction: column;
|
||
align-items: stretch;
|
||
gap: 12px;
|
||
margin-bottom: 12px;
|
||
}
|
||
.card-title {
|
||
font-size: 14px;
|
||
}
|
||
|
||
.mobile-action-grid {
|
||
display: grid !important;
|
||
grid-template-columns: repeat(2, 1fr) !important;
|
||
gap: 8px !important;
|
||
width: 100% !important;
|
||
}
|
||
.mobile-action-grid .el-button {
|
||
margin: 0 !important;
|
||
width: 100% !important;
|
||
height: 38px !important;
|
||
font-size: 13px !important;
|
||
}
|
||
.mobile-full-btn {
|
||
width: 100% !important;
|
||
margin: 0 !important;
|
||
}
|
||
.mobile-stack-grid {
|
||
grid-template-columns: 1fr !important;
|
||
gap: 8px !important;
|
||
}
|
||
|
||
.terminal-body {
|
||
height: 280px;
|
||
font-size: 11.5px;
|
||
padding: 10px;
|
||
}
|
||
}
|
||
|
||
/* ==========================================================================
|
||
登录 / 注册页
|
||
========================================================================== */
|
||
.auth-page {
|
||
min-height: 100vh;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 16px;
|
||
background:
|
||
radial-gradient(900px 420px at 50% -8%, rgba(234, 88, 12, 0.10) 0%, transparent 62%),
|
||
var(--bg-page);
|
||
}
|
||
.auth-card {
|
||
width: 100%;
|
||
max-width: 380px;
|
||
background: var(--bg-surface);
|
||
border: 1px solid var(--border-color);
|
||
border-radius: var(--radius-lg);
|
||
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
|
||
padding: 26px 24px 20px;
|
||
}
|
||
.auth-brand {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 10px;
|
||
margin-bottom: 18px;
|
||
text-align: center;
|
||
}
|
||
.auth-brand .brand-icon { width: 44px; height: 44px; border-radius: 12px; }
|
||
.auth-title { font-size: 17px; font-weight: 700; color: var(--text-main); }
|
||
.auth-subtitle { font-size: 12.5px; color: var(--text-muted); }
|
||
.user-chip {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 5px;
|
||
padding: 0 9px;
|
||
}
|
||
.user-name {
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: var(--text-main);
|
||
max-width: 90px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="app">
|
||
<!-- 登录 / 注册页(未登录时全屏显示) -->
|
||
<div v-if="!authed" class="auth-page">
|
||
<div class="auth-card">
|
||
<div class="auth-brand">
|
||
<div class="brand-icon" v-html="ICONS.fire" aria-hidden="true"></div>
|
||
<div class="auth-title">抖音自动续火花</div>
|
||
<div class="auth-subtitle">登录后管理你的抖音账号续火花</div>
|
||
</div>
|
||
<el-tabs v-model="authMode" stretch>
|
||
<el-tab-pane label="登录" name="login">
|
||
<el-form label-position="top" @submit.prevent>
|
||
<el-form-item label="用户名">
|
||
<el-input v-model="loginForm.username" placeholder="用户名" clearable @keyup.enter="doLogin" />
|
||
</el-form-item>
|
||
<el-form-item label="密码">
|
||
<el-input v-model="loginForm.password" type="password" show-password placeholder="密码" @keyup.enter="doLogin" />
|
||
</el-form-item>
|
||
<el-button type="primary" class="btn-action-primary" style="width: 100%;" :loading="authBusy" @click="doLogin">
|
||
登 录
|
||
</el-button>
|
||
</el-form>
|
||
</el-tab-pane>
|
||
<el-tab-pane label="注册" name="register">
|
||
<el-form label-position="top" @submit.prevent>
|
||
<el-form-item label="用户名">
|
||
<el-input v-model="regForm.username" placeholder="2~32 位中文 / 字母 / 数字 / 下划线" clearable maxlength="32" />
|
||
</el-form-item>
|
||
<el-form-item label="密码">
|
||
<el-input v-model="regForm.password" type="password" show-password placeholder="至少 6 位" @keyup.enter="doRegister" />
|
||
</el-form-item>
|
||
<el-form-item label="确认密码">
|
||
<el-input v-model="regForm.confirm" type="password" show-password placeholder="再输入一次密码" @keyup.enter="doRegister" />
|
||
</el-form-item>
|
||
<el-button type="primary" class="btn-action-primary" style="width: 100%;" :loading="authBusy" @click="doRegister">
|
||
注册并登录
|
||
</el-button>
|
||
</el-form>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
</div>
|
||
</div>
|
||
|
||
<template v-else>
|
||
<!-- 顶部导航栏 -->
|
||
<header class="topbar">
|
||
<div class="topbar-inner">
|
||
<div class="brand">
|
||
<div class="brand-icon" v-html="ICONS.fire" aria-hidden="true"></div>
|
||
<span class="brand-title">抖音自动续火花</span>
|
||
</div>
|
||
<div class="topbar-right">
|
||
<el-select
|
||
v-model="currentAccountId"
|
||
size="small"
|
||
placeholder="选择账号"
|
||
style="width: 130px; flex-shrink: 0;"
|
||
@change="switchAccount"
|
||
>
|
||
<el-option
|
||
v-for="acc in accounts"
|
||
:key="acc.id"
|
||
:label="(acc.is_default ? '★ ' : '') + acc.name"
|
||
:value="acc.id"
|
||
/>
|
||
</el-select>
|
||
<span class="status-pill" :class="status.state_file_exists ? 'status-ok' : 'status-bad'">
|
||
<span class="status-dot"></span>
|
||
{{ status.state_file_exists ? '已就绪' : '未登录' }}
|
||
</span>
|
||
<el-button v-if="status.running" size="small" type="danger" plain @click="resetRunningState" style="padding: 0 8px; height: 26px; font-size: 11px;">
|
||
强制重置
|
||
</el-button>
|
||
<button type="button" class="btn-icon-top" title="刷新状态" @click="loadAll">
|
||
<span class="icon-svg" v-html="ICONS.reload"></span>
|
||
</button>
|
||
<el-dropdown trigger="click" @command="onUserCommand">
|
||
<button type="button" class="btn-icon-top user-chip" :title="'当前用户:' + me.username">
|
||
<span class="icon-svg" v-html="ICONS.user"></span>
|
||
<span class="user-name">{{ me.username }}</span>
|
||
</button>
|
||
<template #dropdown>
|
||
<el-dropdown-menu>
|
||
<el-dropdown-item disabled>
|
||
{{ me.role === 'admin' ? '🛡️ 管理员' : '👤 用户' }}:{{ me.username }}
|
||
</el-dropdown-item>
|
||
<el-dropdown-item divided command="password">修改密码</el-dropdown-item>
|
||
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
|
||
</el-dropdown-menu>
|
||
</template>
|
||
</el-dropdown>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
<!-- 主体容器 -->
|
||
<div class="app-container">
|
||
<div v-if="accounts.length === 0" class="card" style="max-width: 520px; margin: 48px auto; text-align: center; padding: 40px 24px;">
|
||
<h3 class="card-title" style="justify-content: center;">🫥 还没有可用的抖音账号</h3>
|
||
<p class="card-desc" style="margin-top: 10px; line-height: 1.8;">
|
||
<template v-if="me.role === 'admin'">
|
||
点击左侧「账号」标签即可新建第一个抖音账号。<br />已有旧数据?重启服务后历史账号会自动归管理员所有。
|
||
</template>
|
||
<template v-else>
|
||
您的账号尚未分配抖音账号。<br />请联系管理员在「用户管理」中为您分配,分配后刷新页面即可。
|
||
</template>
|
||
</p>
|
||
</div>
|
||
<div v-else class="shell">
|
||
<!-- 侧边 / 底部导航栏 -->
|
||
<nav class="side-nav" aria-label="功能导航">
|
||
<button
|
||
v-for="item in navItems"
|
||
:key="item.name"
|
||
type="button"
|
||
class="nav-btn"
|
||
:class="{ active: tab === item.name }"
|
||
@click="tab = item.name"
|
||
>
|
||
<span class="icon" v-html="ICONS[item.icon]" aria-hidden="true"></span>
|
||
<span>{{ item.label }}</span>
|
||
</button>
|
||
</nav>
|
||
|
||
<!-- 主视图区 -->
|
||
<main class="main-view">
|
||
<!-- 0. 账号管理页(仅管理员) -->
|
||
<div v-if="me.role === 'admin'" v-show="tab === 'accounts'">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">👤 多账号管理</h3>
|
||
<p class="card-desc">每个账号拥有独立的登录凭证、配置与好友台账,互不干扰;全局最多 {{ maxConcurrent }} 个浏览器并发运行。</p>
|
||
</div>
|
||
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
|
||
<el-button type="primary" size="small" class="btn-action-primary" @click="accountDialogVisible = true">
|
||
+ 新建账号
|
||
</el-button>
|
||
<el-button size="small" @click="loadAccounts">刷新</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="accounts.length === 0" style="text-align: center; padding: 30px; color: var(--text-muted); font-size: 13px;">
|
||
暂无账号,点击「新建账号」添加第一个账号。
|
||
</div>
|
||
|
||
<div class="mobile-stack-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px;">
|
||
<div
|
||
v-for="acc in accounts"
|
||
:key="acc.id"
|
||
class="contact-card-row"
|
||
style="align-items: flex-start; cursor: default; flex-direction: column; gap: 8px;"
|
||
:style="currentAccountId === acc.id ? 'border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary);' : ''"
|
||
>
|
||
<div style="display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px;">
|
||
<div style="font-weight: 600; font-size: 14px; color: var(--text-main);">
|
||
{{ acc.is_default ? '★ ' : '' }}{{ acc.name }}
|
||
<span v-if="acc.is_default" style="font-size: 11px; color: var(--text-light); font-weight: 400;">(默认)</span>
|
||
</div>
|
||
<el-switch
|
||
v-model="acc.enabled"
|
||
:disabled="acc.is_default"
|
||
active-text="启用"
|
||
inactive-text="停用"
|
||
style="transform: scale(0.85);"
|
||
@change="updateAccountMeta(acc)"
|
||
/>
|
||
</div>
|
||
|
||
<div style="font-size: 12px; color: var(--text-muted); width: 100%;">
|
||
<div>账号 ID:<code style="font-size: 11px;">{{ acc.id }}</code></div>
|
||
<div style="margin-top: 2px;">登录态:{{ acc.state_file_exists ? '✓ 已就绪' : '✗ 未上传' }}</div>
|
||
<div style="margin-top: 2px;">会话状态:{{ sessionText(acc) }}</div>
|
||
<div v-if="acc.next_run" style="margin-top: 2px;">下次定时:{{ formatTime(acc.next_run) }}</div>
|
||
<div v-if="acc.device" style="margin-top: 2px;">备注:{{ acc.device }}</div>
|
||
</div>
|
||
|
||
<div style="display: flex; gap: 6px; flex-wrap: wrap; width: 100%;">
|
||
<el-button size="small" :type="currentAccountId === acc.id ? 'primary' : 'default'" @click="switchAccount(acc.id)">
|
||
{{ currentAccountId === acc.id ? '当前查看' : '切换到此账号' }}
|
||
</el-button>
|
||
<el-button v-if="!acc.is_default" size="small" type="danger" plain @click="removeAccount(acc)">
|
||
删除
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 并发状态提示 -->
|
||
<div class="card" style="margin-top: 12px;">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">⚙️ 全局并发状态</h3>
|
||
<p class="card-desc">同时运行的浏览器会话数受全局上限保护,超出后新任务会自动排队等待。</p>
|
||
</div>
|
||
</div>
|
||
<div style="font-size: 13px; color: var(--text-regular);">
|
||
并发上限:<strong>{{ maxConcurrent }}</strong> 个浏览器会话 · 当前可用:<strong>{{ browserSlotsAvailable }}</strong>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 0.5 用户管理页(仅管理员) -->
|
||
<div v-if="me.role === 'admin'" v-show="tab === 'users'">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">🛡️ 用户管理</h3>
|
||
<p class="card-desc">创建登录用户并把抖音账号分配给他们:普通用户只能查看/操作被分配的账号,未分配则看不到任何数据。历史旧账号默认全部归管理员。</p>
|
||
</div>
|
||
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
|
||
<el-button type="primary" size="small" class="btn-action-primary" @click="userDialogVisible = true">
|
||
+ 新建用户
|
||
</el-button>
|
||
<el-button size="small" @click="loadUsers">刷新</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="users.length === 0" style="text-align: center; padding: 30px; color: var(--text-muted); font-size: 13px;">
|
||
暂无用户,点击「新建用户」创建第一个登录账号。
|
||
</div>
|
||
|
||
<div class="mobile-stack-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px;">
|
||
<div
|
||
v-for="u in users"
|
||
:key="u.username"
|
||
class="contact-card-row"
|
||
style="align-items: flex-start; cursor: default; flex-direction: column; gap: 8px;"
|
||
>
|
||
<div style="display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px;">
|
||
<div style="font-weight: 600; font-size: 14px; color: var(--text-main);">
|
||
{{ u.username }}
|
||
<el-tag v-if="u.is_admin" size="small" type="warning" effect="plain">管理员</el-tag>
|
||
</div>
|
||
<el-switch
|
||
v-model="u.is_admin"
|
||
:disabled="u.username === me.username"
|
||
active-text="管理员"
|
||
style="transform: scale(0.85);"
|
||
@change="saveUser(u)"
|
||
/>
|
||
</div>
|
||
|
||
<div style="font-size: 12px; color: var(--text-muted); width: 100%;">
|
||
<div>可访问账号:<span v-if="u.is_admin" style="color: var(--text-regular);">全部账号(管理员)</span><template v-else>{{ accountNames(u.account_ids) }}</template></div>
|
||
<div style="margin-top: 2px;">创建于 {{ (u.created_at || '').replace('T', ' ').slice(0, 16) }}</div>
|
||
</div>
|
||
|
||
<div v-if="!u.is_admin" style="display: flex; gap: 6px; flex-wrap: wrap; width: 100%; align-items: center;">
|
||
<el-select
|
||
v-model="u.account_ids"
|
||
multiple
|
||
size="small"
|
||
placeholder="分配可访问的账号"
|
||
style="flex: 1; min-width: 170px;"
|
||
@change="saveUser(u)"
|
||
>
|
||
<el-option v-for="acc in accounts" :key="acc.id" :label="acc.name" :value="acc.id" />
|
||
</el-select>
|
||
<el-button size="small" @click="resetUserPassword(u)">重置密码</el-button>
|
||
<el-button size="small" type="danger" plain @click="removeUser(u)">删除</el-button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 1. 运行概览页 -->
|
||
<div v-show="tab === 'overview'">
|
||
<!-- 指标统计条 -->
|
||
<div class="stats-grid" style="margin-bottom: 16px;">
|
||
<div class="stat-box" style="display: flex; align-items: center; justify-content: space-between; gap: 8px;">
|
||
<div>
|
||
<div class="stat-label">登录凭证</div>
|
||
<div class="stat-value" :style="{ color: status.state_file_exists ? '#16a34a' : '#dc2626' }">
|
||
{{ status.state_file_exists ? '已就绪' : '未登录' }}
|
||
</div>
|
||
</div>
|
||
<el-button v-if="!status.state_file_exists" type="danger" size="small" @click="goToCredentials">
|
||
立即登录
|
||
</el-button>
|
||
</div>
|
||
<div class="stat-box">
|
||
<div class="stat-label">守护状态</div>
|
||
<div class="stat-value" :style="{ color: status.running ? '#d97706' : '#0f172a' }">
|
||
{{ status.running ? '执行中' : (config.auto_run_enabled ? '定时就绪' : '已暂停') }}
|
||
</div>
|
||
</div>
|
||
<div class="stat-box">
|
||
<div class="stat-label">已勾选好友</div>
|
||
<div class="stat-value">
|
||
{{ selectedFriendCount }} <span style="font-size: 12px; color: var(--text-muted); font-weight: 400;">/ {{ totalContactCount }} 人</span>
|
||
</div>
|
||
</div>
|
||
<div class="stat-box">
|
||
<div class="stat-label">火花好友</div>
|
||
<div class="stat-value" style="color: #ea580c;">
|
||
{{ sparkFriendCount }} <span style="font-size: 12px; color: var(--text-muted); font-weight: 400;">人</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 未检测到登录凭证时的醒目指引条 -->
|
||
<div v-if="!status.state_file_exists" style="background: #fff1f2; border: 1px solid #fecdd3; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;">
|
||
<div style="font-size: 13px; color: #9f1239; line-height: 1.5;">
|
||
<strong>⚠️ 当前服务器未检测到登录凭证 (state.json):</strong><br />
|
||
已在电脑端提取?请双击电脑上的 <code>4.同步登录态到服务器.bat</code> 一键同步,或在右侧直接上传文件。
|
||
</div>
|
||
<div style="display: flex; gap: 8px;">
|
||
<input type="file" ref="quickFileInput" accept=".json" style="display: none;" @change="handleFileUpload" />
|
||
<el-button type="danger" size="small" @click="$refs.quickFileInput.click()">直接上传 state.json</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 快捷执行面板 -->
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">🔥 立即触发续火花</h3>
|
||
<p class="card-desc">手动启动一次自动化流程,或在下方查看最近执行记录与结果。</p>
|
||
</div>
|
||
<div class="mobile-action-grid" style="display: flex; gap: 8px;">
|
||
<el-button class="btn-action-fire" :disabled="status.running" @click="runStreak(false)">
|
||
<span class="icon-svg" style="margin-right: 4px;" v-html="ICONS.fire"></span>
|
||
{{ status.running ? '任务执行中...' : '立即续火花' }}
|
||
</el-button>
|
||
<el-button :disabled="status.running" @click="runStreak(true)">
|
||
模拟演练 (Dry-Run)
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 最近执行概况 -->
|
||
<div class="mobile-stack-grid" style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; font-size: 13.5px;">
|
||
<div style="background: var(--bg-surface-subtle); padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);">
|
||
<div style="color: var(--text-muted); margin-bottom: 3px; font-size: 12px;">最近一次执行时间</div>
|
||
<div style="font-weight: 600; color: var(--text-main); font-size: 13px;">{{ lastRunInfo.time || '暂无运行记录' }}</div>
|
||
</div>
|
||
<div style="background: var(--bg-surface-subtle); padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);">
|
||
<div style="color: var(--text-muted); margin-bottom: 3px; font-size: 12px;">执行结果简报</div>
|
||
<div style="font-weight: 600; font-size: 13px;" :style="{ color: lastRunInfo.success ? '#16a34a' : '#d97706' }">
|
||
{{ lastRunInfo.summary || '就绪待命' }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 2. 好友与台账页 -->
|
||
<div v-show="tab === 'friends'">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">👥 好友与消息台账</h3>
|
||
<p class="card-desc">自动同步抖音好友列表,一键勾选火花好友,保存后每日定时自动发送。</p>
|
||
</div>
|
||
<div class="mobile-action-grid" style="display: flex; gap: 8px; flex-wrap: wrap;">
|
||
<el-button type="primary" size="small" class="btn-action-primary" :loading="syncing" @click="syncContacts">
|
||
同步联系人
|
||
</el-button>
|
||
<el-button size="small" @click="autoSelectSparkFriends">
|
||
一键勾选火花
|
||
</el-button>
|
||
<el-button size="small" @click="clearSelectedFriends">
|
||
清空勾选
|
||
</el-button>
|
||
<el-button type="success" size="small" :loading="savingLedger" @click="saveLedgerSelection">
|
||
保存勾选配置
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 搜索过滤条 -->
|
||
<div style="margin-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;">
|
||
<el-input
|
||
v-model="searchKeyword"
|
||
placeholder="搜索好友昵称或火花天数..."
|
||
clearable
|
||
size="small"
|
||
style="flex: 1; min-width: 200px;"
|
||
/>
|
||
<div style="font-size: 12.5px; color: var(--text-muted); white-space: nowrap;">
|
||
已勾选 <strong style="color: var(--text-main);">{{ selectedFriendCount }}</strong> 位好友
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 桌面端表格 (屏幕宽度 >= 769px) -->
|
||
<div class="table-box desktop-only-table">
|
||
<el-table :data="filteredContacts" style="width: 100%;" max-height="520">
|
||
<el-table-column width="55" align="center">
|
||
<template #default="{ row }">
|
||
<el-checkbox v-model="row.selected" />
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="nickname" label="好友昵称" min-width="180">
|
||
<template #default="{ row }">
|
||
<div style="display: flex; align-items: center; gap: 10px;">
|
||
<img v-if="row.avatar" :src="row.avatar" class="table-avatar" alt="" @error="row.avatar = ''" />
|
||
<span v-else class="avatar-badge" style="display: inline-flex;">{{ (row.nickname || '?').charAt(0) }}</span>
|
||
<span style="font-weight: 500; color: var(--text-main);">{{ row.nickname }}</span>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="spark_days" label="火花天数" width="130" sortable>
|
||
<template #default="{ row }">
|
||
<span v-if="row.spark_days && row.spark_days > 0" style="color: #ea580c; font-weight: 600;">
|
||
🔥 {{ row.spark_days }} 天
|
||
</span>
|
||
<span v-else style="color: var(--text-light); font-size: 12px;">未点亮</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="last_status" label="最近状态" width="130">
|
||
<template #default="{ row }">
|
||
<el-tag v-if="row.last_status === 'success'" type="success" size="small">成功</el-tag>
|
||
<el-tag v-else-if="row.last_status === 'failed'" type="danger" size="small">失败</el-tag>
|
||
<el-tag v-else type="info" size="small">待发送</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="last_sent_at" label="最后发送时间" width="170">
|
||
<template #default="{ row }">
|
||
<span style="font-size: 12px; color: var(--text-muted);">{{ formatTime(row.last_sent_at) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
|
||
<!-- 手机端专属卡片列表 (屏幕宽度 <= 768px) -->
|
||
<div class="mobile-only-cards">
|
||
<div
|
||
v-for="item in filteredContacts"
|
||
:key="item.display_name"
|
||
class="contact-card-row"
|
||
:class="{ 'is-selected': item.selected }"
|
||
@click="item.selected = !item.selected"
|
||
>
|
||
<div class="chk-wrap" @click.stop>
|
||
<el-checkbox v-model="item.selected" />
|
||
</div>
|
||
<img v-if="item.avatar" :src="item.avatar" class="contact-avatar-img" alt="" @error="item.avatar = ''" />
|
||
<div v-else class="avatar-badge">{{ (item.nickname || '?').charAt(0) }}</div>
|
||
<div class="user-meta">
|
||
<div class="user-name">{{ item.nickname }}</div>
|
||
<div class="user-sub">{{ formatTime(item.last_sent_at) }}</div>
|
||
</div>
|
||
<div class="pill-group">
|
||
<span v-if="item.spark_days > 0" class="spark-pill">
|
||
🔥 {{ item.spark_days }}天
|
||
</span>
|
||
<span v-else class="no-spark-pill">未点亮</span>
|
||
<span class="status-pill-sub" :class="item.last_status || 'pending'">
|
||
{{ item.last_status === 'success' ? '成功' : (item.last_status === 'failed' ? '失败' : '待发') }}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
<div v-if="filteredContacts.length === 0" style="text-align: center; padding: 30px 10px; color: var(--text-muted); font-size: 13px;">
|
||
暂无好友数据,请点击上方「同步联系人」拉取列表
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 3. 定时与风控设置页 -->
|
||
<div v-show="tab === 'settings'">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">⏰ 定时与拟人化风控配置</h3>
|
||
<p class="card-desc">配置每日自动执行时间、随机抖动延迟与安全发送间隔,保护主号安全。</p>
|
||
</div>
|
||
<el-button type="primary" size="small" class="btn-action-primary mobile-full-btn" :loading="savingConfig" @click="saveConfigForm">
|
||
保存设置
|
||
</el-button>
|
||
</div>
|
||
|
||
<el-form label-position="top" style="max-width: 600px;">
|
||
<el-form-item label="每日自动发送时间 (24小时制)">
|
||
<el-input v-model="config.schedule_time" placeholder="例如 21:00" style="max-width: 200px;" />
|
||
<div style="font-size: 12px; color: var(--text-muted); margin-top: 4px;">建议设置在晚间 20:00 ~ 22:30 之间。</div>
|
||
</el-form-item>
|
||
|
||
<el-form-item label="随机时间抖动 (分钟)">
|
||
<el-input-number v-model="config.jitter_minutes" :min="0" :max="60" />
|
||
<div style="font-size: 12px; color: var(--text-muted); margin-top: 4px;">在设定时间的 0 ~ N 分钟内随机启动,模拟真人不规律上线。</div>
|
||
</el-form-item>
|
||
|
||
<div class="mobile-stack-grid" style="display: grid; grid-template-columns: 1fr 1fr; gap: 16px;">
|
||
<el-form-item label="好友发送最小间隔 (秒)">
|
||
<el-input-number v-model="config.send_gap_min" :min="3" :max="30" />
|
||
</el-form-item>
|
||
<el-form-item label="好友发送最大间隔 (秒)">
|
||
<el-input-number v-model="config.send_gap_max" :min="6" :max="60" />
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<el-form-item label="自定义发送文案列表">
|
||
<el-input
|
||
v-model="messagesText"
|
||
type="textarea"
|
||
:rows="4"
|
||
placeholder="每行一条文案,例如: 🔥 续火花 晚上好 🔥 今天也要开心哦 🔥"
|
||
/>
|
||
<div style="font-size: 12px; color: var(--text-muted); margin-top: 4px;">每行一条文案,每日发送时系统将从列表中随机抽取一条发送并自动防重。</div>
|
||
</el-form-item>
|
||
|
||
<el-form-item label="定时任务开关">
|
||
<el-switch v-model="config.auto_run_enabled" active-text="开启每日自动定时执行" />
|
||
</el-form-item>
|
||
</el-form>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 4. 运行日志终端页 -->
|
||
<div v-show="tab === 'logs'">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">💻 当前账号运行日志</h3>
|
||
<p class="card-desc">仅显示当前账号「{{ currentAccount.name }}」自己的自动化执行日志,其他账号日志不可见。</p>
|
||
</div>
|
||
<div style="display: flex; gap: 8px;">
|
||
<el-button size="small" @click="fetchLogs">刷新日志</el-button>
|
||
<el-button size="small" @click="clearLogs">清空显示</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="terminal-box">
|
||
<div class="terminal-header">
|
||
<span>douyin-cloud-streak.log</span>
|
||
<span>UTF-8</span>
|
||
</div>
|
||
<pre class="terminal-body" id="terminal-view">{{ logsContent || '暂无日志输出,点击上方“刷新日志”获取。' }}</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 5. 通行证凭证管理页 -->
|
||
<div v-show="tab === 'credentials'">
|
||
<div class="card">
|
||
<div class="card-header">
|
||
<div>
|
||
<h3 class="card-title">🔑 登录通行证管理</h3>
|
||
<p class="card-desc">管理抖音账号登录凭据 (state.json),支持直接上传通行证文件。</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div style="display: flex; flex-direction: column; gap: 16px; max-width: 520px;">
|
||
<div style="padding: 16px; background: var(--bg-surface-subtle); border-radius: var(--radius-sm); border: 1px solid var(--border-color);">
|
||
<div style="font-size: 14px; font-weight: 600; margin-bottom: 6px;">
|
||
当前账号:<strong>{{ currentAccount.name }}</strong>
|
||
<span style="font-size: 12px; color: var(--text-muted);">({{ currentAccount.id }})</span>
|
||
</div>
|
||
<div style="font-size: 13px; font-weight: 600; margin-bottom: 6px;">
|
||
凭证状态:
|
||
<span :style="{ color: status.state_file_exists ? '#16a34a' : '#dc2626' }">
|
||
{{ status.state_file_exists ? '✓ 已检测到有效登录态' : '✗ 未检测到登录态' }}
|
||
</span>
|
||
</div>
|
||
<div style="font-size: 12.5px; color: var(--text-muted);">
|
||
推荐直接点击下方「手机扫码登录」,服务器会自动生成二维码,手机扫码后凭证自动保存,全程无需电脑。也可以在电脑端双击 <code>1.本地提取通行证.bat</code> 后上传 <code>state.json</code>;凭证过期时同样在网页端重新扫码即可。
|
||
</div>
|
||
</div>
|
||
|
||
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
|
||
<el-button type="primary" class="btn-action-primary mobile-full-btn" @click="openQrLogin">
|
||
手机扫码登录 / 重新验证
|
||
</el-button>
|
||
<input type="file" ref="fileInput" accept=".json" style="display: none;" @change="handleFileUpload" />
|
||
<el-button class="mobile-full-btn" @click="$refs.fileInput.click()">
|
||
上传 state.json 文件
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- 新建账号弹窗 -->
|
||
<el-dialog v-model="accountDialogVisible" title="新建抖音账号" width="90%" style="max-width: 440px;">
|
||
<div style="font-size: 13px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.6;">
|
||
新建后该账号拥有独立的 <code>data/accounts/{id}/</code> 目录(登录凭证、配置、好友台账互不影响),随后请为其上传对应的 <code>state.json</code> 登录凭证。
|
||
</div>
|
||
<el-form label-position="top">
|
||
<el-form-item label="账号名称(必填)">
|
||
<el-input v-model="newAccountName" placeholder="例如:主号 / 小号 / 备用号" clearable maxlength="20" />
|
||
</el-form-item>
|
||
<el-form-item label="备注(可选)">
|
||
<el-input v-model="newAccountDevice" placeholder="例如:日常主用手机 / 工作室电脑" clearable maxlength="50" />
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<div style="display: flex; gap: 8px; justify-content: flex-end;">
|
||
<el-button @click="accountDialogVisible = false">取消</el-button>
|
||
<el-button type="primary" class="btn-action-primary" @click="createAccount">创建账号</el-button>
|
||
</div>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 网页扫码登录弹窗 -->
|
||
<el-dialog
|
||
v-model="qrDialogVisible"
|
||
title="📱 手机扫码登录"
|
||
width="90%"
|
||
style="max-width: 400px; text-align: center;"
|
||
:close-on-click-modal="false"
|
||
@close="cancelLoginPolling"
|
||
>
|
||
<div style="font-size: 13px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.6;">
|
||
为账号 <strong>{{ currentAccount.name }}</strong> 登录抖音。请打开手机抖音 App → 扫一扫,扫描下方二维码并确认登录。
|
||
</div>
|
||
|
||
<div style="display: flex; flex-direction: column; align-items: center; gap: 12px;">
|
||
<div v-if="loginState.qrcode" style="padding: 10px; background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-sm); line-height: 0;">
|
||
<img :src="loginState.qrcode" alt="登录二维码" style="width: 220px; height: 220px; object-fit: contain;" />
|
||
</div>
|
||
<div v-else-if="isLoginBusy" v-loading="true" style="width: 240px; height: 240px; display: flex; align-items: center; justify-content: center; background: var(--bg-surface-subtle); border-radius: var(--radius-sm);">
|
||
</div>
|
||
|
||
<div style="font-size: 13.5px; font-weight: 600;">
|
||
{{ loginState.message || '等待中…' }}
|
||
<span v-if="loginState.status === 'waiting_scan'" style="color: #16a34a;">(等待扫码确认)</span>
|
||
</div>
|
||
<div v-if="loginState.error" style="font-size: 12px; color: #dc2626; word-break: break-all;">{{ loginState.error }}</div>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<div style="display: flex; gap: 8px; justify-content: center;">
|
||
<el-button v-if="!isLoginBusy" type="primary" class="btn-action-primary" @click="startQrLogin">重新获取二维码</el-button>
|
||
<el-button @click="qrDialogVisible = false">{{ isLoginBusy ? '取消' : '关闭' }}</el-button>
|
||
</div>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 新建用户弹窗(管理员) -->
|
||
<el-dialog v-model="userDialogVisible" title="新建登录用户" width="90%" style="max-width: 440px;">
|
||
<div style="font-size: 13px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.6;">
|
||
创建后请在「用户管理」列表中为其分配可访问的抖音账号;未分配账号的用户登录后看不到任何数据。
|
||
</div>
|
||
<el-form label-position="top">
|
||
<el-form-item label="用户名(必填)">
|
||
<el-input v-model="newUser.username" placeholder="2~32 位中文 / 字母 / 数字 / 下划线" clearable maxlength="32" />
|
||
</el-form-item>
|
||
<el-form-item label="初始密码(必填,至少 6 位)">
|
||
<el-input v-model="newUser.password" type="password" show-password placeholder="请告知对方并建议其登录后自行修改" clearable />
|
||
</el-form-item>
|
||
<el-form-item label="设为管理员">
|
||
<el-switch v-model="newUser.is_admin" />
|
||
<span style="font-size: 12px; color: var(--text-muted); margin-left: 8px;">管理员可看到全部账号并管理用户</span>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<div style="display: flex; gap: 8px; justify-content: flex-end;">
|
||
<el-button @click="userDialogVisible = false">取消</el-button>
|
||
<el-button type="primary" class="btn-action-primary" @click="createUser">创建用户</el-button>
|
||
</div>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 修改密码弹窗 -->
|
||
<el-dialog v-model="pwdDialogVisible" title="修改登录密码" width="90%" style="max-width: 420px;">
|
||
<el-form label-position="top" @submit.prevent>
|
||
<el-form-item label="旧密码">
|
||
<el-input v-model="pwdForm.old_password" type="password" show-password placeholder="当前密码" />
|
||
</el-form-item>
|
||
<el-form-item label="新密码(至少 6 位)">
|
||
<el-input v-model="pwdForm.new_password" type="password" show-password placeholder="新密码" />
|
||
</el-form-item>
|
||
<el-form-item label="确认新密码">
|
||
<el-input v-model="pwdForm.confirm" type="password" show-password placeholder="再输入一次新密码" @keyup.enter="changePassword" />
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<div style="display: flex; gap: 8px; justify-content: flex-end;">
|
||
<el-button @click="pwdDialogVisible = false">取消</el-button>
|
||
<el-button type="primary" class="btn-action-primary" @click="changePassword">确认修改</el-button>
|
||
</div>
|
||
</template>
|
||
</el-dialog>
|
||
</div>
|
||
|
||
<!-- 引入依赖脚本 -->
|
||
<script src="/static/vendor/vue.global.prod.js"></script>
|
||
<script src="/static/vendor/element-plus.full.min.js"></script>
|
||
<script src="/static/vendor/axios.min.js"></script>
|
||
|
||
<script>
|
||
const { createApp, ref, reactive, computed, onMounted, nextTick } = Vue;
|
||
|
||
const ICONS = {
|
||
fire: `<svg class="icon-svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12.003 2c-.12 0-.24.03-.35.08-1.56.75-3.66 2.37-4.52 4.41-.9 2.13-.53 4.2.49 5.86-.48-.68-.86-1.48-1.02-2.35-.07-.37-.47-.59-.83-.46-.35.12-.55.49-.47.85.34 1.63 1.13 3.09 2.24 4.19C6.46 15.65 6 17.27 6 19c0 2.76 2.69 5 6 5s6-2.24 6-5c0-1.89-.54-3.57-1.74-4.88-.23-.25-.49-.48-.76-.69 1.15-1.12 1.95-2.61 2.29-4.28.08-.36-.12-.73-.47-.85-.36-.13-.76.09-.83.46-.16.87-.54 1.67-1.02 2.35 1.02-1.66 1.39-3.73.49-5.86-.86-2.04-2.96-3.66-4.52-4.41-.11-.05-.23-.08-.35-.08zM12 14c1.66 0 3 1.34 3 3 0 1.66-1.34 3-3 3s-3-1.34-3-3c0-1.66 1.34-3 3-3z"/></svg>`,
|
||
grid: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,
|
||
users: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,
|
||
clock: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,
|
||
terminal: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,
|
||
key: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 2l-2 2m-1.5 1.5L14 9m-1.5 1.5l-2.5 2.5a6 6 0 1 1-8.5 8.5 6 6 0 0 1 8.5-8.5l2.5-2.5m1.5-1.5L16 7m1.5-1.5L20 4"></path></svg>`,
|
||
reload: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 4v6h-6"></path><path d="M1 20v-6h6"></path><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path></svg>`,
|
||
user: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>`,
|
||
shield: `<svg class="icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path></svg>`
|
||
};
|
||
|
||
const app = createApp({
|
||
setup() {
|
||
const tab = ref('overview');
|
||
const syncing = ref(false);
|
||
const savingLedger = ref(false);
|
||
const savingConfig = ref(false);
|
||
const searchKeyword = ref('');
|
||
const logsContent = ref('');
|
||
|
||
// ── 登录态 / 当前用户 ──
|
||
const authed = ref(false);
|
||
const authBusy = ref(false);
|
||
const authMode = ref('login');
|
||
const loginForm = reactive({ username: '', password: '' });
|
||
const regForm = reactive({ username: '', password: '', confirm: '' });
|
||
const me = reactive({ username: '', role: 'user', is_admin: false });
|
||
const pwdDialogVisible = ref(false);
|
||
const pwdForm = reactive({ old_password: '', new_password: '', confirm: '' });
|
||
|
||
const applyMe = (d) => {
|
||
authed.value = true;
|
||
me.username = d.username || '';
|
||
me.role = d.role || 'user';
|
||
me.is_admin = d.role === 'admin';
|
||
};
|
||
|
||
const isAdmin = computed(() => me.is_admin);
|
||
|
||
const navItems = computed(() => {
|
||
const items = [];
|
||
if (me.is_admin) {
|
||
items.push({ name: 'accounts', label: '账号', icon: 'users' });
|
||
items.push({ name: 'users', label: '用户', icon: 'shield' });
|
||
}
|
||
items.push(
|
||
{ name: 'overview', label: '概览', icon: 'grid' },
|
||
{ name: 'friends', label: '好友', icon: 'users' },
|
||
{ name: 'settings', label: '定时', icon: 'clock' },
|
||
{ name: 'logs', label: '日志', icon: 'terminal' },
|
||
{ name: 'credentials', label: '凭证', icon: 'key' },
|
||
);
|
||
return items;
|
||
});
|
||
|
||
const status = reactive({
|
||
state_file_exists: false,
|
||
running: false,
|
||
});
|
||
|
||
const currentAccountId = ref('default');
|
||
const accounts = ref([]);
|
||
const maxConcurrent = ref(5);
|
||
const browserSlotsAvailable = ref(5);
|
||
const accountDialogVisible = ref(false);
|
||
const newAccountName = ref('');
|
||
const newAccountDevice = ref('');
|
||
|
||
const config = reactive({
|
||
schedule_time: '21:00',
|
||
jitter_minutes: 30,
|
||
send_gap_min: 6,
|
||
send_gap_max: 12,
|
||
messages: ['🔥 续火花', '晚上好 🔥', '今天也要开心哦 🔥'],
|
||
auto_run_enabled: true
|
||
});
|
||
|
||
const messagesText = ref('');
|
||
const contacts = ref([]);
|
||
const lastRunInfo = reactive({
|
||
time: '',
|
||
summary: '',
|
||
success: true
|
||
});
|
||
|
||
// 会话认证:登录后服务端下发 HttpOnly Cookie,浏览器同源请求自动携带
|
||
const api = axios.create();
|
||
api.interceptors.request.use((req) => {
|
||
if (req.params) {
|
||
req.params = { ...req.params, account_id: currentAccountId.value };
|
||
} else {
|
||
req.params = { account_id: currentAccountId.value };
|
||
}
|
||
return req;
|
||
});
|
||
api.interceptors.response.use(
|
||
(res) => res,
|
||
(err) => {
|
||
const url = (err.config && err.config.url) || '';
|
||
const status = err.response && err.response.status;
|
||
if (status === 401 && !url.startsWith('/api/auth/')) {
|
||
ElementPlus.ElMessage.warning('登录已过期,请重新登录');
|
||
authed.value = false;
|
||
} else if (status === 403 && !url.startsWith('/api/auth/')) {
|
||
ElementPlus.ElMessage.warning(err.response?.data?.detail || '没有权限执行该操作');
|
||
}
|
||
return Promise.reject(err);
|
||
}
|
||
);
|
||
|
||
const totalContactCount = computed(() => contacts.value.length);
|
||
const selectedFriendCount = computed(() => contacts.value.filter(c => c.selected).length);
|
||
const sparkFriendCount = computed(() => contacts.value.filter(c => (c.spark_days || 0) > 0).length);
|
||
|
||
const filteredContacts = computed(() => {
|
||
// 带火花的好友按天数从高到低排在最前
|
||
const sorted = [...contacts.value].sort((a, b) => (b.spark_days || 0) - (a.spark_days || 0));
|
||
const kw = searchKeyword.value.trim().toLowerCase();
|
||
if (!kw) return sorted;
|
||
return sorted.filter(c =>
|
||
(c.nickname && c.nickname.toLowerCase().includes(kw)) ||
|
||
(String(c.spark_days || '').includes(kw))
|
||
);
|
||
});
|
||
|
||
const formatTime = (timeStr) => {
|
||
if (!timeStr) return '今日待发送';
|
||
try {
|
||
const d = new Date(timeStr);
|
||
if (isNaN(d.getTime())) return String(timeStr);
|
||
const m = String(d.getMonth() + 1).padStart(2, '0');
|
||
const day = String(d.getDate()).padStart(2, '0');
|
||
const h = String(d.getHours()).padStart(2, '0');
|
||
const min = String(d.getMinutes()).padStart(2, '0');
|
||
return `上次:${m}-${day} ${h}:${min}`;
|
||
} catch (e) {
|
||
return '今日待发送';
|
||
}
|
||
};
|
||
|
||
const loadStatus = async () => {
|
||
if (!authed.value || accounts.value.length === 0) return;
|
||
try {
|
||
const res = await api.get('/api/status');
|
||
status.running = res.data.running;
|
||
status.state_file_exists = res.data.state_file_exists;
|
||
} catch (e) {
|
||
console.error('Failed to load status', e);
|
||
}
|
||
};
|
||
|
||
const loadAccounts = async () => {
|
||
try {
|
||
const res = await api.get('/api/accounts', { params: {} });
|
||
accounts.value = res.data.accounts || [];
|
||
maxConcurrent.value = res.data.max_concurrent ?? 5;
|
||
browserSlotsAvailable.value = res.data.browser_slots_available ?? res.data.max_concurrent ?? 5;
|
||
// 后端已按角色过滤:普通用户只会拿到自己被分配的账号
|
||
if (accounts.value.length > 0 && !accounts.value.some(a => a.id === currentAccountId.value)) {
|
||
currentAccountId.value = accounts.value[0].id;
|
||
}
|
||
} catch (e) {
|
||
console.error('Failed to load accounts', e);
|
||
}
|
||
};
|
||
|
||
const sessionText = (acc) => {
|
||
const map = { ok: '正常', partial: '部分成功', expired: '登录已过期', failed: '运行失败' };
|
||
return map[acc.session_status] || '未知';
|
||
};
|
||
|
||
const switchAccount = async (id) => {
|
||
if (!id) return;
|
||
currentAccountId.value = id;
|
||
status.state_file_exists = false;
|
||
status.running = false;
|
||
await loadAll();
|
||
};
|
||
|
||
const createAccount = async () => {
|
||
const name = (newAccountName.value || '').trim();
|
||
if (!name) {
|
||
ElementPlus.ElMessage.warning('请输入账号名称');
|
||
return;
|
||
}
|
||
try {
|
||
const res = await api.post('/api/accounts', { name, device: newAccountDevice.value });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success(`账号「${res.data.account.name}」创建成功!`);
|
||
newAccountName.value = '';
|
||
newAccountDevice.value = '';
|
||
accountDialogVisible.value = false;
|
||
await loadAccounts();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('创建失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
const updateAccountMeta = async (acc) => {
|
||
try {
|
||
const res = await api.put(`/api/accounts/${acc.id}`, {
|
||
name: acc.name, device: acc.device, enabled: acc.enabled
|
||
});
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('账号信息已保存');
|
||
await loadAccounts();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('保存失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
const removeAccount = async (acc) => {
|
||
if (acc.is_default) return;
|
||
try {
|
||
const confirmed = await ElementPlus.ElMessageBox.confirm(
|
||
`确定删除账号「${acc.name}」?其数据目录将归档到 data/archived/。`,
|
||
'删除账号', { type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||
);
|
||
const res = await api.delete(`/api/accounts/${acc.id}`);
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('账号已删除');
|
||
if (currentAccountId.value === acc.id) {
|
||
await loadAccounts();
|
||
currentAccountId.value = 'default';
|
||
await switchAccount('default');
|
||
} else {
|
||
await loadAccounts();
|
||
}
|
||
}
|
||
} catch (e) {
|
||
if (e !== 'cancel') {
|
||
ElementPlus.ElMessage.error('删除失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
}
|
||
};
|
||
|
||
const currentAccount = computed(() => {
|
||
return accounts.value.find(a => a.id === currentAccountId.value) || {
|
||
id: currentAccountId.value, name: currentAccountId.value, is_default: true
|
||
};
|
||
});
|
||
|
||
// ── 登录 / 注册 / 退出 / 改密 ──
|
||
const enterApp = async () => {
|
||
await loadAll();
|
||
if (!navItems.value.some(i => i.name === tab.value)) tab.value = 'overview';
|
||
};
|
||
|
||
const checkSession = async () => {
|
||
try {
|
||
const res = await api.get('/api/auth/me');
|
||
applyMe(res.data);
|
||
await enterApp();
|
||
} catch (e) {
|
||
authed.value = false;
|
||
}
|
||
};
|
||
|
||
const doLogin = async () => {
|
||
const username = (loginForm.username || '').trim();
|
||
if (!username || !loginForm.password) {
|
||
ElementPlus.ElMessage.warning('请输入用户名和密码');
|
||
return;
|
||
}
|
||
authBusy.value = true;
|
||
try {
|
||
const res = await api.post('/api/auth/login', { username, password: loginForm.password }, { params: {} });
|
||
applyMe(res.data);
|
||
loginForm.password = '';
|
||
ElementPlus.ElMessage.success(`欢迎回来,${me.username}!`);
|
||
await enterApp();
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error(e.response?.data?.detail || '登录失败');
|
||
} finally {
|
||
authBusy.value = false;
|
||
}
|
||
};
|
||
|
||
const doRegister = async () => {
|
||
const username = (regForm.username || '').trim();
|
||
if (!username || !regForm.password) {
|
||
ElementPlus.ElMessage.warning('请输入用户名和密码');
|
||
return;
|
||
}
|
||
if (regForm.password !== regForm.confirm) {
|
||
ElementPlus.ElMessage.warning('两次输入的密码不一致');
|
||
return;
|
||
}
|
||
authBusy.value = true;
|
||
try {
|
||
const res = await api.post('/api/auth/register', { username, password: regForm.password }, { params: {} });
|
||
applyMe(res.data);
|
||
regForm.password = '';
|
||
regForm.confirm = '';
|
||
ElementPlus.ElMessage.success('注册成功!已为你自动创建专属账号,请在「凭证」页扫码登录抖音。');
|
||
await enterApp();
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error(e.response?.data?.detail || '注册失败');
|
||
} finally {
|
||
authBusy.value = false;
|
||
}
|
||
};
|
||
|
||
const doLogout = async () => {
|
||
try { await api.post('/api/auth/logout', null, { params: {} }); } catch (e) { /* ignore */ }
|
||
authed.value = false;
|
||
me.username = '';
|
||
me.role = 'user';
|
||
me.is_admin = false;
|
||
accounts.value = [];
|
||
tab.value = 'overview';
|
||
ElementPlus.ElMessage.success('已退出登录');
|
||
};
|
||
|
||
const onUserCommand = (cmd) => {
|
||
if (cmd === 'logout') {
|
||
doLogout();
|
||
} else if (cmd === 'password') {
|
||
pwdForm.old_password = '';
|
||
pwdForm.new_password = '';
|
||
pwdForm.confirm = '';
|
||
pwdDialogVisible.value = true;
|
||
}
|
||
};
|
||
|
||
const changePassword = async () => {
|
||
if (!pwdForm.old_password || !pwdForm.new_password) {
|
||
ElementPlus.ElMessage.warning('请填写旧密码和新密码');
|
||
return;
|
||
}
|
||
if (pwdForm.new_password !== pwdForm.confirm) {
|
||
ElementPlus.ElMessage.warning('两次输入的新密码不一致');
|
||
return;
|
||
}
|
||
try {
|
||
const res = await api.post('/api/auth/password', {
|
||
old_password: pwdForm.old_password,
|
||
new_password: pwdForm.new_password
|
||
}, { params: {} });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('密码已修改,下次登录请使用新密码');
|
||
pwdDialogVisible.value = false;
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error(e.response?.data?.detail || '修改失败');
|
||
}
|
||
};
|
||
|
||
// ── 用户管理(管理员) ──
|
||
const users = ref([]);
|
||
const userDialogVisible = ref(false);
|
||
const newUser = reactive({ username: '', password: '', is_admin: false });
|
||
|
||
const accountNames = (ids) => {
|
||
const list = ids || [];
|
||
if (list.length === 0) return '(未分配)';
|
||
return list.map(id => {
|
||
const acc = accounts.value.find(a => a.id === id);
|
||
return acc ? acc.name : id;
|
||
}).join('、');
|
||
};
|
||
|
||
const loadUsers = async () => {
|
||
if (!me.is_admin) return;
|
||
try {
|
||
const res = await api.get('/api/users', { params: {} });
|
||
users.value = (res.data.users || []).map(u => ({ ...u, account_ids: u.account_ids || [] }));
|
||
} catch (e) {
|
||
console.error('Failed to load users', e);
|
||
}
|
||
};
|
||
|
||
const createUser = async () => {
|
||
const username = (newUser.username || '').trim();
|
||
if (!username || !newUser.password) {
|
||
ElementPlus.ElMessage.warning('请填写用户名和初始密码');
|
||
return;
|
||
}
|
||
try {
|
||
const res = await api.post('/api/users', {
|
||
username, password: newUser.password, is_admin: newUser.is_admin
|
||
}, { params: {} });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success(`用户「${username}」创建成功,请为其分配账号`);
|
||
newUser.username = '';
|
||
newUser.password = '';
|
||
newUser.is_admin = false;
|
||
userDialogVisible.value = false;
|
||
await loadUsers();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('创建失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
const saveUser = async (u) => {
|
||
try {
|
||
const res = await api.put(`/api/users/${encodeURIComponent(u.username)}`, {
|
||
account_ids: u.account_ids || [],
|
||
is_admin: u.is_admin
|
||
}, { params: {} });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success(`用户「${u.username}」已更新`);
|
||
await loadUsers();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('保存失败: ' + (e.response?.data?.detail || e.message));
|
||
await loadUsers();
|
||
}
|
||
};
|
||
|
||
const resetUserPassword = async (u) => {
|
||
try {
|
||
const { value } = await ElementPlus.ElMessageBox.prompt(
|
||
`为用户「${u.username}」设置新密码(至少 6 位):`,
|
||
'重置密码',
|
||
{ inputType: 'password', inputPattern: /^.{6,128}$/, inputErrorMessage: '密码长度至少 6 位', confirmButtonText: '重置', cancelButtonText: '取消' }
|
||
);
|
||
const res = await api.put(`/api/users/${encodeURIComponent(u.username)}`, { password: value }, { params: {} });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('密码已重置');
|
||
}
|
||
} catch (e) {
|
||
if (e !== 'cancel' && e?.response) {
|
||
ElementPlus.ElMessage.error('重置失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
}
|
||
};
|
||
|
||
const removeUser = async (u) => {
|
||
try {
|
||
await ElementPlus.ElMessageBox.confirm(
|
||
`确定删除用户「${u.username}」?删除后该用户将无法登录。`,
|
||
'删除用户', { type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||
);
|
||
const res = await api.delete(`/api/users/${encodeURIComponent(u.username)}`, { params: {} });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('用户已删除');
|
||
await loadUsers();
|
||
}
|
||
} catch (e) {
|
||
if (e !== 'cancel' && e?.response) {
|
||
ElementPlus.ElMessage.error('删除失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
}
|
||
};
|
||
|
||
const loadConfig = async () => {
|
||
try {
|
||
const res = await api.get('/api/config');
|
||
Object.assign(config, res.data);
|
||
messagesText.value = (res.data.messages || []).join('\n');
|
||
} catch (e) {
|
||
console.error('Failed to load config', e);
|
||
}
|
||
};
|
||
|
||
const loadLedger = async () => {
|
||
try {
|
||
const res = await api.get('/api/ledger');
|
||
const list = res.data.contacts || res.data.entries || [];
|
||
contacts.value = list.map(item => ({
|
||
display_name: item.display_name || item.nickname || '',
|
||
nickname: item.nickname || item.display_name || '',
|
||
spark_days: Number(item.spark_days || item.streak_days || 0),
|
||
streak_days: Number(item.streak_days || item.spark_days || 0),
|
||
selected: Boolean(item.selected),
|
||
last_status: item.last_status || (item.last_sent_at ? 'success' : 'pending'),
|
||
last_sent_at: item.last_sent_at || ''
|
||
}));
|
||
if (res.data.last_run) {
|
||
lastRunInfo.time = res.data.last_run.time || '';
|
||
lastRunInfo.summary = res.data.last_run.summary || '';
|
||
lastRunInfo.success = res.data.last_run.success !== false;
|
||
}
|
||
} catch (e) {
|
||
console.error('Failed to load ledger', e);
|
||
}
|
||
};
|
||
|
||
const fetchLogs = async () => {
|
||
try {
|
||
const res = await api.get('/api/logs');
|
||
logsContent.value = res.data.logs || '';
|
||
nextTick(() => {
|
||
const el = document.getElementById('terminal-view');
|
||
if (el) el.scrollTop = el.scrollHeight;
|
||
});
|
||
} catch (e) {
|
||
console.error('Failed to fetch logs', e);
|
||
}
|
||
};
|
||
|
||
const clearLogs = () => {
|
||
logsContent.value = '';
|
||
};
|
||
|
||
const loadAll = async () => {
|
||
await loadAccounts();
|
||
if (!authed.value || accounts.value.length === 0) return;
|
||
await Promise.all([loadStatus(), loadConfig(), loadLedger(), fetchLogs()]);
|
||
if (me.is_admin) await loadUsers();
|
||
};
|
||
|
||
const runStreak = async (dryRun = false) => {
|
||
if (selectedFriendCount.value === 0) {
|
||
ElementPlus.ElMessage.warning('⚠️ 您尚未勾选任何好友!请在「好友与消息」中勾选好友后再执行。');
|
||
tab.value = 'friends';
|
||
return;
|
||
}
|
||
try {
|
||
ElementPlus.ElMessage.info(dryRun ? '正在以模拟演练模式启动...' : '正在启动续火花流程...');
|
||
const res = await api.post('/api/run', { dry_run: dryRun });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('任务已成功触发并在后台运行!');
|
||
tab.value = 'logs';
|
||
loadAll();
|
||
} else {
|
||
ElementPlus.ElMessage.error(res.data.message || '启动失败');
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('触发失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
const resetRunningState = async () => {
|
||
try {
|
||
const res = await api.post('/api/reset-running');
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('运行状态已强制重置!');
|
||
await loadAll();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('重置失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
const syncContacts = async () => {
|
||
syncing.value = true;
|
||
try {
|
||
ElementPlus.ElMessage.info('🚀 正在启动后台同步联系人列表(预计 10~20 秒)...');
|
||
await api.post('/api/sync');
|
||
|
||
let checks = 0;
|
||
const timer = setInterval(async () => {
|
||
checks++;
|
||
try {
|
||
const resLedger = await api.get('/api/ledger');
|
||
const isFetching = resLedger.data.fetching;
|
||
if (!isFetching || checks >= 240) {
|
||
clearInterval(timer);
|
||
syncing.value = false;
|
||
await loadLedger();
|
||
const total = contacts.value.length;
|
||
const sparks = contacts.value.filter(c => (c.spark_days || 0) > 0).length;
|
||
if (total > 0) {
|
||
ElementPlus.ElMessage.success(`🎉 同步完成!已获取 ${total} 位好友,其中 ${sparks} 位带有火花!`);
|
||
} else if (checks >= 240) {
|
||
ElementPlus.ElMessage.info('同步耗时较长仍在后台进行,稍后刷新页面即可查看结果。');
|
||
} else {
|
||
ElementPlus.ElMessage.warning('未能读取到联系人,请确认已上传登录凭证 state.json。');
|
||
}
|
||
}
|
||
} catch (err) {
|
||
clearInterval(timer);
|
||
syncing.value = false;
|
||
}
|
||
}, 1500);
|
||
} catch (e) {
|
||
syncing.value = false;
|
||
ElementPlus.ElMessage.error('同步请求失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
const autoSelectSparkFriends = () => {
|
||
let count = 0;
|
||
contacts.value.forEach(c => {
|
||
if ((c.spark_days || 0) > 0) {
|
||
c.selected = true;
|
||
count++;
|
||
}
|
||
});
|
||
ElementPlus.ElMessage.success(`已自动勾选 ${count} 位火花好友,请点击“保存勾选配置”!`);
|
||
};
|
||
|
||
const clearSelectedFriends = () => {
|
||
contacts.value.forEach(c => c.selected = false);
|
||
ElementPlus.ElMessage.info('已清空全部勾选,请点击“保存勾选配置”生效。');
|
||
};
|
||
|
||
const saveLedgerSelection = async () => {
|
||
savingLedger.value = true;
|
||
try {
|
||
const selectedNames = contacts.value.filter(c => c.selected).map(c => c.display_name || c.nickname);
|
||
const res = await api.post('/api/ledger/selection', { selected_names: selectedNames });
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success(`好友勾选配置已成功保存!当前生效勾选 ${selectedNames.length} 人`);
|
||
await loadLedger();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('保存失败: ' + (e.response?.data?.detail || e.message));
|
||
} finally {
|
||
savingLedger.value = false;
|
||
}
|
||
};
|
||
|
||
const saveConfigForm = async () => {
|
||
savingConfig.value = true;
|
||
try {
|
||
const msgs = messagesText.value.split('\n').map(s => s.trim()).filter(Boolean);
|
||
config.messages = msgs.length > 0 ? msgs : ['🔥 续火花'];
|
||
const res = await api.post('/api/config', config);
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('定时与风控设置已保存!');
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('保存失败: ' + (e.response?.data?.detail || e.message));
|
||
} finally {
|
||
savingConfig.value = false;
|
||
}
|
||
};
|
||
|
||
const handleFileUpload = async (event) => {
|
||
const file = event.target.files[0];
|
||
if (!file) return;
|
||
const formData = new FormData();
|
||
formData.append('file', file);
|
||
try {
|
||
ElementPlus.ElMessage.info('正在上传通行证凭据...');
|
||
const res = await api.post('/api/upload-state', formData, {
|
||
headers: { 'Content-Type': 'multipart/form-data' }
|
||
});
|
||
if (res.data.ok) {
|
||
ElementPlus.ElMessage.success('state.json 通行证凭证已成功上传并就绪!');
|
||
await loadStatus();
|
||
}
|
||
} catch (e) {
|
||
ElementPlus.ElMessage.error('上传失败: ' + (e.response?.data?.detail || e.message));
|
||
}
|
||
};
|
||
|
||
// ── 网页扫码登录 ──
|
||
const LOGIN_BUSY_STATES = ['queuing', 'starting', 'waiting_scan'];
|
||
const qrDialogVisible = ref(false);
|
||
const loginState = ref({ status: 'idle', message: '', qrcode: '', error: '' });
|
||
let loginPollTimer = null;
|
||
|
||
const isLoginBusy = computed(() => LOGIN_BUSY_STATES.includes(loginState.value.status));
|
||
|
||
const stopLoginPolling = () => {
|
||
if (loginPollTimer) { clearInterval(loginPollTimer); loginPollTimer = null; }
|
||
};
|
||
|
||
const pollLoginStatus = async () => {
|
||
try {
|
||
const res = await api.get('/api/login/status');
|
||
loginState.value = res.data;
|
||
if (!LOGIN_BUSY_STATES.includes(res.data.status)) {
|
||
stopLoginPolling();
|
||
if (res.data.status === 'success') {
|
||
ElementPlus.ElMessage.success('登录成功!当前账号登录态已更新。');
|
||
setTimeout(() => { qrDialogVisible.value = false; }, 1200);
|
||
await Promise.all([loadStatus(), loadAccounts()]);
|
||
} else if (res.data.status === 'failed' || res.data.status === 'expired') {
|
||
ElementPlus.ElMessage.warning(loginState.value.message || '扫码未完成,请重试');
|
||
}
|
||
}
|
||
} catch (e) { /* 轮询失败静默,下个周期重试 */ }
|
||
};
|
||
|
||
const startLoginPolling = () => {
|
||
stopLoginPolling();
|
||
pollLoginStatus();
|
||
loginPollTimer = setInterval(pollLoginStatus, 1500);
|
||
};
|
||
|
||
const startQrLogin = async () => {
|
||
loginState.value = { status: 'queuing', message: '正在排队获取浏览器名额…', qrcode: '', error: '' };
|
||
try {
|
||
await api.post('/api/login/start');
|
||
startLoginPolling();
|
||
} catch (e) {
|
||
loginState.value = { status: 'failed', message: '发起扫码失败', qrcode: '', error: e.response?.data?.detail || e.message };
|
||
}
|
||
};
|
||
|
||
const goToCredentials = () => {
|
||
tab.value = 'credentials';
|
||
};
|
||
|
||
const openQrLogin = () => {
|
||
ElementPlus.ElMessageBox.confirm(
|
||
'<div style="text-align: left; line-height: 2; font-size: 13px;">'
|
||
+ '1. 请先拿出手机,打开抖音 App 并登录,做好扫码准备<br/>'
|
||
+ '2. 点击「开始扫码」后,二维码生成约需 20~40 秒,请耐心等待<br/>'
|
||
+ '3. 二维码出现后请<b>立即扫码</b>,它会不定时自动刷新,请时刻关注其变化<br/>'
|
||
+ '4. 若提示安全验证,页面会弹出<b>新的二维码</b>,请继续用手机扫码完成验证'
|
||
+ '</div>',
|
||
'手机扫码登录须知',
|
||
{
|
||
dangerouslyUseHTMLString: true,
|
||
confirmButtonText: '已备好手机,开始扫码',
|
||
cancelButtonText: '再等等',
|
||
type: 'warning',
|
||
}
|
||
).then(() => {
|
||
qrDialogVisible.value = true;
|
||
startQrLogin();
|
||
}).catch(() => {});
|
||
};
|
||
|
||
const cancelLoginPolling = async () => {
|
||
stopLoginPolling();
|
||
if (isLoginBusy.value) {
|
||
try { await api.post('/api/login/cancel'); } catch (e) { /* ignore */ }
|
||
loginState.value = { status: 'cancelled', message: '已取消', qrcode: '', error: '' };
|
||
}
|
||
};
|
||
|
||
|
||
onMounted(() => {
|
||
checkSession();
|
||
setInterval(loadStatus, 10000);
|
||
});
|
||
|
||
return {
|
||
tab,
|
||
goToCredentials,
|
||
navItems,
|
||
status,
|
||
// 登录 / 会话
|
||
authed,
|
||
authBusy,
|
||
authMode,
|
||
loginForm,
|
||
regForm,
|
||
me,
|
||
isAdmin,
|
||
pwdDialogVisible,
|
||
pwdForm,
|
||
doLogin,
|
||
doRegister,
|
||
doLogout,
|
||
onUserCommand,
|
||
changePassword,
|
||
// 用户管理(管理员)
|
||
users,
|
||
userDialogVisible,
|
||
newUser,
|
||
accountNames,
|
||
loadUsers,
|
||
createUser,
|
||
saveUser,
|
||
resetUserPassword,
|
||
removeUser,
|
||
currentAccountId,
|
||
accounts,
|
||
currentAccount,
|
||
maxConcurrent,
|
||
browserSlotsAvailable,
|
||
sessionText,
|
||
accountDialogVisible,
|
||
newAccountName,
|
||
newAccountDevice,
|
||
config,
|
||
messagesText,
|
||
contacts,
|
||
lastRunInfo,
|
||
totalContactCount,
|
||
selectedFriendCount,
|
||
sparkFriendCount,
|
||
filteredContacts,
|
||
searchKeyword,
|
||
logsContent,
|
||
syncing,
|
||
savingLedger,
|
||
savingConfig,
|
||
ICONS,
|
||
formatTime,
|
||
loadAll,
|
||
loadAccounts,
|
||
switchAccount,
|
||
createAccount,
|
||
updateAccountMeta,
|
||
removeAccount,
|
||
runStreak,
|
||
resetRunningState,
|
||
syncContacts,
|
||
autoSelectSparkFriends,
|
||
clearSelectedFriends,
|
||
saveLedgerSelection,
|
||
saveConfigForm,
|
||
fetchLogs,
|
||
clearLogs,
|
||
handleFileUpload,
|
||
qrDialogVisible,
|
||
loginState,
|
||
isLoginBusy,
|
||
openQrLogin,
|
||
startQrLogin,
|
||
cancelLoginPolling
|
||
};
|
||
}
|
||
});
|
||
|
||
app.use(ElementPlus);
|
||
app.mount('#app');
|
||
</script>
|
||
</body>
|
||
</html>
|