Files
cmautobuy/admin/static/css/app.css
T
chengmaandClaude Opus 5 5e426cacf6 feat: 顺运宝货运单同步 (#46)
顺运宝模块此前是骨架,「同步」点了提示"待接入"。5195 个蝦皮商品已经
进系统,但货运单(真实订单)一条都没有,后面的规格匹配无从谈起。

按接口契约(docs/admin/08,从 4 份 HAR 还原)实现:配置、登录(界面
手工输验证码)、会话缓存到 SQLite、按日期范围增量同步、落 syb_orders。

shopee_sku_id 绝不被同步覆盖。它是规格匹配的结果,顺运宝那边根本没有
这个值(只给 11 位商品ID,蝦皮規格ID 是 12 位)。同步写进去就是写空,
把人工攒的匹配成果洗掉且不报错。它只出现在 INSERT 列清单里,不在
DO UPDATE SET 里;repository 层和 service 端到端各有一个测试守着。

增量从「上次同步日期当天」重拉,不是第二天。created 筛选粒度是日期而
last_synced_at 精确到秒,从第二天拉会漏掉当天晚些时候创建的单且不报错。
宁可重复拉(upsert 幂等)也不能漏。中途失败不更新 last_synced_at,
否则下次跳过这段区间,漏的单永远补不回来。

日期运算用 UTC+8,不是 UTC。审查时从 HAR 确认 created 是当地时间:
抓包于 2026-07-28T03:31:45Z(= 11:31 UTC+8),同一响应里 created 是
"2026-07-28 10:37:59";若它是 UTC 则等于 18:37 UTC+8,比抓包晚 7 小时,
订单创建于未来,不成立。用 UTC 算会在本地 00:00-08:00 把"今天"算成昨天,
当天早晨的单这轮拉不到。用 time.FixedZone 写死,不用 LoadLocation——
那要读系统 tzdata,Windows 默认没有,打包成 exe 会失败。

金额一律取 detail/listByStock 的值:08 §5.1 实测同一响应里 amtOrder
在列表接口是分、escrowAmount 却不是,单位不统一,取错差 100 倍。

迁移 v5 纯追加(syb_session、syb_sync_state、syb_orders.product_spec),
v1-v4 逐字未动,CheckSchema 覆盖新表新列。

会话有效性判断把「网络故障」和「明确未登录」的分类集中在 Client.do()
一处——网络抖一下就判定登出的话,验证码会弹个不停,还会丢掉有效会话。

测试全部用 httptest 假服务端,不打真实站点。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 11:49:13 +08:00

324 lines
9.0 KiB
CSS

/* Admin 样式表。手写 CSS,不引入框架、不引入构建流程。
见 admin/AGENTS.md 前端约束。
五个模块共用同一套三段式布局的样式:
.toolbar(顶部工具条)/ .table-wrap(中间表格)/ .statusbar(底部状态条)。
改这里会同时影响五个页面,这是有意的——不要为某个页面复制一份。 */
* { box-sizing: border-box; }
body {
margin: 0;
font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
font-size: 14px;
color: #222;
background: #f5f6f8;
/* 底部状态条是固定的,给它留出空间 */
padding-bottom: 40px;
}
/* ── 导航 ─────────────────────────────── */
.nav {
display: flex;
align-items: center;
gap: 4px;
background: #2b3440;
padding: 0 16px;
}
.nav-brand {
color: #fff;
font-weight: 600;
margin-right: 24px;
padding: 12px 0;
}
.nav a {
color: #c8cdd4;
text-decoration: none;
padding: 12px 16px;
}
.nav a:hover { background: #3a4552; color: #fff; }
.nav a.active { background: #1f6feb; color: #fff; }
/* ── 页面主体 ─────────────────────────── */
.page { padding: 16px; }
/* ── 第一段:顶部工具条 ───────────────── */
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
background: #fff;
border: 1px solid #e1e4e8;
border-radius: 4px;
padding: 10px 12px;
margin-bottom: 12px;
}
.toolbar .inline {
display: flex;
align-items: center;
gap: 6px;
margin: 0;
}
/* 搜索表单占据剩余空间,把删除按钮挤到右边 */
.toolbar .grow { flex: 1; }
.toolbar label { color: #555; white-space: nowrap; }
/* 搜索框收窄到 30%。目前 PDD 商品页、顺运宝数据页、采集采购页在用;
蝦皮数据页和客户端列表页仍是撑满的。
这样搜索表单里就没有会伸展的元素了,多余空间留在按钮之后,
「搜索」按钮自然贴着输入框,不会被顶到很右边。
用 flex 而不是 width:工具条是 flex 布局,width 会被 flex-grow 盖掉。
min-width 由下面那条继承,窄屏时不会缩到没法输入。 */
.toolbar input[type="text"].search-narrow { flex: 0 0 30%; }
.toolbar input[type="text"] {
flex: 1;
min-width: 160px;
padding: 5px 8px;
border: 1px solid #ccd1d6;
border-radius: 3px;
}
button {
padding: 5px 14px;
border: 1px solid #ccd1d6;
border-radius: 3px;
background: #fff;
cursor: pointer;
white-space: nowrap;
}
button:hover { background: #f0f2f4; }
button.danger { color: #b42318; border-color: #f0b4ae; }
button.danger:hover { background: #fdf1f0; }
button:disabled { opacity: .5; cursor: not-allowed; }
/* ── 第二段:表格 ─────────────────────── */
/* 列多了横向滚动,不要压缩列宽把字挤成两行 */
.table-wrap {
overflow-x: auto;
background: #fff;
border: 1px solid #e1e4e8;
border-radius: 4px;
}
table { width: 100%; border-collapse: collapse; }
th, td {
padding: 8px 10px;
text-align: left;
border-bottom: 1px solid #eef0f2;
white-space: nowrap;
}
th { background: #fafbfc; font-weight: 600; color: #444; }
tbody tr:hover { background: #f7f9fb; }
.col-check { width: 36px; }
/* 解析失败的行标黄,提示需要人工补 */
tr.row-warn { background: #fffbe6; }
tr.row-warn:hover { background: #fff6d0; }
/* PDD 链接未填写,标红提醒 */
.missing { color: #b42318; font-weight: 600; }
/* 空状态:文案要分情况,不要都写"暂无数据" */
tr.empty td {
text-align: center;
color: #888;
padding: 40px 10px;
white-space: normal;
}
tr.empty small { color: #aaa; }
.hint {
color: #777;
font-size: 13px;
margin: 12px 2px;
}
/* ── 第三段:底部状态条 ───────────────── */
.statusbar {
position: fixed;
left: 0; right: 0; bottom: 0;
display: flex;
align-items: center;
background: #2b3440;
color: #c8cdd4;
padding: 10px 16px;
font-size: 13px;
}
/* 链接和标题这类长内容截断显示,鼠标悬停看全文(title 属性)。
不截断的话一列能把表格撑到屏幕外面去。 */
.truncate {
max-width: 280px;
overflow: hidden;
text-overflow: ellipsis;
}
/* 蝦皮数据页商品名称列收窄,配合 .truncate 一起用(见工单 #41)。
用独立类设 max-width,不用 flex——.search-narrow 那套是给工具条用的,
表格单元格不是 flex 布局,flex 在这里不生效。放在 .truncate 之后,
同优先级下按 CSS 层叠顺序覆盖 .truncate 的 280px。
18% = 初版 30% 的六成。蝦皮标题普遍很长(实测最长 60+ 字,
全是关键词堆砌),不收窄的话这一列会把后面的颜色/尺码/SKU/待补
几个关键数字挤出屏幕——而那几个数字才是这个页面要看的东西。
完整标题靠悬停的 title 属性看。 */
.col-title {
max-width: 18%;
}
/* ── 弹窗 ─────────────────────────────── */
/* 用 hidden 属性控制显示隐藏,JS 只改这一个属性,不拼样式 */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(20, 24, 30, .45);
display: flex;
align-items: flex-start;
justify-content: center;
padding: 40px 16px;
overflow-y: auto;
z-index: 10;
}
.modal {
background: #fff;
border-radius: 6px;
box-shadow: 0 8px 32px rgba(0, 0, 0, .25);
width: 100%;
max-width: 720px;
}
.modal-head {
display: flex;
align-items: center;
padding: 12px 16px;
border-bottom: 1px solid #e1e4e8;
}
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; }
.modal-x {
border: none;
background: none;
font-size: 20px;
line-height: 1;
padding: 0 6px;
color: #666;
}
.modal-body { padding: 16px; }
.modal-body h3 { font-size: 14px; margin: 20px 0 8px; }
.modal-foot {
display: flex;
align-items: center;
gap: 8px;
justify-content: flex-end;
padding: 12px 16px;
border-top: 1px solid #e1e4e8;
background: #fafbfc;
}
/* 把左边的按钮和右边的按钮推开 */
.modal-foot .grow { flex: 1; }
button.primary {
background: #1f6feb;
border-color: #1f6feb;
color: #fff;
}
button.primary:hover { background: #1a5fd0; }
/* 详情弹窗里折叠展开的完整结果(result_data),见任务详情弹窗 */
.result-data {
white-space: pre-wrap;
word-break: break-all;
background: #f5f6f8;
border: 1px solid #e1e4e8;
border-radius: 4px;
padding: 10px;
max-height: 300px;
overflow-y: auto;
font-size: 12px;
}
/* 弹窗里的字段表:左边标签,右边值 */
.detail {
display: grid;
grid-template-columns: 88px 1fr;
gap: 8px 12px;
margin: 0;
align-items: baseline;
}
.detail dt { color: #555; }
.detail dd { margin: 0; word-break: break-all; }
.detail dd small { color: #999; margin-left: 6px; }
/* 创建弹窗里的单个字段,标签在输入框上面 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: #555; }
input[type="text"] {
padding: 5px 8px;
border: 1px solid #ccd1d6;
border-radius: 3px;
}
input.wide { width: 100%; }
select {
padding: 5px 8px;
border: 1px solid #ccd1d6;
border-radius: 3px;
background: #fff;
}
/* ── 分页控件 ─────────────────────────── */
/* 见 docs/admin/05-ui-specification.md §3.2。全项目第一个分页页面
(蝦皮数据页,工单 #43)定的样式,其余四个页面照抄。
控件本身是 <a href>,不是按钮/JS,样式借用 button 的观感即可。 */
.pagination {
display: flex;
align-items: center;
gap: 6px;
margin-left: 12px;
}
.pagination a,
.pagination span.disabled {
padding: 4px 10px;
border: 1px solid #ccd1d6;
border-radius: 3px;
text-decoration: none;
font-size: 13px;
}
.pagination a { color: #1f6feb; background: #fff; }
.pagination a:hover { background: #f0f2f4; }
/* 首页/末页时对应按钮禁用:用 <span> 而不是不可点的 <a>(语义上不再是链接),
再配色区分,不能只靠颜色(见 05 §3.2)。 */
.pagination span.disabled {
color: #aaa;
background: #f5f6f8;
cursor: not-allowed;
}
/* ── 顺运宝登录弹窗:验证码图片、表格缩略图 ─────── */
/* 工单 #46。缩略图故意限制到很小的尺寸——表格一行放不下大图,
要看清楚还是得点开顺运宝或蝦皮后台自己的图。 */
.captcha-img {
display: block;
height: 40px;
border: 1px solid #ccd1d6;
border-radius: 3px;
margin-bottom: 6px;
cursor: pointer;
}
.thumb {
width: 32px;
height: 32px;
object-fit: cover;
border-radius: 3px;
vertical-align: middle;
}
/* ── 错误页 ───────────────────────────── */
.error-box {
background: #fff;
border: 1px solid #f0b4ae;
border-left: 4px solid #b42318;
border-radius: 4px;
padding: 16px 20px;
max-width: 720px;
}
.error-box h2 { margin-top: 0; color: #b42318; font-size: 16px; }