feat: 初始版本

This commit is contained in:
2026-11-24 16:37:13 +08:00
parent 1ec3657d18
commit 9a23cd1d32
23 changed files with 6727 additions and 0 deletions
+1426
View File
File diff suppressed because it is too large Load Diff
+377
View File
@@ -0,0 +1,377 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>金价提醒 · Gold Price Watcher</title>
<link rel="stylesheet" href="/styles.css?v=20261124q" />
</head>
<body>
<header class="topbar">
<div class="brand">
<span class="logo">Au</span>
<div class="brand-text">
<h1>金价提醒</h1>
<p>Gold Price Watcher · 本地监控</p>
</div>
</div>
<div class="status-bar">
<span class="pill" id="runPill"><i class="dot"></i><span id="runText">加载中…</span></span>
<span class="pill muted" id="quietPill" hidden>静默时段</span>
<span class="clock" id="serverTime">--:--:--</span>
<button class="btn ghost" id="btnRefresh">立即刷新</button>
<button class="btn primary" id="btnToggleRun">暂停监控</button>
</div>
</header>
<nav class="tabs" id="tabs">
<button class="tab active" data-tab="market">行情看板</button>
<button class="tab" data-tab="rules">提醒规则</button>
<button class="tab" data-tab="channels">通知设置</button>
<button class="tab" data-tab="alerts">提醒记录<span class="badge" id="alertBadge" hidden>0</span></button>
</nav>
<main>
<!-- ============ 行情看板 ============ -->
<section class="panel active" id="panel-market">
<div class="section-head">
<div>
<h2>监控品种</h2>
<p class="hint">每个品种可以单独设置刷新频率,价格变动后会按规则触发提醒。</p>
</div>
<button class="btn primary" id="btnAddInstrument">+ 添加品种</button>
</div>
<div class="grid" id="instrumentGrid"></div>
<p class="empty" id="instrumentEmpty" hidden>还没有监控品种,点击右上角「添加品种」开始。</p>
</section>
<!-- ============ 提醒规则 ============ -->
<section class="panel" id="panel-rules">
<div class="section-head">
<div>
<h2>提醒规则</h2>
<p class="hint">支持价格阈值、涨跌幅(可指定统计区间,如「近 10 分钟涨 0.5%」)、两个品种之间的价差、定时提醒四类规则;价格类规则还能限定生效时段并按冷却时间防轰炸,定时提醒按时刻去重。</p>
</div>
<button class="btn primary" id="btnAddRule">+ 新建规则</button>
</div>
<div class="rule-list" id="ruleList"></div>
<p class="empty" id="ruleEmpty" hidden>还没有规则。先添加一个「价格上破 800 元/克」试试。</p>
</section>
<!-- ============ 通知设置 ============ -->
<section class="panel" id="panel-channels">
<div class="section-head">
<div>
<h2>通知设置</h2>
<p class="hint">桌面通知走 Windows 原生 Toast;邮件走 SMTP;WebHook 支持内置 JSON 与钉钉机器人两种格式。配置只保存在本机。</p>
</div>
</div>
<div class="cards-2">
<div class="card setting-card">
<div class="card-head">
<h3>Windows 桌面通知</h3>
<label class="switch">
<input type="checkbox" id="desktopEnabled" />
<span></span>
</label>
</div>
<p class="hint">在右下角弹出系统通知,需要 Windows 10/11,且系统的「通知」未关闭。</p>
<div class="row">
<button class="btn ghost" id="btnTestDesktop">发送测试通知</button>
<span class="test-result" id="desktopTestResult"></span>
</div>
</div>
<div class="card setting-card">
<div class="card-head">
<h3>全局默认渠道</h3>
</div>
<p class="hint">规则没有单独指定渠道时,用这里的默认设置。</p>
<div class="row wrap">
<label class="check"><input type="checkbox" id="channelDesktop" /> 桌面通知</label>
<label class="check"><input type="checkbox" id="channelEmail" /> 邮件</label>
<label class="check"><input type="checkbox" id="channelWebhook" /> WebHook</label>
</div>
<div class="row">
<label class="field inline">
<span>默认刷新频率(秒)</span>
<input type="number" id="defaultInterval" min="5" max="86400" step="1" />
</label>
</div>
<div class="row wrap">
<label class="check"><input type="checkbox" id="quietEnabled" /> 静默时段只发邮件,不弹桌面通知</label>
<input type="text" id="quietRange" class="narrow" placeholder="23:00-07:00" />
<label class="check"><input type="checkbox" id="alertOnFirstCheck" /> 启动时已满足条件也提醒一次</label>
</div>
</div>
</div>
<div class="card setting-card" id="emailCard">
<div class="card-head">
<h3>邮箱提醒(SMTP)</h3>
<label class="switch">
<input type="checkbox" id="emailEnabled" />
<span></span>
</label>
</div>
<p class="hint">
常见填写:QQ 邮箱 <code>smtp.qq.com</code> + 465 + 授权码;163 邮箱 <code>smtp.163.com</code> + 465 + 授权码;
企业邮箱按服务商文档填写。密码处请填「授权码」而不是登录密码。
</p>
<div class="form-grid">
<label class="field"><span>SMTP 服务器</span><input type="text" id="emailHost" placeholder="smtp.qq.com" /></label>
<label class="field"><span>端口</span><input type="number" id="emailPort" placeholder="465" /></label>
<label class="field"><span>加密方式</span>
<select id="emailSecure">
<option value="true">SSL(端口 465)</option>
<option value="false">STARTTLS(端口 587)</option>
</select>
</label>
<label class="field"><span>发件邮箱</span><input type="text" id="emailUser" placeholder="you@qq.com" /></label>
<label class="field"><span>授权码 / 密码</span><input type="password" id="emailPass" placeholder="留空则不修改" autocomplete="new-password" /></label>
<label class="field"><span>发件人显示名</span><input type="text" id="emailFrom" placeholder="金价提醒 &lt;you@qq.com&gt;" /></label>
<label class="field wide"><span>收件人(多个用逗号或分号分隔)</span><input type="text" id="emailTo" placeholder="a@qq.com, b@163.com" /></label>
<label class="field"><span>邮件标题前缀</span><input type="text" id="emailPrefix" placeholder="【金价提醒】" /></label>
<label class="field check-field"><span>邮件正文附带行情快照</span><input type="checkbox" id="emailSnapshot" /></label>
</div>
<div class="row">
<button class="btn ghost" id="btnTestEmail">发送测试邮件</button>
<span class="test-result" id="emailTestResult"></span>
</div>
</div>
<div class="card setting-card" id="webhookCard">
<div class="card-head">
<h3>WebHook 推送</h3>
<label class="switch">
<input type="checkbox" id="webhookEnabled" />
<span></span>
</label>
</div>
<p class="hint">
触发提醒时向该地址 POST 一条消息。两种格式:<b>内置 JSON</b> 是本工具固定的字段结构,方便自建服务或自动化脚本消费;
<b>钉钉机器人</b> 直接填群机器人的 Webhook 地址即可,支持「加签」安全设置。
</p>
<div class="form-grid">
<label class="field wide"><span>WebHook 地址</span>
<input type="text" id="webhookUrl" placeholder="https://oapi.dingtalk.com/robot/send?access_token=xxx" />
</label>
<label class="field"><span>报文格式</span>
<select id="webhookFormat">
<option value="generic">内置 JSON(自定义服务)</option>
<option value="dingtalk">钉钉机器人(markdown)</option>
</select>
</label>
<label class="field" id="webhookSecretField"><span>钉钉加签密钥(可选)</span>
<input type="password" id="webhookSecret" placeholder="SEC 开头;机器人未启用加签可留空" autocomplete="new-password" />
</label>
<label class="field" id="webhookKeywordField"><span>钉钉自定义关键词(可选)</span>
<input type="text" id="webhookKeyword" placeholder="例如:金价(填机器人安全设置里的那个词)" />
</label>
<label class="field wide" id="webhookAtMobilesField"><span>钉钉 @ 手机号(多个用逗号分隔,可留空)</span>
<input type="text" id="webhookAtMobiles" placeholder="13800000000, 13900000000" />
</label>
<label class="field check-field" id="webhookMentionAllField"><span>钉钉 @所有人</span>
<input type="checkbox" id="webhookMentionAll" />
</label>
</div>
<p class="hint" id="webhookFormatHint"></p>
<div class="row">
<button class="btn ghost" id="btnTestWebhook">发送测试推送</button>
<span class="test-result" id="webhookTestResult"></span>
</div>
</div>
<div class="card setting-card">
<div class="card-head"><h3>服务与安全</h3></div>
<div class="form-grid">
<label class="field"><span>监听端口(改后需重启)</span><input type="number" id="appPort" min="1" max="65535" /></label>
<label class="field"><span>监听地址</span><input type="text" id="appHost" placeholder="127.0.0.1" /></label>
<label class="field wide"><span>访问令牌(留空表示本机免登录;非本机访问强烈建议设置)</span><input type="text" id="appToken" placeholder="自定义一串字符" /></label>
</div>
<div class="row">
<label class="check"><input type="checkbox" id="appOpenBrowser" /> 启动时自动打开浏览器</label>
</div>
<p class="hint" id="configPathHint"></p>
<div class="row">
<button class="btn ghost" id="btnExportConfig">导出配置</button>
<button class="btn ghost" id="btnImportConfig">导入配置</button>
<input type="file" id="importFile" accept="application/json" hidden />
</div>
</div>
<div class="row sticky-save">
<button class="btn primary" id="btnSaveSettings">保存设置</button>
<span class="test-result" id="saveResult"></span>
</div>
</section>
<!-- ============ 提醒记录 ============ -->
<section class="panel" id="panel-alerts">
<div class="section-head">
<div>
<h2>提醒记录</h2>
<p class="hint">最近 200 条触发记录,同时写入 <code>data/alerts.jsonl</code> 便于追溯。</p>
</div>
<button class="btn ghost" id="btnClearAlerts">清空</button>
</div>
<div class="alert-list" id="alertList"></div>
<p class="empty" id="alertEmpty" hidden>暂时还没有触发过提醒。</p>
</section>
</main>
<!-- ============ 弹窗:添加/编辑品种 ============ -->
<div class="modal" id="modalInstrument" hidden>
<div class="modal-box">
<div class="modal-head">
<h3 id="instrumentModalTitle">添加品种</h3>
<button class="icon-btn" data-close="modalInstrument">✕</button>
</div>
<div class="modal-body">
<label class="field wide">
<span>选择内置品种</span>
<select id="presetSelect"></select>
</label>
<p class="hint" id="presetHint"></p>
<div class="form-grid" id="instrumentCustomFields">
<label class="field wide"><span>名称</span><input type="text" id="instName" placeholder="例如 浙商黄金" /></label>
<label class="field"><span>数据源</span><select id="instSource"></select></label>
<label class="field"><span>刷新频率(秒)</span><input type="number" id="instInterval" min="5" max="86400" step="5" /></label>
<label class="field"><span>价格单位</span><input type="text" id="instUnit" placeholder="元/克" /></label>
<label class="field"><span>小数位</span><input type="number" id="instDigits" min="0" max="4" /></label>
<label class="field wide" id="sinaCodeField"><span>新浪行情代码</span><input type="text" id="instSinaCode" placeholder="SGE_AUTD / hf_XAU / nf_AU0" /></label>
<label class="field wide" id="rijinjiaKeyField"><span>积存金品种 key</span><input type="text" id="instRijinjiaKey" placeholder="czb-jcj" /></label>
<label class="field wide" id="httpUrlField"><span>接口地址</span><input type="text" id="instHttpUrl" placeholder="https://api.example.com/gold" /></label>
<label class="field" id="httpPricePathField"><span>价格字段路径</span><input type="text" id="instHttpPricePath" placeholder="data.price" /></label>
<label class="field" id="httpPrevPathField"><span>昨收字段路径(可选)</span><input type="text" id="instHttpPrevPath" placeholder="data.prevClose" /></label>
</div>
<p class="hint">提示:添加前可以先在「行情」里用「测试抓取」验证数据源是否可用。</p>
</div>
<div class="modal-foot">
<span class="test-result" id="instrumentResult"></span>
<button class="btn ghost" data-close="modalInstrument">取消</button>
<button class="btn ghost" id="btnTestInstrument">测试抓取</button>
<button class="btn primary" id="btnSaveInstrument">保存</button>
</div>
</div>
</div>
<!-- ============ 弹窗:规则 ============ -->
<div class="modal" id="modalRule" hidden>
<div class="modal-box">
<div class="modal-head">
<h3 id="ruleModalTitle">新建规则</h3>
<button class="icon-btn" data-close="modalRule">✕</button>
</div>
<div class="modal-body">
<div class="form-grid">
<!-- 1) 先定类型和标的:类型 → 监控品种(价差再加对比品种) -->
<label class="field"><span>规则类型</span>
<select id="ruleType">
<option value="threshold">价格阈值</option>
<option value="change">涨跌幅</option>
<option value="spread">价差提醒</option>
<option value="schedule">定时提醒</option>
</select>
</label>
<label class="field"><span>监控品种</span><select id="ruleInstrument"></select></label>
<label class="field" id="ruleCompareField" hidden><span>对比品种</span><select id="ruleCompare"></select></label>
<!-- 2) 再定口径和方向:口径决定阈值的单位,放在方向/阈值之前 -->
<label class="field" id="ruleModeField" hidden><span>价差口径</span>
<select id="ruleMode">
<option value="abs">绝对价差(元/克)</option>
<option value="percent">相对价差(%)</option>
</select>
</label>
<!-- 涨跌幅专用:阈值口径(百分比 / 具体价格变动值) -->
<label class="field" id="ruleBasisField" hidden><span>阈值口径</span>
<select id="ruleBasis">
<option value="percent">涨跌幅百分比(%)</option>
<option value="amount">具体变动值(元/克)</option>
</select>
</label>
<label class="field" id="ruleDirectionField"><span>触发方向</span><select id="ruleDirection"></select></label>
<!-- 3) 触发条件:阈值 + 统计区间 -->
<label class="field" id="ruleValueField"><span id="ruleValueLabel">阈值</span>
<input type="number" id="ruleValue" step="0.001" placeholder="800" />
</label>
<!-- 涨跌幅专用:统计区间(日内相对昨收,或近 N 分钟的滚动窗口) -->
<label class="field" id="ruleWindowField" hidden><span>统计区间</span>
<select id="ruleWindow">
<option value="0">日内(相对昨收)</option>
<option value="300">近 5 分钟</option>
<option value="600">近 10 分钟</option>
<option value="900">近 15 分钟</option>
<option value="1800">近 30 分钟</option>
<option value="3600">近 1 小时</option>
<option value="7200">近 2 小时</option>
<option value="14400">近 4 小时</option>
<option value="-1">自定义(分钟)</option>
</select>
</label>
<label class="field" id="ruleWindowCustomField" hidden><span>自定义分钟数(最长 720)</span>
<input type="number" id="ruleWindowCustom" min="1" max="720" step="1" placeholder="20" />
</label>
<!-- 4) 生效与提醒频率 -->
<!-- 生效时段:留空表示全天,支持跨零点(如 22:00 ~ 02:00) -->
<label class="field wide" id="ruleActiveRangeField"><span>生效时段(可选,留空表示全天)</span>
<div class="time-range">
<input type="time" id="ruleActiveFrom" />
<span class="range-sep">~</span>
<input type="time" id="ruleActiveTo" />
</div>
</label>
<label class="field" id="ruleCooldownField"><span>冷却时间(秒)</span><input type="number" id="ruleCooldown" min="30" step="30" value="1800" /></label>
<label class="field" id="ruleRepeatField"><span>持续满足时每 N 秒重复提醒(0 不重复)</span><input type="number" id="ruleRepeat" min="0" step="60" value="0" /></label>
<!-- 定时提醒专用:到点时刻 + 重复方式 -->
<label class="field wide" id="ruleScheduleTimesField" hidden><span>提醒时刻(24 小时制,多个用逗号分隔,最多 12 个)</span>
<input type="text" id="ruleScheduleTimes" placeholder="09:00, 15:30, 21:00" />
</label>
<label class="field" id="ruleScheduleRepeatField" hidden><span>重复方式</span>
<select id="ruleScheduleRepeat">
<option value="daily">每天</option>
<option value="weekday">工作日(周一至周五)</option>
<option value="weekly">每周指定几天</option>
</select>
</label>
<div class="field wide" id="ruleScheduleWeekdaysField" hidden>
<span>每周的哪几天</span>
<div class="row wrap">
<label class="check"><input type="checkbox" class="js-weekday" value="1" /> 周一</label>
<label class="check"><input type="checkbox" class="js-weekday" value="2" /> 周二</label>
<label class="check"><input type="checkbox" class="js-weekday" value="3" /> 周三</label>
<label class="check"><input type="checkbox" class="js-weekday" value="4" /> 周四</label>
<label class="check"><input type="checkbox" class="js-weekday" value="5" /> 周五</label>
<label class="check"><input type="checkbox" class="js-weekday" value="6" /> 周六</label>
<label class="check"><input type="checkbox" class="js-weekday" value="7" /> 周日</label>
</div>
</div>
<!-- 5) 最后填名称:留空则按上面的条件自动生成 -->
<label class="field wide"><span>规则名称(可选,留空自动生成)</span><input type="text" id="ruleName" placeholder="留空则按触发条件自动命名" /></label>
</div>
<div class="row wrap">
<span class="label-text">通知渠道</span>
<label class="check"><input type="checkbox" id="ruleChannelDesktop" /> 桌面通知</label>
<label class="check"><input type="checkbox" id="ruleChannelEmail" /> 邮件</label>
<label class="check"><input type="checkbox" id="ruleChannelWebhook" /> WebHook</label>
<label class="check"><input type="checkbox" id="ruleEnabled" /> 启用该规则</label>
</div>
<p class="hint" id="ruleSummary"></p>
<p class="hint" id="ruleWindowHint">提示:统计区间选「日内」时,涨跌幅相对昨收计算;选「近 N 分钟」时,用本机缓存的行情点回算滚动区间,重启后会接着用已保存的历史。</p>
<p class="hint" id="ruleScheduleHint" hidden>提示:定时提醒会在指定时刻按当时的行情发一条通知,不受价格条件影响;同一时刻每天只响一次,程序当时没运行则不会补发。</p>
</div>
<div class="modal-foot">
<span class="test-result" id="ruleResult"></span>
<button class="btn ghost" data-close="modalRule">取消</button>
<button class="btn primary" id="btnSaveRule">保存规则</button>
</div>
</div>
</div>
<div class="toast-wrap" id="toastWrap"></div>
<script src="/app.js?v=20261124q"></script>
</body>
</html>
+528
View File
@@ -0,0 +1,528 @@
/* 金价提醒 · 界面样式(浅色版)
暖白纸感底色 + 香槟金点缀,靠细描边和轻阴影分层次,避免大面积重色块。 */
:root {
--bg: #f7f5f0;
--bg-soft: #fffdf9;
--panel: #ffffff;
--panel-2: #f4f1e9;
--line: #e6e1d5;
--line-strong: #d8d2c3;
--text: #1d2127;
--text-dim: #5f6773;
--text-faint: #6b7382;
--gold: #b8862f;
--gold-soft: #8a5f13;
--gold-wash: #faf4e6;
--up: #d23c2f;
--down: #0f8a55;
--warn: #c07a12;
--radius: 14px;
--shadow-sm: 0 1px 2px rgba(28, 24, 16, .04);
--shadow-md: 0 10px 28px rgba(28, 24, 16, .07);
}
* { box-sizing: border-box; }
/* 有些元素自带 display,需要强制让 [hidden] 生效 */
[hidden] { display: none !important; }
body {
margin: 0;
min-height: 100vh;
background:
radial-gradient(1100px 520px at 88% -12%, rgba(184, 134, 47, .10), transparent 62%),
radial-gradient(900px 480px at -8% 4%, rgba(120, 150, 190, .07), transparent 58%),
var(--bg);
color: var(--text);
font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
font-size: 14px;
line-height: 1.6;
-webkit-font-smoothing: antialiased;
}
code {
background: var(--gold-wash);
border: 1px solid #efe6d0;
border-radius: 5px;
padding: 1px 5px;
font-size: 12px;
color: #7a5715;
}
/* ---------------- 顶栏 ---------------- */
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 18px 28px 14px;
border-bottom: 1px solid var(--line);
background: rgba(255, 255, 255, .78);
backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
width: 42px; height: 42px;
display: grid; place-items: center;
border-radius: 12px;
background: linear-gradient(140deg, #f6dda2, #c79327 72%);
color: #3a2a06;
font-weight: 800;
font-size: 17px;
letter-spacing: .5px;
box-shadow: 0 3px 10px rgba(184, 134, 47, .28);
}
.brand-text h1 { margin: 0; font-size: 19px; letter-spacing: .5px; color: #171a1f; }
.brand-text p { margin: 0; font-size: 11px; color: var(--text-faint); letter-spacing: 1.5px; text-transform: uppercase; }
.status-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill {
display: inline-flex; align-items: center; gap: 7px;
padding: 5px 12px;
border: 1px solid var(--line);
border-radius: 999px;
font-size: 12px;
color: var(--text-dim);
background: #fff;
box-shadow: var(--shadow-sm);
}
.pill .dot {
width: 7px; height: 7px; border-radius: 50%;
background: var(--text-faint);
}
.pill.running .dot { background: var(--down); box-shadow: 0 0 0 3px rgba(15, 138, 85, .12); }
.pill.running { color: #0c6b44; border-color: #cbe7da; background: #f2fbf7; }
.pill.paused .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(192, 122, 18, .12); }
.pill.muted { color: var(--gold-soft); border-color: #ecdfc2; background: var(--gold-wash); }
.clock { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
/* ---------------- 通用按钮 ---------------- */
.btn {
border: 1px solid var(--line-strong);
background: #fff;
color: var(--text);
padding: 8px 16px;
border-radius: 10px;
font-size: 13px;
cursor: pointer;
transition: .15s ease;
white-space: nowrap;
box-shadow: var(--shadow-sm);
}
.btn:hover { background: #fffdf7; border-color: #cbb98d; transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.primary {
background: linear-gradient(140deg, #f3d38f, #cf9c31);
border-color: #c08b22;
color: #3a2a06;
font-weight: 600;
box-shadow: 0 4px 12px rgba(184, 134, 47, .22);
}
.btn.primary:hover { filter: brightness(1.04); }
.btn.ghost { background: #fff; }
.btn.danger { color: #b8332a; border-color: #eececb; background: #fff8f7; }
.btn.danger:hover { background: #fdf0ee; border-color: #e2b3ad; }
.btn.tiny { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn {
border: none; background: transparent; color: var(--text-faint);
font-size: 16px; cursor: pointer; line-height: 1;
}
.icon-btn:hover { color: var(--text); }
/* ---------------- 标签页 ---------------- */
.tabs {
display: flex;
/* 允许换行:极窄窗口下标签自动折行,不用横向滚动 */
flex-wrap: wrap;
gap: 6px;
padding: 14px 28px 0;
border-bottom: 1px solid var(--line);
background: rgba(255, 255, 255, .6);
/* 注意:这里不要写 overflow-x: auto。
一旦设了 overflow-x,overflow-y 会被一并算成 auto,
再叠加 .tab.active::after 的 bottom:-1px(超出 1px),
顶部菜单就会冒出一条多余的滚动条。 */
}
.tab {
position: relative;
border: none;
background: transparent;
color: var(--text-dim);
padding: 10px 14px 14px;
font-size: 14px;
cursor: pointer;
white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold-soft); font-weight: 600; }
.tab.active::after {
content: "";
position: absolute; left: 12px; right: 12px; bottom: -1px;
height: 2px;
background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.badge {
display: inline-block;
margin-left: 6px;
min-width: 18px;
padding: 0 5px;
border-radius: 999px;
background: #fbecea;
color: #b3352a;
font-size: 11px;
text-align: center;
}
/* ---------------- 主体 ---------------- */
main { padding: 22px 28px 60px; max-width: 1320px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-head {
display: flex; align-items: flex-start; justify-content: space-between;
gap: 16px; margin-bottom: 16px;
}
.section-head h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; color: #14171c; }
.hint { margin: 0; color: var(--text-faint); font-size: 12.5px; }
.empty { color: var(--text-faint); text-align: center; padding: 40px 0; }
/* ---------------- 行情卡片 ---------------- */
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
gap: 14px;
}
.card {
position: relative;
background: var(--panel);
border: 1px solid var(--line);
border-radius: var(--radius);
padding: 16px 18px;
overflow: hidden;
box-shadow: var(--shadow-sm);
transition: box-shadow .18s ease, transform .18s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card::before {
content: "";
position: absolute; inset: 0 auto 0 0;
width: 3px;
background: linear-gradient(180deg, rgba(184, 134, 47, .7), rgba(184, 134, 47, .12));
}
.card.disabled { opacity: .62; }
.card.disabled:hover { transform: none; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; color: #14171c; }
.card-title-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.source-tag {
font-size: 10.5px; color: var(--text-faint);
border: 1px solid var(--line); border-radius: 6px;
padding: 1px 6px;
background: var(--bg-soft);
}
.price-row { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 2px; }
.price {
font-size: 30px; font-weight: 700; letter-spacing: -.5px;
font-variant-numeric: tabular-nums;
color: #0f1216;
}
.price.stale { color: var(--text-faint); font-size: 24px; }
.unit { font-size: 12px; color: var(--text-faint); }
.change-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change.flat { color: var(--text-dim); }
.change-row .js-range { color: var(--text-faint); }
.spark { display: block; width: 100%; height: 34px; margin: 8px 0 6px; }
.meta {
display: flex; flex-wrap: wrap; gap: 4px 12px;
font-size: 11.5px; color: var(--text-faint);
font-variant-numeric: tabular-nums;
}
.meta .status { display: inline-flex; align-items: center; gap: 4px; }
.meta .status i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status.ok { color: #0c6b44; }
.status.ok i { background: var(--down); }
.status.error { color: #b3352a; }
.status.error i { background: var(--up); }
.status.pending { color: #8a5f13; }
.status.pending i { background: var(--warn); }
.status.manual { color: var(--gold-soft); }
.status.manual i { background: var(--gold); }
.status.disabled i { background: var(--text-faint); }
.card-error {
margin-top: 8px;
font-size: 11.5px;
color: #a3271f;
background: #fdf2f0;
border: 1px solid #f0cfca;
border-radius: 8px;
padding: 6px 9px;
word-break: break-all;
}
.card-foot {
display: flex; align-items: center; justify-content: space-between;
gap: 8px; margin-top: 12px; padding-top: 11px;
border-top: 1px dashed var(--line);
}
.card-foot .btn-row { display: flex; gap: 6px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
position: absolute; inset: 0;
background: #dcd7ca;
border: 1px solid #cfc8b8;
border-radius: 999px;
cursor: pointer;
transition: .2s;
}
.switch span::before {
content: "";
position: absolute; width: 14px; height: 14px;
left: 3px; top: 3px;
background: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
border-radius: 50%;
transition: .2s;
}
.switch input:checked + span {
background: linear-gradient(135deg, #e7c27a, #c79230);
border-color: #b8862f;
}
.switch input:checked + span::before { background: #fffdf6; transform: translateX(18px); }
.manual-row { display: flex; gap: 6px; margin-top: 10px; }
.manual-row input {
flex: 1; min-width: 0;
background: #fff;
border: 1px solid var(--line-strong);
border-radius: 9px;
padding: 7px 10px;
font-size: 13px;
color: var(--text);
font-family: inherit;
outline: none;
}
.manual-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184, 134, 47, .12); }
/* ---------------- 规则列表 ---------------- */
.rule-list { display: flex; flex-direction: column; gap: 10px; }
.rule-item {
display: flex; align-items: center; gap: 14px;
padding: 14px 18px;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
box-shadow: var(--shadow-sm);
}
.rule-item.disabled { opacity: .6; }
.rule-main { flex: 1; min-width: 0; }
.rule-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rule-name { font-weight: 600; font-size: 14px; color: #14171c; }
.tag {
font-size: 10.5px; padding: 1px 7px; border-radius: 6px;
border: 1px solid var(--line); color: var(--text-dim);
background: var(--bg-soft);
}
.tag.threshold { color: var(--gold-soft); border-color: #e8d7b4; background: var(--gold-wash); }
.tag.change { color: #2a5b96; border-color: #cfe0f2; background: #f2f7fc; }
.tag.spread { color: #6a4b9a; border-color: #e0d4f0; background: #f7f3fc; }
/* 定时提醒:用偏绿的色,和三种价格条件规则区分开 */
.tag.schedule { color: #1f7a5c; border-color: #cfe8dd; background: #f1faf6; }
.rule-cond { margin-top: 4px; font-size: 12.5px; color: var(--text-dim); }
.rule-sub { margin-top: 3px; font-size: 11.5px; color: var(--text-faint); }
.rule-actions { display: flex; align-items: center; gap: 8px; }
/* ---------------- 设置区 ---------------- */
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-bottom: 14px; }
.setting-card { margin-bottom: 14px; }
.setting-card .card-head { margin-bottom: 6px; align-items: center; }
.setting-card h3 { margin: 0; font-size: 15px; color: #14171c; }
.form-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 12px 16px;
margin: 14px 0 4px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.field.wide { grid-column: 1 / -1; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.check-field { flex-direction: row; align-items: center; justify-content: space-between; }
.field input, .field select, .field textarea {
background: #fff;
border: 1px solid var(--line-strong);
border-radius: 9px;
padding: 8px 11px;
color: var(--text);
font-size: 13px;
font-family: inherit;
outline: none;
transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
border-color: var(--gold);
box-shadow: 0 0 0 3px rgba(184, 134, 47, .12);
}
.field input.narrow { width: 120px; }
.field input[type="checkbox"] {
width: 16px; height: 16px;
padding: 0; border: none; background: none;
accent-color: var(--gold);
}
input::placeholder { color: #a8a294; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
/* 不在 .field 里的裸输入框(如静默时段区间)也套用同一套皮肤 */
.row > input[type="text"], .row > input[type="number"] {
background: #fff;
border: 1px solid var(--line-strong);
border-radius: 9px;
padding: 7px 11px;
color: var(--text);
font-size: 13px;
font-family: inherit;
outline: none;
width: 150px;
}
.row > input[type="text"]:focus, .row > input[type="number"]:focus {
border-color: var(--gold);
box-shadow: 0 0 0 3px rgba(184, 134, 47, .12);
}
.label-text { color: var(--text-dim); font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--gold); }
.test-result { font-size: 12px; color: var(--text-faint); }
.test-result.ok { color: #0c6b44; }
.test-result.err { color: #b8332a; }
.sticky-save {
position: sticky; bottom: 0;
padding: 12px 0 6px;
background: linear-gradient(180deg, transparent, var(--bg) 45%);
}
/* ---------------- 提醒记录 ---------------- */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item {
padding: 13px 16px;
background: var(--panel);
border: 1px solid var(--line);
border-left: 3px solid var(--gold);
border-radius: 10px;
box-shadow: var(--shadow-sm);
}
.alert-title { font-weight: 600; font-size: 13.5px; color: #14171c; }
.alert-msg { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }
.alert-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.alert-meta .chan { color: var(--text-dim); }
.alert-meta .chan.ok { color: #0c6b44; }
.alert-meta .chan.err { color: #b8332a; }
/* ---------------- 弹窗 ---------------- */
.modal {
position: fixed; inset: 0; z-index: 50;
display: grid; place-items: center;
background: rgba(35, 30, 22, .38);
backdrop-filter: blur(4px);
padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
width: min(720px, 100%);
max-height: 88vh;
overflow: auto;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 16px;
box-shadow: 0 24px 60px rgba(28, 24, 16, .18);
}
.modal-head {
display: flex; align-items: center; justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid var(--line);
position: sticky; top: 0;
background: var(--panel);
z-index: 1;
}
.modal-head h3 { margin: 0; font-size: 16px; color: #14171c; }
.modal-body { padding: 18px 20px 6px; }
.modal-foot {
display: flex; align-items: center; justify-content: flex-end; gap: 10px;
padding: 14px 20px 18px;
border-top: 1px solid var(--line);
position: sticky; bottom: 0;
background: var(--panel);
}
.modal-foot .test-result { margin-right: auto; }
/* ---------------- 轻提示 ---------------- */
.toast-wrap {
position: fixed; right: 22px; bottom: 22px;
display: flex; flex-direction: column; gap: 8px;
z-index: 99;
}
.toast {
padding: 10px 16px;
border-radius: 10px;
background: #fff;
border: 1px solid var(--line-strong);
color: var(--text);
font-size: 13px;
box-shadow: var(--shadow-md);
animation: slideIn .2s ease;
}
.toast.ok { border-color: #bfe0d0; background: #f5fcf8; color: #0c6b44; }
.toast.err { border-color: #eec9c4; background: #fdf3f1; color: #a3271f; }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
/* ---------------- 规则弹窗:生效时段 ---------------- */
.time-range {
display: flex;
align-items: center;
gap: 8px;
}
.time-range input[type="time"] {
flex: 1 1 0;
min-width: 0;
}
.range-sep {
color: var(--text-faint);
font-size: 13px;
flex: 0 0 auto;
}
/* ---------------- 窄屏适配 ---------------- */
@media (max-width: 720px) {
.topbar { flex-direction: column; align-items: flex-start; padding: 16px; }
main { padding: 18px 16px 60px; }
.tabs { padding: 10px 16px 0; }
.price { font-size: 26px; }
.rule-item { flex-wrap: wrap; }
.form-grid { grid-template-columns: 1fr; }
}