Compare commits
24
Commits
09b229deee
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c5eec6049 | ||
|
|
c8f3ae4fdb | ||
|
|
973afd7886 | ||
|
|
7c4a747ea9 | ||
|
|
56c1fa648a | ||
|
|
8fbffd8408 | ||
|
|
e453ebb0da | ||
|
|
7d2e65975b | ||
|
|
675e096675 | ||
|
|
bc8402ca67 | ||
|
|
cb7cd3649b | ||
|
|
9f2322e7ae | ||
|
|
09311aac5b | ||
|
|
6a7c7b267f | ||
|
|
4ce09ce173 | ||
|
|
daa78fc25d | ||
|
|
4f76ec4b11 | ||
|
|
f9f406f54b | ||
|
|
fd72f7192e | ||
|
|
b83511ff55 | ||
|
|
f6df52ce63 | ||
|
|
74bf490baa | ||
|
|
12e66badc6 | ||
|
|
6b05fc849a |
@@ -26,3 +26,7 @@ _shots/
|
||||
# 原始私有素材与原站导出(协作仓只保留脱敏副本)
|
||||
raw/
|
||||
backup/
|
||||
|
||||
# Python 缓存
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
@@ -16,3 +16,5 @@
|
||||
> 看后端请从 **`backend/他应该知道的.md`** 开始读(生意背景 / 机器约束 / 数据边界 / 术语表),
|
||||
> 再进 `backend/README.md` 和两份交接说明。
|
||||
> 写回执照 **`backend/回执模板.md`** 填。
|
||||
|
||||
- **内容后台**(2026-10-05):网站展示内容在网页后台里改 —— 设计与安全规则见 `内容后台设计.md`,部署见 `交接文档-2026-10.md` 7.1b。
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
python3 admin.py sweep 清理超过保留期的成品
|
||||
python3 admin.py stat 概览
|
||||
python3 admin.py db [check|backup|export [目录]] 数据库:体检 / 热备份 / 导回旧版 JSON
|
||||
python3 admin.py user list 内容后台:有哪些账号、最近登录
|
||||
python3 admin.py user add <用户名> [--email 邮箱] [--temp] 建账号(密码隐藏输入两遍;--temp = 发临时密码、首次登录必须改)
|
||||
python3 admin.py user passwd <账号> 直接设新密码(这个账号所有会话作废)
|
||||
python3 admin.py user reset <账号> [--to-admin] 忘了密码:会话全作废 → 临时密码 → 下次登录必须改
|
||||
python3 admin.py user disable|enable <账号> 停用 / 启用(停用时会话全作废)
|
||||
python3 admin.py user sessions <账号> [--revoke-all] 在哪些设备登录着 / 全部踢掉
|
||||
python3 admin.py audit [行数] 看兑换码失败/被拒记录
|
||||
"""
|
||||
import csv, json, os, shutil, sys, time
|
||||
@@ -288,6 +294,71 @@ def cmd_db(argv):
|
||||
print("用法:admin.py db [check|backup|export [目录]]")
|
||||
|
||||
|
||||
def cmd_user(argv):
|
||||
"""内容后台的账号(2026-10-05)。账号只能在服务器上用命令行建 —— 网页上没有注册入口。"""
|
||||
import getpass
|
||||
from datetime import datetime as _dt
|
||||
sub, rest = (argv[0] if argv else "list"), argv[1:]
|
||||
C = S.CMS
|
||||
fmt = lambda ts: _dt.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M") if ts else "从没登录过"
|
||||
|
||||
def ask_pw():
|
||||
a = getpass.getpass("新密码(至少 %d 位):" % S.cms.MIN_PW)
|
||||
if getpass.getpass("再输一遍:") != a:
|
||||
sys.exit("两次输的不一样")
|
||||
p = S.cms.pw_problem(a)
|
||||
if p:
|
||||
sys.exit(p)
|
||||
return a
|
||||
try:
|
||||
if sub == "list":
|
||||
for u in C.users():
|
||||
print("%-16s %-28s %s%s 最近登录 %s(%s) 登录着 %d 台" % (
|
||||
u["user"], u["email"] or "-", "【待改密】" if u["must_change"] else "", "【已停用】" if u["disabled"] else "",
|
||||
fmt(u["last_login"]), u["last_ip"] or "-", u["sessions"]))
|
||||
elif sub == "add" and rest:
|
||||
email = rest[rest.index("--email") + 1] if "--email" in rest else None
|
||||
import re as _re # 先校验,再问密码(不然填了半天密码才告诉你用户名不行)
|
||||
if not _re.match(r"^[A-Za-z0-9_.-]{2,32}$", rest[0]):
|
||||
sys.exit("用户名只能是 2–32 位字母、数字、点、横线、下划线")
|
||||
if C.user_row(rest[0]) or (email and C.user_row(email)):
|
||||
sys.exit("用户名或邮箱已经有人用了")
|
||||
if "--temp" in rest:
|
||||
import secrets as _sec
|
||||
pw = _sec.token_urlsafe(9)
|
||||
C.user_add(rest[0], pw, email, must_change=True)
|
||||
print("建好了。临时密码:%s\n(只显示这一次;他第一次登录必须改密码)" % pw)
|
||||
else:
|
||||
C.user_add(rest[0], ask_pw(), email)
|
||||
print("建好了:%s" % rest[0])
|
||||
elif sub == "passwd" and rest:
|
||||
name = C.user_set_password(rest[0], ask_pw())
|
||||
C.audit("命令行", "-", "设了 %s 的新密码(所有会话已作废)" % name)
|
||||
print("改好了;%s 所有登录着的设备都已退出" % name)
|
||||
elif sub == "reset" and rest:
|
||||
tmp = C.user_reset(rest[0], to_admin="--to-admin" in rest)
|
||||
print("重置好了。临时密码:%s\n所有会话已作废;下次登录必须改密码。(临时密码只显示这一次)" % tmp)
|
||||
elif sub in ("disable", "enable") and rest:
|
||||
C.user_disable(rest[0], off=(sub == "disable"))
|
||||
print("已%s:%s" % ("停用" if sub == "disable" else "启用", rest[0]))
|
||||
elif sub == "sessions" and rest:
|
||||
if "--revoke-all" in rest:
|
||||
print("踢掉了 %d 个会话" % C.revoke_all(rest[0]))
|
||||
else:
|
||||
r = C.user_row(rest[0])
|
||||
if not r:
|
||||
sys.exit("没有这个账号")
|
||||
rows = C.sessions_of(r[0])
|
||||
if not rows:
|
||||
print("(没有登录着的设备)")
|
||||
for s in rows:
|
||||
print("%s 最近 %s %s %s%s" % (s["id"], fmt(s["last"]), s["ip"], (s["ua"] or "")[:50], " 记住我" if s["remember"] else ""))
|
||||
else:
|
||||
print(__doc__)
|
||||
except S.cms.Bad as e:
|
||||
sys.exit(str(e))
|
||||
|
||||
|
||||
def cmd_calls(argv):
|
||||
rows = S.STORE.calls() # 数据库 calls 表(2026-10-05 起;calls.jsonl 只是给手机通知的副本)
|
||||
if not rows:
|
||||
@@ -437,6 +508,7 @@ def cmd_price(argv):
|
||||
raise SystemExit("用法:price / price per N / price set N 价格 [链接] / price rm N")
|
||||
d["tiers"] = tiers
|
||||
S.jsave(S.PRICES_FILE, d)
|
||||
print("⚠️ 2026-10-05 起价格建议在内容后台改(「价格与付款」页):后台下次改价格并发布时,会以后台里的为准覆盖这里的改动。")
|
||||
try:
|
||||
os.chmod(S.PRICES_FILE, 0o644)
|
||||
except OSError:
|
||||
@@ -553,7 +625,7 @@ def cmd_gift(argv):
|
||||
CMDS = {"gen": cmd_gen, "codes": cmd_codes, "ls": cmd_ls, "show": cmd_show,
|
||||
"gift": cmd_gift,
|
||||
"price": cmd_price,
|
||||
"retry": cmd_retry, "calls": cmd_calls, "db": cmd_db, "sweep": cmd_sweep, "stat": cmd_stat,
|
||||
"retry": cmd_retry, "calls": cmd_calls, "db": cmd_db, "user": cmd_user, "sweep": cmd_sweep, "stat": cmd_stat,
|
||||
"audit": cmd_audit, "activate": cmd_activate, "pending": cmd_pending,
|
||||
"edit": cmd_edit}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+157
-35
@@ -42,6 +42,14 @@ def payplatform_creds():
|
||||
return "", ""
|
||||
|
||||
|
||||
def _pp_key(d, suffix=""):
|
||||
"""读付款配置:真实配置文件里的键是 afdian / afdian_uid,代码里叫 payplatform / payplatform_uid。
|
||||
⚠️ 2026-10-07 实测:正式站只认后者 → 读到空 → 下单页拿不到专链,付款区只剩「付款方式找金钻要」。两种都认。"""
|
||||
if not isinstance(d, dict):
|
||||
return ""
|
||||
return str(d.get("afdian" + suffix) or d.get("payplatform" + suffix) or "").strip()
|
||||
|
||||
|
||||
def payplatform_api(path, params=None):
|
||||
"""调爱发电开放接口。签名算法:md5(token + 'params' + params + 'ts' + ts + 'user_id' + user_id)。"""
|
||||
uid, tok = payplatform_creds()
|
||||
@@ -60,8 +68,27 @@ def payplatform_api(path, params=None):
|
||||
return {"ec": -1, "em": "调用失败:%r" % e}
|
||||
|
||||
|
||||
def _hook_unverified(oid_af, order, why, ip):
|
||||
"""没验证过的爱发电回调:只留最近 50 条在 kv「hook_unverified」里,给金钻人工核对用(2026-10-06 安全加固)。
|
||||
字段全部截断,不进账本 pay_orders —— 伪造的报文刷再多也只占这 50 格。"""
|
||||
try:
|
||||
lst = STORE.kv_get("hook_unverified", []) or []
|
||||
lst.append({"ts": now().isoformat(timespec="seconds"), "out_trade_no": str(oid_af)[:64], "why": why[:60],
|
||||
"amount": str(order.get("show_amount") or order.get("total_amount") or "")[:16],
|
||||
"title": ("%s %s" % (order.get("plan_title") or "", order.get("title") or "")).strip()[:60], "ip": str(ip)[:45]})
|
||||
STORE.kv_put("hook_unverified", lst[-50:])
|
||||
except Exception as e:
|
||||
log("记待核对回调失败:%s" % e)
|
||||
|
||||
|
||||
def payplatform_find_order(out_trade_no, pages=3):
|
||||
"""按订单号反查(确认这笔真的存在、真的付款了)。返回订单 dict 或 None。"""
|
||||
"""按订单号反查(确认这笔真的存在、真的付款了)。返回订单 dict 或 None。
|
||||
2026-10-07:开放接口支持直接按 out_trade_no 查 —— 先精确查,查不到(接口延迟等)再翻页兜底。"""
|
||||
r = payplatform_api("query-order", {"out_trade_no": str(out_trade_no)})
|
||||
if r.get("ec") == 200:
|
||||
for o in ((r.get("data") or {}).get("list") or []):
|
||||
if str(o.get("out_trade_no")) == str(out_trade_no):
|
||||
return o
|
||||
for pg in range(1, pages + 1):
|
||||
r = payplatform_api("query-order", {"page": pg})
|
||||
if r.get("ec") != 200:
|
||||
@@ -401,7 +428,8 @@ def gift_claim(bid, token, ip):
|
||||
return False, "这批券过期了"
|
||||
with LOCK:
|
||||
cs = load_codes()
|
||||
mine = [c for c, r in cs.items() if r.get("gift") == bid and r.get("claim_token") == tok]
|
||||
mine = [c for c, r in cs.items() if r.get("gift") == bid and isinstance(tok, str) and tok
|
||||
and hmac.compare_digest(str(r.get("claim_token") or ""), tok)] # 定长比较(2026-10-06 安全加固)
|
||||
if mine:
|
||||
return False, "你已经领过啦 —— 这批每人限一张 😉 想多要就等下一波福利"
|
||||
ip_n = len([c for c, r in cs.items()
|
||||
@@ -621,10 +649,10 @@ def price_for(n_img, tiers=None):
|
||||
def payplatform_link_for(n_img):
|
||||
"""n 张图该跳哪个爱发电商品;这档没配就回落到总链接。"""
|
||||
t = (price_tiers().get("tiers") or {}).get(str(max(1, int(n_img or 1))))
|
||||
if isinstance(t, dict) and (t.get("payplatform") or "").strip():
|
||||
return t["payplatform"].strip()
|
||||
if isinstance(t, dict) and _pp_key(t):
|
||||
return _pp_key(t)
|
||||
d = jload(PAYINFO_FILE, {}) or {}
|
||||
return (d.get("payplatform") or "").strip()
|
||||
return _pp_key(d)
|
||||
TERMS_VERSION = "2026-10-04.1"
|
||||
|
||||
|
||||
@@ -638,6 +666,69 @@ def _recent(bucket, ip, win):
|
||||
return lst
|
||||
|
||||
|
||||
class _ReconcileCall:
|
||||
"""对账时借用回调处理逻辑(账本去重、金额闸门、激活、通知全一样)的「替身请求」。"""
|
||||
headers = {}
|
||||
client_address = ("reconcile", 0)
|
||||
|
||||
def __init__(self):
|
||||
self.out = None
|
||||
|
||||
def js(self, obj, code=200):
|
||||
self.out = obj
|
||||
|
||||
|
||||
RECONCILE_LAST = {"at": 0.0}
|
||||
|
||||
|
||||
def payplatform_reconcile(only_oid=None, pages=5):
|
||||
"""主动对账(2026-10-07):去爱发电拉最近的订单,凡是带回了**待付款网页单**订单号、而账本里还没有的,
|
||||
按回调同样的流程处理一遍(反查 → 金额闸门 → 激活)。返回激活了的订单号列表。
|
||||
- 定时线程每分钟跑一次(有待付款单才真的去调接口);
|
||||
- 买家点「我付好了」时只针对这一单立刻跑一次(only_oid)。"""
|
||||
pend = {m["oid"] for m in list_orders(("unpaid", "paid"))}
|
||||
if only_oid:
|
||||
pend &= {only_oid}
|
||||
if not pend:
|
||||
return []
|
||||
led = STORE.ledger_all()
|
||||
done = []
|
||||
for pg in range(1, pages + 1):
|
||||
r = payplatform_api("query-order", {"page": pg})
|
||||
if r.get("ec") != 200:
|
||||
break
|
||||
data = r.get("data") or {}
|
||||
for o in (data.get("list") or []):
|
||||
otn = str(o.get("out_trade_no") or "")
|
||||
if not otn or otn in led or int(o.get("status") or 0) != 2:
|
||||
continue
|
||||
coid = str(o.get("custom_order_id") or "").strip().upper()
|
||||
rm = re.sub(r"[^0-9A-Z]", "", str(o.get("remark") or "").upper())
|
||||
hit = coid if coid in pend else next((x for x in pend if x in rm), None)
|
||||
if not hit:
|
||||
continue
|
||||
call = _ReconcileCall()
|
||||
with HOOK_LOCK:
|
||||
H._payplatform_hook_locked(call, {"data": {"type": "order", "order": o}})
|
||||
m = read_meta(hit) or {}
|
||||
if m.get("state") not in ("unpaid", "paid"):
|
||||
done.append(hit)
|
||||
log("对账:爱发电订单 %s → 激活了网页单 %s" % (otn[-8:], hit))
|
||||
if pg >= int(data.get("total_page") or 1):
|
||||
break
|
||||
RECONCILE_LAST["at"] = time.time()
|
||||
return done
|
||||
|
||||
|
||||
def reconcile_loop():
|
||||
while True:
|
||||
time.sleep(60)
|
||||
try:
|
||||
payplatform_reconcile()
|
||||
except Exception as e:
|
||||
log("对账出错:%r" % e)
|
||||
|
||||
|
||||
def ip_of(handler):
|
||||
return (handler.headers.get("X-Real-IP") or handler.client_address[0] or "?").strip()
|
||||
|
||||
@@ -1285,6 +1376,11 @@ def purge_order(oid):
|
||||
|
||||
import pngcheck # PNG 结构核验(防夹带)—— 同目录,零依赖
|
||||
|
||||
# 内容后台(2026-10-05):网站展示内容在网页后台里改。账号 / 会话 / 草稿 / 发布全在 cms.py,
|
||||
# 这里只把 /api/cms/* 交给它。和卡密 / 订单完全分开(它只读写 cms_* 表、内容文件、prices.json / payinfo.json)。
|
||||
import cms # noqa: E402
|
||||
CMS = cms.CMS(STORE, ROOT, log=log, prices_file=PRICES_FILE, payinfo_file=PAYINFO_FILE, tpl_keys=TPL_KEYS, pngcheck=pngcheck)
|
||||
|
||||
|
||||
def png_size(data):
|
||||
"""从 PNG 头读宽高,零依赖"""
|
||||
@@ -1644,6 +1740,8 @@ class H(BaseHTTPRequestHandler):
|
||||
u = urlparse(self.path)
|
||||
p, q = u.path, parse_qs(u.query)
|
||||
try:
|
||||
if p.startswith("/api/cms/"):
|
||||
return CMS.handle(self, "GET", p, q)
|
||||
if p == "/api/status":
|
||||
# ?fresh=1 → 跳过 60 秒缓存,现算(页面上的「刷新」按钮用这个)。
|
||||
# ⚠️ 不加的话:渲染机刚上线,用户连刷几次都还是缓存的「离线」(金钻 2026-10-01 反馈)
|
||||
@@ -1720,6 +1818,8 @@ class H(BaseHTTPRequestHandler):
|
||||
u = urlparse(self.path)
|
||||
p = u.path
|
||||
try:
|
||||
if p.startswith("/api/cms/"):
|
||||
return CMS.handle(self, "POST", p, parse_qs(u.query))
|
||||
# 领一张福利券(免费、免付费、只限张数)
|
||||
if p == "/api/gift/claim":
|
||||
return self.gift_take()
|
||||
@@ -2024,6 +2124,7 @@ class H(BaseHTTPRequestHandler):
|
||||
"name": f.get("name"),
|
||||
"size": fsz,
|
||||
"skin": f.get("skin"),
|
||||
"tpl": f.get("tpl") or "", # 重渲弹窗要知道哪个模板已经出图(2026-10-07)
|
||||
"is_raw": ("无压缩" in (f.get("name") or "")),
|
||||
# 收货前:给预览地址;收货后:给原图地址
|
||||
# ⚠️ 必须带 v=<文件 mtime>:重渲会把同名文件原地覆盖,URL 不变的话
|
||||
@@ -2080,6 +2181,10 @@ class H(BaseHTTPRequestHandler):
|
||||
"accepted": accepted,
|
||||
# 买家自助重渲:用过没有 + 上次选了什么(页面按钮据此置灰)
|
||||
"redo_used": bool(m.get("redo_used")),
|
||||
# 直发单没有收货这一步(accepted 恒为真),免费重渲照样给;
|
||||
# 买家亲手点过「确认收货」的单才关掉重渲 —— 前端靠这个区分(2026-10-07)
|
||||
"direct": bool(m.get("direct")),
|
||||
"accepted_by_buyer": bool(m.get("accepted")),
|
||||
"redo_files": m.get("redo_files") or [],
|
||||
"amount": amount,
|
||||
"amount": amount,
|
||||
@@ -2257,10 +2362,16 @@ class H(BaseHTTPRequestHandler):
|
||||
obj = json.loads(raw.decode("utf-8", "replace") or "{}")
|
||||
except ValueError:
|
||||
obj = {"_parse_error": True, "_raw": raw[:2000].decode("utf-8", "replace")}
|
||||
# 回调日志(2026-10-06 安全加固):这个地址谁都能 POST —— 只记几个关键头 + 正文前 4KB,
|
||||
# 超过 5MB 轮转成 .1(只留一份旧的),不然一个人就能把磁盘写满。
|
||||
try:
|
||||
if os.path.exists(PAYPLATFORM_LOG) and os.path.getsize(PAYPLATFORM_LOG) > 5 * 1024 * 1024:
|
||||
os.replace(PAYPLATFORM_LOG, PAYPLATFORM_LOG + ".1")
|
||||
keep = {k: v for k, v in self.headers.items() if k.lower() in ("user-agent", "content-type", "x-real-ip", "x-forwarded-for")}
|
||||
body = json.dumps(obj, ensure_ascii=False)
|
||||
with open(PAYPLATFORM_LOG, "a", encoding="utf-8") as f:
|
||||
f.write(json.dumps({"ts": now().isoformat(timespec="seconds"), "ip": ip_of(self),
|
||||
"headers": dict(self.headers.items()), "body": obj},
|
||||
f.write(json.dumps({"ts": now().isoformat(timespec="seconds"), "ip": ip_of(self), "headers": keep,
|
||||
"body": body[:4096] + ("…(截断)" if len(body) > 4096 else "")},
|
||||
ensure_ascii=False) + "\n")
|
||||
except OSError:
|
||||
pass
|
||||
@@ -2291,21 +2402,17 @@ class H(BaseHTTPRequestHandler):
|
||||
|
||||
if int(order.get("status") or 0) != 2:
|
||||
log("爱发电回调:%s 状态不是已付款(status=%s),先不发码"
|
||||
% (oid_af, order.get("status")))
|
||||
led[oid_af] = {"ts": now().isoformat(timespec="seconds"), "status": order.get("status"),
|
||||
"amount": order.get("show_amount") or order.get("total_amount"),
|
||||
"code": None, "note": "未付款"}
|
||||
STORE.ledger_save(led)
|
||||
% (oid_af[:64], str(order.get("status"))[:8]))
|
||||
# ⚠️ 2026-10-06 安全加固:没经过开放接口验证的报文**不写进账本**(原来会把任何人编的单号 / 金额
|
||||
# 写进库里的 pay_orders,一刷就是成千上万条,每次存账本还要整表重写 → 拖慢真付款)。
|
||||
_hook_unverified(oid_af, order, "未付款(status=%s)" % str(order.get("status"))[:8], ip_of(self))
|
||||
return self.js({"ec": 200, "em": ""})
|
||||
|
||||
real = payplatform_find_order(oid_af)
|
||||
if not real:
|
||||
# 没验过就不发码 —— 宁可让金钻手工补,也不给伪造的报文发货
|
||||
log("⚠️ 爱发电回调:%s 在开放接口里查不到(可能官方延迟/伪造),没发码" % oid_af)
|
||||
led[oid_af] = {"ts": now().isoformat(timespec="seconds"), "code": None,
|
||||
"amount": order.get("show_amount") or order.get("total_amount"),
|
||||
"note": "接口没查到,待人工核对", "need_human": True}
|
||||
STORE.ledger_save(led)
|
||||
log("⚠️ 爱发电回调:%s 在开放接口里查不到(可能官方延迟/伪造),没发码" % oid_af[:64])
|
||||
_hook_unverified(oid_af, order, "接口没查到,待人工核对", ip_of(self))
|
||||
return self.js({"ec": 200, "em": ""})
|
||||
|
||||
n_img_af = payplatform_img_count(real)
|
||||
@@ -2315,7 +2422,6 @@ class H(BaseHTTPRequestHandler):
|
||||
# ===== 先看这笔付款是不是"网页单来付的"(金钻 2026-10-01 的状态机)=====
|
||||
# 线索优先级:⓪ 回调带回的订单号 custom_order_id(专链里塞的,金钻 2026-10-03 新加,最硬)
|
||||
# ① 留言里写了我方的兑换码(YS-XXXX-….)② 留言里写了订单号(YS7ZBZW6)
|
||||
# ③ 留言空着,但**只有一笔**待付款单的金额对得上(唯一才敢自动认,两笔就人工)
|
||||
rm_up = str(real.get("remark") or "").upper()
|
||||
target, how = None, ""
|
||||
# ⓪ 专链下单:前端把订单号写进 custom_order_id,爱发电下单后原样带回来。
|
||||
@@ -2335,14 +2441,8 @@ class H(BaseHTTPRequestHandler):
|
||||
h2 = re.search(r"YS[0-9A-Z]{6}", rm_up.replace("-", ""))
|
||||
if h2 and read_meta(h2.group(0)):
|
||||
target, how = h2.group(0), "留言里的订单号"
|
||||
if not target:
|
||||
try:
|
||||
amt = int(round(float(str(real.get("show_amount") or real.get("total_amount")))))
|
||||
except (TypeError, ValueError):
|
||||
amt = -1
|
||||
cands = [x for x in list_orders(("unpaid", "paid")) if int(x.get("amount") or 0) == amt]
|
||||
if len(cands) == 1:
|
||||
target, how = cands[0]["oid"], "唯一一笔金额对得上的待付款单"
|
||||
# 2026-10-07:去掉了「只有一笔待付款单金额对得上就自动认」—— 纯猜测,两笔同金额就会认错单。
|
||||
# 专链会带回订单号(custom_order_id),对不上的按「买卡密」处理或进人工,不再猜。
|
||||
if target:
|
||||
m_t = read_meta(target)
|
||||
# ⚠️ 金额闸门(金钻 2026-10-03 提的洞):留言里的凭证/订单号只能说明"这笔钱想付哪一单",
|
||||
@@ -2584,17 +2684,19 @@ class H(BaseHTTPRequestHandler):
|
||||
d = jload(PAYINFO_FILE, {})
|
||||
if not isinstance(d, dict):
|
||||
d = {}
|
||||
link, uid = _pp_key(d), _pp_key(d, "_uid")
|
||||
return self.js({"ok": True,
|
||||
"payplatform": (d.get("payplatform") or "").strip(),
|
||||
# 创作者 ID:前端用它拼「按本单金额生成的专链」
|
||||
# (pay-platform.example/order/create?user_id=…&custom_price=…&custom_order_id=…&remark=…)。
|
||||
# 没配就回落上面的固定商品链接 payplatform(兜底,金钻 2026-10-03)。
|
||||
"payplatform_uid": (d.get("payplatform_uid") or "").strip(),
|
||||
# 两种键名都给:下单页读 afdian / afdian_uid(2026-10-07 修:原来只给 payplatform*,页面拿不到专链)
|
||||
"afdian": link, "afdian_uid": uid,
|
||||
"payplatform": link, "payplatform_uid": uid,
|
||||
"qr_img": (d.get("qr_img") or "").strip(), # 服务器上的相对路径,比如 payme.png
|
||||
"note": (d.get("note") or "").strip(),
|
||||
# 支付宝当面付:审批还没过,只预留入口(页面显示灰色「待开通」),后端不接任何通道
|
||||
"alipay": {"on": False, "label": "支付宝扫码", "note": "待开通"},
|
||||
"price": PRICE_UNIT,
|
||||
# 价格档位表(金钻 2026-10-01):页面按买家选的张数取档位价 + 对应商品链接
|
||||
"tiers": price_tiers().get("tiers") or {},
|
||||
"tiers": {k: (dict(v, afdian=_pp_key(v), payplatform=_pp_key(v)) if isinstance(v, dict) else v)
|
||||
for k, v in (price_tiers().get("tiers") or {}).items()},
|
||||
"per": price_tiers().get("per") or PRICE_UNIT})
|
||||
|
||||
def redo(self):
|
||||
@@ -2611,7 +2713,14 @@ class H(BaseHTTPRequestHandler):
|
||||
return self.err("这一单还没渲完(或正在渲),等它停下来再说")
|
||||
if m.get("redo_used"):
|
||||
return self.err("这一单已经用过一次免费重渲了。还不行的话进官方群找金钻,他看着办。")
|
||||
# ⚠️ 2026-10-07:确认收货 = 买家认可了成品、原图已经放出去了。以前收货后照样能点免费重渲,
|
||||
# 等于原图拿走了还能再白出一套。直发单(没有收货这一步)不受影响。
|
||||
if m.get("accepted") and not m.get("direct"):
|
||||
return self.err("这一单已经确认收货了,免费重渲只能在确认收货之前用。图有问题请进官方群找金钻。")
|
||||
files = [str(x)[:60] for x in (d.get("files") or [])][:12]
|
||||
# 没渲出来的模板(渲染失败的那几张根本没有成品文件,勾不了文件名 → 直接报模板 key)
|
||||
miss = [t for t in (d.get("miss_tpls") or []) if t in TPL_KEYS
|
||||
and t in (m.get("templates") or [])][:MAX_IMAGES]
|
||||
note = str(d.get("note") or "").strip()[:200]
|
||||
# 换皮肤(金钻 2026-10-02:「或者他皮肤填错了重新换」)——
|
||||
# 传错了很正常,他上传时只看到 512 预览,不该卡在这儿。
|
||||
@@ -2675,12 +2784,15 @@ class H(BaseHTTPRequestHandler):
|
||||
for f in (m.get("files") or []):
|
||||
if (f.get("name") or "") in want and f.get("tpl") and f["tpl"] not in redo_tpls:
|
||||
redo_tpls.append(f["tpl"])
|
||||
for t in miss:
|
||||
if t not in redo_tpls:
|
||||
redo_tpls.append(t)
|
||||
if not redo_tpls and files:
|
||||
# 勾的图找不到模板(老单缺 tpl 字段)→ 退回整单,别让玩家点了没反应
|
||||
redo_tpls = []
|
||||
m["redo_tpls"] = redo_tpls
|
||||
# 没换皮肤、只重渲一部分 → **保留**其它成品(claim 里清了就再也找不回来了)
|
||||
if files and redo_tpls:
|
||||
if redo_tpls:
|
||||
log("免费重渲 %s:只重出 %s" % (oid, "、".join(redo_tpls)))
|
||||
# 重渲中的那几张先从列表里撤掉(渲染机交新的回来时同名字覆盖)
|
||||
if files:
|
||||
@@ -2688,8 +2800,8 @@ class H(BaseHTTPRequestHandler):
|
||||
m["state"] = "waiting"
|
||||
m["started"] = m["finished"] = None
|
||||
m["note"] = "买家申请免费重渲%s:%s" % (
|
||||
("(只重出 %d 张:%s)" % (len(files), "、".join(files))
|
||||
if (files and redo_tpls) else "(整单重出)"),
|
||||
("(只重出:%s)" % "、".join((files or []) + ["%s(上次没出来)" % t for t in miss])
|
||||
if redo_tpls else "(整单重出)"),
|
||||
note or "(没写原因)")
|
||||
with LOCK:
|
||||
write_meta(oid, m)
|
||||
@@ -2778,6 +2890,15 @@ class H(BaseHTTPRequestHandler):
|
||||
m = read_meta(oid)
|
||||
if not m or not hmac.compare_digest(m.get("token", ""), tok):
|
||||
return self.err("not found", 404)
|
||||
# 2026-10-07:先当场去爱发电对一次账 —— 已经付了就直接激活,不用等人工
|
||||
if m.get("state") in ("unpaid", "paid"):
|
||||
try:
|
||||
if payplatform_reconcile(only_oid=oid):
|
||||
return self.js({"ok": True, "state": "waiting", "found": True,
|
||||
"msg": "查到你的付款了,已经开始排队出图。"})
|
||||
except Exception as e:
|
||||
log("买家自查对账出错:%r" % e)
|
||||
m = read_meta(oid) or m
|
||||
if m.get("state") == "paid":
|
||||
return self.js({"ok": True, "state": "paid", "at": m.get("paid_at")})
|
||||
if m.get("state") != "unpaid":
|
||||
@@ -3530,6 +3651,7 @@ def main():
|
||||
os.makedirs(d, exist_ok=True)
|
||||
srv = ThreadingHTTPServer((HOST, PORT), H)
|
||||
srv.daemon_threads = True
|
||||
threading.Thread(target=reconcile_loop, daemon=True).start() # 主动对账(回调丢了也能自动激活)
|
||||
log("ys-order 启动 %s:%d | 数据 %s | 保留 %dh" % (HOST, PORT, ROOT, KEEP_HOURS))
|
||||
srv.serve_forever()
|
||||
|
||||
|
||||
@@ -0,0 +1,397 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""内容后台(cms.py)测试 —— 数据全是这里现编的,不碰任何真实环境。
|
||||
|
||||
用法:python3 tests/内容后台测试.py <server.py 所在目录> [仓库根目录]
|
||||
· 交付副本里三个 URL 格式串被脱敏弄坏了(http<WIN-PATH>),跑之前先换成能格式化的占位(同另外两份测试);
|
||||
· 会在临时目录建数据目录 + 门户 / 下单页目录(从仓库拷 content/ 当初始内容),起一份 server,从 HTTP 层打接口;
|
||||
· 需要 ffmpeg 才测得到「缩略图生成」那一条(没有就测「退回用原图」)。
|
||||
"""
|
||||
import base64, json, os, re, shutil, sqlite3, struct, subprocess, sys, tempfile, threading, time, urllib.request, urllib.error, zlib
|
||||
|
||||
SRC = os.path.abspath(sys.argv[1])
|
||||
REPO = os.path.abspath(sys.argv[2]) if len(sys.argv) > 2 else os.path.abspath(os.path.join(SRC, "..", ".."))
|
||||
TMP = tempfile.mkdtemp(prefix="ys-cms-")
|
||||
ROOT, PORTAL, ORDER = os.path.join(TMP, "data"), os.path.join(TMP, "www"), os.path.join(TMP, "www", "order")
|
||||
os.makedirs(ROOT); os.makedirs(PORTAL); os.makedirs(ORDER)
|
||||
shutil.copytree(os.path.join(REPO, "portal", "content"), os.path.join(PORTAL, "content"))
|
||||
shutil.copytree(os.path.join(REPO, "order", "content"), os.path.join(ORDER, "content"))
|
||||
os.environ.update(YS_ROOT=ROOT, YS_PORTAL_DIR=PORTAL, YS_ORDER_DIR=ORDER)
|
||||
sys.path.insert(0, SRC)
|
||||
import server as S # noqa: E402
|
||||
|
||||
RESULTS = []
|
||||
|
||||
|
||||
def check(name, cond, detail=""):
|
||||
RESULTS.append((name, bool(cond), detail))
|
||||
print(("PASS " if cond else "FAIL ") + name + ((" —— " + str(detail)[:160]) if detail else ""), flush=True)
|
||||
|
||||
|
||||
srv = S.ThreadingHTTPServer(("127.0.0.1", 0), S.H)
|
||||
srv.daemon_threads = True
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
BASE = "http://127.0.0.1:%d/api/cms/" % srv.server_address[1]
|
||||
|
||||
|
||||
class C(object):
|
||||
"""一个「浏览器」:自己记 Cookie 和 CSRF。默认走「反代 + https」的请求头。"""
|
||||
def __init__(self, ip="203.0.113.10", proto="https", origin=None):
|
||||
self.cookie, self.csrf, self.ip, self.proto, self.origin = None, "", ip, proto, origin
|
||||
|
||||
def req(self, ep, body=None, headers=None, raw=None):
|
||||
data = raw if raw is not None else (json.dumps(body).encode() if body is not None else None)
|
||||
r = urllib.request.Request(BASE + ep, data=data, method="POST" if data is not None else "GET")
|
||||
r.add_header("Content-Type", "application/json")
|
||||
r.add_header("Host", "shop.example.com")
|
||||
if self.ip:
|
||||
r.add_header("X-Real-IP", self.ip)
|
||||
if self.proto:
|
||||
r.add_header("X-Forwarded-Proto", self.proto)
|
||||
if self.origin:
|
||||
r.add_header("Origin", self.origin)
|
||||
if self.cookie:
|
||||
r.add_header("Cookie", "jz_cms=" + self.cookie)
|
||||
if data is not None and self.csrf:
|
||||
r.add_header("X-CSRF", self.csrf)
|
||||
for k, v in (headers or {}).items():
|
||||
r.add_header(k, v)
|
||||
try:
|
||||
with urllib.request.urlopen(r, timeout=60) as resp:
|
||||
st, hd, b = resp.status, resp.headers, resp.read()
|
||||
except urllib.error.HTTPError as e:
|
||||
st, hd, b = e.code, e.headers, e.read()
|
||||
for sc in hd.get_all("Set-Cookie") or []:
|
||||
m = re.match(r"jz_cms=([^;]*)", sc)
|
||||
if m:
|
||||
self.cookie = m.group(1) or None
|
||||
self.last_cookie = sc
|
||||
try:
|
||||
j = json.loads(b.decode("utf-8"))
|
||||
except ValueError:
|
||||
j = {"_raw": b.decode("utf-8", "replace")}
|
||||
if isinstance(j, dict) and j.get("csrf"):
|
||||
self.csrf = j["csrf"]
|
||||
return st, j
|
||||
|
||||
def login(self, user, pw, remember=True):
|
||||
return self.req("login", {"user": user, "password": pw, "remember": remember})
|
||||
|
||||
|
||||
def db():
|
||||
return sqlite3.connect(os.path.join(ROOT, "ys.db"))
|
||||
|
||||
|
||||
NEWPW = "Jz-内容后台-2026!"
|
||||
# ================================================================== 1. 首次启动 / 初始账号
|
||||
rows = db().execute("SELECT username, must_change, pw FROM cms_users").fetchall()
|
||||
check("首次启动:自动建了唯一一个初始账号 admin,标了必须改密", len(rows) == 1 and rows[0][0] == "admin" and rows[0][1] == 1, rows and rows[0][:2])
|
||||
check("初始密码存的是 scrypt 哈希,不是明文", rows and rows[0][2].startswith(("scrypt$", "pbkdf2$")) and rows[0][2] != "admin", rows and rows[0][2][:10])
|
||||
|
||||
# ================================================================== 2. 登录
|
||||
a = C()
|
||||
st, j = a.login("admin", "wrong-pass")
|
||||
check("错密码 → 401「账号或密码不对」", st == 401 and j.get("error") == "账号或密码不对", j)
|
||||
st, j = C(ip="203.0.113.11").login("nobody", "whatever")
|
||||
check("不存在的账号 → 同样的提示(不透露账号在不在)", st == 401 and j.get("error") == "账号或密码不对", j)
|
||||
st, j = a.login("admin", "admin")
|
||||
check("admin / admin 能登录,回 must_change", st == 200 and j.get("must_change") is True, j)
|
||||
ck = getattr(a, "last_cookie", "")
|
||||
check("Cookie:HttpOnly + SameSite=Strict + https 下 Secure + 记住我 30 天", all(x in ck for x in ("HttpOnly", "SameSite=Strict", "Secure", "Max-Age=2592000")), ck)
|
||||
|
||||
# ================================================================== 3. 强制改密前:服务端只放行 me / password / logout
|
||||
blocked = []
|
||||
for ep, body in (("content", None), ("versions", None), ("audit", None), ("sessions", None), ("draft.js", None), ("draft", {"doc": {}}),
|
||||
("publish", {}), ("rollback", {"no": 1}), ("upload", {"data": "x"}), ("discard", {}), ("sessions/revoke", {"others": True})):
|
||||
st, j = a.req(ep, body)
|
||||
if not (st == 403 and j.get("must_change")):
|
||||
blocked.append((ep, st))
|
||||
check("改密前:其它 11 个接口一律 403「请先修改初始密码」", not blocked, blocked)
|
||||
st, j = a.req("me")
|
||||
check("改密前:me 照常能用", st == 200 and j.get("must_change") is True)
|
||||
st, j = a.req("password", {"old": "admin", "new": "12345678"})
|
||||
check("新密码太常见 → 拒", st == 400 and "常见" in j.get("error", ""), j)
|
||||
st, j = a.req("password", {"old": "admin", "new": "short"})
|
||||
check("新密码太短 → 拒", st == 400 and "8" in j.get("error", ""), j)
|
||||
st, j = a.req("password", {"old": "admin", "new": "admin"})
|
||||
check("新密码是 admin → 拒", st == 400, j)
|
||||
st, j = a.req("password", {"old": "bad", "new": NEWPW})
|
||||
check("旧密码不对 → 拒", st == 400 and "现在的密码" in j.get("error", ""), j)
|
||||
old_cookie = a.cookie
|
||||
st, j = a.req("password", {"old": "admin", "new": NEWPW})
|
||||
check("首次改密成功 → 要求重新登录", st == 200 and j.get("relogin") is True, j)
|
||||
a2 = C(); a2.cookie = old_cookie
|
||||
st, _ = a2.req("me")
|
||||
check("首次改密后:原来那个会话立即作废", st == 401)
|
||||
# ⚠️ 不能在本进程里 open() 库文件:POSIX 规定关掉任何一个句柄会释放本进程对这个文件的所有锁,SQLite 的锁会被顺带清掉。
|
||||
# 所以用另一个进程(cat)去读。
|
||||
raw_db = subprocess.run(["cat", os.path.join(ROOT, "ys.db")] + ([os.path.join(ROOT, "ys.db-wal")] if os.path.exists(os.path.join(ROOT, "ys.db-wal")) else []), capture_output=True).stdout
|
||||
check("库文件(含 WAL)里找不到新密码明文", NEWPW.encode("utf-8") not in raw_db)
|
||||
st, j = a.login("admin", NEWPW)
|
||||
check("新密码登录 → 不再要求改密", st == 200 and j.get("must_change") is False, j)
|
||||
|
||||
# ================================================================== 4. 安全闸:https / CSRF / 来源 / 爆破
|
||||
st, j = C(ip="203.0.113.20", proto="http").login("admin", NEWPW)
|
||||
check("经反代但不是 https → 403,不收密码", st == 403 and "https" in j.get("error", ""), j)
|
||||
st, j = C(ip="203.0.113.21", proto=None).login("admin", NEWPW)
|
||||
check("经反代但没带 X-Forwarded-Proto → 也当成不是 https 拒掉", st == 403, j)
|
||||
loc = C(ip=None, proto=None)
|
||||
st, j = loc.login("admin", NEWPW)
|
||||
check("服务器本机直连(调试)可以 http;这时 Cookie 不带 Secure", st == 200 and "Secure" not in getattr(loc, "last_cookie", ""), getattr(loc, "last_cookie", ""))
|
||||
csrf = a.csrf; a.csrf = ""
|
||||
st, j = a.req("draft", {"doc": {}})
|
||||
check("修改类请求不带 X-CSRF → 403", st == 403, j)
|
||||
a.csrf = "forged"
|
||||
st, j = a.req("draft", {"doc": {}})
|
||||
check("X-CSRF 不对 → 403", st == 403, j)
|
||||
a.csrf = csrf
|
||||
a.origin = "https://evil.example"
|
||||
st, j = a.req("discard", {})
|
||||
check("跨站来源(Origin 不是本站)→ 403", st == 403 and "来源" in j.get("error", ""), j)
|
||||
a.origin = "https://shop.example.com"
|
||||
st, j = a.req("discard", {})
|
||||
check("同站来源照常", st == 200, j)
|
||||
a.origin = None
|
||||
bf = C(ip="198.51.100.66")
|
||||
codes = [bf.login("admin", "guess%d" % k)[0] for k in range(7)]
|
||||
check("同一 IP 连错 5 次后开始冷却 → 429", codes[:5] == [401] * 5 and 429 in codes[5:], codes)
|
||||
st, j = C(ip="198.51.100.77").login("admin", NEWPW)
|
||||
check("别的 IP 乱试几次,店主从自己的网络用对密码照常能登(不能一键把人锁在门外)", st == 200, st)
|
||||
codes = [C(ip="192.0.2.%d" % k).login("admin", "spread%d" % k)[0] for k in range(22)]
|
||||
check("分散在很多 IP 上慢慢试:同一账号合计错满 20 次也冷却", 429 in codes[20:], codes[-4:])
|
||||
for k in list(S.CMS.fails): # 清掉冷却记录,后面的用例要正常登录
|
||||
S.CMS.fails.pop(k, None)
|
||||
|
||||
# ================================================================== 5. 内容:读 / 存草稿 / 校验
|
||||
st, j = a.req("content")
|
||||
check("读内容:第 1 版 = 从网站现有内容文件导入", st == 200 and j.get("version") == 1 and j["published"]["site"]["links"], j.get("version"))
|
||||
doc = j["draft"]
|
||||
bad = json.loads(json.dumps(doc)); bad["site"]["links"][0]["url"] = "http://example.com/x"
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:平台链接用 http:// → 拒,并说清是哪一个", st == 400 and "https" in j.get("error", "") and "平台入口第 1 个" in j.get("error", ""), j)
|
||||
bad = json.loads(json.dumps(doc)); bad["site"]["links"][0]["url"] = "javascript:alert(1)"
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:javascript: 链接 → 拒", st == 400, j)
|
||||
bad = json.loads(json.dumps(doc)); bad["site"]["gallery"][0]["src"] = "../../etc/passwd"
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:图片路径想往上跳目录 → 拒", st == 400, j)
|
||||
bad = json.loads(json.dumps(doc)); bad["order"]["templates"] = [dict(t, on=False) for t in bad["order"]["templates"]]
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:模板全部下架 → 拒(至少留一个)", st == 400 and "至少" in j.get("error", ""), j)
|
||||
bad = json.loads(json.dumps(doc)); bad["order"]["templates"].append({"k": "notatpl", "n": "x", "s": "", "on": True})
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:不认识的模板 key → 拒(后台不能新增模板)", st == 400, j)
|
||||
bad = json.loads(json.dumps(doc)); bad["site"]["universe"]["items"][1]["look"]["style"] = "unknownstyle"
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:不认识的星球风格 → 拒", st == 400, j)
|
||||
bad = json.loads(json.dumps(doc)); bad["site"]["hero"]["tagline"] = "长" * 200
|
||||
st, j = a.req("draft", {"doc": bad, "base": 1})
|
||||
check("校验:超长 → 拒,并说清多长", st == 400 and "最多 160" in j.get("error", ""), j)
|
||||
|
||||
# 真实画展的样子(2026-10-06 线上恢复时踩到):文件名带空格、本站 mp4 视频 + 网页版副本、作品外链、离线缩略图索引、世界线主色
|
||||
real = json.loads(json.dumps(doc))
|
||||
real["site"]["gallery"] = [
|
||||
{"id": "r1", "type": "image", "date": "2024-10-20", "title": "定制 (1)", "owner": "own", "src": "exhibition/渲染与动画/20241020/星野 渲染-定制 (1).webp", "r": 1.7778,
|
||||
"links": ["https://example.com/workshop/1", "https://example.com/cgmodel/2"], "link": "https://example.com/a"},
|
||||
{"id": "r2", "type": "video", "date": "2022-10-23", "title": "本站视频", "owner": "gift", "src": "exhibition/他人赠或合照带我/20221023/忘了谁做的了 (1).mp4",
|
||||
"web": "exhibition_web/他人赠或合照带我/20221023/忘了谁做的了 (1).mp4", "r": 2.3636}]
|
||||
real["site"]["media"] = {"exhibition/渲染与动画/20241020/星野 渲染-定制 (1).webp": {"t": "thumbs/abc123.png", "r": 1.7778},
|
||||
"exhibition/他人赠或合照带我/20221023/忘了谁做的了 (1).mp4": {"t": "thumbs/def456.png", "r": 2.3636}}
|
||||
real["site"]["universe"]["items"][0]["tone"] = "#e6e1d6"
|
||||
tk = tuple(t["k"] for t in doc["order"]["templates"])
|
||||
try:
|
||||
n = S.cms.normalize(real, tk)
|
||||
ok = (n["site"]["gallery"][0]["src"] == real["site"]["gallery"][0]["src"] and n["site"]["gallery"][0]["links"] == real["site"]["gallery"][0]["links"]
|
||||
and n["site"]["gallery"][0]["link"] == "https://example.com/a" and n["site"]["gallery"][1]["web"] == real["site"]["gallery"][1]["web"]
|
||||
and n["site"]["media"] == real["site"]["media"] and n["site"]["universe"]["items"][0]["tone"] == "#e6e1d6")
|
||||
pay = S.cms.site_payload(n["site"])
|
||||
check("真实画展:带空格的文件名、本站 mp4 视频(不填 B 站链接)、网页版副本、外链、缩略图索引、世界线主色全部原样保留",
|
||||
ok and S.cms.normalize(n, tk) == n, n["site"]["gallery"])
|
||||
check("真实画展:网站内容文件里缩略图索引还在(不然画展会直接拉几百张原图)",
|
||||
pay["media"]["exhibition/他人赠或合照带我/20221023/忘了谁做的了 (1).mp4"].get("t") == "thumbs/def456.png" and pay["universe"]["UNIVERSES"][0].get("tone") == "#e6e1d6", pay["media"])
|
||||
except S.cms.Bad as e:
|
||||
check("真实画展:带空格的文件名、本站 mp4 视频、网页版副本、外链、缩略图索引全部原样保留", False, e)
|
||||
for badp in ["exhibition/a\tb.webp", "exhibition/a\"b.webp", "exhibition/a?b.webp", "thumbs/../x.png", "other/a.webp"]:
|
||||
bad = json.loads(json.dumps(real)); bad["site"]["gallery"][0]["src"] = badp
|
||||
try:
|
||||
S.cms.normalize(bad, tk); rej = False
|
||||
except S.cms.Bad:
|
||||
rej = True
|
||||
check("校验:站内路径 %r → 拒" % badp, rej)
|
||||
bad = json.loads(json.dumps(real)); bad["site"]["gallery"][1]["src"] = "exhibition/x/a.webp"
|
||||
try:
|
||||
S.cms.normalize(bad, tk); rej = False
|
||||
except S.cms.Bad as e:
|
||||
rej = "B 站" in str(e)
|
||||
check("校验:视频既没有 B 站链接、也不是本站 mp4 → 拒", rej)
|
||||
|
||||
XSS = '</script><script>alert(1)</script><img src=x onerror=alert(2)>'
|
||||
good = json.loads(json.dumps(doc))
|
||||
good["site"]["hero"]["tagline"] = "首页改一句 " + XSS[:40]
|
||||
good["site"]["hero"]["notice"] = {"on": True, "text": "国庆照常营业", "from": "", "to": ""}
|
||||
good["site"]["links"][0]["name"] = "哔哩哔哩" + "<b>x</b>"
|
||||
good["site"]["universe"]["items"].append({"no": "0005", "name": "新地球", "kind": "原创", "tag": "卡通地球", "desc": XSS, "tags": ["新"], "look": {"style": "earth", "accent": "#7FE0A8", "enter": "push"}})
|
||||
good["order"]["templates"][-1]["on"] = False
|
||||
good["order"]["prices"] = {"per": 6, "tiers": [{"n": 3, "price": 15, "url": "https://example.com/afdian/3"}]}
|
||||
good["order"]["pay"]["note"] = "付款时留言写订单号"
|
||||
st, j = a.req("draft", {"doc": good, "base": 1})
|
||||
check("存草稿:合格的内容存上,返回改了哪些板块", st == 200 and any(c[0] == "金钻宇宙" for c in j.get("changes", [])), j.get("changes"))
|
||||
st, j = a.req("content")
|
||||
check("草稿存在库里,网站上(已发布)还是原样", j.get("has_draft") and j["published"]["site"]["hero"]["tagline"] != good["site"]["hero"]["tagline"])
|
||||
|
||||
# ================================================================== 6. 预览草稿(要登录)
|
||||
st, j = C(ip="203.0.113.30").req("draft.js")
|
||||
check("预览草稿:没登录 → 401", st == 401)
|
||||
st, j = a.req("draft.js")
|
||||
body = j.get("_raw", "")
|
||||
check("预览草稿:登录了 → 拿到草稿内容 + JZ_PREVIEW", st == 200 and "window.JZ_PREVIEW = true" in body and "新地球" in body)
|
||||
check("预览草稿:</script> 被转义,塞不进脚本", "</script>" not in body.split("window.JZ_CONTENT = ", 1)[1].split("window.JZ_PREVIEW")[0], body[:80])
|
||||
|
||||
# ================================================================== 7. 发布 / 冲突 / 回滚
|
||||
st, j = a.req("publish", {"note": "测试发布", "base": 1})
|
||||
check("发布 → v2", st == 200 and j.get("version") == 2, j)
|
||||
site_js = open(os.path.join(PORTAL, "content", "site.js"), encoding="utf-8").read()
|
||||
order_js = open(os.path.join(ORDER, "content", "order.js"), encoding="utf-8").read()
|
||||
check("发布写出门户 site.js:有新世界线、</script> 被转义", "新地球" in site_js and "</script>" not in site_js.split("=", 1)[1], site_js[:120])
|
||||
check("发布写出 site.json(正本)", json.load(open(os.path.join(PORTAL, "content", "site.json"), encoding="utf-8"))["hero"]["notice"]["on"] is True)
|
||||
check("发布写出下单页 order.js:最后一个模板已下架", '"on":false' in order_js)
|
||||
pr = json.load(open(S.PRICES_FILE, encoding="utf-8")); pay = json.load(open(S.PAYINFO_FILE, encoding="utf-8"))
|
||||
check("价格档位写回 prices.json(server.py 原来的格式)", pr.get("per") == 6 and pr.get("tiers", {}).get("3", {}).get("price") == 15, pr)
|
||||
check("付款方式写回 payinfo.json", pay.get("note") == "付款时留言写订单号", pay)
|
||||
check("下单页的价格接口立刻反映新档位", S.price_for(3) == 15)
|
||||
lit = [x for x in json.loads(site_js.split("window.JZ_CONTENT = ", 1)[1].rsplit(";", 1)[0])["universe"]["UNIVERSES"] if not x.get("empty")]
|
||||
check("星系图数据:新世界线没写位置(交给 layout.js 自动排)", any(x["no"] == "0005" for x in lit))
|
||||
# 命令行改了价格之后,后台发布别的内容不能把它改回去
|
||||
pr = json.load(open(S.PRICES_FILE, encoding="utf-8")); pr["tiers"]["5"] = {"price": 22, "payplatform": ""}
|
||||
S.jsave(S.PRICES_FILE, pr)
|
||||
b = C(ip="203.0.113.40"); b.login("admin", NEWPW)
|
||||
st, j = b.req("content")
|
||||
d2 = j["draft"]; d2["site"]["hero"]["cta1"] = "看看画"
|
||||
st, j = b.req("draft", {"doc": d2, "base": 1}) # 故意拿旧底稿
|
||||
st, j = b.req("publish", {"base": 1})
|
||||
check("别人已经发布过(底稿是旧版)→ 409 冲突,不静默覆盖", st == 409 and j.get("conflict"), j)
|
||||
st, j = b.req("publish", {"base": 2})
|
||||
check("刷新到新底稿再发 → v3", st == 200 and j.get("version") == 3, j)
|
||||
check("后台发布没动价格时,不覆盖命令行改过的 prices.json", json.load(open(S.PRICES_FILE, encoding="utf-8")).get("tiers", {}).get("5", {}).get("price") == 22)
|
||||
st, j = a.req("rollback", {"no": 1})
|
||||
check("回到 v1 → 记为 v4", st == 200 and j.get("version") == 4, j)
|
||||
v1 = json.loads(db().execute("SELECT data FROM cms_versions WHERE no=1").fetchone()[0])
|
||||
v4 = json.loads(db().execute("SELECT data FROM cms_versions WHERE no=4").fetchone()[0])
|
||||
check("回滚后内容和 v1 一模一样", v1 == v4)
|
||||
check("回滚后网站文件也回去了(没有新地球)", "新地球" not in open(os.path.join(PORTAL, "content", "site.js"), encoding="utf-8").read())
|
||||
st, j = a.req("versions")
|
||||
check("发布记录 4 条,带改动摘要", st == 200 and len(j.get("versions", [])) == 4 and j["versions"][0]["chg"], j.get("versions", [{}])[0])
|
||||
|
||||
# ================================================================== 8. 传图
|
||||
def png(w=64, h=48, tail=b""):
|
||||
raw = b"".join(b"\x00" + b"".join(bytes(((x * 3) % 256, (y * 5) % 256, 120, 255)) for x in range(w)) for y in range(h))
|
||||
ch = lambda t, d: struct.pack(">I", len(d)) + t + d + struct.pack(">I", zlib.crc32(t + d) & 0xffffffff)
|
||||
return b"\x89PNG\r\n\x1a\n" + ch(b"IHDR", struct.pack(">IIBBBBB", w, h, 8, 6, 0, 0, 0)) + ch(b"tEXt", b"Comment\x00secret") + ch(b"IDAT", zlib.compress(raw)) + ch(b"IEND", b"") + tail
|
||||
du = lambda b, t="png": "data:image/%s;base64,%s" % (t, base64.b64encode(b).decode())
|
||||
st, j = a.req("upload", {"name": "测试.png", "data": du(png())})
|
||||
ok_up = st == 200 and j.get("src", "").startswith("uploads/") and os.path.exists(os.path.join(PORTAL, j.get("src", "x")))
|
||||
check("传 PNG:存进 uploads/,量好宽高比", ok_up and abs(j.get("r", 0) - 64 / 48) < 0.01, j)
|
||||
if ok_up:
|
||||
saved = open(os.path.join(PORTAL, j["src"]), "rb").read()
|
||||
check("PNG 的文字元数据块被剥掉", b"secret" not in saved)
|
||||
has_ff = shutil.which("ffmpeg") is not None
|
||||
check("缩略图:有 ffmpeg 就生成 .t.jpg,没有就退回原图", (j["thumb"].endswith(".t.jpg") and os.path.exists(os.path.join(PORTAL, j["thumb"]))) if has_ff else j["thumb"] == j["src"], j.get("thumb"))
|
||||
st, j = a.req("upload", {"name": "x.png", "data": du(png(tail=b"hidden-payload"))})
|
||||
check("传图:PNG 尾部夹带数据 → 拒", st == 400 and "核验" in j.get("error", ""), j)
|
||||
jpeg = b"\xff\xd8" + b"\xff\xe1" + struct.pack(">H", 2 + 20) + b"Exif\x00\x00GPS-LOCATION" + b"\x00" * 2 \
|
||||
+ b"\xff\xc0" + struct.pack(">HBHHB", 11, 8, 40, 60, 1) + b"\x01\x11\x00" \
|
||||
+ b"\xff\xda" + struct.pack(">HB", 8, 1) + b"\x01\x00\x00\x3f\x00" + b"\x12\x34\x56" + b"\xff\xd9"
|
||||
st, j = a.req("upload", {"name": "p.jpg", "data": du(jpeg, "jpeg")})
|
||||
saved = open(os.path.join(PORTAL, j["src"]), "rb").read() if st == 200 else b""
|
||||
check("传 JPEG:EXIF(含拍摄地点)被剥掉,尺寸读对", st == 200 and b"GPS-LOCATION" not in saved and j.get("w") == 60 and j.get("h") == 40, j)
|
||||
st, j = a.req("upload", {"name": "p.jpg", "data": du(jpeg + b"tail", "jpeg")})
|
||||
check("传 JPEG:结尾后夹带数据 → 拒", st == 400, j)
|
||||
st, j = a.req("upload", {"name": "a.txt", "data": "data:text/plain;base64,aGVsbG8="})
|
||||
check("传图:不是图片 → 拒", st == 400, j)
|
||||
st, j = a.req("upload", {"name": "big.png", "data": du(b"\x89PNG\r\n\x1a\n" + b"0" * (10 * 1024 * 1024 + 10))})
|
||||
check("传图:超过 10MB → 拒", st == 400 and "太大" in j.get("error", ""), j)
|
||||
|
||||
# ================================================================== 9. 会话管理
|
||||
c1, c2 = C(ip="203.0.113.51"), C(ip="203.0.113.52")
|
||||
c1.login("admin", NEWPW); c2.login("admin", NEWPW)
|
||||
st, j = c1.req("sessions")
|
||||
check("设备列表能看到多台,标出这台", st == 200 and len(j.get("sessions", [])) >= 3 and sum(1 for s in j["sessions"] if s.get("cur")) == 1, len(j.get("sessions", [])))
|
||||
st, j = c1.req("sessions/revoke", {"others": True})
|
||||
st2, _ = c2.req("me"); st3, _ = c1.req("me")
|
||||
check("「退出所有其它设备」:别的当场失效,这台还在", st == 200 and st2 == 401 and st3 == 200)
|
||||
st, j = c1.req("logout", {})
|
||||
st2, _ = c1.req("me")
|
||||
check("退出:服务端会话删掉,同一个 Cookie 再用 → 401", st == 200 and st2 == 401)
|
||||
c3 = C(ip="203.0.113.53"); c3.login("admin", NEWPW)
|
||||
with db() as con:
|
||||
con.execute("UPDATE cms_sessions SET expires=? WHERE th=?", (time.time() - 1, S.cms._th(c3.cookie)))
|
||||
st, _ = c3.req("me")
|
||||
check("会话过期 → 401", st == 401)
|
||||
|
||||
# ================================================================== 10. 命令行
|
||||
env = dict(os.environ, YS_ROOT=ROOT, YS_PORTAL_DIR=PORTAL, YS_ORDER_DIR=ORDER)
|
||||
run = lambda *args: subprocess.run([sys.executable, os.path.join(SRC, "admin.py"), "user"] + list(args), capture_output=True, text=True, env=env, cwd=SRC, timeout=120)
|
||||
keep = C(ip="203.0.113.60"); keep.login("admin", NEWPW)
|
||||
r = run("reset", "admin")
|
||||
m = re.search(r"临时密码:(\S+)", r.stdout)
|
||||
st, _ = keep.req("me")
|
||||
check("命令行 user reset:打印临时密码,原来的会话全部作废", m and st == 401, (r.stdout + r.stderr)[-120:])
|
||||
tmp_pw = m.group(1) if m else ""
|
||||
st, j = C(ip="203.0.113.61").login("admin", tmp_pw)
|
||||
check("用临时密码登录 → 必须改密", st == 200 and j.get("must_change") is True, j)
|
||||
check("临时密码没写进日志", tmp_pw and tmp_pw not in (open(S.LOG_FILE, encoding="utf-8").read() if os.path.exists(S.LOG_FILE) else ""))
|
||||
r = run("reset", "admin", "--to-admin")
|
||||
st, j = C(ip="203.0.113.62").login("admin", "admin")
|
||||
check("user reset --to-admin:退回 admin / admin 且必须改密", st == 200 and j.get("must_change") is True, j)
|
||||
r = run("add", "editor2", "--email", "ed@example.com", "--temp")
|
||||
m = re.search(r"临时密码:(\S+)", r.stdout)
|
||||
st, j = C(ip="203.0.113.63").login("ed@example.com", m.group(1) if m else "")
|
||||
check("user add --temp:用邮箱也能登,首次必须改密", st == 200 and j.get("must_change") is True and j.get("user") == "editor2", (r.stdout + r.stderr)[-120:])
|
||||
r = run("disable", "editor2")
|
||||
st, j = C(ip="203.0.113.64").login("editor2", m.group(1) if m else "")
|
||||
check("user disable:停用后登不上", st == 401, j)
|
||||
r = run("list")
|
||||
check("user list 能跑,列出两个账号", r.returncode == 0 and "admin" in r.stdout and "editor2" in r.stdout and "已停用" in r.stdout, r.stdout[-200:])
|
||||
r = run("add", "x y")
|
||||
check("user add:非法用户名 → 报错退出", r.returncode != 0, (r.stdout + r.stderr)[-80:])
|
||||
|
||||
# ================================================================== 11. 多个进程同时首次启动:只建一个初始账号
|
||||
R2 = tempfile.mkdtemp(prefix="ys-cms-race-")
|
||||
probe = "import sys,os;sys.path.insert(0,%r);os.environ['YS_ROOT']=%r;import server" % (SRC, R2)
|
||||
ps = [subprocess.Popen([sys.executable, "-c", probe], env=dict(os.environ, YS_ROOT=R2), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) for _ in range(3)]
|
||||
[p.wait(timeout=120) for p in ps]
|
||||
n = sqlite3.connect(os.path.join(R2, "ys.db")).execute("SELECT COUNT(*) FROM cms_users").fetchone()[0]
|
||||
check("三个进程同时首次启动:只建了一个初始账号", n == 1, n)
|
||||
|
||||
# ================================================================== 11b. 部署漏配:目录不对 / 缺内容文件 → 不建第一版、不写文件
|
||||
import store as ST
|
||||
R3 = tempfile.mkdtemp(prefix="ys-cms-dirs-")
|
||||
c3 = S.cms.CMS(ST.Store(R3), R3, log=lambda *a: None, prices_file=os.path.join(R3, "prices.json"), payinfo_file=os.path.join(R3, "payinfo.json"), tpl_keys=S.TPL_KEYS, pngcheck=S.pngcheck)
|
||||
old_p = S.cms.PORTAL_DIR
|
||||
for bad_dir, why in (("<PORTAL_DIR>", "没配环境变量"), (os.path.join(R3, "empty-www"), "目录里没有 content/site.json")):
|
||||
if not bad_dir.startswith("<"):
|
||||
os.makedirs(bad_dir, exist_ok=True)
|
||||
S.cms.PORTAL_DIR = bad_dir
|
||||
try:
|
||||
c3.current(); refused = False
|
||||
except S.cms.Bad as e:
|
||||
refused = True; msg = str(e)
|
||||
n = sqlite3.connect(os.path.join(R3, "ys.db")).execute("SELECT COUNT(*) FROM cms_versions").fetchone()[0]
|
||||
check("部署漏配(%s):内容后台拒绝工作、不建空的第一版" % why, refused and n == 0 and not os.path.exists("<PORTAL_DIR>"), msg if refused else "没拒")
|
||||
S.cms.PORTAL_DIR = old_p
|
||||
shutil.rmtree(R3, ignore_errors=True)
|
||||
|
||||
# ================================================================== 12. 原有接口不受影响
|
||||
try:
|
||||
with urllib.request.urlopen("http://127.0.0.1:%d/api/status" % srv.server_address[1], timeout=10) as r:
|
||||
stj = json.loads(r.read())
|
||||
except Exception as e:
|
||||
stj = {"err": repr(e)}
|
||||
check("下单那边的接口照常(/api/status)", stj.get("ok") is True, stj)
|
||||
|
||||
srv.shutdown()
|
||||
shutil.rmtree(TMP, ignore_errors=True); shutil.rmtree(R2, ignore_errors=True)
|
||||
bad = [n for n, ok, _ in RESULTS if not ok]
|
||||
print("\n%d 条,失败 %d 条" % (len(RESULTS), len(bad)))
|
||||
for n in bad:
|
||||
print(" ✗ " + n)
|
||||
sys.exit(1 if bad else 0)
|
||||
@@ -199,6 +199,22 @@ m2 = S.read_meta(h2)
|
||||
check("洞:同一笔付款改报文里的订单号,不能再激活另一单", (m2 or {}).get("state") in ("unpaid", "paid"),
|
||||
"第二单状态=%s" % (m2 or {}).get("state"))
|
||||
|
||||
# 2026-10-06 安全加固:伪造的回调(没付款 / 开放接口查不到)不能写进账本,刷再多也只占 50 格待核对
|
||||
led0 = len(S.STORE.ledger_all())
|
||||
for k in range(60):
|
||||
fake = {"data": {"order": {"out_trade_no": "FAKE%04d" % k, "status": 1 if k % 2 else 2,
|
||||
"total_amount": "999", "title": "x" * 500}}}
|
||||
req("POST", "/api/payplatform-hook", fake)
|
||||
pend = S.STORE.kv_get("hook_unverified", []) or []
|
||||
check("洞:伪造回调刷 60 次 → 账本一条都不多,待核对清单封顶 50 条、字段截断",
|
||||
len(S.STORE.ledger_all()) == led0 and len(pend) == 50 and all(len(x.get("title", "")) <= 60 for x in pend),
|
||||
"账本 %d → %d,待核对 %d 条" % (led0, len(S.STORE.ledger_all()), len(pend)))
|
||||
logsz = os.path.getsize(S.PAYPLATFORM_LOG) if os.path.exists(S.PAYPLATFORM_LOG) else 0
|
||||
hook_big = {"data": {"order": {"out_trade_no": "BIG", "status": 1}}, "junk": "y" * 60000}
|
||||
req("POST", "/api/payplatform-hook", hook_big)
|
||||
grew = (os.path.getsize(S.PAYPLATFORM_LOG) if os.path.exists(S.PAYPLATFORM_LOG) else 0) - logsz
|
||||
check("加固:回调日志一条最多记 4KB 正文(60KB 的报文不会整包写盘)", 0 < grew < 6000, "这一条写了 %d 字节" % grew)
|
||||
|
||||
# ================================================================== 5. 重渲换皮肤绕过 PNG 核验
|
||||
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
|
||||
r_oid, r_tok = j["order"], j["token"]
|
||||
@@ -218,6 +234,35 @@ S.write_meta(r2, dict(S.read_meta(r2), state="done"))
|
||||
st, j, _ = req("POST", "/api/redo", {"oid": r2, "token": t2, "skin": durl(png(seed=9)), "skin_id": "s1", "all": 1})
|
||||
check("回归:重渲换一张正常皮肤照常可以", st == 200 and j.get("ok"), str(j)[:80])
|
||||
|
||||
# 2026-10-07:确认收货后不能再免费重渲(原图都拿走了还能白出一套)
|
||||
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
|
||||
a_oid, a_tok = j["order"], j["token"]
|
||||
S.write_meta(a_oid, dict(S.read_meta(a_oid), state="done", accepted=True, accepted_at="2026-10-07T10:00:00"))
|
||||
st, j, _ = req("POST", "/api/redo", {"oid": a_oid, "token": a_tok, "files": [], "all": 1})
|
||||
check("洞:确认收货后还能点免费重渲 → 必须拒", not (st == 200 and j.get("ok"))
|
||||
and (S.read_meta(a_oid) or {}).get("state") == "done" and not (S.read_meta(a_oid) or {}).get("redo_used"),
|
||||
"server 说:%s" % (j.get("error") if isinstance(j, dict) else j))
|
||||
st, j, _ = submit([S.gen_codes(1)[0]], ["stand"])
|
||||
d_oid, d_tok = j["order"], j["token"]
|
||||
S.write_meta(d_oid, dict(S.read_meta(d_oid), state="done", direct=True))
|
||||
st, j, _ = req("POST", "/api/redo", {"oid": d_oid, "token": d_tok, "files": [], "all": 1})
|
||||
check("回归:直发单(没有收货这一步)照常能免费重渲", st == 200 and j.get("ok"), str(j)[:80])
|
||||
|
||||
# 2026-10-07:渲染失败的模板没有成品文件 —— 只报模板 key 也要能重渲,而且只重渲没出来的那几个
|
||||
st, j, _ = submit([S.gen_codes(1, n_fix=2)[0]], ["stand", "wheat"], nTotal=2)
|
||||
f_oid, f_tok = j["order"], j["token"]
|
||||
S.write_meta(f_oid, dict(S.read_meta(f_oid), state="failed",
|
||||
files=[{"name": "站立正反.png", "path": "x.png", "tpl": "stand"}]))
|
||||
st, j, _ = req("GET", "/api/order/%s?t=%s" % (f_oid, f_tok))
|
||||
check("状态接口:成品带模板 key、带 direct 标记(重渲弹窗靠它算哪张没出来)",
|
||||
st == 200 and (j.get("files") or [{}])[0].get("tpl") == "stand" and "direct" in j, str(j)[:120])
|
||||
st, j, _ = req("POST", "/api/redo", {"oid": f_oid, "token": f_tok, "files": [], "miss_tpls": ["wheat", "boom"]})
|
||||
mf = S.read_meta(f_oid) or {}
|
||||
check("修:失败单只勾「没出图」的模板也能重渲,只重出那一个(不认这单以外的模板)",
|
||||
st == 200 and j.get("ok") and mf.get("state") == "waiting" and mf.get("redo_tpls") == ["wheat"]
|
||||
and [x.get("name") for x in mf.get("files") or []] == ["站立正反.png"],
|
||||
"redo_tpls=%s files=%s err=%s" % (mf.get("redo_tpls"), mf.get("files"), j.get("error") if isinstance(j, dict) else j))
|
||||
|
||||
# ================================================================== 6. 反馈接口灌盘
|
||||
ip = new_ip()
|
||||
codes_ = []
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""收款自动化测试(2026-10-07):精确反查、主动对账、买家自查、去掉金额猜单、付款配置键名、支付宝待开通。
|
||||
|
||||
用法:python3 tests/收款对账测试.py <server.py 所在目录>
|
||||
· 临时数据目录 + 进程内起一份 server;爱发电开放接口用假的(FAKE 列表),不连外网。
|
||||
"""
|
||||
import base64, json, os, struct, sys, tempfile, threading, urllib.error, urllib.request, zlib
|
||||
|
||||
SRC = os.path.abspath(sys.argv[1])
|
||||
ROOT = tempfile.mkdtemp(prefix="ys-pay-")
|
||||
os.environ["YS_ROOT"] = ROOT
|
||||
sys.path.insert(0, SRC)
|
||||
import server as S # noqa: E402
|
||||
|
||||
RESULTS = []
|
||||
|
||||
|
||||
def check(name, cond, detail=""):
|
||||
RESULTS.append((name, bool(cond)))
|
||||
print(("PASS " if cond else "FAIL ") + name + ((" —— " + str(detail)[:200]) if detail != "" else ""), flush=True)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 假的爱发电开放接口
|
||||
FAKE, CALLS = [], []
|
||||
S.payplatform_creds = lambda: ("uid-test", "tok-test")
|
||||
|
||||
|
||||
def fake_api(path, params=None):
|
||||
params = params or {}
|
||||
CALLS.append(dict(params))
|
||||
if params.get("out_trade_no"):
|
||||
ids = str(params["out_trade_no"]).split(",")
|
||||
return {"ec": 200, "data": {"list": [o for o in FAKE if o["out_trade_no"] in ids], "total_page": 1}}
|
||||
pg = int(params.get("page") or 1)
|
||||
lst = list(reversed(FAKE))[(pg - 1) * 50: pg * 50]
|
||||
return {"ec": 200, "data": {"list": lst, "total_page": max(1, (len(FAKE) + 49) // 50)}}
|
||||
|
||||
|
||||
S.payplatform_api = fake_api
|
||||
_n = [0]
|
||||
|
||||
|
||||
def afd(custom="", amount="6.00", remark="", status=2):
|
||||
_n[0] += 1
|
||||
o = {"out_trade_no": "2026100712%010d" % _n[0], "custom_order_id": custom, "user_id": "buyer%d" % _n[0],
|
||||
"plan_id": "plan", "total_amount": amount, "show_amount": amount, "status": status, "remark": remark,
|
||||
"plan_title": "自选金额", "title": "", "sku_detail": [], "create_time": 0}
|
||||
FAKE.append(o)
|
||||
return o
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 起服务
|
||||
srv = S.ThreadingHTTPServer(("127.0.0.1", 0), S.H)
|
||||
srv.daemon_threads = True
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
BASE = "http://127.0.0.1:%d" % srv.server_address[1]
|
||||
|
||||
|
||||
def req(method, path, obj=None, headers=None):
|
||||
r = urllib.request.Request(BASE + path, data=json.dumps(obj).encode() if obj is not None else None, method=method)
|
||||
r.add_header("Content-Type", "application/json")
|
||||
for k, v in (headers or {}).items():
|
||||
r.add_header(k, v)
|
||||
try:
|
||||
with urllib.request.urlopen(r, timeout=30) as resp:
|
||||
return resp.status, json.loads(resp.read())
|
||||
except urllib.error.HTTPError as e:
|
||||
return e.code, json.loads(e.read() or b"{}")
|
||||
|
||||
|
||||
def png(seed=0):
|
||||
raw = b"".join(b"\x00" + b"".join(bytes(((x * 7 + y * 3 + seed) % 256, x % 256, y % 256, 255)) for x in range(64))
|
||||
for y in range(64))
|
||||
ch = lambda t, d: struct.pack(">I", len(d)) + t + d + struct.pack(">I", zlib.crc32(t + d) & 0xffffffff)
|
||||
return (b"\x89PNG\r\n\x1a\n" + ch(b"IHDR", struct.pack(">IIBBBBB", 64, 64, 8, 6, 0, 0, 0))
|
||||
+ ch(b"IDAT", zlib.compress(raw)) + ch(b"IEND", b""))
|
||||
|
||||
|
||||
_ip = [0]
|
||||
|
||||
|
||||
def prepay(templates=("stand",)):
|
||||
_ip[0] += 1
|
||||
body = {"skin": "data:image/png;base64," + base64.b64encode(png(_ip[0])).decode(), "fileName": "t.png",
|
||||
"arm": "classic", "templates": list(templates), "res": 1000, "codes": [], "pay": "prepay",
|
||||
"terms": {"v": S.TERMS_VERSION, "agreed": True}}
|
||||
st, j = req("POST", "/api/submit", body, {"X-Real-IP": "203.0.113.%d" % _ip[0]})
|
||||
assert j.get("ok"), j
|
||||
return j["order"], j["token"], S.read_meta(j["order"])["amount"]
|
||||
|
||||
|
||||
def state(oid):
|
||||
return (S.read_meta(oid) or {}).get("state")
|
||||
|
||||
|
||||
def hook(o):
|
||||
return req("POST", "/api/payplatform-hook", {"ec": 200, "em": "ok", "data": {"type": "order", "order": o}})
|
||||
|
||||
|
||||
# ================================================================ 1. 付款配置键名
|
||||
with open(os.path.join(ROOT, "payinfo.json"), "w", encoding="utf-8") as f:
|
||||
json.dump({"afdian": "https://example.com/fixed", "afdian_uid": "UID-REAL"}, f)
|
||||
st, j = req("GET", "/api/payinfo")
|
||||
check("付款配置写的是 afdian / afdian_uid → 接口两种键名都给到(页面能拼出专链)",
|
||||
j.get("afdian_uid") == "UID-REAL" and j.get("payplatform_uid") == "UID-REAL"
|
||||
and j.get("afdian") == "https://example.com/fixed", {k: j.get(k) for k in ("afdian", "afdian_uid", "payplatform_uid")})
|
||||
check("支付宝扫码:只预留入口,状态是「待开通」", (j.get("alipay") or {}).get("on") is False
|
||||
and (j.get("alipay") or {}).get("note") == "待开通", j.get("alipay"))
|
||||
|
||||
# ================================================================ 2. 回调:精确反查 + 激活
|
||||
oid, tok, amt = prepay(("stand", "wheat"))
|
||||
o = afd(custom=oid, amount="%.2f" % amt)
|
||||
CALLS.clear()
|
||||
st, j = hook(o)
|
||||
check("回调带回订单号 → 先按 out_trade_no 精确反查 → 激活", state(oid) == "waiting"
|
||||
and CALLS and CALLS[0].get("out_trade_no") == o["out_trade_no"], (state(oid), CALLS[:2]))
|
||||
check("回调应答是 JSON 且 ec=200", st == 200 and j.get("ec") == 200, j)
|
||||
st, j = hook(o)
|
||||
check("同一笔回调再推一次 → 不重复处理,仍回 ec=200", j.get("ec") == 200 and state(oid) == "waiting", j)
|
||||
|
||||
# ================================================================ 3. 主动对账:回调丢了也能激活
|
||||
oid2, tok2, amt2 = prepay()
|
||||
afd(custom=oid2, amount="%.2f" % amt2) # 只在爱发电那边有,回调没推过来
|
||||
before = state(oid2)
|
||||
got = S.payplatform_reconcile()
|
||||
check("回调丢了 → 定时对账发现并激活", before == "unpaid" and oid2 in got and state(oid2) == "waiting", (before, got))
|
||||
led_n = len(S.STORE.ledger_all())
|
||||
got2 = S.payplatform_reconcile()
|
||||
check("再对一次账 → 不会重复激活、账本不多记", got2 == [] and len(S.STORE.ledger_all()) == led_n, (got2, led_n))
|
||||
|
||||
# 留言里写了订单号(没走专链)也认
|
||||
oid3, tok3, amt3 = prepay()
|
||||
afd(custom="", amount="%.2f" % amt3, remark="我的订单 %s 谢谢" % oid3)
|
||||
got = S.payplatform_reconcile()
|
||||
check("没走专链、但留言里写了订单号 → 对账也能认出来", oid3 in got and state(oid3) == "waiting", got)
|
||||
|
||||
# ================================================================ 4. 金额不足不激活
|
||||
oid4, tok4, amt4 = prepay(("stand", "wheat", "beach"))
|
||||
afd(custom=oid4, amount="0.10")
|
||||
S.payplatform_reconcile()
|
||||
led = S.STORE.ledger_all()
|
||||
rec = [v for v in led.values() if v.get("want_order") == oid4]
|
||||
check("实付 ¥0.10 < 应付 → 不激活,记一笔待人工核对", state(oid4) == "unpaid" and rec and rec[0].get("need_human"), rec[:1])
|
||||
|
||||
# ================================================================ 5. 去掉「金额唯一匹配」猜单
|
||||
oid5, tok5, amt5 = prepay(("stand", "boom", "sakura", "airship"))
|
||||
o5 = afd(custom="", amount="%.2f" % amt5, remark="")
|
||||
hook(o5)
|
||||
check("没带订单号、留言也空 → 不再按「金额唯一」去猜,网页单保持待付款", state(oid5) == "unpaid", state(oid5))
|
||||
|
||||
# ================================================================ 6. 买家点「我付好了」→ 当场对账
|
||||
oid6, tok6, amt6 = prepay()
|
||||
afd(custom=oid6, amount="%.2f" % amt6)
|
||||
st, j = req("POST", "/api/paid", {"oid": oid6, "token": tok6})
|
||||
check("买家点「我付好了」→ 当场查到付款,直接开始排队", j.get("found") and state(oid6) == "waiting", j)
|
||||
oid7, tok7, amt7 = prepay()
|
||||
st, j = req("POST", "/api/paid", {"oid": oid7, "token": tok7})
|
||||
check("还没付就点「我付好了」→ 照旧登记成「待确认」,不会被激活", state(oid7) == "paid" and not j.get("found"), (state(oid7), j))
|
||||
afd(custom=oid7, amount="%.2f" % amt7)
|
||||
S.payplatform_reconcile()
|
||||
check("登记过「待确认」的单,钱到了 → 对账自动激活,不用人工", state(oid7) == "waiting", state(oid7))
|
||||
|
||||
# ================================================================ 7. 卡密单 / 不相关的单不受影响
|
||||
code = S.gen_codes(1)[0]
|
||||
_ip[0] += 1
|
||||
st, j = req("POST", "/api/submit", {"skin": "data:image/png;base64," + base64.b64encode(png(99)).decode(),
|
||||
"fileName": "c.png", "arm": "classic", "templates": ["stand"], "res": 1000,
|
||||
"codes": [code], "terms": {"v": S.TERMS_VERSION, "agreed": True}},
|
||||
{"X-Real-IP": "203.0.113.%d" % _ip[0]})
|
||||
check("回归:卡密下单照旧直接进队列", j.get("ok") and state(j["order"]) == "waiting", j)
|
||||
|
||||
srv.shutdown()
|
||||
bad = [n for n, ok in RESULTS if not ok]
|
||||
print("\n%d 条,失败 %d 条" % (len(RESULTS), len(bad)))
|
||||
for n in bad:
|
||||
print(" ✗ " + n)
|
||||
sys.exit(1 if bad else 0)
|
||||
@@ -51,11 +51,14 @@
|
||||
| `server.py` | ~3100 | **全部服务端逻辑**:路由、订单状态机、卡密生命周期、限流、PNG 结构核验的调用方、爱发电回调、打包下载、小票生成 |
|
||||
| `admin.py` | ~540 | 命令行管理工具:发卡密 / 看队列 / 重渲 / 清过期 / 审计被拦记录 |
|
||||
| `pngcheck.py` | ~130 | PNG **结构**核验(不解码像素):防「夹带私货」——尾部塞字节、未知关键块、APNG |
|
||||
| `cms.py` | ~900 | **内容后台**(2026-10-05 晚):账号 / 会话 / 草稿 / 发布 / 回滚 / 传图;`server.py` 把 `/api/cms/*` 交给它。见仓库根目录 `内容后台设计.md` |
|
||||
| `store.py` | ~400 | **数据层**(2026-10-05 新增):SQLite 建库 / 第一次启动自动导入旧 JSON / 存取 / 导出回旧格式 / 体检 / 热备份 |
|
||||
| `tests/回执复现测试.py` | ~280 | 回归 + 漏洞复现(27 条,HTTP 层打接口) |
|
||||
| `tests/内容后台测试.py` | ~360 | 内容后台专项(78 条:强制改密、无明文、Cookie、https / CSRF / 来源 / 冷却、校验、发布、回滚、传图、会话、命令行) |
|
||||
| `tests/数据库测试.py` | ~290 | 数据库专项(38 条:全新安装、迁移、回退、事务、并发、规模),数据全是现编的 |
|
||||
|
||||
> 这几个文件是**自足**的:没有 import 本项目之外的模块。**部署时 `store.py` 必须和 `server.py` 放在同一个目录**(`server.py` 直接 `import store`)。
|
||||
> 这几个文件是**自足**的:没有 import 本项目之外的模块。**部署时 `store.py`、`cms.py` 必须和 `server.py` 放在同一个目录**(`server.py` 直接 `import store` / `import cms`)。
|
||||
> 内容后台还要两个环境变量 `YS_PORTAL_DIR` / `YS_ORDER_DIR`、nginx 一节配置、首次部署马上改初始密码 —— 见 `交接文档-2026-10.md` 7.1b。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -496,7 +496,8 @@ const STN={unpaid:'待付款',paid:'买家说付好了',waiting:'排队中',work
|
||||
const STC={unpaid:'n',paid:'g',waiting:'b',working:'b',done:'g',failed:'r',void:'n'};
|
||||
const CSTN={active:'还没用',inactive:'停用',bound:'已激活',used:'已核销'};
|
||||
const CSTC={active:'g',inactive:'n',bound:'b',used:'n'};
|
||||
function esc(s){const d=document.createElement('div');d.textContent=s==null?'':String(s);return d.innerHTML;}
|
||||
/* 转义:连引号一起转(2026-10-06 安全加固:原来用 textContent 只转 <>&,放进属性里会被买家写的备注撑破) */
|
||||
function esc(s){return String(s==null?'':s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));}
|
||||
function when(s){return String(s||'').replace('T',' ').slice(5,16);}
|
||||
function toast(t){const e=$('#toast');e.textContent=t;e.classList.add('on');clearTimeout(e._t);e._t=setTimeout(()=>e.classList.remove('on'),2600);}
|
||||
function copytxt(t,what){
|
||||
@@ -1070,6 +1071,13 @@ class H(BaseHTTPRequestHandler):
|
||||
"codes": (cd.get("codes") if ok3 else []) or []})
|
||||
|
||||
|
||||
class _Server(ThreadingHTTPServer):
|
||||
# ⚠️ 2026-10-07 实测:HTTPServer 默认开 SO_REUSEADDR,**Windows 上这等于允许两个进程绑同一个端口**——
|
||||
# 金钻再双击一次「开单后台」,第二个实例照样起来了(没走"已经有一个在跑"分支),两个面板并存。
|
||||
# Windows 上关掉它,第二个实例 bind 就会失败 → 只开浏览器。Linux 上留着(重启时不用等 TIME_WAIT)。
|
||||
allow_reuse_address = (os.name != "nt")
|
||||
|
||||
|
||||
def single_instance():
|
||||
s = socket.socket()
|
||||
try:
|
||||
@@ -1090,7 +1098,7 @@ def main():
|
||||
# 两个地址在同一个端口上会 EADDRINUSE(2026-09-30 自测实踩)。
|
||||
# 直接起服务:起不来就说明已经有一个在跑,开个浏览器就完事。
|
||||
try:
|
||||
srv = ThreadingHTTPServer(("<ALL-INTERFACES>", PORT), H) # <ALL-INTERFACES> = 局域网(手机同 WiFi 也能开)
|
||||
srv = _Server(("<ALL-INTERFACES>", PORT), H) # <ALL-INTERFACES> = 局域网(手机同 WiFi 也能开)
|
||||
except OSError:
|
||||
log("已经有一个开单后台在跑了%s" % (",这次只开浏览器" if OPEN_BROWSER else ",这次什么都不做"))
|
||||
if OPEN_BROWSER:
|
||||
|
||||
@@ -203,7 +203,7 @@ def run_job(job_id):
|
||||
"--template", tpl, "--skin", skin,
|
||||
"--orders-dir", root, "--out-dir", d, "--res", str(res)]
|
||||
W.log("[本机单] 渲染 %s → %s(%d px)" % (fname, os.path.basename(d), res))
|
||||
okr, tail, dt, note = W.run_blender(cmd)
|
||||
okr, tail, dt, note = W.run_blender(cmd, timeout=W.blender_timeout(res))
|
||||
if not okr:
|
||||
j["errors"].append("%s:%s" % (fname, note))
|
||||
continue
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
只在需要时连服务器(出站),服务器从不主动连你。
|
||||
"""
|
||||
import base64, json, os, re, shutil, signal, socket, subprocess, sys, threading, time, traceback
|
||||
import base64, codecs, json, os, re, shutil, signal, socket, subprocess, sys, threading, time, traceback
|
||||
import urllib.request, urllib.error
|
||||
from datetime import datetime
|
||||
|
||||
@@ -214,10 +214,22 @@ def next_seq(rec=None):
|
||||
|
||||
|
||||
# ===== Blender 看门狗(金钻 2026-09-30:卡到十分钟就关掉重开再渲)=====
|
||||
BLENDER_TIMEOUT = 600 # 单张 10 分钟;4096 实测 ~10 分钟内,够用
|
||||
BLENDER_TIMEOUT = 600 # 1000 px 单张的总时长上限(10 分钟);更大的图按像素放宽,见 blender_timeout()
|
||||
BLENDER_STALL = 900 # 连续这么久 Blender **一个字都没吐** 才算真卡住(不分分辨率)
|
||||
BLENDER_RETRY = 1 # 卡住就杀掉重开一次;再卡就判失败,别死循环
|
||||
|
||||
|
||||
def blender_timeout(res):
|
||||
"""总时长上限随分辨率放宽:1000 → 600s,2048 → ~21 分钟,4096 → ~84 分钟。
|
||||
|
||||
⚠️ 2026-10-07:以前不分分辨率一律 600 秒。空艇 1000 px 要 70~130 秒,4096 像素多 16.8 倍,
|
||||
每次都在第 10 分钟被当成"卡住"杀掉、重开再杀 → 订单 YSPPVNXQ(空艇 4096)白白失败。
|
||||
真卡死靠 BLENDER_STALL 抓(渲染中 Blender 每隔几十秒就会刷一次 Sample 进度)。
|
||||
"""
|
||||
r = (int(res or DEFAULT_RES) / 1000.0) ** 2
|
||||
return int(BLENDER_TIMEOUT * max(1.0, r * 0.5))
|
||||
|
||||
|
||||
def _kill_tree(proc):
|
||||
"""连子进程一起杀。Blender 会开子进程,只杀父进程会留孤儿继续吃 GPU。
|
||||
|
||||
@@ -280,7 +292,7 @@ def blender_pct(line):
|
||||
return None
|
||||
|
||||
|
||||
def run_blender(cmd, timeout=None, retry=None, on_progress=None):
|
||||
def run_blender(cmd, timeout=None, retry=None, on_progress=None, stall=None):
|
||||
"""带超时看门狗的渲染。返回 (ok, 输出尾巴, 耗时秒, 说明)。
|
||||
|
||||
「关掉重新打开」= 直接重跑同一条命令 —— 工程每次都是**从干净模板新复制的副本**,
|
||||
@@ -290,7 +302,8 @@ def run_blender(cmd, timeout=None, retry=None, on_progress=None):
|
||||
所以:不许抛异常、不许阻塞太久(回调里已经有节流 + 超时)。
|
||||
"""
|
||||
timeout = timeout or BLENDER_TIMEOUT
|
||||
retry = BLENDER_RETRY if retry is None else retry
|
||||
stall = stall or BLENDER_STALL
|
||||
retry =BLENDER_RETRY if retry is None else retry
|
||||
t_all = time.time()
|
||||
last = ""
|
||||
for attempt in range(retry + 1):
|
||||
@@ -299,20 +312,26 @@ def run_blender(cmd, timeout=None, retry=None, on_progress=None):
|
||||
if os.name != "nt":
|
||||
kw["start_new_session"] = True # 自成进程组,超时能整组杀干净
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
text=True, encoding="utf-8", errors="replace", bufsize=1, **kw)
|
||||
**kw)
|
||||
except OSError as e:
|
||||
return False, "", time.time() - t_all, "启动 Blender 失败:%r" % e
|
||||
# 输出交给**独立线程**读:一边攒全文,一边挑进度行回调。
|
||||
# 主线程只负责等它结束 / 超时 —— 超时看门狗的行为和以前完全一样。
|
||||
# 输出交给**独立线程**读:一边攒全文,一边挑进度行回调,一边记"最后一次有输出"的时刻。
|
||||
# 主线程只负责等它结束 / 超时(总时长超限 或 太久没输出)。
|
||||
buf = []
|
||||
last_out = [time.time()]
|
||||
|
||||
def _pump():
|
||||
try:
|
||||
tail = ""
|
||||
# ⚠️ 按**字节**有多少读多少(read1)再增量解码:文本模式的 read(512) 会憋到凑满
|
||||
# 512 个字才返回,"最后一次有输出"就不准了(2026-10-07 测出来的)
|
||||
dec = codecs.getincrementaldecoder("utf-8")("replace")
|
||||
while True:
|
||||
chunk = p.stdout.read(512)
|
||||
if not chunk:
|
||||
raw = p.stdout.read1(4096)
|
||||
if not raw:
|
||||
break
|
||||
chunk = dec.decode(raw)
|
||||
last_out[0] = time.time()
|
||||
tail += chunk
|
||||
# ⚠️ Blender 的进度条是**回车原地刷新**的(`... Sample 4/128\r`),
|
||||
# 按"行"读(for line in stdout)压根读不到 —— 2026-10-04 金钻要
|
||||
@@ -337,8 +356,21 @@ def run_blender(cmd, timeout=None, retry=None, on_progress=None):
|
||||
pass
|
||||
th = threading.Thread(target=_pump, daemon=True)
|
||||
th.start()
|
||||
t_run = time.time()
|
||||
try:
|
||||
p.wait(timeout=timeout)
|
||||
while True:
|
||||
try:
|
||||
p.wait(timeout=5)
|
||||
break
|
||||
except subprocess.TimeoutExpired:
|
||||
now = time.time()
|
||||
if now - t_run > timeout:
|
||||
why = "总时长超过 %d 秒" % timeout
|
||||
elif now - last_out[0] > stall:
|
||||
why = "%d 秒没有任何输出" % stall
|
||||
else:
|
||||
continue
|
||||
raise subprocess.TimeoutExpired(cmd, timeout, output=why)
|
||||
th.join(timeout=15)
|
||||
out = "".join(buf)
|
||||
if p.returncode == 0:
|
||||
@@ -351,14 +383,17 @@ def run_blender(cmd, timeout=None, retry=None, on_progress=None):
|
||||
p.returncode,
|
||||
(" | ".join(_keys[-6:]) + " | " if _keys else "") + _txt[-1200:])
|
||||
log("渲染失败:%s" % last)
|
||||
except subprocess.TimeoutExpired:
|
||||
log("⚠️ 渲染卡住超过 %d 秒 —— 杀掉,重新打开再渲" % timeout)
|
||||
except subprocess.TimeoutExpired as e:
|
||||
why = e.output or ("总时长超过 %d 秒" % timeout)
|
||||
# 卡在哪一步留个底(以前超时直接丢掉输出,事后完全查不到)
|
||||
_seen = [ln.strip() for ln in "".join(buf).replace("\r", "\n").splitlines() if ln.strip()]
|
||||
log("⚠️ 渲染卡住(%s)—— 杀掉,重新打开再渲|最后输出:%s" % (why, " | ".join(_seen[-3:])[-600:]))
|
||||
_kill_tree(p)
|
||||
try:
|
||||
p.wait(timeout=10) # 收尸;整组杀过就该立刻返回
|
||||
except Exception:
|
||||
pass
|
||||
last = "渲染卡住超过 %d 秒(已杀掉重开)" % timeout
|
||||
last = "渲染卡住(%s,已杀掉重开)" % why
|
||||
if attempt < retry:
|
||||
log("↻ 重开渲染(第 %d 次尝试)" % (attempt + 2))
|
||||
return False, "", time.time() - t_all, last
|
||||
@@ -394,8 +429,8 @@ def render_one(tpl_key, skin_path, order_meta, res=DEFAULT_RES, arm="auto", on_p
|
||||
_sm = (CFG.get("skin_materials") or {}).get(tpl_key)
|
||||
if _sm:
|
||||
cmd += ["--skin-material", _sm]
|
||||
log("渲染 %s(模板 %s,臂型 %s)" % (tpl_key, fname, arm or "auto"))
|
||||
okr, tail, dt, note = run_blender(cmd, on_progress=on_progress)
|
||||
log("渲染 %s(模板 %s,臂型 %s,%d px)" % (tpl_key, fname, arm or "auto", int(res)))
|
||||
okr, tail, dt, note = run_blender(cmd, timeout=blender_timeout(res), on_progress=on_progress)
|
||||
note_skin_diag(tpl_key, tail) # 不管成没成,先把"皮肤节点认了谁"记下来
|
||||
if not okr:
|
||||
return False, note
|
||||
|
||||
@@ -55,6 +55,40 @@ location /order/api/ {
|
||||
}
|
||||
```
|
||||
|
||||
### ④ 内容后台(2026-10-05 加)
|
||||
|
||||
```nginx
|
||||
# 登录 / 内容接口。⚠️ 必须带 X-Forwarded-Proto —— 后端看它判断是不是 https,不带一律拒绝(内容后台只走 https)
|
||||
location /order/api/cms/ {
|
||||
limit_req zone=<ZONE_ORDER> burst=20 nodelay;
|
||||
limit_req_status 429;
|
||||
client_max_body_size 16m; # 画展传图:单张 10MB,base64 后约 13.4MB
|
||||
proxy_pass http://localhost:<PORT>/api/cms/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# 后台发布出来的内容文件:文件名不变、内容会变 → 让浏览器每次都问一下有没有新的
|
||||
location /content/ { add_header Cache-Control "no-cache"; }
|
||||
location /order/content/ { add_header Cache-Control "no-cache"; }
|
||||
# 页面本身(2026-10-06 起门户是多页:index / gallery / tools / universe / links / about.html)不缓存:改版后手机浏览器别老吃旧副本
|
||||
location ~ \.html$ { add_header Cache-Control "no-cache"; }
|
||||
# 站点固定信息(群号 / 备案号 / 邮箱):正式服务器上的这份是真实值,部署别用仓库里的占位覆盖
|
||||
location = /assets/site-info.js { add_header Cache-Control "no-cache"; }
|
||||
# 后台页面本身不缓存(改版后别人拿到旧页面会调错接口)
|
||||
location /admin/ { add_header Cache-Control "no-store"; }
|
||||
# 画展上传的图(文件名是随机的,可以长缓存)
|
||||
location /uploads/ { add_header Cache-Control "public, max-age=2592000"; }
|
||||
|
||||
# 整站 http → https,并加 HSTS(登录页绝不能走 http)
|
||||
server { listen 80; server_name shop.example.com; return 301 https://$host$request_uri; }
|
||||
# 在 443 的 server 块里加:
|
||||
# add_header Strict-Transport-Security "max-age=31536000" always;
|
||||
```
|
||||
|
||||
> 没配好证书之前**不要开放内容后台**:后端会拒绝所有非 https 的请求(返回 403「内容后台只能用 https 打开」)。
|
||||
|
||||
⚠️ **打包下载(zip)那条要另外配**:`proxy_buffering off` + 更长的 `proxy_read_timeout`,
|
||||
因为它是**先落临时文件再边读边发**的,不能在 nginx 这层再缓存一份(小机器内存受不住)。
|
||||
|
||||
@@ -98,3 +132,57 @@ location /order/ {
|
||||
防护全在后端自己的限流 + 两把令牌 + 来源 IP 门上。
|
||||
- **没做多机/负载均衡**:单机单进程,够用。
|
||||
- **HTTPS 用自动签发的证书**,续期自动化,没有额外动作。
|
||||
|
||||
|
||||
## ⑤ 安全加固(2026-10-06,线上已加)
|
||||
|
||||
```nginx
|
||||
# 文件:/etc/nginx/snippets/jz-sec-base.conf
|
||||
add_header Strict-Transport-Security "max-age=31536000" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=()" always;
|
||||
|
||||
# 文件:/etc/nginx/snippets/jz-sec-csp.conf(只给本站页面)
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; media-src 'self' blob:; font-src 'self' data:; connect-src 'self'; frame-src https://player.bilibili.com; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'" always;
|
||||
|
||||
# server 块里:
|
||||
include snippets/jz-sec-base.conf;
|
||||
include snippets/jz-sec-csp.conf;
|
||||
location ~* (\.bak[^/]*|\.maint[^/]*|\.old[^/]*|\.orig|\.swp|~|\.v[0-9]+-(live|new)[^/]*)$ { return 404; }
|
||||
location ~* ^/(order/)?preview-[^/]*\.html$ { return 404; }
|
||||
location ~ /\.(?!well-known/) { return 404; }
|
||||
location = /content/site.json { return 404; }
|
||||
location = /order/content/order.json { return 404; }
|
||||
# 回调单独限流(http 级:limit_req_zone $binary_remote_addr zone=jzhook:1m rate=20r/m;)
|
||||
location ~ ^/order/api/(payplatform|afdian)-hook$ {
|
||||
limit_req zone=jzhook burst=10 nodelay; limit_req_status 429; client_max_body_size 64k;
|
||||
rewrite ^/order/api/(.*)$ /api/$1 break; proxy_pass http://localhost:<PORT>;
|
||||
proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;
|
||||
add_header Cache-Control "no-store" always; include snippets/jz-sec-base.conf;
|
||||
}
|
||||
# ⚠️ 每个自己写了 add_header 的 location 里都要再 include 上面两个文件(nginx 不继承 server 级的 add_header)
|
||||
# nginx.conf 的 http 块:server_tokens off;
|
||||
```
|
||||
|
||||
## ⑥ 维护页开关(2026-10-07 加)
|
||||
|
||||
放在 `jinzuan.work` 的 server 块里(两个安全头 include 之后)。**开关不用 reload**:
|
||||
|
||||
- 开:`sudo touch /var/www/jinzuan/.maintenance && sudo chown www-data:www-data /var/www/jinzuan/.maintenance`
|
||||
- 关:`sudo rm -f /var/www/jinzuan/.maintenance`
|
||||
|
||||
只拦金钻客栈的页面(返回 503 + `/maintenance.html`);`/order/api/`(爱发电回调、渲染机、内容后台)、同域其它应用、
|
||||
`/assets/` `/fonts/` 一律放行。带请求头 `X-Jz-Bypass: <BYPASS_SECRET>` 可以绕过维护页验证新页面(密钥只在服务器配置里)。
|
||||
|
||||
```nginx
|
||||
set $jz_maint 0;
|
||||
if (-f /var/www/jinzuan/.maintenance) { set $jz_maint 1; }
|
||||
if ($uri ~ "^/(order/api/|api/|ws$|todo|gw|hit$|admin|uploads/|assets/|fonts/|maintenance\.html$|\.well-known/)") { set $jz_maint 0; }
|
||||
if ($http_x_jz_bypass = "<BYPASS_SECRET>") { set $jz_maint 0; }
|
||||
if ($jz_maint = 1) { rewrite ^ /__jz_maint last; }
|
||||
location = /__jz_maint { internal; error_page 503 /maintenance.html; return 503; }
|
||||
location = /maintenance.html { add_header Cache-Control "no-store" always; add_header Retry-After "900" always;
|
||||
include snippets/jz-sec-base.conf; include snippets/jz-sec-csp.conf; }
|
||||
```
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
data/
|
||||
__pycache__/
|
||||
@@ -0,0 +1,41 @@
|
||||
# 收款原型(pay-proto)
|
||||
|
||||
设计文档里「渠道抽象层 + 爱发电主通道 + 当面付辅助通道」的可运行原型。
|
||||
标准库 + SQLite + `cryptography`,只绑 127.0.0.1,由 nginx 反代。
|
||||
|
||||
## 占位符
|
||||
|
||||
`config.py` 里所有账号 / 密钥都是 `<占位符>`。值还是占位符的渠道,自动接到内置的**模拟网关**(`mockgw.py`):
|
||||
签名、验签、HTTP 调用都是真实代码,只是对面换成模拟的爱发电 / 支付宝。填上真实值(环境变量)即切到真渠道。
|
||||
|
||||
| 环境变量 | 说明 |
|
||||
|---|---|
|
||||
| `AFDIAN_USER_ID` / `AFDIAN_TOKEN` | 爱发电开放接口(query-order 的 md5 签名) |
|
||||
| `AFDIAN_PUBKEY_FILE` | 爱发电 Webhook 验签公钥(PEM) |
|
||||
| `AFDIAN_PLAN_ID` | 承载 `custom_price` 的「自选金额」方案 |
|
||||
| `ALIPAY_APP_ID` | 当面付应用 AppID |
|
||||
| `ALIPAY_APP_PRIVATE_KEY_FILE` | 应用私钥(PEM,权限 600,只放服务器) |
|
||||
| `ALIPAY_PUBLIC_KEY_FILE` | 支付宝公钥(验响应 / 异步通知) |
|
||||
| `PAY_ADMIN_TOKEN` | 后台口令;占位符时首次启动自动生成到 `data/admin_token` |
|
||||
| `PAY_BASE_URL` / `PAY_PORT` / `PAY_DATA_DIR` | 对外地址 / 端口 / 数据目录 |
|
||||
|
||||
## 结构
|
||||
|
||||
- `core.py`:数据库、演示时钟、统一到账入口 `settle_payment()`、定时任务(爱发电对账 / 当面付补查 / 支付单过期 / 订单超时 / 迟到扫描)
|
||||
- `channels.py`:渠道抽象层,`Afdian`、`AlipayF2F`(create / verify_notify / query / close / refund)
|
||||
- `mockgw.py`:模拟网关(只在占位符时用)
|
||||
- `app.py`:HTTP 服务(只有接口和模拟网关,页面都在站点里)
|
||||
- `preview/`:并进预览站的页面 —— `order.html`(下单表单 + 我的订单)、`pay.html`(收银台 / 订单页)、
|
||||
`cms/pay.html`(收款后台)、`assets/pay.css`、`assets/pay.js`(含演示控制台)、`assets/vendor/qrcode.min.js`(qrcode-generator 1.4.4,MIT)。
|
||||
另外 `cms/index.html` 的「下单页」分组里加了一个「收款与对账」链接(预览站上直接改的,三行)。
|
||||
|
||||
## 测试
|
||||
|
||||
`python3 tests/test_proto.py`:临时目录起一份服务,从 HTTP 层打 26 个场景。
|
||||
|
||||
## 预览部署(甲骨文 ARM)
|
||||
|
||||
`/opt/jz-pay-proto` + systemd `jz-pay-proto`(DynamicUser,数据 `/var/lib/jz-pay-proto`,
|
||||
`PAY_BASE_URL=http://161.33.11.66/svc`、`PAY_SITE_URL=http://161.33.11.66`),
|
||||
nginx `jz-preview.conf` 里 `/svc/` 反代到 `127.0.0.1:18100`;旧的 `/pay-proto/` 301 到 `/order.html`。
|
||||
页面:`/order.html` → `/pay.html?o=…&t=…`;后台 `/cms/pay.html`。**只在预览机,不碰生产。**
|
||||
@@ -0,0 +1,351 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""支付原型 HTTP 服务(标准库,只绑 127.0.0.1,由 nginx 反代到 /pay-proto/)。
|
||||
|
||||
买家: POST api/order · GET api/order · POST api/pay · GET api/pay · POST api/check
|
||||
回调: POST api/notify/afdian · POST api/notify/alipay
|
||||
后台: api/admin/*(请求头 X-Admin-Token)
|
||||
演示: api/demo/*(快进时钟、立即跑定时任务、模拟场景 —— 只在原型里有)
|
||||
模拟网关:mock/afdian/* · mock/alipay/*
|
||||
"""
|
||||
import json, os, secrets, sys, urllib.parse
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import config as C # noqa: E402
|
||||
import core # noqa: E402
|
||||
import channels # noqa: E402
|
||||
import mockgw # noqa: E402
|
||||
|
||||
STATE_TEXT = {"unpaid": "待付款", "waiting": "已付款 · 排队中", "working": "渲染中", "done": "已完成",
|
||||
"failed": "渲染失败", "closed": "已关闭", "void": "已注销"}
|
||||
PAY_TEXT = {"created": "等待付款", "paid": "已到账", "mismatch": "金额不足", "closed": "已关闭", "refunded": "已退款"}
|
||||
|
||||
|
||||
def admin_token():
|
||||
if not C.is_placeholder(C.ADMIN_TOKEN):
|
||||
return C.ADMIN_TOKEN
|
||||
p = os.path.join(C.DATA_DIR, "admin_token")
|
||||
if not os.path.exists(p):
|
||||
os.makedirs(C.DATA_DIR, exist_ok=True)
|
||||
with open(p, "w") as f:
|
||||
f.write(secrets.token_urlsafe(18))
|
||||
os.chmod(p, 0o600)
|
||||
return open(p).read().strip()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 视图
|
||||
def pay_view(p, with_display=True):
|
||||
d = {k: p[k] for k in ("pay_id", "channel", "state", "amount_due", "amount_paid", "trade_no",
|
||||
"created_at", "expire_at", "paid_at", "note")}
|
||||
d["state_text"] = PAY_TEXT.get(p["state"], p["state"])
|
||||
d["display"] = json.loads(p["display"] or "{}") if (with_display and p["state"] == "created") else {}
|
||||
return d
|
||||
|
||||
|
||||
def order_view(o):
|
||||
pays = core.order_payments(o["oid"])
|
||||
chans = []
|
||||
for ch in channels.all_channels():
|
||||
ok, why = ch.available(o)
|
||||
chans.append({"name": ch.name, "label": ch.label, "ok": ok, "reason": why, "mock": ch.mock})
|
||||
ev = core.q("SELECT ts,channel,kind,pay_id,result FROM pay_events WHERE oid=? OR pay_id LIKE ? "
|
||||
"ORDER BY id DESC LIMIT 40", (o["oid"], o["oid"] + "P%"))
|
||||
return {"ok": True, "now": core.now(), "order": {
|
||||
"oid": o["oid"], "state": o["state"], "state_text": STATE_TEXT.get(o["state"], o["state"]),
|
||||
"n_img": o["n_img"], "amount": o["amount"], "created_at": o["created_at"], "paid_at": o["paid_at"],
|
||||
"closed_at": o["closed_at"], "expire_at": o["created_at"] + C.ORDER_TTL,
|
||||
"templates": [{"k": k, "n": C.TEMPLATES.get(k, k)} for k in json.loads(o.get("templates") or "[]")],
|
||||
"res": o.get("res") or 1000, "skin_name": o.get("skin_name") or "", "price_unit": C.PRICE_UNIT},
|
||||
"payments": [pay_view(p) for p in pays], "channels": chans, "events": ev,
|
||||
"params": {"qr_ttl": C.QR_TTL, "order_ttl": C.ORDER_TTL, "late_grace": C.LATE_GRACE,
|
||||
"ali_max": C.ALI_MAX_AMOUNT}}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 动作
|
||||
def create_payment(o, chname):
|
||||
if o["state"] != "unpaid":
|
||||
return {"ok": False, "error": "订单现在是「%s」,不能再付款" % STATE_TEXT.get(o["state"], o["state"])}
|
||||
ch = channels.get(chname)
|
||||
ok, why = ch.available(o)
|
||||
if not ok:
|
||||
return {"ok": False, "error": why}
|
||||
for p in core.order_payments(o["oid"]): # 同渠道还有没过期的支付单 → 直接复用
|
||||
if p["channel"] == chname and p["state"] == "created" and p["expire_at"] > core.now() + 30:
|
||||
return {"ok": True, "payment": pay_view(p)}
|
||||
p = core.new_payment(o, chname, ch.ttl())
|
||||
try:
|
||||
disp = ch.create(o, p)
|
||||
except Exception as e:
|
||||
core.x("UPDATE payments SET state='closed',note=? WHERE pay_id=?", ("创建失败:%s" % e, p["pay_id"]))
|
||||
core.event(chname, "create_failed", p["pay_id"], o["oid"], "error", repr(e))
|
||||
return {"ok": False, "error": "%s暂时不可用,请换爱发电付款" % ch.label}
|
||||
core.set_display(p["pay_id"], disp)
|
||||
return {"ok": True, "payment": pay_view(core.get_payment(p["pay_id"]))}
|
||||
|
||||
|
||||
def buyer_check(o):
|
||||
"""买家点「付好了没反应?」→ 立刻把这单所有没到账的支付单查一遍。"""
|
||||
core.x("UPDATE orders SET buyer_claim_at=? WHERE oid=?", (core.now(), o["oid"]))
|
||||
core.event("", "buyer_check", "", o["oid"], "requested")
|
||||
found = []
|
||||
for p in core.order_payments(o["oid"]):
|
||||
if p["state"] in ("created", "closed"):
|
||||
try:
|
||||
r = core.poll_payment(channels.get(p["channel"]), p, "buyer_check")
|
||||
found.append(r["result"])
|
||||
except Exception as e:
|
||||
core.event(p["channel"], "query_failed", p["pay_id"], o["oid"], "error", repr(e))
|
||||
o2 = core.get_order(o["oid"])
|
||||
if o2["state"] == "waiting":
|
||||
return {"ok": True, "found": True, "msg": "找到了,已到账 —— 正在排队出图"}
|
||||
if "short" in found:
|
||||
return {"ok": True, "found": True, "msg": "收到了付款,但金额不足,已通知金钻核对"}
|
||||
return {"ok": True, "found": False, "msg": "暂时还没查到到账。刚付完可能要等几十秒;超过几分钟还没有,请点「呼叫金钻」。"}
|
||||
|
||||
|
||||
def handle_notify(chname, body, ctype):
|
||||
ch = channels.get(chname)
|
||||
try:
|
||||
facts, why, resp = ch.verify_notify(body, ctype)
|
||||
except Exception as e:
|
||||
core.event(chname, "notify", "", "", "error", repr(e))
|
||||
return resp_default(chname)
|
||||
core.event(chname, "notify", (facts or {}).get("pay_id", ""), "", why,
|
||||
body.decode("utf-8", "replace") if isinstance(body, bytes) else str(body))
|
||||
if facts:
|
||||
if not facts["pay_id"]:
|
||||
# 没带 custom_order_id:买家直接在爱发电店铺下的单 → 按「买卡密」处理(正式版沿用现有发码逻辑)
|
||||
core.event(chname, "card_purchase", "", "", "(原型)会按实付金额发一张卡密",
|
||||
{"trade_no": facts["trade_no"], "amount": facts["amount"]})
|
||||
else:
|
||||
core.settle_payment(chname, facts["pay_id"], facts["trade_no"], facts["amount"], "notify", facts["raw"])
|
||||
return resp
|
||||
|
||||
|
||||
def resp_default(chname):
|
||||
return json.dumps({"ec": 200, "em": ""}) if chname == "afdian" else "fail"
|
||||
|
||||
|
||||
def admin_overview():
|
||||
return {"ok": True, "now": core.now(), "clock_offset": core.kv_get("clock_offset", 0),
|
||||
"todo": core.q("SELECT * FROM pay_todo ORDER BY state='done', id DESC LIMIT 100"),
|
||||
"payments": [dict(pay_view(p, False), oid=p["oid"]) for p in
|
||||
core.q("SELECT * FROM payments ORDER BY created_at DESC LIMIT 60")],
|
||||
"orders": core.q("SELECT oid,state,amount,created_at,paid_at,closed_at,buyer_claim_at FROM orders "
|
||||
"ORDER BY created_at DESC LIMIT 40"),
|
||||
"events": core.q("SELECT * FROM pay_events ORDER BY id DESC LIMIT 80"),
|
||||
"breaker": channels.get("alipay").breaker(),
|
||||
"channels": [{"name": c.name, "label": c.label, "mock": c.mock} for c in channels.all_channels()],
|
||||
"mock_alipay_risk": bool(core.kv_get("mock_alipay_risk"))}
|
||||
|
||||
|
||||
def admin_todo(d):
|
||||
t = core.q1("SELECT * FROM pay_todo WHERE id=?", (int(d.get("id") or 0),))
|
||||
if not t:
|
||||
return {"ok": False, "error": "没有这条待办"}
|
||||
act, note = d.get("action"), str(d.get("note") or "")[:200]
|
||||
p = core.get_payment(t["pay_id"]) if t["pay_id"] else None
|
||||
msg = ""
|
||||
if act == "confirm": # 金额不足 → 人工确认补齐,按到账处理
|
||||
if not p:
|
||||
return {"ok": False, "error": "这条待办没有关联支付单"}
|
||||
core.x("UPDATE payments SET state='paid',note='人工确认补齐' WHERE pay_id=?", (p["pay_id"],))
|
||||
core.x("UPDATE orders SET state='waiting',paid_at=? WHERE oid=? AND state IN ('unpaid','closed')",
|
||||
(core.now(), p["oid"]))
|
||||
msg = "已确认,订单激活"
|
||||
elif act == "activate":
|
||||
core.x("UPDATE orders SET state='waiting',paid_at=? WHERE oid=? AND state IN ('unpaid','closed','void')",
|
||||
(core.now(), t["oid"]))
|
||||
msg = "订单已手动激活"
|
||||
elif act == "refund":
|
||||
if not p:
|
||||
return {"ok": False, "error": "这条待办没有关联支付单"}
|
||||
amt = float(t["amount_paid"] or p["amount_paid"] or 0)
|
||||
try:
|
||||
ch = channels.get(p["channel"])
|
||||
if t["kind"] == "duplicate" and t["trade_no"] and t["trade_no"] != p["trade_no"]:
|
||||
return {"ok": False, "error": "重复付款的第二笔不在本地支付单上:请到%s后台按交易号 %s 退款" % (ch.label, t["trade_no"])}
|
||||
ch.refund(p, amt)
|
||||
core.x("UPDATE payments SET state='refunded',note='已退款 ¥%.2f' WHERE pay_id=?" % amt, (p["pay_id"],))
|
||||
msg = "已退款 ¥%.2f" % amt
|
||||
except Exception as e:
|
||||
return {"ok": False, "error": str(e)}
|
||||
elif act != "ignore":
|
||||
return {"ok": False, "error": "不认识的操作"}
|
||||
core.x("UPDATE pay_todo SET state='done',resolution=?,resolved_at=? WHERE id=?",
|
||||
("%s:%s %s" % (act, msg, note), core.now(), t["id"]))
|
||||
core.event(t["channel"] or "", "todo_resolved", t["pay_id"] or "", t["oid"] or "", act, note)
|
||||
return {"ok": True, "msg": msg or "已处理"}
|
||||
|
||||
|
||||
def admin_claim(d):
|
||||
"""按爱发电订单号认领到某张订单(买家没走专链、或 custom_order_id 丢了)。"""
|
||||
o = core.get_order(str(d.get("oid") or "").upper())
|
||||
if not o:
|
||||
return {"ok": False, "error": "没有这张订单"}
|
||||
ch = channels.get("afdian")
|
||||
real = ch.query_trade(str(d.get("trade_no") or "").strip())
|
||||
if not real:
|
||||
return {"ok": False, "error": "爱发电查不到这个订单号"}
|
||||
f = ch.facts(real)
|
||||
if not f["paid"]:
|
||||
return {"ok": False, "error": "这笔爱发电订单还没付款"}
|
||||
p = core.new_payment(o, "afdian", ch.ttl())
|
||||
r = core.settle_payment("afdian", p["pay_id"], f["trade_no"], f["amount"], "admin_claim", f["raw"])
|
||||
return {"ok": True, "msg": "认领结果:%s" % r["result"]}
|
||||
|
||||
|
||||
def demo(d):
|
||||
k = d.get("kind")
|
||||
if k == "clock":
|
||||
core.advance_clock(float(d.get("seconds") or 0))
|
||||
return {"ok": True, "jobs": core.run_jobs()}
|
||||
if k == "jobs":
|
||||
return {"ok": True, "jobs": core.run_jobs()}
|
||||
if k == "alipay_risk":
|
||||
core.kv_set("mock_alipay_risk", bool(d.get("on")))
|
||||
return {"ok": True}
|
||||
if k == "breaker_reset":
|
||||
core.kv_set("alipay_breaker", {"fails": 0, "open_until": 0, "reason": ""})
|
||||
return {"ok": True}
|
||||
if k == "afdian_direct":
|
||||
o = mockgw.afd_create_order("", d.get("amount") or 12, "直接在爱发电店铺下单(没带订单号)")
|
||||
return {"ok": True, "trade_no": o["out_trade_no"]}
|
||||
if k == "afdian_forge":
|
||||
fake = {"out_trade_no": "FORGED" + secrets.token_hex(4), "custom_order_id": str(d.get("pay_id") or ""),
|
||||
"user_id": "evil", "plan_id": "mock-plan", "total_amount": "999.00", "status": 2,
|
||||
"remark": "", "create_time": int(core.now())}
|
||||
return {"ok": True, "result": mockgw.afd_push(fake, forge=True)}
|
||||
return {"ok": False, "error": "unknown"}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- HTTP
|
||||
class H(BaseHTTPRequestHandler):
|
||||
server_version = "jz-pay-proto"
|
||||
|
||||
def log_message(self, fmt, *a):
|
||||
pass
|
||||
|
||||
def send(self, code, ctype, body, extra=None):
|
||||
if isinstance(body, str):
|
||||
body = body.encode("utf-8")
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
for k, v in (extra or {}).items():
|
||||
self.send_header(k, v)
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def js(self, obj, code=200):
|
||||
self.send(code, "application/json; charset=utf-8", json.dumps(obj, ensure_ascii=False))
|
||||
|
||||
def body(self):
|
||||
n = int(self.headers.get("Content-Length") or 0)
|
||||
return self.rfile.read(min(n, 65536)) if n > 0 else b""
|
||||
|
||||
def jbody(self):
|
||||
try:
|
||||
return json.loads(self.body() or b"{}")
|
||||
except ValueError:
|
||||
return {}
|
||||
|
||||
def order_auth(self, oid, tok):
|
||||
o = core.get_order(str(oid or "").upper())
|
||||
if not o or not secrets.compare_digest(o["token"], str(tok or "")):
|
||||
return None
|
||||
return o
|
||||
|
||||
def is_admin(self):
|
||||
return secrets.compare_digest(self.headers.get("X-Admin-Token") or "", admin_token())
|
||||
|
||||
def do_GET(self):
|
||||
u = urllib.parse.urlparse(self.path)
|
||||
p, qs = u.path, urllib.parse.parse_qs(u.query)
|
||||
g = lambda k: (qs.get(k) or [""])[0]
|
||||
try:
|
||||
if p in ("/", "/index.html", "/admin", "/admin.html"): # 页面都在站点里,这里只有接口
|
||||
return self.send(302, "text/plain", "", {"Location": C.SITE_URL + ("/cms/pay.html" if "admin" in p else "/order.html")})
|
||||
if p == "/api/order":
|
||||
o = self.order_auth(g("oid"), g("t"))
|
||||
return self.js(order_view(o)) if o else self.js({"ok": False, "error": "订单不存在"}, 404)
|
||||
if p == "/api/pay":
|
||||
pay = core.get_payment(g("pay_id"))
|
||||
o = self.order_auth(pay["oid"] if pay else "", g("t"))
|
||||
if not (pay and o):
|
||||
return self.js({"ok": False, "error": "支付单不存在"}, 404)
|
||||
gap = C.QUERY_MIN_GAP if pay["channel"] == "alipay" else 15
|
||||
if pay["state"] == "created" and core.now() - (pay["last_query_at"] or 0) >= gap:
|
||||
try:
|
||||
core.poll_payment(channels.get(pay["channel"]), pay, "page_poll")
|
||||
except Exception as e:
|
||||
core.event(pay["channel"], "query_failed", pay["pay_id"], o["oid"], "error", repr(e))
|
||||
return self.js(order_view(core.get_order(o["oid"])))
|
||||
if p == "/api/admin/overview":
|
||||
return self.js(admin_overview()) if self.is_admin() else self.js({"ok": False, "error": "口令不对"}, 403)
|
||||
if p == "/mock/afdian/order/create":
|
||||
return self.send(*mockgw.afd_checkout(qs))
|
||||
if p.startswith("/mock/alipay/scan/"):
|
||||
return self.send(*mockgw.ali_scan(p.rsplit("/", 1)[-1]))
|
||||
return self.send(404, "text/plain; charset=utf-8", "not found")
|
||||
except Exception as e:
|
||||
core.event("", "http_error", "", "", p, repr(e))
|
||||
return self.js({"ok": False, "error": "服务器出错了"}, 500)
|
||||
|
||||
def do_POST(self):
|
||||
p = urllib.parse.urlparse(self.path).path
|
||||
try:
|
||||
if p == "/api/order":
|
||||
d = self.jbody()
|
||||
o = core.new_order(d.get("templates"), d.get("res"), d.get("skin_name"), d.get("n_img"))
|
||||
return self.js(dict(order_view(o), token=o["token"]))
|
||||
if p in ("/api/pay", "/api/check"):
|
||||
d = self.jbody()
|
||||
o = self.order_auth(d.get("oid"), d.get("t"))
|
||||
if not o:
|
||||
return self.js({"ok": False, "error": "订单不存在"}, 404)
|
||||
return self.js(create_payment(o, d.get("channel")) if p == "/api/pay" else buyer_check(o))
|
||||
if p == "/api/notify/afdian":
|
||||
return self.send(200, "application/json", handle_notify("afdian", self.body(), self.headers.get("Content-Type")))
|
||||
if p == "/api/notify/alipay":
|
||||
return self.send(200, "text/plain", handle_notify("alipay", self.body(), self.headers.get("Content-Type")))
|
||||
if p.startswith("/api/admin/"):
|
||||
if not self.is_admin():
|
||||
return self.js({"ok": False, "error": "口令不对"}, 403)
|
||||
d = self.jbody()
|
||||
if p == "/api/admin/todo":
|
||||
return self.js(admin_todo(d))
|
||||
if p == "/api/admin/claim":
|
||||
return self.js(admin_claim(d))
|
||||
return self.js({"ok": False, "error": "unknown"}, 404)
|
||||
if p == "/api/demo":
|
||||
return self.js(demo(self.jbody()))
|
||||
if p == "/mock/afdian/order/pay":
|
||||
return self.send(*mockgw.afd_pay(urllib.parse.parse_qs(self.body().decode())))
|
||||
if p.startswith("/mock/afdian/api/open/"):
|
||||
return self.send(*mockgw.afd_api(p, self.body()))
|
||||
if p == "/mock/alipay/gateway.do":
|
||||
return self.send(*mockgw.ali_gateway(self.body()))
|
||||
if p == "/mock/alipay/scanpay":
|
||||
return self.send(*mockgw.ali_scanpay(urllib.parse.parse_qs(self.body().decode())))
|
||||
return self.js({"ok": False, "error": "not found"}, 404)
|
||||
except Exception as e:
|
||||
core.event("", "http_error", "", "", p, repr(e))
|
||||
return self.js({"ok": False, "error": "服务器出错了"}, 500)
|
||||
|
||||
|
||||
def main():
|
||||
core.db()
|
||||
mockgw.init()
|
||||
channels.init()
|
||||
admin_token() # 首次启动就生成后台口令(data/admin_token,600)
|
||||
core.start_scheduler()
|
||||
print("支付原型启动 :%d 对外 %s 爱发电=%s 当面付=%s" % (
|
||||
C.PORT, C.BASE_URL, "模拟" if channels.get("afdian").mock else "真实",
|
||||
"模拟" if channels.get("alipay").mock else "真实"), flush=True)
|
||||
ThreadingHTTPServer(("127.0.0.1", C.PORT), H).serve_forever()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,373 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""支付渠道抽象层。
|
||||
|
||||
每个渠道只做五件事:生成付款方式 create / 验证回调 verify_notify / 主动查单 query / 关单 close / 退款 refund。
|
||||
到账一律交给 core.settle_payment(),渠道自己不改订单。
|
||||
|
||||
「事实」facts = {"pay_id", "trade_no", "amount", "paid", "raw"},只来自验过真的数据。
|
||||
"""
|
||||
import base64, hashlib, json, os, re, time, urllib.parse, urllib.request
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from cryptography.hazmat.primitives import hashes, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import padding
|
||||
from cryptography.exceptions import InvalidSignature
|
||||
|
||||
import config as C
|
||||
import core
|
||||
|
||||
CST = timezone(timedelta(hours=8))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- RSA 小工具(签名 / 验签分开两把钥匙)
|
||||
def load_pub(path):
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
if b"BEGIN" not in data: # 支付宝后台给的常是不带头尾的一行 base64
|
||||
data = b"-----BEGIN PUBLIC KEY-----\n" + data.strip() + b"\n-----END PUBLIC KEY-----\n"
|
||||
return serialization.load_pem_public_key(data)
|
||||
|
||||
|
||||
def load_priv(path):
|
||||
with open(path, "rb") as f:
|
||||
return serialization.load_pem_private_key(f.read(), password=None)
|
||||
|
||||
|
||||
def rsa_sign(priv, text):
|
||||
return base64.b64encode(priv.sign(text.encode("utf-8"), padding.PKCS1v15(), hashes.SHA256())).decode()
|
||||
|
||||
|
||||
def rsa_verify(pub, text, sig_b64):
|
||||
try:
|
||||
pub.verify(base64.b64decode(sig_b64 or ""), text.encode("utf-8"), padding.PKCS1v15(), hashes.SHA256())
|
||||
return True
|
||||
except (InvalidSignature, ValueError, TypeError):
|
||||
return False
|
||||
|
||||
|
||||
def http_post(url, body, ctype, timeout=10):
|
||||
req = urllib.request.Request(url, data=body, method="POST", headers={"Content-Type": ctype})
|
||||
with urllib.request.urlopen(req, timeout=timeout) as r:
|
||||
return r.read().decode("utf-8")
|
||||
|
||||
|
||||
def fmt_cst(ts):
|
||||
return datetime.fromtimestamp(ts, CST).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 基类
|
||||
class Channel:
|
||||
name = ""
|
||||
label = ""
|
||||
mock = False
|
||||
|
||||
def available(self, order):
|
||||
return True, ""
|
||||
|
||||
def ttl(self):
|
||||
return 3600
|
||||
|
||||
def create(self, order, pay):
|
||||
raise NotImplementedError
|
||||
|
||||
def verify_notify(self, body, ctype):
|
||||
"""返回 (facts 或 None, 说明, 给渠道的应答文本)"""
|
||||
raise NotImplementedError
|
||||
|
||||
def query(self, pay):
|
||||
return None
|
||||
|
||||
def close(self, pay):
|
||||
return True
|
||||
|
||||
def refund(self, pay, amount):
|
||||
raise RuntimeError("这个渠道不支持接口退款")
|
||||
|
||||
|
||||
# ================================================================ 爱发电
|
||||
class Afdian(Channel):
|
||||
name, label = "afdian", "爱发电"
|
||||
|
||||
def __init__(self):
|
||||
cfg = dict(C.AFDIAN)
|
||||
self.mock = any(C.is_placeholder(v) for v in cfg.values())
|
||||
if self.mock:
|
||||
import mockgw
|
||||
cfg.update(user_id="mock-user", token="mock-token", plan_id="mock-plan",
|
||||
pubkey_file=mockgw.key_path("afdian_platform", public=True),
|
||||
api=C.INTERNAL_URL + "/mock/afdian/api/open",
|
||||
checkout=C.BASE_URL + "/mock/afdian/order/create")
|
||||
self.cfg = cfg
|
||||
self.pub = load_pub(cfg["pubkey_file"]) if os.path.exists(cfg["pubkey_file"]) else None
|
||||
|
||||
def ttl(self):
|
||||
return C.AFD_TTL
|
||||
|
||||
def create(self, order, pay):
|
||||
qs = urllib.parse.urlencode({"user_id": self.cfg["user_id"], "plan_id": self.cfg["plan_id"],
|
||||
"product_type": 0, "custom_price": pay["amount_due"],
|
||||
"custom_order_id": pay["pay_id"], "remark": order["oid"]})
|
||||
url = self.cfg["checkout"] + "?" + qs
|
||||
return {"type": "redirect", "url": url, "qr": url}
|
||||
|
||||
# ---- OpenAPI:sign = md5(token + "params" + params + "ts" + ts + "user_id" + user_id)
|
||||
def api(self, path, params):
|
||||
p = json.dumps(params, separators=(",", ":"))
|
||||
ts = int(time.time())
|
||||
sign = hashlib.md5(("%sparams%sts%duser_id%s" % (self.cfg["token"], p, ts, self.cfg["user_id"]))
|
||||
.encode()).hexdigest()
|
||||
body = json.dumps({"user_id": self.cfg["user_id"], "params": p, "ts": ts, "sign": sign}).encode()
|
||||
r = json.loads(http_post(self.cfg["api"] + "/" + path, body, "application/json"))
|
||||
if r.get("ec") != 200:
|
||||
raise RuntimeError("爱发电接口错误:%s %s" % (r.get("ec"), r.get("em")))
|
||||
return r.get("data") or {}
|
||||
|
||||
@staticmethod
|
||||
def facts(o):
|
||||
return {"pay_id": str(o.get("custom_order_id") or ""), "trade_no": str(o.get("out_trade_no") or ""),
|
||||
"amount": float(o.get("total_amount") or 0), "paid": int(o.get("status") or 0) == 2,
|
||||
"raw": json.dumps(o, ensure_ascii=False)[:2000]}
|
||||
|
||||
def query_trade(self, out_trade_no):
|
||||
lst = (self.api("query-order", {"out_trade_no": out_trade_no}).get("list") or [])
|
||||
return lst[0] if lst else None
|
||||
|
||||
def list_paid_since(self, since_ts, max_pages=10):
|
||||
"""从最新往前翻,翻到早于 since_ts 为止;只返回已付款的。"""
|
||||
out = []
|
||||
for page in range(1, max_pages + 1):
|
||||
d = self.api("query-order", {"page": page})
|
||||
lst = d.get("list") or []
|
||||
for o in lst:
|
||||
if int(o.get("status") or 0) == 2:
|
||||
out.append(self.facts(o))
|
||||
if not lst or page >= int(d.get("total_page") or 1) or \
|
||||
min(float(o.get("create_time") or 0) for o in lst) < since_ts:
|
||||
break
|
||||
return out
|
||||
|
||||
def verify_notify(self, body, ctype):
|
||||
ok_resp = json.dumps({"ec": 200, "em": ""})
|
||||
try:
|
||||
obj = json.loads(body or b"{}")
|
||||
except ValueError:
|
||||
return None, "报文不是 JSON", ok_resp
|
||||
data = obj.get("data") or {}
|
||||
o = data.get("order") or {}
|
||||
otn = str(o.get("out_trade_no") or "")
|
||||
if not otn:
|
||||
return None, "缺 out_trade_no", ok_resp
|
||||
# ① 验签:out_trade_no + user_id + plan_id + total_amount,平台公钥,SHA256,Base64
|
||||
if self.pub is not None:
|
||||
content = "%s%s%s%s" % (otn, o.get("user_id") or "", o.get("plan_id") or "", o.get("total_amount") or "")
|
||||
if not rsa_verify(self.pub, content, data.get("sign")):
|
||||
return None, "验签失败", ok_resp
|
||||
# ② 用开放接口按订单号精确反查,之后只认反查结果
|
||||
real = self.query_trade(otn)
|
||||
if not real:
|
||||
return None, "接口反查不到这笔单", ok_resp
|
||||
f = self.facts(real)
|
||||
if not f["paid"]:
|
||||
return None, "反查结果未付款", ok_resp
|
||||
return f, "ok", ok_resp
|
||||
|
||||
def query(self, pay):
|
||||
for f in self.list_paid_since(pay["created_at"] - 600, max_pages=5):
|
||||
if f["pay_id"] == pay["pay_id"]:
|
||||
return f
|
||||
return None
|
||||
|
||||
def close(self, pay):
|
||||
return True # 爱发电无法远程关单,只在本地标记
|
||||
|
||||
def refund(self, pay, amount):
|
||||
raise RuntimeError("爱发电没有退款接口:请到爱发电后台对订单 %s 手动退款" % pay.get("trade_no"))
|
||||
|
||||
|
||||
# ================================================================ 支付宝当面付
|
||||
RISK_CODES = ("ACQ.ACCESS_FORBIDDEN", "ACQ.SELLER_BEEN_BLOCKED", "ACQ.RISK_CONTROL", "isv.insufficient-isv-permissions",
|
||||
"ACQ.MERCHANT_STATUS_NOT_NORMAL", "ACQ.PAYMENT_AUTH_CODE_INVALID")
|
||||
|
||||
|
||||
class AlipayF2F(Channel):
|
||||
name, label = "alipay", "支付宝扫码"
|
||||
|
||||
def __init__(self):
|
||||
cfg = dict(C.ALIPAY)
|
||||
self.mock = any(C.is_placeholder(cfg[k]) for k in ("app_id", "app_private_key_file", "alipay_public_key_file"))
|
||||
if self.mock:
|
||||
import mockgw
|
||||
cfg.update(app_id="mock-app", app_private_key_file=mockgw.key_path("alipay_app"),
|
||||
alipay_public_key_file=mockgw.key_path("alipay_platform", public=True),
|
||||
gateway=C.INTERNAL_URL + "/mock/alipay/gateway.do")
|
||||
self.cfg = cfg
|
||||
self.priv = load_priv(cfg["app_private_key_file"])
|
||||
self.pub = load_pub(cfg["alipay_public_key_file"])
|
||||
|
||||
def ttl(self):
|
||||
return C.QR_TTL
|
||||
|
||||
# ---- 熔断(连续失败 / 风控类错误码 → 关 6 小时)
|
||||
def breaker(self):
|
||||
return core.kv_get("alipay_breaker", {"fails": 0, "open_until": 0, "reason": ""})
|
||||
|
||||
def _ok(self):
|
||||
b = self.breaker()
|
||||
if b["fails"]:
|
||||
b["fails"] = 0
|
||||
core.kv_set("alipay_breaker", b)
|
||||
|
||||
def _fail(self, reason, risk=False):
|
||||
b = self.breaker()
|
||||
b["fails"] += 1
|
||||
b["reason"] = reason
|
||||
if risk or b["fails"] >= C.BREAKER_FAILS:
|
||||
b["open_until"] = core.now() + C.BREAKER_COOL
|
||||
core.event("alipay", "breaker_open", "", "", reason, b)
|
||||
core.kv_set("alipay_breaker", b)
|
||||
|
||||
def available(self, order):
|
||||
b = self.breaker()
|
||||
if b["open_until"] > core.now():
|
||||
return False, "支付宝扫码暂时不可用"
|
||||
if order["amount"] > C.ALI_MAX_AMOUNT:
|
||||
return False, "金额超过 ¥%d,请用爱发电" % C.ALI_MAX_AMOUNT
|
||||
t = core.now()
|
||||
n_order = core.q1("SELECT COUNT(*) AS c FROM payments WHERE oid=? AND channel='alipay' AND created_at>?",
|
||||
(order["oid"], t - 600))["c"]
|
||||
if n_order >= C.ALI_PER_ORDER_10MIN:
|
||||
return False, "二维码生成太频繁,稍后再试或用爱发电"
|
||||
n_all = core.q1("SELECT COUNT(*) AS c FROM payments WHERE channel='alipay' AND state='created'")["c"]
|
||||
if n_all >= C.ALI_GLOBAL_PENDING:
|
||||
return False, "当前扫码人数较多,请用爱发电"
|
||||
return True, ""
|
||||
|
||||
# ---- 网关调用:请求用应用私钥签,响应用支付宝公钥验
|
||||
def call(self, method, biz, notify=False):
|
||||
params = {"app_id": self.cfg["app_id"], "method": method, "format": "JSON", "charset": "utf-8",
|
||||
"sign_type": "RSA2", "timestamp": fmt_cst(time.time()), "version": "1.0",
|
||||
"biz_content": json.dumps(biz, ensure_ascii=False, separators=(",", ":"))}
|
||||
if notify:
|
||||
params["notify_url"] = C.BASE_URL + "/api/notify/alipay"
|
||||
params["sign"] = rsa_sign(self.priv, "&".join("%s=%s" % (k, params[k]) for k in sorted(params)))
|
||||
try:
|
||||
text = http_post(self.cfg["gateway"], urllib.parse.urlencode(params).encode(),
|
||||
"application/x-www-form-urlencoded;charset=utf-8")
|
||||
except Exception as e:
|
||||
self._fail("网关不通:%r" % e)
|
||||
raise
|
||||
node = method.replace(".", "_") + "_response"
|
||||
raw_node = extract_json_node(text, node)
|
||||
sign = json.loads(text).get("sign")
|
||||
if raw_node is None or not rsa_verify(self.pub, raw_node, sign):
|
||||
self._fail("响应验签失败")
|
||||
raise RuntimeError("支付宝响应验签失败")
|
||||
r = json.loads(raw_node)
|
||||
code, sub = str(r.get("code")), str(r.get("sub_code") or "")
|
||||
if code != "10000" and sub in RISK_CODES:
|
||||
self._fail("风控/权限:%s %s" % (sub, r.get("sub_msg")), risk=True)
|
||||
elif code in ("10000", "40004"):
|
||||
self._ok()
|
||||
else:
|
||||
self._fail("%s %s" % (code, sub))
|
||||
return r
|
||||
|
||||
def create(self, order, pay):
|
||||
r = self.call("alipay.trade.precreate", {
|
||||
"out_trade_no": pay["pay_id"], "total_amount": "%.2f" % pay["amount_due"],
|
||||
"subject": "%s %s" % (self.cfg["subject"], order["oid"]),
|
||||
"time_expire": fmt_cst(core.now() + C.QR_TTL)}, notify=True)
|
||||
if str(r.get("code")) != "10000":
|
||||
raise RuntimeError("预下单失败:%s %s" % (r.get("sub_code") or r.get("code"), r.get("sub_msg") or r.get("msg")))
|
||||
return {"type": "qr", "qr": r["qr_code"], "expire_at": pay["expire_at"]}
|
||||
|
||||
def query(self, pay):
|
||||
r = self.call("alipay.trade.query", {"out_trade_no": pay["pay_id"]})
|
||||
if str(r.get("code")) != "10000":
|
||||
return None
|
||||
st = r.get("trade_status")
|
||||
return {"pay_id": pay["pay_id"], "trade_no": str(r.get("trade_no") or ""),
|
||||
"amount": float(r.get("total_amount") or 0), "paid": st in ("TRADE_SUCCESS", "TRADE_FINISHED"),
|
||||
"raw": json.dumps(r, ensure_ascii=False)}
|
||||
|
||||
def close(self, pay):
|
||||
r = self.call("alipay.trade.close", {"out_trade_no": pay["pay_id"]})
|
||||
return str(r.get("code")) == "10000" or r.get("sub_code") == "ACQ.TRADE_NOT_EXIST"
|
||||
|
||||
def refund(self, pay, amount):
|
||||
r = self.call("alipay.trade.refund", {"out_trade_no": pay["pay_id"], "refund_amount": "%.2f" % amount,
|
||||
"out_request_no": "%sR%d" % (pay["pay_id"], int(time.time()))})
|
||||
if str(r.get("code")) != "10000":
|
||||
raise RuntimeError("退款失败:%s %s" % (r.get("sub_code"), r.get("sub_msg")))
|
||||
return r
|
||||
|
||||
def verify_notify(self, body, ctype):
|
||||
form = dict(urllib.parse.parse_qsl((body or b"").decode("utf-8"), keep_blank_values=True))
|
||||
sign = form.pop("sign", "")
|
||||
form.pop("sign_type", None)
|
||||
content = "&".join("%s=%s" % (k, form[k]) for k in sorted(form) if form[k] != "")
|
||||
if not rsa_verify(self.pub, content, sign):
|
||||
return None, "验签失败", "fail"
|
||||
if form.get("app_id") != self.cfg["app_id"]:
|
||||
return None, "app_id 不符", "fail"
|
||||
f = {"pay_id": form.get("out_trade_no", ""), "trade_no": form.get("trade_no", ""),
|
||||
"amount": float(form.get("total_amount") or 0),
|
||||
"paid": form.get("trade_status") in ("TRADE_SUCCESS", "TRADE_FINISHED"),
|
||||
"raw": json.dumps(form, ensure_ascii=False)}
|
||||
if not f["paid"]:
|
||||
return None, "状态 %s,不是到账" % form.get("trade_status"), "success"
|
||||
return f, "ok", "success"
|
||||
|
||||
|
||||
def extract_json_node(text, key):
|
||||
"""取出响应里某个节点的**原始 JSON 文本**(支付宝对原文签名,不能先解析再序列化)。"""
|
||||
m = re.search(r'"%s"\s*:\s*' % re.escape(key), text)
|
||||
if not m:
|
||||
return None
|
||||
i = m.end()
|
||||
if i >= len(text) or text[i] != "{":
|
||||
return None
|
||||
depth, in_str, esc = 0, False, False
|
||||
for j in range(i, len(text)):
|
||||
ch = text[j]
|
||||
if in_str:
|
||||
if esc:
|
||||
esc = False
|
||||
elif ch == "\\":
|
||||
esc = True
|
||||
elif ch == '"':
|
||||
in_str = False
|
||||
elif ch == '"':
|
||||
in_str = True
|
||||
elif ch == "{":
|
||||
depth += 1
|
||||
elif ch == "}":
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
return text[i:j + 1]
|
||||
return None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 注册表
|
||||
_CH = {}
|
||||
|
||||
|
||||
def init():
|
||||
_CH["afdian"] = Afdian()
|
||||
_CH["alipay"] = AlipayF2F()
|
||||
|
||||
|
||||
def get(name):
|
||||
return _CH[name]
|
||||
|
||||
|
||||
def all_channels():
|
||||
return [_CH["afdian"], _CH["alipay"]]
|
||||
|
||||
|
||||
def safe_close(pay):
|
||||
try:
|
||||
get(pay["channel"]).close(pay)
|
||||
core.event(pay["channel"], "close", pay["pay_id"], pay["oid"], "ok")
|
||||
except Exception as e:
|
||||
core.event(pay["channel"], "close", pay["pay_id"], pay["oid"], "error", repr(e))
|
||||
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""支付原型的配置。
|
||||
|
||||
所有账号 / 密钥都是 <占位符>。值是占位符的渠道自动接到原型内置的「模拟网关」
|
||||
(mockgw.py:模拟爱发电收银台 + 查单接口、模拟支付宝网关 + 扫码页),
|
||||
签名、验签、HTTP 调用走的都是真实代码,只是对面换成了模拟器。
|
||||
填上真实值(环境变量或直接改这里)就切到真渠道。
|
||||
"""
|
||||
import os
|
||||
|
||||
|
||||
def env(k, d=""):
|
||||
return os.environ.get(k, d)
|
||||
|
||||
|
||||
def is_placeholder(v):
|
||||
return isinstance(v, str) and v.startswith("<") and v.endswith(">")
|
||||
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
DATA_DIR = env("PAY_DATA_DIR", os.path.join(HERE, "data"))
|
||||
PORT = int(env("PAY_PORT", "18100"))
|
||||
# 对外地址:拼回调地址、专链、二维码页用(原型挂在预览站 /pay-proto/ 下)
|
||||
BASE_URL = env("PAY_BASE_URL", "http://127.0.0.1:%d" % PORT).rstrip("/")
|
||||
# 服务器自己调自己(模拟网关)用的内网地址
|
||||
INTERNAL_URL = "http://127.0.0.1:%d" % PORT
|
||||
# 站点地址:模拟收银台付完「回到订单页」用(预览站根)
|
||||
SITE_URL = env("PAY_SITE_URL", BASE_URL).rstrip("/")
|
||||
ADMIN_TOKEN = env("PAY_ADMIN_TOKEN", "<PAY_ADMIN_TOKEN>")
|
||||
|
||||
# ---------------- 爱发电(主通道) ----------------
|
||||
AFDIAN = {
|
||||
"user_id": env("AFDIAN_USER_ID", "<AFDIAN_USER_ID>"),
|
||||
"token": env("AFDIAN_TOKEN", "<AFDIAN_TOKEN>"),
|
||||
# 爱发电开发者后台给的 Webhook 验签公钥(PEM 文件路径)
|
||||
"pubkey_file": env("AFDIAN_PUBKEY_FILE", "<AFDIAN_PUBKEY_FILE>"),
|
||||
# 承载 custom_price 的「自选金额」方案
|
||||
"plan_id": env("AFDIAN_PLAN_ID", "<AFDIAN_PLAN_ID>"),
|
||||
"api": "https://afdian.com/api/open",
|
||||
"checkout": "https://afdian.com/order/create",
|
||||
}
|
||||
|
||||
# ---------------- 支付宝当面付(辅助通道) ----------------
|
||||
ALIPAY = {
|
||||
"app_id": env("ALIPAY_APP_ID", "<ALIPAY_APP_ID>"),
|
||||
"app_private_key_file": env("ALIPAY_APP_PRIVATE_KEY_FILE", "<ALIPAY_APP_PRIVATE_KEY_FILE>"),
|
||||
"alipay_public_key_file": env("ALIPAY_PUBLIC_KEY_FILE", "<ALIPAY_PUBLIC_KEY_FILE>"),
|
||||
"gateway": "https://openapi.alipay.com/gateway.do",
|
||||
"subject": "金钻工坊 渲染服务", # 商品名:中性、真实
|
||||
}
|
||||
|
||||
PRICE_UNIT = 6 # 每张图 ¥
|
||||
# 模板 key → 名字(和下单页一致);分辨率可选值
|
||||
TEMPLATES = {"stand": "站立正反", "standb": "站立正反(虚化)", "wheat": "麦田萤火", "beach": "海边自拍",
|
||||
"boom": "不看爆炸", "sakura": "飞跃樱花林", "airship": "空艇巡游"}
|
||||
RESOLUTIONS = (1000, 1024, 2048, 4096)
|
||||
|
||||
# ---------------- 时间参数(秒) ----------------
|
||||
QR_TTL = 15 * 60 # 当面付二维码有效期
|
||||
AFD_TTL = 2 * 3600 # 爱发电支付单本地有效期(过期后付款仍能被对账收回)
|
||||
ORDER_TTL = 24 * 3600 # 订单待付款保留
|
||||
LATE_GRACE = 72 * 3600 # 订单关闭后,迟到付款自动恢复的宽限
|
||||
QUERY_MIN_GAP = 5 # 同一张当面付支付单两次查单的最小间隔
|
||||
JOB_TICK = 60 # 定时任务一轮的间隔
|
||||
|
||||
# ---------------- 当面付降风险 ----------------
|
||||
ALI_MAX_AMOUNT = 500 # 单笔上限,超过只给爱发电
|
||||
ALI_PER_ORDER_10MIN = 3 # 同一订单 10 分钟内最多生成几个二维码
|
||||
ALI_GLOBAL_PENDING = 20 # 全站同时未付的当面付二维码上限
|
||||
BREAKER_FAILS = 3 # 连续失败几次熔断
|
||||
BREAKER_COOL = 6 * 3600 # 熔断多久
|
||||
@@ -0,0 +1,331 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""支付原型核心:数据库、时钟、统一到账入口 settle_payment()、订单状态机、定时任务。
|
||||
|
||||
订单状态:unpaid → waiting(到账)/ closed(超时)/ void(注销);closed → waiting(宽限期内迟到付款)
|
||||
支付单状态:created → paid / mismatch / closed;closed → paid(迟到);paid / mismatch → refunded
|
||||
"""
|
||||
import json, os, secrets, sqlite3, threading, time
|
||||
|
||||
import config as C
|
||||
|
||||
LOCK = threading.RLock()
|
||||
_DB = None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 时钟(原型可快进,方便演示超时)
|
||||
def now():
|
||||
return time.time() + float(kv_get("clock_offset", 0) or 0)
|
||||
|
||||
|
||||
def advance_clock(seconds):
|
||||
kv_set("clock_offset", float(kv_get("clock_offset", 0) or 0) + seconds)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 数据库
|
||||
SCHEMA = """
|
||||
CREATE TABLE IF NOT EXISTS orders(
|
||||
oid TEXT PRIMARY KEY, token TEXT, state TEXT, n_img INTEGER, amount INTEGER,
|
||||
created_at REAL, paid_at REAL, closed_at REAL, buyer_claim_at REAL, note TEXT DEFAULT '',
|
||||
templates TEXT DEFAULT '[]', res INTEGER DEFAULT 1000, skin_name TEXT DEFAULT '');
|
||||
CREATE TABLE IF NOT EXISTS payments(
|
||||
pay_id TEXT PRIMARY KEY, oid TEXT, channel TEXT, amount_due INTEGER, state TEXT,
|
||||
created_at REAL, expire_at REAL, trade_no TEXT UNIQUE, amount_paid REAL, paid_at REAL,
|
||||
last_query_at REAL DEFAULT 0, display TEXT DEFAULT '{}', note TEXT DEFAULT '');
|
||||
CREATE INDEX IF NOT EXISTS pay_oid ON payments(oid);
|
||||
CREATE TABLE IF NOT EXISTS pay_events(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT, ts REAL, channel TEXT, kind TEXT,
|
||||
pay_id TEXT, oid TEXT, result TEXT, raw TEXT);
|
||||
CREATE TABLE IF NOT EXISTS pay_todo(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT, ts REAL, kind TEXT, oid TEXT, pay_id TEXT, channel TEXT,
|
||||
trade_no TEXT, amount_due REAL, amount_paid REAL, detail TEXT, state TEXT DEFAULT 'open',
|
||||
resolution TEXT DEFAULT '', resolved_at REAL);
|
||||
CREATE TABLE IF NOT EXISTS kv(k TEXT PRIMARY KEY, v TEXT);
|
||||
"""
|
||||
|
||||
|
||||
def db():
|
||||
global _DB
|
||||
if _DB is None:
|
||||
os.makedirs(C.DATA_DIR, exist_ok=True)
|
||||
_DB = sqlite3.connect(os.path.join(C.DATA_DIR, "pay.db"), check_same_thread=False,
|
||||
isolation_level=None)
|
||||
_DB.row_factory = sqlite3.Row
|
||||
_DB.execute("PRAGMA journal_mode=WAL")
|
||||
_DB.executescript(SCHEMA)
|
||||
for col, decl in (("templates", "TEXT DEFAULT '[]'"), ("res", "INTEGER DEFAULT 1000"),
|
||||
("skin_name", "TEXT DEFAULT ''")):
|
||||
try: # 老库补列
|
||||
_DB.execute("ALTER TABLE orders ADD COLUMN %s %s" % (col, decl))
|
||||
except sqlite3.OperationalError:
|
||||
pass
|
||||
return _DB
|
||||
|
||||
|
||||
def q(sql, args=()):
|
||||
with LOCK:
|
||||
return [dict(r) for r in db().execute(sql, args).fetchall()]
|
||||
|
||||
|
||||
def q1(sql, args=()):
|
||||
r = q(sql, args)
|
||||
return r[0] if r else None
|
||||
|
||||
|
||||
def x(sql, args=()):
|
||||
with LOCK:
|
||||
return db().execute(sql, args)
|
||||
|
||||
|
||||
def kv_get(k, d=None):
|
||||
with LOCK:
|
||||
r = db().execute("SELECT v FROM kv WHERE k=?", (k,)).fetchone()
|
||||
if not r:
|
||||
return d
|
||||
try:
|
||||
return json.loads(r[0])
|
||||
except ValueError:
|
||||
return d
|
||||
|
||||
|
||||
def kv_set(k, v):
|
||||
x("INSERT INTO kv(k,v) VALUES(?,?) ON CONFLICT(k) DO UPDATE SET v=excluded.v", (k, json.dumps(v)))
|
||||
|
||||
|
||||
def event(channel, kind, pay_id="", oid="", result="", raw=""):
|
||||
raw = raw if isinstance(raw, str) else json.dumps(raw, ensure_ascii=False)
|
||||
x("INSERT INTO pay_events(ts,channel,kind,pay_id,oid,result,raw) VALUES(?,?,?,?,?,?,?)",
|
||||
(now(), channel, kind, pay_id, oid, result, raw[:4096]))
|
||||
|
||||
|
||||
def todo(kind, detail, oid="", pay_id="", channel="", trade_no="", amount_due=None, amount_paid=None):
|
||||
# 同一笔渠道流水只进一次待办(回调 + 对账可能各报一次)
|
||||
if trade_no and q1("SELECT id FROM pay_todo WHERE trade_no=? AND kind=?", (trade_no, kind)):
|
||||
return
|
||||
x("INSERT INTO pay_todo(ts,kind,oid,pay_id,channel,trade_no,amount_due,amount_paid,detail) "
|
||||
"VALUES(?,?,?,?,?,?,?,?,?)", (now(), kind, oid, pay_id, channel, trade_no, amount_due, amount_paid, detail))
|
||||
event(channel, "todo", pay_id, oid, kind, detail)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 订单 / 支付单
|
||||
def new_order(templates=None, res=1000, skin_name="", n_img=None):
|
||||
"""下单。templates = 模板 key 列表(一张皮肤 × 每个模板出一张);老调用只给 n_img 也行。"""
|
||||
tpls = [t for t in (templates or []) if t in C.TEMPLATES]
|
||||
tpls = list(dict.fromkeys(tpls))
|
||||
if tpls:
|
||||
n = len(tpls)
|
||||
else:
|
||||
n = max(1, min(int(n_img or 1), 20))
|
||||
res = int(res or 1000) if int(res or 1000) in C.RESOLUTIONS else 1000
|
||||
oid = "YS" + "".join(secrets.choice("ABCDEFGHJKLMNPQRSTUVWXYZ23456789") for _ in range(6))
|
||||
tok = "".join(secrets.choice("ABCDEFGHJKLMNPQRSTUVWXYZ23456789") for _ in range(10)) # 取件码:好抄、不混淆
|
||||
x("INSERT INTO orders(oid,token,state,n_img,amount,created_at,templates,res,skin_name) VALUES(?,?,?,?,?,?,?,?,?)",
|
||||
(oid, tok, "unpaid", n, n * C.PRICE_UNIT, now(), json.dumps(tpls), res, str(skin_name or "")[:80]))
|
||||
event("", "order_created", "", oid, "unpaid", {"templates": tpls, "res": res, "amount": n * C.PRICE_UNIT})
|
||||
return get_order(oid)
|
||||
|
||||
|
||||
def get_order(oid):
|
||||
return q1("SELECT * FROM orders WHERE oid=?", (oid,))
|
||||
|
||||
|
||||
def order_payments(oid):
|
||||
return q("SELECT * FROM payments WHERE oid=? ORDER BY created_at", (oid,))
|
||||
|
||||
|
||||
def get_payment(pay_id):
|
||||
return q1("SELECT * FROM payments WHERE pay_id=?", (pay_id,))
|
||||
|
||||
|
||||
def new_payment(order, channel, ttl):
|
||||
with LOCK:
|
||||
seq = (q1("SELECT COUNT(*) AS c FROM payments WHERE oid=?", (order["oid"],)) or {}).get("c", 0) + 1
|
||||
pay_id = "%sP%d" % (order["oid"], seq)
|
||||
t = now()
|
||||
x("INSERT INTO payments(pay_id,oid,channel,amount_due,state,created_at,expire_at) VALUES(?,?,?,?,?,?,?)",
|
||||
(pay_id, order["oid"], channel, order["amount"], "created", t, t + ttl))
|
||||
event(channel, "payment_created", pay_id, order["oid"], "created", {"amount_due": order["amount"]})
|
||||
return get_payment(pay_id)
|
||||
|
||||
|
||||
def set_display(pay_id, display):
|
||||
x("UPDATE payments SET display=? WHERE pay_id=?", (json.dumps(display, ensure_ascii=False), pay_id))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 统一到账入口
|
||||
def settle_payment(channel, pay_id, trade_no, amount_paid, source, raw=""):
|
||||
"""所有「钱到了」都只走这里。回调、对账、轮询、买家自查、后台认领都调它。
|
||||
|
||||
返回 {"result": ...}:
|
||||
activated 首次到账,订单激活
|
||||
reopened 订单已超时关闭,但在宽限期内 → 恢复并激活
|
||||
dup_trade 这笔渠道流水已经处理过(幂等,什么都不做)
|
||||
already 这张支付单早就到账了,这次是另一笔钱 → 待办「重复付款」
|
||||
short 金额不足 → 待办
|
||||
late 超过宽限才付 / 订单已注销 → 待办
|
||||
duplicate 订单已经被别的支付单激活过 → 待办「重复付款」
|
||||
unknown 对不上本地支付单 → 待办
|
||||
"""
|
||||
trade_no = str(trade_no or "")
|
||||
to_close = []
|
||||
with LOCK:
|
||||
conn = db()
|
||||
conn.execute("BEGIN IMMEDIATE")
|
||||
try:
|
||||
if trade_no and conn.execute("SELECT 1 FROM payments WHERE trade_no=?", (trade_no,)).fetchone():
|
||||
conn.execute("COMMIT")
|
||||
event(channel, "settle", pay_id, "", "dup_trade", {"trade_no": trade_no, "source": source})
|
||||
return {"result": "dup_trade"}
|
||||
p = conn.execute("SELECT * FROM payments WHERE pay_id=?", (pay_id,)).fetchone()
|
||||
if not p:
|
||||
conn.execute("COMMIT")
|
||||
todo("unknown", "渠道报了一笔对不上本地支付单的到账(%s)" % pay_id, "", pay_id, channel,
|
||||
trade_no, None, amount_paid)
|
||||
return {"result": "unknown"}
|
||||
p = dict(p)
|
||||
oid = p["oid"]
|
||||
if p["state"] in ("paid", "refunded"):
|
||||
conn.execute("COMMIT")
|
||||
todo("duplicate", "同一张支付单又来了一笔钱(第一笔 %s)" % p["trade_no"], oid, pay_id, channel,
|
||||
trade_no, p["amount_due"], amount_paid)
|
||||
return {"result": "already"}
|
||||
if float(amount_paid or 0) + 0.005 < float(p["amount_due"]):
|
||||
conn.execute("UPDATE payments SET state='mismatch',trade_no=?,amount_paid=?,paid_at=?,note=? "
|
||||
"WHERE pay_id=?", (trade_no or None, amount_paid, now(), "金额不足", pay_id))
|
||||
conn.execute("COMMIT")
|
||||
todo("short", "实付 ¥%s,应付 ¥%s,未激活" % (amount_paid, p["amount_due"]), oid, pay_id,
|
||||
channel, trade_no, p["amount_due"], amount_paid)
|
||||
return {"result": "short"}
|
||||
conn.execute("UPDATE payments SET state='paid',trade_no=?,amount_paid=?,paid_at=?,note=? WHERE pay_id=?",
|
||||
(trade_no or None, amount_paid, now(), "到账(%s)" % source, pay_id))
|
||||
o = dict(conn.execute("SELECT * FROM orders WHERE oid=?", (oid,)).fetchone())
|
||||
if o["state"] == "unpaid":
|
||||
res = "activated"
|
||||
elif o["state"] == "closed" and now() - float(o["closed_at"] or 0) <= C.LATE_GRACE:
|
||||
res = "reopened"
|
||||
elif o["state"] in ("closed", "void"):
|
||||
res = "late"
|
||||
else:
|
||||
res = "duplicate"
|
||||
if res in ("activated", "reopened"):
|
||||
conn.execute("UPDATE orders SET state='waiting',paid_at=? WHERE oid=?", (now(), oid))
|
||||
to_close = [dict(r) for r in conn.execute(
|
||||
"SELECT * FROM payments WHERE oid=? AND state='created' AND pay_id<>?", (oid, pay_id))]
|
||||
conn.execute("UPDATE payments SET state='closed',note='订单已在别的支付单付过' "
|
||||
"WHERE oid=? AND state='created' AND pay_id<>?", (oid, pay_id))
|
||||
conn.execute("COMMIT")
|
||||
except Exception:
|
||||
conn.execute("ROLLBACK")
|
||||
raise
|
||||
event(channel, "settle", pay_id, oid, res, {"trade_no": trade_no, "amount": amount_paid, "source": source})
|
||||
if res == "late":
|
||||
todo("late", "订单已%s,超过宽限才到账" % ("注销" if o["state"] == "void" else "关闭"), oid, pay_id,
|
||||
channel, trade_no, p["amount_due"], amount_paid)
|
||||
elif res == "duplicate":
|
||||
todo("duplicate", "订单已经付过(状态 %s),这笔是重复付款" % o["state"], oid, pay_id, channel,
|
||||
trade_no, p["amount_due"], amount_paid)
|
||||
if to_close:
|
||||
import channels
|
||||
for op in to_close:
|
||||
channels.safe_close(op)
|
||||
return {"result": res}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 定时任务
|
||||
def job_afdian_reconcile():
|
||||
import channels
|
||||
ch = channels.get("afdian")
|
||||
oldest = q1("SELECT MIN(created_at) AS t FROM payments WHERE channel='afdian' AND "
|
||||
"(state='created' OR (state='closed' AND created_at>?))", (now() - C.LATE_GRACE,))
|
||||
if not oldest or not oldest.get("t"):
|
||||
return 0
|
||||
n = 0
|
||||
for f in ch.list_paid_since(oldest["t"] - 600):
|
||||
if f.get("pay_id"):
|
||||
p = get_payment(f["pay_id"])
|
||||
if p and p["state"] in ("created", "closed"):
|
||||
r = settle_payment("afdian", f["pay_id"], f["trade_no"], f["amount"], "reconcile", f.get("raw", ""))
|
||||
n += r["result"] in ("activated", "reopened")
|
||||
return n
|
||||
|
||||
|
||||
def job_alipay_poll():
|
||||
import channels
|
||||
ch = channels.get("alipay")
|
||||
t = now()
|
||||
rows = q("SELECT * FROM payments WHERE channel='alipay' AND state='created' AND created_at<? AND last_query_at<?",
|
||||
(t - 60, t - 30))
|
||||
for p in rows:
|
||||
poll_payment(ch, p, "poll")
|
||||
return len(rows)
|
||||
|
||||
|
||||
def poll_payment(ch, p, source):
|
||||
x("UPDATE payments SET last_query_at=? WHERE pay_id=?", (now(), p["pay_id"]))
|
||||
f = ch.query(p)
|
||||
if f and f.get("paid"):
|
||||
return settle_payment(ch.name, p["pay_id"], f["trade_no"], f["amount"], source, f.get("raw", ""))
|
||||
return {"result": "unpaid"}
|
||||
|
||||
|
||||
def job_expire_payments():
|
||||
import channels
|
||||
rows = q("SELECT * FROM payments WHERE state='created' AND expire_at<=?", (now(),))
|
||||
for p in rows:
|
||||
ch = channels.get(p["channel"])
|
||||
f = ch.query(p) # 关单前最后查一次,防止「刚付就被关」
|
||||
if f and f.get("paid"):
|
||||
settle_payment(ch.name, p["pay_id"], f["trade_no"], f["amount"], "expire_check", f.get("raw", ""))
|
||||
continue
|
||||
x("UPDATE payments SET state='closed',note='过期' WHERE pay_id=? AND state='created'", (p["pay_id"],))
|
||||
channels.safe_close(p)
|
||||
event(ch.name, "payment_expired", p["pay_id"], p["oid"], "closed")
|
||||
return len(rows)
|
||||
|
||||
|
||||
def job_close_orders():
|
||||
t = now()
|
||||
rows = q("SELECT * FROM orders WHERE state='unpaid' AND created_at<=?", (t - C.ORDER_TTL,))
|
||||
n = 0
|
||||
for o in rows:
|
||||
if q1("SELECT 1 AS y FROM payments WHERE oid=? AND state='created'", (o["oid"],)):
|
||||
continue
|
||||
x("UPDATE orders SET state='closed',closed_at=? WHERE oid=? AND state='unpaid'", (t, o["oid"]))
|
||||
event("", "order_closed", "", o["oid"], "closed", "超过 %d 小时未付款" % (C.ORDER_TTL // 3600))
|
||||
n += 1
|
||||
return n
|
||||
|
||||
|
||||
def job_late_scan():
|
||||
"""最近宽限期内关闭的当面付支付单再查一次,抓迟到付款(爱发电的由对账覆盖)。"""
|
||||
import channels
|
||||
ch = channels.get("alipay")
|
||||
rows = q("SELECT * FROM payments WHERE channel='alipay' AND state='closed' AND created_at>? AND last_query_at<?",
|
||||
(now() - C.LATE_GRACE, now() - 600))
|
||||
for p in rows:
|
||||
poll_payment(ch, p, "late_scan")
|
||||
return len(rows)
|
||||
|
||||
|
||||
JOBS = [("爱发电对账", job_afdian_reconcile), ("当面付补查", job_alipay_poll),
|
||||
("支付单过期", job_expire_payments), ("订单超时关闭", job_close_orders), ("迟到付款扫描", job_late_scan)]
|
||||
|
||||
|
||||
def run_jobs():
|
||||
out = {}
|
||||
for name, fn in JOBS:
|
||||
try:
|
||||
out[name] = fn()
|
||||
except Exception as e: # 单个任务失败不影响其他任务
|
||||
out[name] = "错误:%r" % e
|
||||
event("", "job_error", "", "", name, repr(e))
|
||||
return out
|
||||
|
||||
|
||||
def scheduler():
|
||||
while True:
|
||||
time.sleep(C.JOB_TICK)
|
||||
run_jobs()
|
||||
|
||||
|
||||
def start_scheduler():
|
||||
threading.Thread(target=scheduler, daemon=True).start()
|
||||
@@ -0,0 +1,285 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""模拟网关:配置还是占位符时,渠道代码连的是这里。
|
||||
|
||||
模拟爱发电:收银台页面(金额可改、可模拟回调丢失)+ query-order 接口(校验 md5 签名)+ Webhook 推送(RSA 签名)。
|
||||
模拟支付宝:gateway.do(校验应用签名,响应用「支付宝」私钥签名)+ 手机扫码付款页 + 异步通知。
|
||||
密钥首次启动时生成在 data/mock_keys/,只用于模拟,和真实渠道无关。
|
||||
"""
|
||||
import hashlib, html, json, os, secrets, threading, time, urllib.parse
|
||||
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
|
||||
import config as C
|
||||
import core
|
||||
|
||||
KEY_DIR = os.path.join(C.DATA_DIR, "mock_keys")
|
||||
|
||||
|
||||
def key_path(name, public=False):
|
||||
os.makedirs(KEY_DIR, exist_ok=True)
|
||||
priv = os.path.join(KEY_DIR, name + ".pem")
|
||||
pub = os.path.join(KEY_DIR, name + ".pub.pem")
|
||||
if not os.path.exists(priv):
|
||||
k = rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
||||
with open(priv, "wb") as f:
|
||||
f.write(k.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8,
|
||||
serialization.NoEncryption()))
|
||||
os.chmod(priv, 0o600)
|
||||
with open(pub, "wb") as f:
|
||||
f.write(k.public_key().public_bytes(serialization.Encoding.PEM,
|
||||
serialization.PublicFormat.SubjectPublicKeyInfo))
|
||||
return pub if public else priv
|
||||
|
||||
|
||||
def init():
|
||||
core.db().executescript("""
|
||||
CREATE TABLE IF NOT EXISTS mock_afd(out_trade_no TEXT PRIMARY KEY, custom_order_id TEXT, user_id TEXT,
|
||||
plan_id TEXT, total_amount TEXT, status INTEGER, remark TEXT, create_time INTEGER);
|
||||
CREATE TABLE IF NOT EXISTS mock_ali(out_trade_no TEXT PRIMARY KEY, trade_no TEXT, total_amount TEXT, subject TEXT,
|
||||
status TEXT, notify_url TEXT, expire_ts REAL, qr TEXT, created REAL, paid_at REAL, refunded TEXT DEFAULT '0');
|
||||
""")
|
||||
for n in ("afdian_platform", "alipay_platform", "alipay_app"):
|
||||
key_path(n)
|
||||
|
||||
|
||||
def _priv(name):
|
||||
from channels import load_priv
|
||||
return load_priv(key_path(name))
|
||||
|
||||
|
||||
def _pub(name):
|
||||
from channels import load_pub
|
||||
return load_pub(key_path(name, public=True))
|
||||
|
||||
|
||||
def _later(fn, delay=0.6):
|
||||
threading.Timer(delay, fn).start()
|
||||
|
||||
|
||||
def _post(url, body, ctype):
|
||||
from channels import http_post
|
||||
try:
|
||||
return http_post(url, body, ctype)
|
||||
except Exception as e:
|
||||
return "ERR %r" % e
|
||||
|
||||
|
||||
def _trade_no():
|
||||
return time.strftime("%Y%m%d%H%M%S") + "".join(secrets.choice("0123456789") for _ in range(10))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 页面外壳
|
||||
def page(title, body):
|
||||
return ("""<!doctype html><html lang="zh-CN"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"><title>%s</title>
|
||||
<style>
|
||||
body{margin:0;font:15px/1.7 system-ui,"PingFang SC","Microsoft YaHei",sans-serif;background:#f3f4f6;color:#1f2329}
|
||||
.top{padding:12px 16px;color:#fff;font-weight:600}
|
||||
.box{max-width:420px;margin:18px auto;background:#fff;border-radius:12px;padding:20px 18px;box-shadow:0 8px 24px -16px rgba(0,0,0,.3)}
|
||||
.amt{font-size:34px;font-weight:700;margin:6px 0}
|
||||
.mute{color:#6b7280;font-size:13px}
|
||||
label{display:flex;gap:8px;align-items:center;margin:10px 0;font-size:14px}
|
||||
input[type=number]{font-size:20px;width:120px;padding:6px 8px;border:1px solid #d1d5db;border-radius:8px}
|
||||
button{width:100%%;margin-top:12px;padding:12px;border:0;border-radius:10px;font-size:16px;font-weight:600;color:#fff;cursor:pointer}
|
||||
.warn{background:#fff7e6;border-radius:8px;padding:8px 10px;font-size:13px;color:#8a5a00;margin-top:10px}
|
||||
code{background:#f3f4f6;padding:1px 5px;border-radius:4px;font-size:12.5px}
|
||||
</style></head><body>%s</body></html>""" % (html.escape(title), body)).encode("utf-8")
|
||||
|
||||
|
||||
# ================================================================ 模拟爱发电
|
||||
def afd_checkout(qs):
|
||||
g = lambda k: (qs.get(k) or [""])[0]
|
||||
price = g("custom_price") or "0"
|
||||
body = """<div class="top" style="background:#946ce6">爱发电(模拟收银台)</div>
|
||||
<div class="box"><div class="mute">自选金额发电 · 方案 <code>%s</code></div>
|
||||
<div class="amt">¥<span id="a">%s</span></div>
|
||||
<div class="mute">订单留言:%s<br>custom_order_id:<code>%s</code></div>
|
||||
<form method="post" action="pay">
|
||||
<input type="hidden" name="custom_order_id" value="%s"><input type="hidden" name="remark" value="%s">
|
||||
<label>实付金额(可改,模拟买家改价)<input type="number" step="0.01" min="0" name="amount" value="%s"></label>
|
||||
<label><input type="checkbox" name="drop"> 模拟 Webhook 丢失(靠对账补)</label>
|
||||
<button style="background:#946ce6">确认付款</button></form>
|
||||
<div class="warn">这是原型里的模拟页面,不会真的扣钱。</div></div>""" % tuple(html.escape(x) for x in (
|
||||
g("plan_id"), price, g("remark") or "(无)", g("custom_order_id") or "(无)",
|
||||
g("custom_order_id"), g("remark"), price))
|
||||
return 200, "text/html; charset=utf-8", page("爱发电 · 模拟收银台", body)
|
||||
|
||||
|
||||
def afd_create_order(custom_order_id, amount, remark, drop=False):
|
||||
otn = _trade_no()
|
||||
o = {"out_trade_no": otn, "custom_order_id": custom_order_id, "user_id": "buyer" + secrets.token_hex(4),
|
||||
"plan_id": "mock-plan", "total_amount": "%.2f" % float(amount or 0), "status": 2, "remark": remark,
|
||||
"create_time": int(core.now())}
|
||||
core.x("INSERT INTO mock_afd VALUES(?,?,?,?,?,?,?,?)", tuple(o[k] for k in (
|
||||
"out_trade_no", "custom_order_id", "user_id", "plan_id", "total_amount", "status", "remark", "create_time")))
|
||||
core.event("mock-afdian", "mock_paid", custom_order_id, "", "drop_webhook" if drop else "webhook_soon", o)
|
||||
if not drop:
|
||||
_later(lambda: afd_push(o))
|
||||
return o
|
||||
|
||||
|
||||
def afd_push(o, forge=False):
|
||||
from channels import rsa_sign
|
||||
content = "%s%s%s%s" % (o["out_trade_no"], o["user_id"], o["plan_id"], o["total_amount"])
|
||||
sign = rsa_sign(_priv("afdian_platform"), content)
|
||||
if forge:
|
||||
sign = sign[::-1]
|
||||
body = json.dumps({"ec": 200, "em": "ok", "data": {"type": "order", "order": o, "sign": sign}}).encode()
|
||||
return _post(C.INTERNAL_URL + "/api/notify/afdian", body, "application/json")
|
||||
|
||||
|
||||
def afd_pay(form):
|
||||
g = lambda k: (form.get(k) or [""])[0]
|
||||
o = afd_create_order(g("custom_order_id"), g("amount"), g("remark"), drop=bool(g("drop")))
|
||||
back = C.SITE_URL + "/pay.html?o=" + urllib.parse.quote(g("remark") or "")
|
||||
body = """<div class="top" style="background:#946ce6">爱发电(模拟)</div><div class="box">
|
||||
<div class="amt">付款成功</div><div class="mute">爱发电订单号 <code>%s</code><br>实付 ¥%s%s</div>
|
||||
<p><a href="%s">回到订单页</a>(订单页会自动发现到账)</p></div>""" % (
|
||||
o["out_trade_no"], o["total_amount"], "<br><b>已模拟 Webhook 丢失</b>,等对账补上" if g("drop") else "", back)
|
||||
return 200, "text/html; charset=utf-8", page("付款成功", body)
|
||||
|
||||
|
||||
def afd_api(path, raw):
|
||||
try:
|
||||
req = json.loads(raw or b"{}")
|
||||
except ValueError:
|
||||
return _json({"ec": 400, "em": "bad json"})
|
||||
want = hashlib.md5(("mock-tokenparams%sts%suser_id%s" % (req.get("params"), req.get("ts"), req.get("user_id")))
|
||||
.encode()).hexdigest()
|
||||
if req.get("user_id") != "mock-user" or req.get("sign") != want:
|
||||
return _json({"ec": 400005, "em": "sign error"})
|
||||
if not path.endswith("query-order"):
|
||||
return _json({"ec": 404, "em": "unknown api"})
|
||||
p = json.loads(req.get("params") or "{}")
|
||||
cols = ("out_trade_no", "custom_order_id", "user_id", "plan_id", "total_amount", "status", "remark", "create_time")
|
||||
if p.get("out_trade_no"):
|
||||
ids = [s for s in str(p["out_trade_no"]).split(",") if s]
|
||||
rows = core.q("SELECT * FROM mock_afd WHERE out_trade_no IN (%s)" % ",".join("?" * len(ids)), ids)
|
||||
return _json({"ec": 200, "data": {"list": [{k: r[k] for k in cols} for r in rows], "total_page": 1}})
|
||||
page_no = max(1, int(p.get("page") or 1))
|
||||
total = core.q1("SELECT COUNT(*) AS c FROM mock_afd")["c"]
|
||||
rows = core.q("SELECT * FROM mock_afd ORDER BY create_time DESC LIMIT 50 OFFSET ?", ((page_no - 1) * 50,))
|
||||
return _json({"ec": 200, "data": {"list": [{k: r[k] for k in cols} for r in rows],
|
||||
"total_count": total, "total_page": max(1, (total + 49) // 50)}})
|
||||
|
||||
|
||||
# ================================================================ 模拟支付宝
|
||||
def _ali_resp(method, node):
|
||||
from channels import rsa_sign
|
||||
key = method.replace(".", "_") + "_response"
|
||||
raw = json.dumps(node, ensure_ascii=False, separators=(",", ":"))
|
||||
sign = rsa_sign(_priv("alipay_platform"), raw)
|
||||
return 200, "application/json; charset=utf-8", ('{"%s":%s,"sign":"%s"}' % (key, raw, sign)).encode()
|
||||
|
||||
|
||||
def ali_gateway(raw):
|
||||
from channels import rsa_verify
|
||||
form = dict(urllib.parse.parse_qsl(raw.decode("utf-8"), keep_blank_values=True))
|
||||
sign = form.pop("sign", "")
|
||||
content = "&".join("%s=%s" % (k, form[k]) for k in sorted(form))
|
||||
method = form.get("method", "")
|
||||
if not rsa_verify(_pub("alipay_app"), content, sign):
|
||||
return _ali_resp(method, {"code": "40002", "msg": "Invalid Arguments", "sub_code": "isv.invalid-signature"})
|
||||
biz = json.loads(form.get("biz_content") or "{}")
|
||||
otn = biz.get("out_trade_no", "")
|
||||
t = core.q1("SELECT * FROM mock_ali WHERE out_trade_no=?", (otn,))
|
||||
if t and t["status"] in ("NEW", "WAIT_BUYER_PAY") and core.now() > t["expire_ts"]:
|
||||
core.x("UPDATE mock_ali SET status='TRADE_CLOSED' WHERE out_trade_no=?", (otn,))
|
||||
t["status"] = "TRADE_CLOSED"
|
||||
if method == "alipay.trade.precreate":
|
||||
if core.kv_get("mock_alipay_risk"):
|
||||
return _ali_resp(method, {"code": "40004", "msg": "Business Failed", "sub_code": "ACQ.ACCESS_FORBIDDEN",
|
||||
"sub_msg": "(模拟)商户收款功能被限制"})
|
||||
if t:
|
||||
return _ali_resp(method, {"code": "10000", "msg": "Success", "out_trade_no": otn,
|
||||
"qr_code": C.BASE_URL + "/mock/alipay/scan/" + t["qr"]})
|
||||
from datetime import datetime
|
||||
from channels import CST
|
||||
exp = datetime.strptime(biz["time_expire"], "%Y-%m-%d %H:%M:%S").replace(tzinfo=CST).timestamp()
|
||||
qr = secrets.token_urlsafe(10)
|
||||
core.x("INSERT INTO mock_ali(out_trade_no,total_amount,subject,status,notify_url,expire_ts,qr,created) "
|
||||
"VALUES(?,?,?,?,?,?,?,?)", (otn, biz["total_amount"], biz.get("subject", ""), "NEW",
|
||||
form.get("notify_url", ""), exp, qr, core.now()))
|
||||
return _ali_resp(method, {"code": "10000", "msg": "Success", "out_trade_no": otn,
|
||||
"qr_code": C.BASE_URL + "/mock/alipay/scan/" + qr})
|
||||
if method == "alipay.trade.query":
|
||||
if not t or t["status"] == "NEW":
|
||||
return _ali_resp(method, {"code": "40004", "msg": "Business Failed", "sub_code": "ACQ.TRADE_NOT_EXIST",
|
||||
"sub_msg": "交易不存在"})
|
||||
return _ali_resp(method, {"code": "10000", "msg": "Success", "out_trade_no": otn,
|
||||
"trade_no": t["trade_no"] or "", "trade_status": t["status"],
|
||||
"total_amount": t["total_amount"]})
|
||||
if method == "alipay.trade.close":
|
||||
if not t or t["status"] == "NEW":
|
||||
if t:
|
||||
core.x("UPDATE mock_ali SET status='TRADE_CLOSED' WHERE out_trade_no=?", (otn,))
|
||||
return _ali_resp(method, {"code": "40004", "msg": "Business Failed", "sub_code": "ACQ.TRADE_NOT_EXIST"})
|
||||
if t["status"] == "WAIT_BUYER_PAY":
|
||||
core.x("UPDATE mock_ali SET status='TRADE_CLOSED' WHERE out_trade_no=?", (otn,))
|
||||
return _ali_resp(method, {"code": "10000", "msg": "Success", "out_trade_no": otn})
|
||||
return _ali_resp(method, {"code": "40004", "msg": "Business Failed", "sub_code": "ACQ.TRADE_STATUS_ERROR"})
|
||||
if method == "alipay.trade.refund":
|
||||
if not t or t["status"] not in ("TRADE_SUCCESS",):
|
||||
return _ali_resp(method, {"code": "40004", "msg": "Business Failed", "sub_code": "ACQ.TRADE_STATUS_ERROR"})
|
||||
core.x("UPDATE mock_ali SET refunded=? WHERE out_trade_no=?", (biz.get("refund_amount"), otn))
|
||||
return _ali_resp(method, {"code": "10000", "msg": "Success", "out_trade_no": otn, "trade_no": t["trade_no"],
|
||||
"refund_fee": biz.get("refund_amount"), "fund_change": "Y"})
|
||||
return _ali_resp(method, {"code": "40004", "msg": "Business Failed", "sub_code": "ACQ.METHOD_NOT_SUPPORTED"})
|
||||
|
||||
|
||||
def ali_scan(qr):
|
||||
t = core.q1("SELECT * FROM mock_ali WHERE qr=?", (qr,))
|
||||
if not t:
|
||||
return 404, "text/plain; charset=utf-8", "二维码无效".encode()
|
||||
if t["status"] in ("NEW", "WAIT_BUYER_PAY") and core.now() > t["expire_ts"]:
|
||||
core.x("UPDATE mock_ali SET status='TRADE_CLOSED' WHERE qr=?", (qr,))
|
||||
t["status"] = "TRADE_CLOSED"
|
||||
if t["status"] == "NEW":
|
||||
core.x("UPDATE mock_ali SET status='WAIT_BUYER_PAY' WHERE qr=?", (qr,))
|
||||
t["status"] = "WAIT_BUYER_PAY"
|
||||
if t["status"] != "WAIT_BUYER_PAY":
|
||||
msg = {"TRADE_SUCCESS": "这笔已经付过了", "TRADE_CLOSED": "二维码已失效,请回到订单页重新生成"}.get(t["status"], t["status"])
|
||||
body = '<div class="top" style="background:#1677ff">支付宝(模拟)</div><div class="box"><div class="amt" style="font-size:22px">%s</div></div>' % msg
|
||||
return 200, "text/html; charset=utf-8", page("支付宝", body)
|
||||
body = """<div class="top" style="background:#1677ff">支付宝(模拟扫码付款)</div>
|
||||
<div class="box"><div class="mute">%s</div><div class="amt">¥%s</div>
|
||||
<form method="post" action="../scanpay"><input type="hidden" name="qr" value="%s">
|
||||
<label><input type="checkbox" name="drop"> 模拟异步通知丢失(靠页面轮询 / 补查发现)</label>
|
||||
<button style="background:#1677ff">确认付款</button></form>
|
||||
<div class="warn">这是原型里的模拟页面,不会真的扣钱。</div></div>""" % (
|
||||
html.escape(t["subject"]), html.escape(t["total_amount"]), html.escape(qr))
|
||||
return 200, "text/html; charset=utf-8", page("支付宝 · 模拟扫码", body)
|
||||
|
||||
|
||||
def ali_scanpay(form):
|
||||
from channels import rsa_sign, fmt_cst
|
||||
g = lambda k: (form.get(k) or [""])[0]
|
||||
t = core.q1("SELECT * FROM mock_ali WHERE qr=?", (g("qr"),))
|
||||
if not t or t["status"] != "WAIT_BUYER_PAY" or core.now() > t["expire_ts"]:
|
||||
return 200, "text/html; charset=utf-8", page("支付宝", '<div class="box">二维码已失效</div>')
|
||||
tn = _trade_no()
|
||||
core.x("UPDATE mock_ali SET status='TRADE_SUCCESS',trade_no=?,paid_at=? WHERE qr=?", (tn, core.now(), g("qr")))
|
||||
core.event("mock-alipay", "mock_paid", t["out_trade_no"], "", "drop_notify" if g("drop") else "notify_soon",
|
||||
{"trade_no": tn, "amount": t["total_amount"]})
|
||||
if not g("drop") and t["notify_url"]:
|
||||
p = {"notify_time": fmt_cst(core.now()), "notify_type": "trade_status_sync", "notify_id": secrets.token_hex(8),
|
||||
"app_id": "mock-app", "charset": "utf-8", "version": "1.0", "trade_no": tn,
|
||||
"out_trade_no": t["out_trade_no"], "trade_status": "TRADE_SUCCESS", "total_amount": t["total_amount"],
|
||||
"receipt_amount": t["total_amount"], "buyer_pay_amount": t["total_amount"], "subject": t["subject"],
|
||||
"gmt_payment": fmt_cst(core.now())}
|
||||
p["sign"] = rsa_sign(_priv("alipay_platform"), "&".join("%s=%s" % (k, p[k]) for k in sorted(p)))
|
||||
p["sign_type"] = "RSA2"
|
||||
url = C.INTERNAL_URL + "/api/notify/alipay"
|
||||
_later(lambda: _post(url, urllib.parse.urlencode(p).encode(), "application/x-www-form-urlencoded"))
|
||||
body = """<div class="top" style="background:#1677ff">支付宝(模拟)</div><div class="box">
|
||||
<div class="amt">支付成功</div><div class="mute">¥%s · 交易号 <code>%s</code>%s</div>
|
||||
<p class="mute">回到电脑上的订单页,它会自动变成「已到账」。</p>
|
||||
<p><a href="%s/pay.html?o=%s">在这台设备看订单</a></p></div>""" % (
|
||||
t["total_amount"], tn, "<br><b>已模拟异步通知丢失</b>" if g("drop") else "",
|
||||
C.SITE_URL, urllib.parse.quote(t["out_trade_no"].rsplit("P", 1)[0]))
|
||||
return 200, "text/html; charset=utf-8", page("支付成功", body)
|
||||
|
||||
|
||||
def _json(obj):
|
||||
return 200, "application/json; charset=utf-8", json.dumps(obj, ensure_ascii=False).encode()
|
||||
@@ -0,0 +1,183 @@
|
||||
/* 自助渲染 · 下单与收银台(预览)—— 只放新组件,站点通用样式仍在 site.css */
|
||||
|
||||
/* ---------- 下单表单 ---------- */
|
||||
.buy-step{margin-top:26px}
|
||||
.buy-step>h3{margin:0 0 4px;font-size:18px}
|
||||
.buy-step>p{margin:0 0 14px;font-size:14px;color:var(--ink-3)}
|
||||
.tpl-grid .tpl{cursor:pointer;text-align:left;font:inherit;color:inherit;border:2px solid rgba(255,255,255,.95);transition:border-color .15s var(--ease),box-shadow .15s var(--ease)}
|
||||
.tpl .pick{position:absolute;top:18px;right:18px;width:24px;height:24px;border-radius:4px;background:rgba(255,255,255,.92);border:2px solid rgba(30,36,64,.18);display:grid;place-items:center;color:#fff;font-size:15px;font-weight:700;line-height:1}
|
||||
.tpl[aria-pressed=true]{border-color:var(--mc-green)!important;box-shadow:0 0 0 3px rgba(91,170,60,.22),0 18px 30px -22px rgba(29,77,19,.45)!important}
|
||||
.tpl[aria-pressed=true] .pick{background:var(--mc-green);border-color:var(--mc-green-lo)}
|
||||
.tpl:focus-visible{outline:3px solid var(--mc-green-hi);outline-offset:2px}
|
||||
|
||||
.skin{display:grid;grid-template-columns:132px minmax(0,1fr);gap:18px;align-items:start;padding:18px;border-radius:var(--r)}
|
||||
@media (max-width:560px){.skin{grid-template-columns:1fr}}
|
||||
.skin-drop{position:relative;display:grid;place-items:center;aspect-ratio:1/1;border-radius:12px;border:2px dashed rgba(140,150,200,.45);background:rgba(255,255,255,.7);cursor:pointer;text-align:center;font-size:13px;color:var(--ink-3);padding:8px;overflow:hidden}
|
||||
.skin-drop:hover{border-color:var(--mc-green-hi)}
|
||||
.skin-drop canvas{width:100%;height:100%;image-rendering:pixelated;display:block}
|
||||
.skin-drop input{position:absolute;inset:0;opacity:0;cursor:pointer}
|
||||
.skin-rep{display:flex;flex-direction:column;gap:8px}
|
||||
.lamp{display:flex;gap:10px;align-items:flex-start;padding:9px 12px;border-radius:10px;font-size:13.5px;color:var(--ink-2);background:rgba(255,255,255,.6)}
|
||||
.lamp::before{content:"";flex:none;width:8px;height:8px;margin-top:7px;border-radius:2px;background:#3CC985}
|
||||
.lamp.warn{background:rgba(245,178,62,.055)} .lamp.warn::before{background:#F5B23E}
|
||||
.lamp.bad{background:rgba(224,83,61,.055)} .lamp.bad::before{background:#E0533D}
|
||||
.lamp b{color:var(--ink)}
|
||||
.lamp label{display:flex;gap:6px;align-items:center;margin-top:4px;cursor:pointer}
|
||||
|
||||
.sumbar{position:sticky;bottom:12px;z-index:4;margin-top:26px;display:flex;flex-wrap:wrap;align-items:center;gap:12px 18px;padding:14px 18px;border-radius:var(--r);background:rgba(255,255,255,.96)!important;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
|
||||
.sumbar .sum{display:flex;flex-direction:column;gap:2px;min-width:0}
|
||||
.sumbar .sum b{font-size:24px;font-variant-numeric:tabular-nums}
|
||||
.sumbar .sum span{font-size:13px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.sumbar .sp{flex:1}
|
||||
.sumbar .btn{min-width:150px}
|
||||
.sumbar .why{font-size:13px;color:#B4412F}
|
||||
|
||||
/* ---------- 我的订单(这台浏览器里下过的单) ---------- */
|
||||
.mine{display:flex;flex-direction:column;gap:10px}
|
||||
.mine a.mrow{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:6px 16px;align-items:center;padding:14px 18px;border-radius:var(--r-sm);text-decoration:none;color:inherit}
|
||||
.mine a.mrow:hover{border-color:var(--mc-green-hi)}
|
||||
.mrow .code{font-weight:700;letter-spacing:.05em;font-variant-numeric:tabular-nums}
|
||||
.mrow .what{font-size:13.5px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.lookup{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-top:14px}
|
||||
.lookup input{height:44px;padding:0 14px;border-radius:4px;border:2px solid var(--stone-edge,#C9CED8);background:#fff;font:inherit;font-size:15px;min-width:0;flex:1 1 160px;letter-spacing:.04em;text-transform:uppercase}
|
||||
.lookup input:focus{outline:none;border-color:var(--mc-green)}
|
||||
|
||||
/* ---------- 状态 ---------- */
|
||||
.state.unpaid{background:#FFF4D9;color:#8A5A00}
|
||||
.state.waiting,.state.working{background:#E5F3DF;color:#2E6A1D}
|
||||
.state.done{background:#E5F3DF;color:#2E6A1D}
|
||||
.state.closed,.state.void,.state.failed{background:#FBE8E4;color:#A33A2A}
|
||||
|
||||
/* ---------- 收银台 ---------- */
|
||||
.pay .amt{font-size:34px;font-weight:700;font-variant-numeric:tabular-nums;line-height:1.1}
|
||||
.pay .items{display:flex;flex-wrap:wrap;gap:6px}
|
||||
.pay .items .chip{height:26px}
|
||||
.chs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
|
||||
@media (max-width:560px){.chs{grid-template-columns:1fr}}
|
||||
.chx{position:relative;display:flex;flex-direction:column;gap:4px;padding:14px 16px;border-radius:var(--r-sm);cursor:pointer;text-align:left;font:inherit;color:inherit;border:2px solid rgba(255,255,255,.95)}
|
||||
.chx b{font-size:16px;display:flex;align-items:center;gap:8px}
|
||||
.chx b i{width:22px;height:22px;border-radius:5px;display:grid;place-items:center;color:#fff;font-style:normal;font-size:12px;font-weight:700}
|
||||
.chx.afd b i{background:#946CE6} .chx.ali b i{background:#1677FF}
|
||||
.chx span{font-size:13px;color:var(--ink-3)}
|
||||
.chx .rec{position:absolute;top:12px;right:12px;font-size:11.5px;font-weight:700;color:#2E6A1D;background:#E5F3DF;padding:1px 8px;border-radius:4px}
|
||||
.chx[aria-pressed=true]{border-color:var(--mc-green)!important;box-shadow:0 0 0 3px rgba(91,170,60,.2)!important}
|
||||
.chx:disabled{cursor:not-allowed;opacity:.55}
|
||||
.chx .why{color:#A33A2A}
|
||||
.qrbox{display:grid;grid-template-columns:184px minmax(0,1fr);gap:20px;align-items:start;padding-top:16px;border-top:1px dashed rgba(140,150,200,.35)}
|
||||
@media (max-width:560px){.qrbox{grid-template-columns:1fr;justify-items:start}}
|
||||
.qr{width:184px;height:184px;padding:10px;border-radius:12px;background:#fff;box-shadow:inset 0 0 0 1px rgba(30,36,64,.08),0 12px 24px -18px rgba(30,36,64,.4)}
|
||||
.qr svg{display:block;width:100%;height:100%}
|
||||
.qrbox h4{margin:0 0 6px;font-size:16px}
|
||||
.qrbox p{margin:0 0 10px;font-size:13.5px;color:var(--ink-3);line-height:1.7}
|
||||
.cd{display:flex;align-items:baseline;gap:8px;margin:4px 0 12px;font-size:13px;color:var(--ink-3)}
|
||||
.cd b{font:700 26px/1 var(--pixel,inherit);color:var(--ink);font-variant-numeric:tabular-nums}
|
||||
.cd.low b{color:#C2410C}
|
||||
.waitline{display:flex;align-items:center;gap:8px;font-size:13.5px;color:var(--ink-2)}
|
||||
.waitline::before{content:"";width:8px;height:8px;border-radius:2px;background:var(--mc-green-hi);animation:blink 1.2s steps(2) infinite}
|
||||
@keyframes blink{50%{opacity:.25}}
|
||||
.paid-hero{display:flex;gap:16px;align-items:center}
|
||||
.paid-hero .ok{flex:none;width:52px;height:52px;border-radius:6px;display:grid;place-items:center;font-size:28px;color:#fff;background:var(--mc-green);box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -4px 0 var(--mc-green-lo)}
|
||||
.paid-hero b{font-size:20px}
|
||||
.paid-hero p{margin:2px 0 0;font-size:14px;color:var(--ink-3)}
|
||||
.pmsg{font-size:13.5px;padding:10px 14px;border-radius:10px;background:rgba(255,255,255,.7);color:var(--ink-2)}
|
||||
.pmsg.bad{background:rgba(224,83,61,.07);color:#A33A2A}
|
||||
.plog{width:100%;border-collapse:collapse;font-size:13px}
|
||||
.plog td{padding:7px 4px;border-top:1px solid var(--line);color:var(--ink-2)}
|
||||
.plog code{font-size:12px}
|
||||
.pass .stub .code{font-size:20px;word-break:break-all}
|
||||
|
||||
#tpl,#pass{scroll-margin-top:76px}
|
||||
.sum-h,.sum-list,.sum-note{display:none}
|
||||
|
||||
/* 平板(761–1023px):模板每行 4 张,两行排齐 */
|
||||
@media (min-width:761px) and (max-width:1023px){#tplGrid.tpl-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
|
||||
|
||||
/* ================= 电脑(≥1024px):左边表单,右边跟随滚动的「你的订单」 ================= */
|
||||
@media (min-width:1024px){
|
||||
.buy{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:28px;align-items:start;margin-top:26px}
|
||||
.buy-form>.buy-step:first-child{margin-top:0}
|
||||
#tplGrid.tpl-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
|
||||
#tplGrid .tpl .sw{height:64px}
|
||||
.skin{grid-template-columns:120px minmax(0,1fr)}
|
||||
.sumbar{position:sticky;top:92px;bottom:auto;margin-top:0;flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:12px;padding:20px 20px 18px}
|
||||
.sumbar .sum{gap:10px}
|
||||
.sum-h{display:block;font-size:13px;font-weight:700;letter-spacing:.12em;color:var(--ink-3)}
|
||||
.sum-list{display:flex;flex-direction:column;list-style:none;margin:0;padding:0;font-size:14px}
|
||||
.sum-list li{display:flex;justify-content:space-between;gap:10px;padding:7px 0;border-top:1px solid var(--line)}
|
||||
.sum-list li:first-child{border-top:0}
|
||||
.sum-list li.meta{color:var(--ink-3);font-size:13px}
|
||||
.sum-list li.meta:first-of-type{border-top:1px dashed rgba(140,150,200,.4);margin-top:4px}
|
||||
.sumbar .sum b{font-size:30px;padding-top:10px;border-top:2px solid var(--line)}
|
||||
.sumbar .sum span#sumTxt{display:none}
|
||||
.sumbar .sp{display:none}
|
||||
.sumbar .why{min-height:0}
|
||||
.sumbar .why:empty{display:none}
|
||||
.sumbar .btn{width:100%;min-width:0;height:50px;font-size:15.5px}
|
||||
.sum-note{display:block;margin:0;font-size:12.5px;line-height:1.7;color:var(--ink-3)}
|
||||
}
|
||||
.qrfold{margin-top:14px}
|
||||
.qrfold summary{cursor:pointer;font-size:13.5px;color:var(--ink-2);list-style:none;display:inline-flex;align-items:center;gap:6px}
|
||||
.qrfold summary::-webkit-details-marker{display:none}
|
||||
.qrfold summary::before{content:"▸";font-size:11px;transition:transform .15s}
|
||||
.qrfold[open] summary::before{transform:rotate(90deg)}
|
||||
.qrfold .qr{margin-top:10px}
|
||||
.btn-wide{width:100%}
|
||||
|
||||
/* ================= 手机(≤760px) ================= */
|
||||
@media (max-width:760px){
|
||||
/* 模板:两列网格,全部 7 个一眼看完(不再横向滑) */
|
||||
#tplGrid.tpl-grid{grid-auto-flow:row;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-columns:auto;overflow:visible;margin:0;padding:0;gap:10px;scroll-snap-type:none}
|
||||
#tplGrid .tpl{padding:10px;gap:3px}
|
||||
#tplGrid .tpl .sw{height:46px}
|
||||
#tplGrid .tpl b{font-size:14px;line-height:1.35}
|
||||
#tplGrid .tpl span{font-size:12px;line-height:1.5}
|
||||
#tplGrid .tpl .pick{top:15px;right:15px;width:22px;height:22px;font-size:13px}
|
||||
/* 分辨率:2×2 方格,档位和时间各占一行 */
|
||||
#resSeg.seg{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;width:100%;padding:6px}
|
||||
#resSeg.seg button{height:auto;min-height:52px;padding:6px 8px 8px;line-height:1.3;display:flex;flex-direction:column;align-items:center;justify-content:center}
|
||||
#resSeg.seg button em{display:block;margin:2px 0 0;font-size:12px}
|
||||
/* 皮肤:预览缩小放左边,质检结果在右边 */
|
||||
.skin{grid-template-columns:96px minmax(0,1fr);gap:12px;padding:12px}
|
||||
.skin-drop{font-size:11.5px;border-radius:10px}
|
||||
.lamp{font-size:12.5px;padding:7px 9px;gap:7px}
|
||||
.lamp::before{margin-top:6px}
|
||||
/* 吸底条:一行,金额在左、按钮在右;挡不住的原因写进说明行 */
|
||||
.sumbar{flex-wrap:nowrap;gap:10px;padding:10px 12px;margin-top:20px;bottom:calc(86px + env(safe-area-inset-bottom,0px))}
|
||||
.sumbar .sum{flex:1;min-width:0}
|
||||
.sumbar .sum b{font-size:20px;line-height:1.2}
|
||||
.sumbar .sum span{font-size:12px}
|
||||
.sumbar .sp,.sumbar .why{display:none}
|
||||
.sumbar .sum span.blocked{color:#B4412F}
|
||||
.sumbar .btn{min-width:0;flex:none;height:44px;padding:0 16px 3px}
|
||||
/* 查单:上下排,按钮整行 */
|
||||
.lookup input{flex-basis:100%}
|
||||
.lookup .btn{width:100%}
|
||||
.mine a.mrow{grid-template-columns:minmax(0,1fr) auto;padding:12px 14px}
|
||||
.mine a.mrow .what{grid-column:1/-1;grid-row:2}
|
||||
/* 收银台 */
|
||||
.pay .amt{font-size:30px}
|
||||
.qrbox{grid-template-columns:1fr;gap:6px}
|
||||
.chx{padding:12px 14px}
|
||||
.chx .rec{top:10px;right:10px}
|
||||
.pass .main{padding:20px 18px}
|
||||
.pass .stub{padding:20px 18px}
|
||||
}
|
||||
|
||||
/* ---------- 演示控制台(只在预览站) ---------- */
|
||||
.demo-fab{margin-left:4px;height:24px;padding:0 9px;border-radius:4px;border:1.5px solid #8A5A00;background:#FFF4D9;color:#8A5A00;font:700 12px/1 inherit;cursor:pointer;vertical-align:middle}
|
||||
.demo-fab[aria-expanded=true]{background:#8A5A00;color:#FFF4D9}
|
||||
.demo{position:fixed;right:16px;top:calc(46px + env(safe-area-inset-top,0px));z-index:31;width:min(380px,calc(100vw - 32px));max-height:min(70vh,640px);overflow:auto;padding:16px;border-radius:var(--r);background:rgba(255,255,255,.97);box-shadow:0 30px 60px -30px rgba(30,36,64,.55),inset 0 0 0 1px rgba(30,36,64,.08)}
|
||||
.demo h4{margin:0 0 2px;font-size:15px}
|
||||
.demo .mut{font-size:12.5px;color:var(--ink-3)}
|
||||
.demo .grp{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0 12px}
|
||||
.demo button.d{height:32px;padding:0 10px;border-radius:4px;border:2px solid var(--stone-edge,#C9CED8);background:#fff;font:600 12.5px/1 inherit;color:var(--ink);cursor:pointer}
|
||||
.demo button.d:hover{border-color:var(--mc-green)}
|
||||
.demo .clock{font:700 15px/1.4 ui-monospace,Menlo,Consolas,monospace}
|
||||
.demo .out{font-size:12.5px;padding:8px 10px;border-radius:8px;background:#F4F6FB;color:var(--ink-2);margin-bottom:10px}
|
||||
.demo ul{list-style:none;margin:0;padding:0;font-size:12.5px}
|
||||
.demo li{display:grid;grid-template-columns:56px 1fr;gap:6px;padding:5px 0;border-top:1px solid var(--line)}
|
||||
.demo li time{font-family:ui-monospace,Menlo,Consolas,monospace;color:var(--ink-3);font-size:11.5px}
|
||||
.demo li .c{font-size:11px;font-weight:700;margin-right:4px}
|
||||
.demo li .c.afdian{color:#7A55D8} .demo li .c.alipay{color:#1677FF}
|
||||
|
||||
@media (prefers-reduced-motion:reduce){.waitline::before{animation:none}}
|
||||
@@ -0,0 +1,118 @@
|
||||
/* 自助渲染 · 下单与收银台共用(预览站)
|
||||
- 接口:/svc/api/*(预览机上的收款服务,全模拟渠道)
|
||||
- 本机订单:照独角数卡「浏览器缓存查单」—— 这台浏览器下过的单记在 localStorage,换设备用「订单号 + 取件码」查
|
||||
- 演示控制台:快进时钟 / 立即跑定时任务 / 模拟风控等,只在预览站有 */
|
||||
(function () {
|
||||
'use strict';
|
||||
var API = 'svc/api';
|
||||
var KEY = 'jz_orders_v1';
|
||||
var TPLS = [
|
||||
{k: 'stand', n: '站立正反', s: '正面站着,背景干净', c: '#8a8f98'},
|
||||
{k: 'standb', n: '站立正反(虚化)', s: '同上,背景虚化', c: '#6f7680'},
|
||||
{k: 'wheat', n: '麦田萤火', s: '麦田、暖光、萤火虫', c: '#a8863a'},
|
||||
{k: 'beach', n: '海边自拍', s: '海边,天光', c: '#4a7fa5'},
|
||||
{k: 'boom', n: '不看爆炸', s: '身后爆炸,头也不回', c: '#a2563f'},
|
||||
{k: 'sakura', n: '飞跃樱花林', s: '樱花林,动态', c: '#b07a92'},
|
||||
{k: 'airship', n: '空艇巡游', s: '坐飞空艇巡航', c: '#5e7f8f'}
|
||||
];
|
||||
var STATE = {unpaid: '待付款', waiting: '已付款 · 排队中', working: '渲染中', done: '已完成', failed: '渲染失败',
|
||||
closed: '已关闭', void: '已注销'};
|
||||
|
||||
function api(method, path, body) {
|
||||
return fetch(API + path, {method: method, cache: 'no-store',
|
||||
headers: body ? {'Content-Type': 'application/json'} : {}, body: body ? JSON.stringify(body) : undefined})
|
||||
.then(function (r) { return r.json().catch(function () { return {ok: false, error: '服务器没回应'}; }); })
|
||||
.catch(function () { return {ok: false, error: '网络不通,稍后再试'}; });
|
||||
}
|
||||
function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
|
||||
return {'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[c]; }); }
|
||||
function left(sec) {
|
||||
sec = Math.max(0, Math.round(sec));
|
||||
var h = Math.floor(sec / 3600), m = Math.floor(sec % 3600 / 60), s = sec % 60;
|
||||
return h ? (h + ' 小时 ' + m + ' 分') : ((m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s);
|
||||
}
|
||||
function hm(ts) { return new Date(ts * 1000).toLocaleTimeString('zh-CN', {hour12: false, timeZone: 'Asia/Shanghai'}); }
|
||||
function full(ts) { return new Date(ts * 1000).toLocaleString('zh-CN', {hour12: false, timeZone: 'Asia/Shanghai'}); }
|
||||
function qrSvg(text) {
|
||||
try { var q = qrcode(0, 'M'); q.addData(text); q.make(); return q.createSvgTag({cellSize: 4, margin: 0, scalable: true}); }
|
||||
catch (e) { return ''; }
|
||||
}
|
||||
function orders() { try { return JSON.parse(localStorage.getItem(KEY) || '[]') || []; } catch (e) { return []; } }
|
||||
function saveOrder(o) {
|
||||
try {
|
||||
var l = orders().filter(function (x) { return x.oid !== o.oid; });
|
||||
l.unshift(o); localStorage.setItem(KEY, JSON.stringify(l.slice(0, 30)));
|
||||
} catch (e) {}
|
||||
}
|
||||
function tokenOf(oid) { var o = orders().filter(function (x) { return x.oid === oid; })[0]; return o ? o.t : ''; }
|
||||
|
||||
/* ---------------- 演示控制台 ---------------- */
|
||||
var KIND = {order_created: '下单', payment_created: '建支付单', notify: '收到回调', settle: '到账处理', close: '关单',
|
||||
payment_expired: '支付单过期', order_closed: '订单超时关闭', buyer_check: '买家点「付好了没反应」', todo: '进待办',
|
||||
mock_paid: '(模拟)买家付款', card_purchase: '按买卡密处理', breaker_open: '支付宝熔断', create_failed: '生成付款失败',
|
||||
query_failed: '查单失败', todo_resolved: '待办已处理'};
|
||||
var RES = {activated: '激活订单', reopened: '恢复并激活', dup_trade: '重复,忽略', short: '金额不足', duplicate: '重复付款',
|
||||
late: '迟到付款', ok: '验证通过', webhook_soon: '稍后推送回调', drop_webhook: '回调丢失(模拟)',
|
||||
notify_soon: '稍后推送通知', drop_notify: '通知丢失(模拟)', '验签失败': '验签失败,丢弃'};
|
||||
var CH = {afdian: '爱发电', alipay: '支付宝', 'mock-afdian': '爱发电', 'mock-alipay': '支付宝'};
|
||||
var demo = {view: null, onChange: null};
|
||||
|
||||
function demoUI() {
|
||||
var fab = document.createElement('button');
|
||||
fab.className = 'demo-fab'; fab.type = 'button'; fab.textContent = '演示控制台';
|
||||
fab.setAttribute('aria-expanded', 'false');
|
||||
var box = document.createElement('div'); box.className = 'demo'; box.hidden = true;
|
||||
box.innerHTML = '<h4>演示控制台</h4><div class="mut">只在预览站有:付款全部走模拟的爱发电 / 支付宝,不会扣钱。</div>'
|
||||
+ '<div class="mut" style="margin-top:10px">演示时钟(快进用来看超时关单)</div><div class="clock" id="dClock">—</div>'
|
||||
+ '<div class="grp"><button class="d" data-ff="900">快进 15 分钟</button><button class="d" data-ff="7200">快进 2 小时</button>'
|
||||
+ '<button class="d" data-ff="86400">快进 1 天</button><button class="d" data-k="jobs">立即跑一轮定时任务</button></div>'
|
||||
+ '<div class="mut">场景</div><div class="grp">'
|
||||
+ '<button class="d" data-k="risk_on">支付宝被风控</button><button class="d" data-k="risk_off">恢复支付宝</button>'
|
||||
+ '<button class="d" data-k="direct">有人直接在爱发电店铺下单</button><button class="d" data-k="forge">伪造一条爱发电回调</button>'
|
||||
+ '<a class="d" href="cms/pay.html" style="display:inline-flex;align-items:center;height:32px;padding:0 10px;border-radius:4px;border:2px solid #C9CED8;font:600 12.5px/1 inherit;color:inherit;text-decoration:none">打开收款后台</a></div>'
|
||||
+ '<div class="out" id="dOut" hidden></div><div class="mut">这张单的流水(新的在上)</div><ul id="dEv"><li><span></span><span class="mut">还没有</span></li></ul>';
|
||||
document.body.appendChild(box);
|
||||
var rib = document.querySelector('.ribbon'); /* 放进顶部「设计预览版」横幅,不压页面内容 */
|
||||
if (rib) rib.appendChild(fab); else { fab.style.cssText = 'position:fixed;right:16px;top:16px;z-index:30'; document.body.appendChild(fab); }
|
||||
fab.onclick = function () { box.hidden = !box.hidden; fab.setAttribute('aria-expanded', String(!box.hidden)); };
|
||||
function out(t) { var o = document.getElementById('dOut'); o.hidden = false; o.textContent = t; }
|
||||
function run(body, msg) {
|
||||
out('执行中…');
|
||||
return api('POST', '/demo', body).then(function (j) {
|
||||
var jobs = j.jobs ? ' 定时任务:' + Object.keys(j.jobs).map(function (k) { return k + ' ' + j.jobs[k]; }).join(',') : '';
|
||||
out((j.ok ? (msg || '完成。') : ('没成功:' + (j.error || ''))) + jobs);
|
||||
if (demo.onChange) demo.onChange();
|
||||
});
|
||||
}
|
||||
[].forEach.call(box.querySelectorAll('[data-ff]'), function (b) {
|
||||
b.onclick = function () { run({kind: 'clock', seconds: +b.dataset.ff}, '时钟已快进,并跑了一轮定时任务。'); };
|
||||
});
|
||||
box.querySelector('[data-k=jobs]').onclick = function () { run({kind: 'jobs'}, '已跑一轮。'); };
|
||||
box.querySelector('[data-k=risk_on]').onclick = function () {
|
||||
run({kind: 'alipay_risk', on: true}, '支付宝网关会返回风控错误码:现在点「支付宝扫码」会触发熔断,这个选项随即变灰。'); };
|
||||
box.querySelector('[data-k=risk_off]').onclick = function () {
|
||||
api('POST', '/demo', {kind: 'alipay_risk', on: false}).then(function () { run({kind: 'breaker_reset'}, '风控已解除,支付宝恢复可用。'); }); };
|
||||
box.querySelector('[data-k=direct]').onclick = function () {
|
||||
run({kind: 'afdian_direct', amount: 12}, '模拟了一笔没带订单号的爱发电成交:系统按「买卡密」处理,不去猜是哪张单;后台可以按爱发电订单号认领。'); };
|
||||
box.querySelector('[data-k=forge]').onclick = function () {
|
||||
var p = demo.view && demo.view.payments.filter(function (x) { return x.channel === 'afdian' && x.state === 'created'; })[0];
|
||||
if (!p) { out('先在收银台选「爱发电」生成一张支付单,再伪造它的回调。'); return; }
|
||||
run({kind: 'afdian_forge', pay_id: p.pay_id}, '发出了一条签名不对、金额 ¥999 的回调。看流水:验签失败,被丢弃。');
|
||||
};
|
||||
}
|
||||
function demoUpdate(v) {
|
||||
demo.view = v;
|
||||
var c = document.getElementById('dClock'); if (c && v) c.textContent = full(v.now);
|
||||
var ul = document.getElementById('dEv'); if (!ul || !v) return;
|
||||
ul.innerHTML = (v.events || []).map(function (e) {
|
||||
var r = RES.hasOwnProperty(e.result) ? RES[e.result] : e.result;
|
||||
return '<li><time>' + hm(e.ts) + '</time><span>' + (e.channel ? '<span class="c ' + esc(String(e.channel).replace('mock-', '')) + '">'
|
||||
+ esc(CH[e.channel] || e.channel) + '</span>' : '') + esc(KIND[e.kind] || e.kind)
|
||||
+ (r && r !== 'created' && r !== 'unpaid' && r !== 'closed' ? ' · <span class="mut">' + esc(r) + '</span>' : '') + '</span></li>';
|
||||
}).join('') || '<li><span></span><span class="mut">还没有</span></li>';
|
||||
}
|
||||
|
||||
window.JZPay = {api: api, esc: esc, left: left, full: full, qrSvg: qrSvg, orders: orders, saveOrder: saveOrder,
|
||||
tokenOf: tokenOf, TPLS: TPLS, STATE: STATE, demo: demo, demoUpdate: demoUpdate};
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', demoUI); else demoUI();
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,129 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<title>收款后台 · 金钻客栈(设计预览)</title>
|
||||
<link rel="stylesheet" href="../assets/site.css?v=33">
|
||||
<link rel="stylesheet" href="../assets/pay.css?v=2">
|
||||
<style>
|
||||
.adm{padding:18px 20px;border-radius:var(--r);margin-top:16px}
|
||||
.adm h2{margin:0 0 4px;font-size:18px}
|
||||
.adm>p{margin:0 0 12px;font-size:13.5px;color:var(--ink-3)}
|
||||
.tw{overflow-x:auto}
|
||||
.tb{border-collapse:collapse;width:100%;font-size:13px;min-width:640px}
|
||||
.tb th,.tb td{text-align:left;padding:8px 8px;border-top:1px solid var(--line);vertical-align:top}
|
||||
.tb th{color:var(--ink-3);font-weight:700;border-top:0;white-space:nowrap}
|
||||
.tb td{font-variant-numeric:tabular-nums}
|
||||
.tb code{font-size:12px;word-break:break-all}
|
||||
.tb tr.done td{opacity:.5}
|
||||
.tb .btn{height:30px;padding:0 10px 2px;font-size:12.5px}
|
||||
.kd{display:inline-block;font-size:12px;font-weight:700;padding:1px 8px;border-radius:4px;white-space:nowrap}
|
||||
.kd.short,.kd.late{background:#FFF4D9;color:#8A5A00}.kd.duplicate,.kd.unknown{background:#FBE8E4;color:#A33A2A}
|
||||
.st{font-size:12px;font-weight:700;padding:1px 8px;border-radius:4px;background:#EEF1F8;white-space:nowrap}
|
||||
.st.paid,.st.waiting{background:#E5F3DF;color:#2E6A1D}.st.closed,.st.mismatch,.st.void{background:#FBE8E4;color:#A33A2A}.st.unpaid,.st.created{background:#FFF4D9;color:#8A5A00}
|
||||
.cha{font-weight:700}.cha.afdian{color:#7A55D8}.cha.alipay{color:#1677FF}
|
||||
.two{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px}
|
||||
.two .adm{margin-top:16px}
|
||||
.back-links{display:none;gap:8px;margin-top:8px}
|
||||
@media (max-width:760px){
|
||||
.back-links{display:flex}
|
||||
.adm{padding:14px}
|
||||
/* 表格 → 一行一张卡片:表头藏起来,单元格顺着排 */
|
||||
.tb{min-width:0}
|
||||
.tb tr:first-child{display:none}
|
||||
.tb tr{display:flex;flex-wrap:wrap;gap:4px 10px;padding:10px 0;border-top:1px solid var(--line)}
|
||||
.tb td{border:0;padding:0;font-size:12.5px}
|
||||
.tb td:empty{display:none}
|
||||
.tb .btn{height:34px}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i></div>
|
||||
<div class="ribbon"><span><b>设计预览版</b>,收款全部走模拟渠道</span></div>
|
||||
<header class="top"><div class="wrap top-in">
|
||||
<a class="brand" href="../index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a>
|
||||
<nav class="nav" aria-label="后台"><a href="index.html">内容管理</a><a href="pay.html" aria-current="page">收款</a></nav>
|
||||
</div></header>
|
||||
<main class="wrap" style="padding-bottom:60px">
|
||||
<div class="room-head svc-head"><div class="svc-ic" aria-hidden="true"><i class="gem-img"></i></div>
|
||||
<div><h1>收款后台</h1><p>到账、关单、对账都是自动的。这里只处理系统判断不了的情况。</p><p class="svc-line" id="clock">演示时钟 —</p><div class="back-links"><a class="btn btn-crystal btn-sm" href="index.html">内容管理</a><a class="btn btn-crystal btn-sm" href="../order.html">回自助渲染</a></div></div></div>
|
||||
|
||||
<section class="adm crystal" id="login">
|
||||
<h2>后台口令</h2><p>预览机 <code>/var/lib/jz-pay-proto/admin_token</code> 里的那串。</p>
|
||||
<form class="lookup" id="fTok" style="margin-top:0"><input id="tok" type="password" placeholder="后台口令" autocomplete="off" style="text-transform:none" aria-label="后台口令"><button class="btn btn-prism" type="submit">进入</button></form>
|
||||
<div class="pmsg bad" id="loginMsg" hidden style="margin-top:10px"></div>
|
||||
</section>
|
||||
|
||||
<div id="main" hidden>
|
||||
<section class="adm crystal">
|
||||
<h2>支付待办</h2><p>金额不足、重复付款、迟到太久的付款、对不上的到账。</p>
|
||||
<div class="tw"><table class="tb" id="todo"></table></div>
|
||||
<div class="pmsg" id="todoMsg" hidden style="margin-top:10px"></div>
|
||||
</section>
|
||||
<div class="two">
|
||||
<section class="adm crystal">
|
||||
<h2>按爱发电订单号认领</h2><p>买家没走专链、或者回调里没带订单号时,把那笔成交指定到某张订单。会先向爱发电反查确认已付款。</p>
|
||||
<form class="lookup" id="fClaim" style="margin-top:0"><input id="cOid" placeholder="订单号" maxlength="8" aria-label="订单号"><input id="cTn" placeholder="爱发电订单号" style="text-transform:none" aria-label="爱发电订单号"><button class="btn btn-prism" type="submit">认领</button></form>
|
||||
<div class="pmsg" id="claimMsg" hidden style="margin-top:10px"></div>
|
||||
</section>
|
||||
<section class="adm crystal"><h2>渠道</h2><p>当面付熔断后会自动隐藏,恢复用付款页左下角的演示控制台。</p><div id="chs"></div></section>
|
||||
</div>
|
||||
<section class="adm crystal"><h2>订单</h2><div class="tw"><table class="tb" id="orders"></table></div></section>
|
||||
<section class="adm crystal"><h2>支付单</h2><div class="tw"><table class="tb" id="pays"></table></div></section>
|
||||
<section class="adm crystal"><h2>流水</h2><p>最近 80 条。</p><div class="tw"><table class="tb" id="evs"></table></div></section>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
(function(){
|
||||
'use strict';
|
||||
var API='../svc/api', $=function(i){return document.getElementById(i);}, TOK='';
|
||||
try{ TOK=localStorage.getItem('jz_pay_admin')||''; }catch(e){}
|
||||
var KIND={short:'金额不足',duplicate:'重复付款',late:'迟到付款',unknown:'对不上'};
|
||||
var ACTS={short:[['confirm','确认补齐'],['refund','退款'],['ignore','忽略']],duplicate:[['refund','退款'],['ignore','忽略']],
|
||||
late:[['activate','手动激活'],['refund','退款'],['ignore','忽略']],unknown:[['ignore','忽略']]};
|
||||
var ST={unpaid:'待付款',waiting:'已付款',closed:'已关闭',void:'已注销',created:'等待付款',paid:'已到账',mismatch:'金额不足',refunded:'已退款'};
|
||||
function esc(s){return String(s==null?'':s).replace(/[&<>"']/g,function(c){return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c];});}
|
||||
function t(ts){return ts?new Date(ts*1000).toLocaleString('zh-CN',{hour12:false,timeZone:'Asia/Shanghai'}):'—';}
|
||||
function api(m,p,b){return fetch(API+p,{method:m,cache:'no-store',headers:Object.assign({'X-Admin-Token':TOK},b?{'Content-Type':'application/json'}:{}),
|
||||
body:b?JSON.stringify(b):undefined}).then(function(r){return r.json();}).catch(function(){return {ok:false,error:'网络不通'};});}
|
||||
function st(s){return '<span class="st '+esc(s)+'">'+esc(ST[s]||s)+'</span>';}
|
||||
function ch(c){return '<span class="cha '+esc(c)+'">'+esc(c==='afdian'?'爱发电':c==='alipay'?'支付宝':c)+'</span>';}
|
||||
function note(id,txt){var m=$(id);m.hidden=false;m.textContent=txt;}
|
||||
function load(){
|
||||
return api('GET','/admin/overview').then(function(j){
|
||||
if(!j.ok){ $('main').hidden=true; $('login').hidden=false; if(TOK) note('loginMsg',j.error||'口令不对'); return; }
|
||||
$('login').hidden=true; $('main').hidden=false; $('clock').textContent='演示时钟 '+t(j.now);
|
||||
$('todo').innerHTML='<tr><th>时间</th><th>类型</th><th>订单 / 支付单</th><th>渠道流水</th><th>应付 / 实付</th><th>说明</th><th>处理</th></tr>'
|
||||
+(j.todo.map(function(x){
|
||||
var acts=x.state==='done'?esc(x.resolution):(ACTS[x.kind]||[['ignore','忽略']]).map(function(a){
|
||||
return '<button class="btn '+(a[0]==='ignore'?'btn-crystal':'btn-prism')+'" data-id="'+x.id+'" data-a="'+a[0]+'">'+a[1]+'</button>';}).join(' ');
|
||||
return '<tr class="'+(x.state==='done'?'done':'')+'"><td>'+t(x.ts)+'</td><td><span class="kd '+esc(x.kind)+'">'+esc(KIND[x.kind]||x.kind)+'</span></td><td><code>'+esc(x.oid)
|
||||
+'</code><br><code>'+esc(x.pay_id)+'</code></td><td>'+ch(x.channel)+'<br><code>'+esc(x.trade_no)+'</code></td><td>¥'+esc(x.amount_due)+' / ¥'+esc(x.amount_paid)
|
||||
+'</td><td>'+esc(x.detail)+'</td><td>'+acts+'</td></tr>';}).join('')||'<tr><td colspan="7" style="color:var(--ink-3)">没有待办 —— 全都自动处理了</td></tr>');
|
||||
[].forEach.call($('todo').querySelectorAll('button[data-id]'),function(b){ b.onclick=function(){
|
||||
b.disabled=true; api('POST','/admin/todo',{id:+b.dataset.id,action:b.dataset.a}).then(function(r){ note('todoMsg',r.ok?r.msg:('没成功:'+r.error)); load(); }); }; });
|
||||
var br=j.breaker, open=br.open_until>j.now;
|
||||
$('chs').innerHTML=j.channels.map(function(c){ return '<div style="padding:8px 0;border-top:1px solid var(--line)">'+ch(c.name)+' · '+(c.mock?'模拟网关':'真实渠道')
|
||||
+(c.name==='alipay'?' · '+(open?'<span class="st closed">熔断中,至 '+t(br.open_until)+'</span>':'<span class="st paid">正常</span>')
|
||||
+(br.reason?'<div style="font-size:12.5px;color:var(--ink-3)">最近一次问题:'+esc(br.reason)+'</div>':''):' · <span class="st paid">正常</span>')+'</div>'; }).join('');
|
||||
$('orders').innerHTML='<tr><th>订单</th><th>状态</th><th>金额</th><th>下单</th><th>到账</th><th>关闭</th><th>买家点过「没反应」</th></tr>'
|
||||
+j.orders.map(function(o){ return '<tr><td><code>'+esc(o.oid)+'</code></td><td>'+st(o.state)+'</td><td>¥'+o.amount+'</td><td>'+t(o.created_at)+'</td><td>'+t(o.paid_at)
|
||||
+'</td><td>'+t(o.closed_at)+'</td><td>'+t(o.buyer_claim_at)+'</td></tr>'; }).join('');
|
||||
$('pays').innerHTML='<tr><th>支付单</th><th>渠道</th><th>状态</th><th>应付 / 实付</th><th>渠道流水</th><th>创建</th><th>过期</th><th>备注</th></tr>'
|
||||
+j.payments.map(function(p){ return '<tr><td><code>'+esc(p.pay_id)+'</code></td><td>'+ch(p.channel)+'</td><td>'+st(p.state)+'</td><td>¥'+p.amount_due+' / '
|
||||
+(p.amount_paid!=null?'¥'+p.amount_paid:'—')+'</td><td><code>'+esc(p.trade_no||'')+'</code></td><td>'+t(p.created_at)+'</td><td>'+t(p.expire_at)+'</td><td>'+esc(p.note)+'</td></tr>'; }).join('');
|
||||
$('evs').innerHTML='<tr><th>时间</th><th>渠道</th><th>事件</th><th>支付单 / 订单</th><th>结果</th></tr>'
|
||||
+j.events.slice(0,matchMedia('(max-width:760px)').matches?30:80).map(function(e){ return '<tr><td>'+t(e.ts)+'</td><td>'+ch(e.channel)+'</td><td>'+esc(e.kind)+'</td><td><code>'+esc(e.pay_id||e.oid)+'</code></td><td>'+esc(e.result)+'</td></tr>'; }).join('');
|
||||
});
|
||||
}
|
||||
$('fTok').onsubmit=function(e){ e.preventDefault(); TOK=$('tok').value.trim(); try{ localStorage.setItem('jz_pay_admin',TOK); }catch(e2){} load(); };
|
||||
$('fClaim').onsubmit=function(e){ e.preventDefault(); api('POST','/admin/claim',{oid:$('cOid').value.trim().toUpperCase(),trade_no:$('cTn').value.trim()}).then(function(r){
|
||||
note('claimMsg',r.ok?r.msg:('没成功:'+r.error)); load(); }); };
|
||||
load(); setInterval(function(){ if(!document.hidden&&TOK) load(); },5000);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,147 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<title>自助渲染 · 金钻客栈(设计预览)</title>
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<link rel="preload" href="assets/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=33">
|
||||
<link rel="stylesheet" href="assets/pay.css?v=2">
|
||||
</head>
|
||||
<body>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<div class="ribbon"><span><b>设计预览版</b>,方括号里的是占位内容</span></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html">画展</a><a href="tools.html">工具与开源</a><a href="universe.html">金钻宇宙</a><a href="links.html">平台入口</a><a href="about.html">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="order.html" aria-current="page"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="cms/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head svc-head"><div class="svc-ic" aria-hidden="true"><i class="gem-img"></i></div><div><h1>自助模板渲染</h1><p>传一张皮肤,选个模板,等一会儿就能拿到渲染图。</p><p class="svc-line">渲染机在线 · 每张 6 元起</p></div></div>
|
||||
<section aria-labelledby="go-h"><div class="sec-h"><div><h2 id="go-h">怎么下单?</h2></div></div><div class="paths"><a class="path crystal" href="#tpl"><span class="pi"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="20" r="1.5"/><circle cx="18" cy="20" r="1.5"/><path d="M3 4h2l2.4 11.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.5L21 8H6"/></svg></span><h3>网页下单</h3><p style="margin:0;font-size:14.5px;color:var(--ink-2);line-height:1.75">选好模板,在收银台用爱发电或支付宝扫码付款,到账自动开始渲染。</p><div class="hint"><span></span><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></div></a><a class="path code crystal" href="#tpl"><span class="pi"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="8" cy="15" r="4"/><path d="m10.85 12.15 7.65-7.65"/><path d="m15 6 3 3"/><path d="m17.5 3.5 3 3"/></svg></span><h3>用卡密</h3><p style="margin:0;font-size:14.5px;color:var(--ink-2);line-height:1.75">在闲鱼、B站工坊或爱发电买了卡密?填进来就行,模板会自动选好。</p><div class="hint"><span></span><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></div></a></div><div class="pickup"><span>下过单了?</span><span class="sp"></span><a class="btn btn-crystal btn-sm" href="#pass">取图</a><a class="btn btn-crystal btn-sm" href="#pass">我的订单</a></div></section>
|
||||
<section class="sec" id="tpl" aria-labelledby="tpl-h">
|
||||
<div class="sec-h"><div><h2 id="tpl-h">网页下单</h2><p>每个模板出两张:一张压缩过的,一张无压缩 16bit 的。一张 ¥6。</p></div></div>
|
||||
<div class="buy"><div class="buy-form">
|
||||
<div class="buy-step"><h3>选模板</h3><p>可以多选,选几个出几张。</p><div class="tpl-grid" id="tplGrid"></div></div>
|
||||
<div class="buy-step"><h3>分辨率</h3><p>默认 1000px 就是网易我的世界头图的标准尺寸,出图最快。</p>
|
||||
<div class="seg crystal" id="resSeg" role="group" aria-label="分辨率">
|
||||
<button type="button" data-r="1000" aria-pressed="true">1000px<em>约 40 秒</em></button><button type="button" data-r="1024" aria-pressed="false">1024px<em>约 45 秒</em></button><button type="button" data-r="2048" aria-pressed="false">2048px<em>约 2.5 分钟</em></button><button type="button" data-r="4096" aria-pressed="false">4096px<em>约 10 分钟</em></button>
|
||||
</div></div>
|
||||
<div class="buy-step"><h3>皮肤</h3><p>.png 文件,64×64 的标准皮肤最稳。质检在你自己的浏览器里完成。</p>
|
||||
<div class="skin crystal">
|
||||
<label class="skin-drop" id="skinDrop"><span id="skinPh">点这里选皮肤<br>或把 .png 拖进来</span><canvas id="skinCv" width="64" height="64" hidden></canvas><input type="file" id="skinFile" accept="image/png" aria-label="选择皮肤文件"></label>
|
||||
<div class="skin-rep" id="skinRep"><div class="lamp warn">还没选皮肤</div></div>
|
||||
</div></div>
|
||||
</div>
|
||||
<aside class="sumbar crystal" aria-label="你的订单"><div class="sum"><span class="sum-h">你的订单</span><ul class="sum-list" id="sumList"></ul><b id="sumAmt">¥0</b><span id="sumTxt">还没选模板</span></div><span class="sp"></span><span class="why" id="sumWhy"></span><button type="button" class="btn btn-prism" id="btnBuy" disabled>去付款</button><p class="sum-note">付款方式:爱发电或支付宝扫码。到账后自动开始渲染,不用再操作。</p></aside>
|
||||
</div>
|
||||
</section>
|
||||
<section class="sec" id="pass" aria-labelledby="pass-h">
|
||||
<div class="sec-h"><div><h2 id="pass-h">我的订单</h2><p>这台浏览器下过的单都在这里。换了设备,用订单号和取件码查。</p></div></div>
|
||||
<div class="mine" id="mine"></div>
|
||||
<form class="lookup" id="lookup"><input id="lkOid" placeholder="订单号,如 YSAB12CD" maxlength="8" autocomplete="off" aria-label="订单号"><input id="lkTok" placeholder="取件码" maxlength="12" autocomplete="off" aria-label="取件码"><button class="btn btn-crystal" type="submit">查订单</button></form>
|
||||
<div class="pmsg bad" id="lkMsg" hidden style="margin-top:10px"></div>
|
||||
</section>
|
||||
<p class="note" style="margin-top:28px;line-height:1.9">非官方 Minecraft 产品,与 Mojang 无关<br>有问题来 QQ 群找金钻:123456789</p>
|
||||
</main>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="order.html" aria-current="page"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><span>© 2026 example.com</span><span>QQ 群:屑钻小窝 123456789</span><span class="sp"></span><span>备案号(已移除)</span></div></footer>
|
||||
<script src="assets/pay.js?v=2"></script>
|
||||
<script>
|
||||
(function(){
|
||||
'use strict';
|
||||
var P=window.JZPay, $=function(i){return document.getElementById(i);};
|
||||
var S={tpls:[], res:1000, skin:null};
|
||||
/* 模板 */
|
||||
var g=$('tplGrid');
|
||||
P.TPLS.forEach(function(t){
|
||||
var b=document.createElement('button'); b.type='button'; b.className='tpl crystal'; b.setAttribute('aria-pressed','false'); b.dataset.k=t.k;
|
||||
b.innerHTML='<span class="sw" style="--c:'+t.c+'" aria-hidden="true"></span><span class="pick" aria-hidden="true">✓</span><b>'+P.esc(t.n)+'</b><span>'+P.esc(t.s)+'</span><span class="num">¥6</span>';
|
||||
b.onclick=function(){ var on=S.tpls.indexOf(t.k)<0; S.tpls=on?S.tpls.concat([t.k]):S.tpls.filter(function(x){return x!==t.k;});
|
||||
b.setAttribute('aria-pressed',String(on)); sum(); };
|
||||
g.appendChild(b);
|
||||
});
|
||||
/* 分辨率 */
|
||||
[].forEach.call(document.querySelectorAll('#resSeg button'),function(b){ b.onclick=function(){ S.res=+b.dataset.r;
|
||||
[].forEach.call(document.querySelectorAll('#resSeg button'),function(x){ x.setAttribute('aria-pressed',String(x===b)); }); sum(); }; });
|
||||
/* 皮肤:三色灯(绿放行 / 黄勾了「无视风险」才放行 / 红拦住) */
|
||||
function lamps(list){ $('skinRep').innerHTML=list.map(function(l){ return '<div class="lamp '+l[0]+'">'+l[1]+'</div>'; }).join(''); }
|
||||
function checkSkin(f){
|
||||
S.skin=null; sum();
|
||||
if(!f) return;
|
||||
if(!/\.png$/i.test(f.name)||(f.type&&f.type!=='image/png')){ lamps([['bad','<span><b>不是 PNG 图片</b>,模板只认 .png 皮肤</span>']]); return; }
|
||||
if(f.size>10*1024*1024){ lamps([['bad','<span><b>文件太大</b>(上限 10MB)</span>']]); return; }
|
||||
var img=new Image(), url=URL.createObjectURL(f);
|
||||
img.onload=function(){
|
||||
var w=img.naturalWidth,h=img.naturalHeight,cv=$('skinCv'); cv.width=w; cv.height=h;
|
||||
var cx=cv.getContext('2d'); cx.imageSmoothingEnabled=false; cx.clearRect(0,0,w,h); cx.drawImage(img,0,0);
|
||||
cv.hidden=false; $('skinPh').hidden=true; URL.revokeObjectURL(url);
|
||||
var L=[], lv='ok';
|
||||
if(w===h*2){ L.push(['bad','<span><b>旧版 2:1 皮肤('+w+'×'+h+')</b>:没有左手左腿和外层,模板渲染不了。换一张新版 64×64 的。</span>']); lv='bad'; }
|
||||
else if(w!==h){ L.push(['bad','<span><b>不是皮肤比例('+w+'×'+h+')</b>:皮肤应该是正方形的。</span>']); lv='bad'; }
|
||||
else if(w%64){ L.push(['warn','<span><b>尺寸 '+w+'×'+h+' 不是 64 的倍数</b>:能渲,但手臂和外层可能错位。<label><input type="checkbox" id="riskOk"> 我知道,无视风险继续</label></span>']); lv='warn'; }
|
||||
else if(w>1024){ L.push(['warn','<span><b>超大皮肤 '+w+'×'+h+'</b>:能渲,出图会慢一些。<label><input type="checkbox" id="riskOk"> 我知道,继续</label></span>']); lv='warn'; }
|
||||
else L.push(['ok','<span><b>标准皮肤 '+w+'×'+h+'</b>:可以直接渲染。</span>']);
|
||||
L.push(['ok','<span>文件 '+P.esc(f.name)+' · '+Math.round(f.size/1024)+' KB</span>']);
|
||||
lamps(L); S.skin={name:f.name,lv:lv,ack:false};
|
||||
var r=$('riskOk'); if(r) r.onchange=function(){ S.skin.ack=r.checked; sum(); };
|
||||
sum();
|
||||
};
|
||||
img.onerror=function(){ lamps([['bad','<span><b>这张图读不出来</b>,换一个文件试试</span>']]); };
|
||||
img.src=url;
|
||||
}
|
||||
$('skinFile').onchange=function(e){ checkSkin(e.target.files[0]); };
|
||||
var drop=$('skinDrop');
|
||||
drop.addEventListener('dragover',function(e){ e.preventDefault(); });
|
||||
drop.addEventListener('drop',function(e){ e.preventDefault(); checkSkin(e.dataTransfer.files[0]); });
|
||||
/* 汇总 */
|
||||
function why(){
|
||||
if(!S.tpls.length) return '先选至少一个模板';
|
||||
if(!S.skin) return '还没选皮肤';
|
||||
if(S.skin.lv==='bad') return '这张皮肤渲染不了';
|
||||
if(S.skin.lv==='warn'&&!S.skin.ack) return '勾一下「无视风险」才能继续';
|
||||
return '';
|
||||
}
|
||||
function sum(){
|
||||
var n=S.tpls.length, w=why();
|
||||
$('sumAmt').textContent='¥'+(n*6);
|
||||
$('sumTxt').textContent=n?(n+' 张 · '+S.res+'px · '+P.TPLS.filter(function(t){return S.tpls.indexOf(t.k)>=0;}).map(function(t){return t.n;}).join('、')):'还没选模板';
|
||||
var L=P.TPLS.filter(function(t){return S.tpls.indexOf(t.k)>=0;}).map(function(t){ return '<li><span>'+P.esc(t.n)+'</span><span class="num">¥6</span></li>'; });
|
||||
L.push('<li class="meta"><span>分辨率</span><span class="num">'+S.res+'px</span></li>');
|
||||
L.push('<li class="meta"><span>皮肤</span><span>'+(S.skin?(S.skin.lv==='bad'?'不能渲染':(S.skin.lv==='warn'?(S.skin.ack?'已确认风险':'待确认风险'):'已通过质检')):'还没选')+'</span></li>');
|
||||
$('sumList').innerHTML=L.join('');
|
||||
$('sumWhy').textContent=w; $('btnBuy').disabled=!!w;
|
||||
if(matchMedia('(max-width:760px)').matches && w){ $('sumTxt').textContent=w; $('sumTxt').className='blocked'; } else $('sumTxt').className='';
|
||||
}
|
||||
$('btnBuy').onclick=function(){
|
||||
var b=this; b.disabled=true; b.textContent='正在下单…';
|
||||
P.api('POST','/order',{templates:S.tpls,res:S.res,skin_name:S.skin&&S.skin.name}).then(function(j){
|
||||
if(!j.ok){ $('sumWhy').textContent=j.error||'下单失败'; b.disabled=false; b.textContent='去付款'; return; }
|
||||
P.saveOrder({oid:j.order.oid,t:j.token,ts:Date.now(),amount:j.order.amount,n:j.order.n_img});
|
||||
location.href='pay.html?o='+encodeURIComponent(j.order.oid)+'&t='+encodeURIComponent(j.token);
|
||||
});
|
||||
};
|
||||
sum();
|
||||
/* 我的订单 */
|
||||
function mine(){
|
||||
var l=P.orders().slice(0,10), box=$('mine');
|
||||
if(!l.length){ box.innerHTML='<div class="note">这台浏览器还没下过单。</div>'; return; }
|
||||
box.innerHTML=l.map(function(o){ return '<a class="mrow crystal" id="m_'+o.oid+'" href="pay.html?o='+encodeURIComponent(o.oid)+'&t='+encodeURIComponent(o.t)+'">'
|
||||
+'<span class="code">'+P.esc(o.oid)+'</span><span class="what">'+o.n+' 张 · ¥'+o.amount+' · '+new Date(o.ts).toLocaleString('zh-CN',{hour12:false})+'</span><span class="state">…</span></a>'; }).join('');
|
||||
l.forEach(function(o){ P.api('GET','/order?oid='+encodeURIComponent(o.oid)+'&t='+encodeURIComponent(o.t)).then(function(j){
|
||||
var el=document.querySelector('#m_'+o.oid+' .state'); if(!el) return;
|
||||
if(j.ok){ el.textContent=P.STATE[j.order.state]||j.order.state_text; el.className='state '+j.order.state; } else el.textContent='查不到'; }); });
|
||||
}
|
||||
mine(); P.demo.onChange=mine;
|
||||
$('lookup').onsubmit=function(e){ e.preventDefault();
|
||||
var oid=$('lkOid').value.trim().toUpperCase(), t=$('lkTok').value.trim().toUpperCase(), m=$('lkMsg');
|
||||
if(!oid||!t){ m.hidden=false; m.textContent='订单号和取件码都要填'; return; }
|
||||
P.api('GET','/order?oid='+encodeURIComponent(oid)+'&t='+encodeURIComponent(t)).then(function(j){
|
||||
if(!j.ok){ m.hidden=false; m.textContent='没查到:订单号或取件码不对'; return; }
|
||||
P.saveOrder({oid:oid,t:t,ts:j.order.created_at*1000,amount:j.order.amount,n:j.order.n_img});
|
||||
location.href='pay.html?o='+encodeURIComponent(oid)+'&t='+encodeURIComponent(t); });
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
<script src="assets/site.js?v=32"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,189 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<title>收银台 · 金钻客栈(设计预览)</title>
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<link rel="preload" href="assets/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=33">
|
||||
<link rel="stylesheet" href="assets/pay.css?v=2">
|
||||
</head>
|
||||
<body>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<div class="ribbon"><span><b>设计预览版</b>,方括号里的是占位内容</span></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html">画展</a><a href="tools.html">工具与开源</a><a href="universe.html">金钻宇宙</a><a href="links.html">平台入口</a><a href="about.html">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="order.html" aria-current="page"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="cms/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head svc-head"><div class="svc-ic" aria-hidden="true"><i class="gem-img"></i></div>
|
||||
<div><h1 id="pTitle">收银台</h1><p id="pSub">选一种方式付款,到账后自动开始渲染。</p><p class="svc-line"><a href="order.html" style="color:inherit">← 回到自助渲染</a></p></div></div>
|
||||
<section class="sec" style="padding-top:6px" aria-label="订单">
|
||||
<div class="pass crystal pay" id="passCard">
|
||||
<div class="main">
|
||||
<div class="row"><div><div class="lbl">订单号</div><div class="code" id="pOid">—</div></div><span class="state" id="pState">读取中</span></div>
|
||||
<div class="row" style="align-items:flex-end"><div><div class="lbl">应付</div><div class="amt" id="pAmt">—</div></div><div class="items" id="pItems"></div></div>
|
||||
<div id="unpaidBox" hidden>
|
||||
<div class="lbl" style="margin-bottom:8px">付款方式</div>
|
||||
<div class="chs" id="chs"></div>
|
||||
<div class="qrbox" id="qrbox" hidden style="margin-top:16px"><div class="qr" id="qr"></div><div id="qrInfo"></div></div>
|
||||
<div class="row" style="justify-content:flex-start;gap:10px 14px;margin-top:16px">
|
||||
<button type="button" class="btn btn-crystal btn-sm" id="btnCheck">付好了没反应?</button>
|
||||
<span class="note" id="keep" style="margin:0"></span></div>
|
||||
<div class="pmsg" id="pMsg" hidden style="margin-top:10px"></div>
|
||||
</div>
|
||||
<div id="paidBox" hidden>
|
||||
<div class="paid-hero"><div class="ok" aria-hidden="true">✓</div><div><b>已付款,正在排队出图</b><p>不用再做任何操作。出图后在这一页看预览、确认收货、下载原图。</p></div></div>
|
||||
<div class="prog" id="pProg" aria-hidden="true" style="margin-top:14px"></div>
|
||||
<div class="note" id="paidAt"></div>
|
||||
</div>
|
||||
<div id="closedBox" hidden>
|
||||
<div class="pmsg bad">这张订单超过 24 小时没付款,已经自动关闭。如果其实付过了,系统会在 72 小时内自动认回来;也可以点下面立即查一次。</div>
|
||||
<div class="row" style="justify-content:flex-start;gap:10px;margin-top:12px"><a class="btn btn-prism btn-sm" href="order.html#tpl">重新下单</a><button type="button" class="btn btn-crystal btn-sm" id="btnCheck2">付好了没反应?</button></div>
|
||||
<div class="pmsg" id="pMsg2" hidden style="margin-top:10px"></div>
|
||||
</div>
|
||||
<div id="missBox" hidden><div class="pmsg bad">没找到这张订单:链接里缺了取件码,或者取件码不对。去「我的订单」用订单号和取件码查。</div>
|
||||
<a class="btn btn-crystal btn-sm" href="order.html#pass" style="margin-top:12px">我的订单</a></div>
|
||||
<details id="logBox" hidden><summary class="note" style="cursor:pointer">付款记录</summary><table class="plog" id="plog"></table></details>
|
||||
</div>
|
||||
<div class="stub">
|
||||
<div><div class="lbl">取件码</div><div class="code" id="pTok">—</div></div>
|
||||
<div class="barcode" aria-hidden="true"></div>
|
||||
<div style="font-size:13px;color:var(--ink-3);line-height:1.7">记好订单号和取件码,换了手机也能查单、取图。</div>
|
||||
<button type="button" class="btn btn-crystal btn-sm" id="btnCopy">复制订单链接</button>
|
||||
<a class="btn btn-crystal btn-sm" href="order.html#pass">我的订单</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<p class="note" style="margin-top:28px;line-height:1.9">非官方 Minecraft 产品,与 Mojang 无关<br>有问题来 QQ 群找金钻:123456789</p>
|
||||
</main>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="order.html" aria-current="page"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><span>© 2026 example.com</span><span>QQ 群:屑钻小窝 123456789</span><span class="sp"></span><span>备案号(已移除)</span></div></footer>
|
||||
<script src="assets/vendor/qrcode.min.js"></script>
|
||||
<script src="assets/pay.js?v=2"></script>
|
||||
<script>
|
||||
(function(){
|
||||
'use strict';
|
||||
var P=window.JZPay, $=function(i){return document.getElementById(i);};
|
||||
var q=new URLSearchParams(location.search);
|
||||
var S={oid:(q.get('o')||'').toUpperCase(), t:(q.get('t')||'').toUpperCase(), v:null, pay:null, timer:0, skew:0};
|
||||
if(!S.t) S.t=P.tokenOf(S.oid);
|
||||
var mobile=matchMedia('(max-width:760px), (pointer:coarse)').matches;
|
||||
var PST={created:'等待付款',paid:'已到账',mismatch:'金额不足',closed:'已关闭',refunded:'已退款'};
|
||||
|
||||
function show(id,on){ $(id).hidden=!on; }
|
||||
function nowSec(){ return Date.now()/1000+S.skew; } /* 服务器(演示)时钟 */
|
||||
function render(v){
|
||||
S.v=v; S.skew=v.now-Date.now()/1000; P.demoUpdate(v);
|
||||
var o=v.order;
|
||||
P.saveOrder({oid:o.oid,t:S.t,ts:o.created_at*1000,amount:o.amount,n:o.n_img});
|
||||
$('pOid').textContent=o.oid; $('pTok').textContent=S.t;
|
||||
var st=$('pState'); st.textContent=P.STATE[o.state]||o.state_text; st.className='state '+o.state;
|
||||
$('pAmt').textContent='¥'+o.amount;
|
||||
$('pItems').innerHTML=o.templates.map(function(t){ return '<span class="chip">'+P.esc(t.n)+'</span>'; }).join('')
|
||||
+'<span class="chip num">'+o.res+'px</span>'+(o.skin_name?'<span class="chip">'+P.esc(o.skin_name)+'</span>':'');
|
||||
var unpaid=o.state==='unpaid';
|
||||
$('pTitle').textContent=unpaid?'收银台':'订单';
|
||||
$('pSub').textContent=unpaid?'选一种方式付款,到账后自动开始渲染。':(o.state==='closed'?'这张订单已关闭。':'进度都在这一页看。');
|
||||
show('unpaidBox',unpaid); show('paidBox',o.state==='waiting'||o.state==='working'||o.state==='done'); show('closedBox',o.state==='closed'); show('missBox',false);
|
||||
if(o.state==='waiting'){
|
||||
$('pProg').style.gridTemplateColumns='repeat('+o.n_img+',minmax(0,1fr))';
|
||||
$('pProg').innerHTML=new Array(o.n_img+1).join('<i></i>');
|
||||
$('paidAt').textContent=o.paid_at?('到账时间 '+P.full(o.paid_at)+' · 一共 '+o.n_img+' 张,排队中'):'';
|
||||
}
|
||||
/* 渠道 */
|
||||
var box=$('chs'); box.innerHTML='';
|
||||
v.channels.forEach(function(c){
|
||||
var b=document.createElement('button'); b.type='button'; b.className='chx crystal '+(c.name==='afdian'?'afd':'ali'); b.disabled=!c.ok;
|
||||
b.innerHTML=(c.name==='afdian'?'<span class="rec">推荐</span>':'')
|
||||
+'<b><i aria-hidden="true">'+(c.name==='afdian'?'爱':'支')+'</i>'+(c.name==='afdian'?'爱发电':'支付宝扫码')+'</b>'
|
||||
+'<span>'+(c.name==='afdian'?'跳到爱发电付款,到账自动确认':'在这一页扫码付款,秒级到账')+'</span>'
|
||||
+(c.ok?'':'<span class="why">'+P.esc(c.reason)+'</span>');
|
||||
b.setAttribute('aria-pressed',String(!!(S.pay&&S.pay.channel===c.name)));
|
||||
b.onclick=function(){ choose(c.name); };
|
||||
box.appendChild(b);
|
||||
});
|
||||
/* 当前支付单:还在用的那张优先;没有就取最新一张待付款的 */
|
||||
var created=v.payments.filter(function(p){ return p.state==='created'; });
|
||||
var keep=S.pay&&created.filter(function(p){ return p.pay_id===S.pay.pay_id; })[0];
|
||||
S.pay=keep||created[created.length-1]||null;
|
||||
[].forEach.call(box.children,function(b,i){ b.setAttribute('aria-pressed',String(!!(S.pay&&S.pay.channel===v.channels[i].name))); });
|
||||
paintQR();
|
||||
/* 记录 */
|
||||
show('logBox',v.payments.length>0);
|
||||
$('plog').innerHTML=v.payments.map(function(p){ return '<tr><td><code>'+P.esc(p.pay_id)+'</code></td><td>'+(p.channel==='afdian'?'爱发电':'支付宝')
|
||||
+'</td><td>¥'+p.amount_due+(p.amount_paid!=null?' · 实付 ¥'+p.amount_paid:'')+'</td><td>'+P.esc(PST[p.state]||p.state)+'</td></tr>'; }).join('');
|
||||
$('keep').textContent=unpaid?('订单保留 '+P.left(o.expire_at-nowSec())+',超时自动关闭'):'';
|
||||
}
|
||||
function paintQR(){
|
||||
var p=S.pay, box=$('qrbox');
|
||||
if(!p||!S.v||S.v.order.state!=='unpaid'){ box.hidden=true; return; }
|
||||
box.hidden=false;
|
||||
var d=p.display||{}, link=p.channel==='afdian'?(d.url||''):(d.qr||''), wait='<div class="waitline" style="margin-top:14px">正在等待到账,不用刷新页面</div>';
|
||||
if(mobile){
|
||||
/* 手机:买家就在这台手机上付,自己扫不了自己的屏幕 → 按钮优先,二维码收起来留给「另一台设备」 */
|
||||
$('qr').innerHTML=''; $('qr').style.display='none'; box.style.display='block';
|
||||
$('qrInfo').innerHTML=(p.channel==='afdian'
|
||||
? '<h4>爱发电付款 ¥'+p.amount_due+'</h4><p>点下面的按钮去爱发电付款,付完回到这一页,会自动变成「已付款」。</p>'
|
||||
+'<a class="btn btn-prism btn-wide" href="'+P.esc(link)+'" target="_blank" rel="noopener">去爱发电付款</a>'
|
||||
: '<h4>支付宝付款 ¥'+p.amount_due+'</h4><div class="cd" id="cd">付款码有效 <b id="cdv">--:--</b></div>'
|
||||
+'<a class="btn btn-prism btn-wide" href="'+P.esc(link)+'" target="_blank" rel="noopener">打开支付宝付款</a>')
|
||||
+wait+'<details class="qrfold"><summary>用另一台设备扫码付款</summary><div class="qr">'+P.qrSvg(link)+'</div></details>';
|
||||
}else{
|
||||
box.style.display=''; $('qr').style.display='';
|
||||
$('qr').innerHTML=P.qrSvg(link);
|
||||
$('qrInfo').innerHTML=(p.channel==='afdian'
|
||||
? '<h4>爱发电付款 ¥'+p.amount_due+'</h4><p>用手机扫左边的码,在爱发电付款;用这台电脑付就点下面的按钮。付完回到这一页,会自动变成「已付款」。</p>'
|
||||
+'<a class="btn btn-prism btn-sm" href="'+P.esc(link)+'" target="_blank" rel="noopener">去爱发电付款</a>'
|
||||
: '<h4>支付宝扫码 ¥'+p.amount_due+'</h4><p>打开手机支付宝「扫一扫」,扫左边的二维码付款。</p>'
|
||||
+'<div class="cd" id="cd">二维码有效 <b id="cdv">--:--</b></div>'
|
||||
+'<a href="'+P.esc(link)+'" target="_blank" rel="noopener" style="font-size:13px">预览站:在这台设备打开模拟扫码页</a>')
|
||||
+wait;
|
||||
}
|
||||
tick();
|
||||
}
|
||||
function tick(){
|
||||
var e=$('cdv'); if(!e||!S.pay) return;
|
||||
var r=S.pay.expire_at-nowSec(); e.textContent=P.left(r); $('cd').classList.toggle('low',r<120);
|
||||
if(r<=0){ e.textContent='已过期'; var w=$('qrInfo').querySelector('.waitline'); if(w) w.textContent='付款码已过期:点上面的「支付宝扫码」重新生成一张。'; }
|
||||
}
|
||||
setInterval(function(){ tick(); if(S.v&&S.v.order.state==='unpaid') $('keep').textContent='订单保留 '+P.left(S.v.order.expire_at-nowSec())+',超时自动关闭'; },1000);
|
||||
|
||||
function choose(ch){
|
||||
$('pMsg').hidden=true;
|
||||
P.api('POST','/pay',{oid:S.oid,t:S.t,channel:ch}).then(function(j){
|
||||
if(!j.ok){ msg('pMsg',j.error,true); return refresh(); }
|
||||
S.pay=j.payment; refresh();
|
||||
});
|
||||
}
|
||||
function msg(id,t,bad){ var m=$(id); m.hidden=false; m.textContent=t; m.className='pmsg'+(bad?' bad':''); }
|
||||
function check(id){
|
||||
msg(id,'正在向支付渠道查询…');
|
||||
P.api('POST','/check',{oid:S.oid,t:S.t}).then(function(j){ msg(id,j.msg||j.error||'',!j.found); refresh(); });
|
||||
}
|
||||
$('btnCheck').onclick=function(){ check('pMsg'); };
|
||||
$('btnCheck2').onclick=function(){ check('pMsg2'); };
|
||||
$('btnCopy').onclick=function(){
|
||||
var u=location.origin+location.pathname+'?o='+S.oid+'&t='+S.t, b=this;
|
||||
(navigator.clipboard?navigator.clipboard.writeText(u):Promise.reject()).then(function(){ b.textContent='已复制'; },function(){ prompt('复制这个链接',u); });
|
||||
setTimeout(function(){ b.textContent='复制订单链接'; },1600);
|
||||
};
|
||||
|
||||
function refresh(){
|
||||
if(!S.oid||!S.t){ miss(); return Promise.resolve(); }
|
||||
var url=(S.pay&&S.pay.state==='created'&&S.v&&S.v.order.state==='unpaid')
|
||||
? '/pay?pay_id='+encodeURIComponent(S.pay.pay_id)+'&t='+encodeURIComponent(S.t)
|
||||
: '/order?oid='+encodeURIComponent(S.oid)+'&t='+encodeURIComponent(S.t);
|
||||
return P.api('GET',url).then(function(j){ if(j.ok) render(j); else if(!S.v) miss(); });
|
||||
}
|
||||
function miss(){ show('missBox',true); show('unpaidBox',false); $('pOid').textContent=S.oid||'—'; $('pState').textContent='查不到'; $('pTitle').textContent='订单'; }
|
||||
function loop(){ clearTimeout(S.timer); if(document.visibilityState!=='visible') return;
|
||||
refresh().then(function(){ S.timer=setTimeout(loop,(S.v&&S.v.order.state==='unpaid')?3000:8000); }); }
|
||||
document.addEventListener('visibilitychange',function(){ if(document.visibilityState==='visible') loop(); });
|
||||
P.demo.onChange=refresh;
|
||||
loop();
|
||||
})();
|
||||
</script>
|
||||
<script src="assets/site.js?v=32"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,269 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""支付原型场景测试:临时目录起一份服务(全模拟渠道),从 HTTP 层打。
|
||||
|
||||
用法:python3 tests/test_proto.py
|
||||
"""
|
||||
import base64, json, os, re, shutil, socket, subprocess, sys, tempfile, time, urllib.parse, urllib.request
|
||||
|
||||
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
RESULTS = []
|
||||
|
||||
|
||||
def check(name, ok, detail=""):
|
||||
RESULTS.append((name, bool(ok)))
|
||||
print(("PASS " if ok else "FAIL ") + name + ((" —— " + str(detail)[:200]) if detail != "" else ""))
|
||||
|
||||
|
||||
def free_port():
|
||||
s = socket.socket()
|
||||
s.bind(("127.0.0.1", 0))
|
||||
p = s.getsockname()[1]
|
||||
s.close()
|
||||
return p
|
||||
|
||||
|
||||
PORT = free_port()
|
||||
BASE = "http://127.0.0.1:%d" % PORT
|
||||
DATA = tempfile.mkdtemp(prefix="payproto_")
|
||||
env = dict(os.environ, PAY_PORT=str(PORT), PAY_DATA_DIR=DATA, PAY_BASE_URL=BASE)
|
||||
srv = subprocess.Popen([sys.executable, os.path.join(HERE, "app.py")], env=env,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
|
||||
|
||||
def req(method, path, obj=None, form=None, headers=None, raw=False):
|
||||
data, h = None, dict(headers or {})
|
||||
if obj is not None:
|
||||
data = json.dumps(obj).encode()
|
||||
h["Content-Type"] = "application/json"
|
||||
if form is not None:
|
||||
data = urllib.parse.urlencode(form).encode()
|
||||
h["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
r = urllib.request.Request(BASE + path, data=data, method=method, headers=h)
|
||||
try:
|
||||
with urllib.request.urlopen(r, timeout=20) as resp:
|
||||
body = resp.read().decode()
|
||||
return resp.status, (body if raw else json.loads(body))
|
||||
except urllib.error.HTTPError as e:
|
||||
body = e.read().decode()
|
||||
return e.code, (body if raw else json.loads(body or "{}"))
|
||||
|
||||
|
||||
for _ in range(300):
|
||||
try:
|
||||
urllib.request.urlopen(BASE + "/", timeout=1)
|
||||
break
|
||||
except Exception:
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
def new_order(n=2):
|
||||
st, j = req("POST", "/api/order", {"n_img": n})
|
||||
return j["order"]["oid"], j["token"], j
|
||||
|
||||
|
||||
def view(oid, tok):
|
||||
return req("GET", "/api/order?oid=%s&t=%s" % (oid, tok))[1]
|
||||
|
||||
|
||||
def pay(oid, tok, ch):
|
||||
return req("POST", "/api/pay", {"oid": oid, "t": tok, "channel": ch})[1]
|
||||
|
||||
|
||||
def afd_pay_link(url, amount=None, drop=False):
|
||||
qs = dict(urllib.parse.parse_qsl(urllib.parse.urlparse(url).query))
|
||||
form = {"custom_order_id": qs["custom_order_id"], "remark": qs["remark"],
|
||||
"amount": amount if amount is not None else qs["custom_price"]}
|
||||
if drop:
|
||||
form["drop"] = "on"
|
||||
req("POST", "/mock/afdian/order/pay", form=form, raw=True)
|
||||
return qs
|
||||
|
||||
|
||||
def ali_scan_pay(qr_url, drop=False):
|
||||
path = urllib.parse.urlparse(qr_url).path
|
||||
req("GET", path, raw=True) # 扫码 → WAIT_BUYER_PAY
|
||||
form = {"qr": path.rsplit("/", 1)[-1]}
|
||||
if drop:
|
||||
form["drop"] = "on"
|
||||
return req("POST", "/mock/alipay/scanpay", form=form, raw=True)[1]
|
||||
|
||||
|
||||
def demo(**kw):
|
||||
return req("POST", "/api/demo", kw)[1]
|
||||
|
||||
|
||||
def todos():
|
||||
tok = open(os.path.join(DATA, "admin_token")).read().strip()
|
||||
return req("GET", "/api/admin/overview", headers={"X-Admin-Token": tok})[1]["todo"]
|
||||
|
||||
|
||||
def admin(path, obj):
|
||||
tok = open(os.path.join(DATA, "admin_token")).read().strip()
|
||||
return req("POST", path, obj, headers={"X-Admin-Token": tok})[1]
|
||||
|
||||
|
||||
try:
|
||||
# 1. 爱发电正常到账(Webhook)
|
||||
oid, tok, j = new_order(2)
|
||||
check("下单:应付 ¥12、状态 unpaid、两个渠道可选", j["order"]["amount"] == 12 and j["order"]["state"] == "unpaid"
|
||||
and [c["name"] for c in j["channels"] if c["ok"]] == ["afdian", "alipay"])
|
||||
r = pay(oid, tok, "afdian")
|
||||
url = r["payment"]["display"]["url"]
|
||||
check("爱发电专链带 custom_order_id=支付单号、custom_price=应付", "custom_order_id=%sP1" % oid in url
|
||||
and "custom_price=12" in url, url)
|
||||
afd_pay_link(url)
|
||||
time.sleep(3)
|
||||
v = view(oid, tok)
|
||||
check("爱发电付款 → Webhook 验签 + 精确反查 → 订单 waiting", v["order"]["state"] == "waiting",
|
||||
[e["kind"] + ":" + e["result"] for e in v["events"][:4]])
|
||||
|
||||
# 1b. 按真实下单内容建单:模板 × 1 张皮肤,金额按模板数算,非法模板/分辨率被过滤
|
||||
st, jt = req("POST", "/api/order", {"templates": ["stand", "sakura", "nope", "stand"], "res": 2048, "skin_name": "a.png"})
|
||||
o = jt["order"]
|
||||
check("下单带模板:去重、丢掉不认识的模板,2 个模板 = ¥12,分辨率 2048,皮肤名带回",
|
||||
o["amount"] == 12 and [t["n"] for t in o["templates"]] == ["站立正反", "飞跃樱花林"] and o["res"] == 2048
|
||||
and o["skin_name"] == "a.png" and len(jt["token"]) == 10, o)
|
||||
st, jt = req("POST", "/api/order", {"templates": ["wheat"], "res": 777})
|
||||
check("不支持的分辨率 → 回落 1000", jt["order"]["res"] == 1000, jt["order"]["res"])
|
||||
|
||||
# 2. 同一笔 Webhook 重复推送 → 幂等
|
||||
from cryptography.hazmat.primitives import hashes, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import padding
|
||||
import sqlite3
|
||||
con = sqlite3.connect(os.path.join(DATA, "pay.db"))
|
||||
con.row_factory = sqlite3.Row
|
||||
mo = dict(con.execute("SELECT * FROM mock_afd ORDER BY create_time DESC LIMIT 1").fetchone())
|
||||
pk = serialization.load_pem_private_key(open(os.path.join(DATA, "mock_keys", "afdian_platform.pem"), "rb").read(), None)
|
||||
content = "%s%s%s%s" % (mo["out_trade_no"], mo["user_id"], mo["plan_id"], mo["total_amount"])
|
||||
sig = base64.b64encode(pk.sign(content.encode(), padding.PKCS1v15(), hashes.SHA256())).decode()
|
||||
body = {"ec": 200, "data": {"type": "order", "order": mo, "sign": sig}}
|
||||
st, resp = req("POST", "/api/notify/afdian", body)
|
||||
n_settle = con.execute("SELECT COUNT(*) FROM pay_events WHERE kind='settle' AND pay_id=? AND result='activated'",
|
||||
(oid + "P1",)).fetchone()[0]
|
||||
dup = con.execute("SELECT COUNT(*) FROM pay_events WHERE kind='settle' AND pay_id=? AND result='dup_trade'",
|
||||
(oid + "P1",)).fetchone()[0]
|
||||
check("同一笔 Webhook 再推一次 → 只激活一次(dup_trade),仍回 ec=200", n_settle == 1 and dup >= 1 and resp.get("ec") == 200,
|
||||
(n_settle, dup, resp))
|
||||
|
||||
# 3. 伪造回调(签名不对)→ 丢弃
|
||||
oid3, tok3, _ = new_order(1)
|
||||
p3 = pay(oid3, tok3, "afdian")["payment"]["pay_id"]
|
||||
demo(kind="afdian_forge", pay_id=p3)
|
||||
time.sleep(0.3)
|
||||
check("伪造 Webhook(签名不对)→ 不激活", view(oid3, tok3)["order"]["state"] == "unpaid")
|
||||
|
||||
# 4. Webhook 丢失 → 对账补上
|
||||
oid4, tok4, _ = new_order(1)
|
||||
afd_pay_link(pay(oid4, tok4, "afdian")["payment"]["display"]["url"], drop=True)
|
||||
time.sleep(2)
|
||||
before = view(oid4, tok4)["order"]["state"]
|
||||
demo(kind="jobs")
|
||||
check("Webhook 丢了 → 定时对账发现并激活", before == "unpaid" and view(oid4, tok4)["order"]["state"] == "waiting", before)
|
||||
|
||||
# 5. 买家把金额改小 → 不激活,进待办
|
||||
oid5, tok5, _ = new_order(3)
|
||||
afd_pay_link(pay(oid5, tok5, "afdian")["payment"]["display"]["url"], amount="0.10")
|
||||
time.sleep(3)
|
||||
td = [t for t in todos() if t["oid"] == oid5]
|
||||
check("实付 ¥0.10 < 应付 ¥18 → 不激活,待办「金额不足」", view(oid5, tok5)["order"]["state"] == "unpaid"
|
||||
and td and td[0]["kind"] == "short", td[:1])
|
||||
r = admin("/api/admin/todo", {"id": td[0]["id"], "action": "confirm", "note": "买家补了差价"})
|
||||
check("后台「确认补齐」→ 订单激活", r.get("ok") and view(oid5, tok5)["order"]["state"] == "waiting", r)
|
||||
|
||||
# 6. 当面付正常:预下单 → 扫码 → 异步通知
|
||||
oid6, tok6, _ = new_order(2)
|
||||
r = pay(oid6, tok6, "alipay")
|
||||
qr = r["payment"]["display"]["qr"]
|
||||
check("当面付预下单 → 返回二维码内容和过期时间", r["ok"] and "/mock/alipay/scan/" in qr
|
||||
and r["payment"]["expire_at"] > 0, r)
|
||||
ali_scan_pay(qr)
|
||||
time.sleep(3)
|
||||
check("当面付付款 → 异步通知验签 → 订单 waiting", view(oid6, tok6)["order"]["state"] == "waiting")
|
||||
|
||||
# 7. 当面付异步通知丢失 → 页面轮询查单发现
|
||||
oid7, tok7, _ = new_order(1)
|
||||
r = pay(oid7, tok7, "alipay")
|
||||
ali_scan_pay(r["payment"]["display"]["qr"], drop=True)
|
||||
time.sleep(2)
|
||||
st, v = req("GET", "/api/pay?pay_id=%s&t=%s" % (r["payment"]["pay_id"], tok7))
|
||||
check("当面付通知丢了 → 页面轮询 trade.query 发现到账", v["order"]["state"] == "waiting")
|
||||
|
||||
# 8. 二维码过期 → 关单;订单超时 → closed;宽限内迟到付款 → 恢复
|
||||
oid8, tok8, _ = new_order(1)
|
||||
p8 = pay(oid8, tok8, "alipay")["payment"]
|
||||
a8 = pay(oid8, tok8, "afdian")["payment"]
|
||||
demo(kind="clock", seconds=16 * 60)
|
||||
pays = {p["pay_id"]: p["state"] for p in view(oid8, tok8)["payments"]}
|
||||
check("二维码 15 分钟没付 → 支付单关闭;爱发电支付单还在", pays[p8["pay_id"]] == "closed"
|
||||
and pays[a8["pay_id"]] == "created", pays)
|
||||
demo(kind="clock", seconds=25 * 3600)
|
||||
check("超过 24 小时没付 → 订单 closed", view(oid8, tok8)["order"]["state"] == "closed")
|
||||
afd_pay_link(a8["display"]["url"])
|
||||
time.sleep(3)
|
||||
check("关闭后宽限期内付了爱发电 → 订单自动恢复为 waiting", view(oid8, tok8)["order"]["state"] == "waiting",
|
||||
[e["kind"] + ":" + e["result"] for e in view(oid8, tok8)["events"][:3]])
|
||||
|
||||
# 9. 两个渠道都付了 → 只激活一次,第二笔进待办
|
||||
oid9, tok9, _ = new_order(1)
|
||||
a9 = pay(oid9, tok9, "afdian")["payment"]
|
||||
q9 = pay(oid9, tok9, "alipay")["payment"]
|
||||
ali_scan_pay(q9["display"]["qr"])
|
||||
time.sleep(3)
|
||||
afd_pay_link(a9["display"]["url"])
|
||||
time.sleep(3)
|
||||
td = [t for t in todos() if t["oid"] == oid9]
|
||||
check("先付支付宝、又付爱发电 → 订单只激活一次,爱发电那笔进待办「重复付款」",
|
||||
view(oid9, tok9)["order"]["state"] == "waiting" and td and td[0]["kind"] == "duplicate", td[:1])
|
||||
r = admin("/api/admin/todo", {"id": td[0]["id"], "action": "refund"})
|
||||
check("爱发电重复付款点退款 → 提示去爱发电后台(没有退款接口)", not r.get("ok") and "爱发电" in r.get("error", ""), r)
|
||||
|
||||
# 10. 风控熔断
|
||||
demo(kind="alipay_risk", on=True)
|
||||
oid10, tok10, _ = new_order(1)
|
||||
r = pay(oid10, tok10, "alipay")
|
||||
v = view(oid10, tok10)
|
||||
ali = [c for c in v["channels"] if c["name"] == "alipay"][0]
|
||||
check("当面付返回风控错误码 → 熔断,页面不再提供支付宝,只剩爱发电", not r["ok"] and not ali["ok"], (r, ali))
|
||||
demo(kind="alipay_risk", on=False)
|
||||
demo(kind="breaker_reset")
|
||||
check("后台恢复熔断后 → 支付宝重新可用",
|
||||
[c for c in view(oid10, tok10)["channels"] if c["name"] == "alipay"][0]["ok"])
|
||||
|
||||
# 11. 买家直接在爱发电店铺下单(没带订单号)→ 按买卡密处理;后台按爱发电订单号认领
|
||||
r = demo(kind="afdian_direct", amount=6)
|
||||
time.sleep(3)
|
||||
ev = con.execute("SELECT COUNT(*) FROM pay_events WHERE kind='card_purchase'").fetchone()[0]
|
||||
check("没带订单号的爱发电成交 → 走「按实付发卡密」,不去猜是哪张单", ev >= 1)
|
||||
oid11, tok11, _ = new_order(1)
|
||||
r2 = admin("/api/admin/claim", {"oid": oid11, "trade_no": r["trade_no"]})
|
||||
check("后台按爱发电订单号认领 → 订单激活", r2.get("ok") and view(oid11, tok11)["order"]["state"] == "waiting", r2)
|
||||
|
||||
# 12. 「付好了没反应?」→ 立即对账
|
||||
oid12, tok12, _ = new_order(1)
|
||||
afd_pay_link(pay(oid12, tok12, "afdian")["payment"]["display"]["url"], drop=True)
|
||||
time.sleep(1.5)
|
||||
st, r = req("POST", "/api/check", {"oid": oid12, "t": tok12})
|
||||
check("买家点「付好了没反应?」→ 当场查到并激活", r.get("found") and view(oid12, tok12)["order"]["state"] == "waiting", r)
|
||||
|
||||
# 13. 鉴权
|
||||
st, _ = req("GET", "/api/admin/overview")
|
||||
check("后台接口没口令 → 403", st == 403)
|
||||
st, _ = req("GET", "/api/order?oid=%s&t=wrong" % oid)
|
||||
check("取件码不对 → 查不到订单", st == 404)
|
||||
st, r = req("POST", "/api/pay", {"oid": oid, "t": tok, "channel": "afdian"})
|
||||
check("已到账的订单不能再建支付单", not r.get("ok"), r)
|
||||
finally:
|
||||
srv.terminate()
|
||||
try:
|
||||
out = srv.communicate(timeout=5)[0].decode()
|
||||
except Exception:
|
||||
out = ""
|
||||
shutil.rmtree(DATA, ignore_errors=True)
|
||||
|
||||
bad = [n for n, ok in RESULTS if not ok]
|
||||
print("\n%d 条,失败 %d 条" % (len(RESULTS), len(bad)))
|
||||
for n in bad:
|
||||
print(" ✗ " + n)
|
||||
if bad and out:
|
||||
print(out[-2000:])
|
||||
sys.exit(1 if bad else 0)
|
||||
+7
-5
@@ -1,17 +1,19 @@
|
||||
# 交付清单(自查用)
|
||||
|
||||
> 生成:2026-10-05 17:30 共 36 个文件 合计 44.9 MB(2026-10-05 第二轮:数据库 store.py、两份测试、回执;后台面板和本机开单页面重写;推送前审查修复)
|
||||
> 生成:2026-10-05 21:54 共 38 个文件 合计 44.9 MB(2026-10-05 晚:内容后台 cms.py + 推送后全量细审的修复)
|
||||
|
||||
| 文件 | 字节 | SHA-256 |
|
||||
|---|---|---|
|
||||
| `README.md` | 8,696 | `5cef368dbf5916def012dbfcf7fdfb35d1f435faf5a7b42b65f6ad683343b1c2` |
|
||||
| `backend-site/admin.py` | 26,020 | `d7f86dcf0b07962ceb55a7714b43c876628118d19159dc3a9215535db1bc47f7` |
|
||||
| `backend-site/admin.py` | 30,382 | `9b4069444b4c1716a6abef22dfada6bcb3171d78c896579457c926a468d734ec` |
|
||||
| `backend-site/cms.py` | 61,942 | `3d5ea3869427f94fbc9a71e464e10b2c275450e617fbc42c9feb68a66b45fde3` |
|
||||
| `backend-site/pngcheck.py` | 4,945 | `ccec7ab21b0399da651029ffa5781bad498e0905b31a1102f6ba3e3f01e8594d` |
|
||||
| `backend-site/server.py` | 181,352 | `438fcd98d57043ee503222b6decc83e873dda2d62c66a8d36f521c7d21e6afed` |
|
||||
| `backend-site/server.py` | 181,993 | `05c0aaa93f5adf39beecb9042313da8233099cee6060013d8f7cbf7fd142788a` |
|
||||
| `backend-site/store.py` | 19,303 | `9d22007b43188225d4254f8c9710c310d9d55635d0d67496ec99e91fe47bcd2d` |
|
||||
| `backend-site/tests/内容后台测试.py` | 24,099 | `9fd44d4aff00c32270fde4347e365781b3fb4b7aca89e024b5b3b252416b9f87` |
|
||||
| `backend-site/tests/回执复现测试.py` | 15,355 | `4529f6076abdfce89bf4406c7fbd0789482deaa595383749580bdc3e08ddc327` |
|
||||
| `backend-site/tests/数据库测试.py` | 16,045 | `9838f32bf213cd3c727625a50b5e0cbff7da98ded8b7452cacd187c448bde04f` |
|
||||
| `backend-site/交接说明.md` | 21,795 | `03b9cb73b27a265c32fc5a36120da0d6d61c2e1d612308cba0221818493cb3f0` |
|
||||
| `backend-site/交接说明.md` | 22,394 | `d226d6613f48343a867e2b5961b3290c3bd8238f3941eeca36b1efc5dd01ac48` |
|
||||
| `backend-site/回执-Claude.md` | 37,690 | `de1648832fe8bcd004c32ed538d4a90c6c29a0d72b8c70f448fdbe5332d8b5d9` |
|
||||
| `backend-tools/chk_worker.ps1` | 486 | `939a42cafa0954347f28d69e75b8af407ed1dab870cc3956fa8b7c5eb55e372f` |
|
||||
| `backend-tools/deploy.py` | 5,694 | `bf2cf47e715a3663faba5f1125ca9dee57596fd59664e2898515985924a0cc8c` |
|
||||
@@ -33,7 +35,7 @@
|
||||
| `backend-tools/ys_worker.py` | 30,465 | `ab6cdff13ce16ed15363c28cf016628b378a1ec255d2b8eeb62566cf38631eb9` |
|
||||
| `backend-tools/交接说明.md` | 15,276 | `5468d47b9f51bb6cca6172db6a61bed209a181814ac662093345d02445305dea` |
|
||||
| `backend-tools/回执-Claude.md` | 11,578 | `d1151810199f0dc585872027870666963e528f7027f12ce146334c5f36f761e4` |
|
||||
| `deploy/nginx-片段.md` | 4,145 | `183179dc694e1f2ac3a791f3c96aa6f7d292b1968276ae1af4d850e26fbf78d0` |
|
||||
| `deploy/nginx-片段.md` | 5,696 | `7ec0cc36e69d62025b240312bb604cb088c77a0a40337623e01f9bc0e5dbdca7` |
|
||||
| `他应该知道的.md` | 6,988 | `177f08cb455bf5cf4b299abda5b227ff530c1da634c69f81c8ca7498ccc00cbe` |
|
||||
| `回执模板.md` | 5,049 | `0e38a6c19dff7b55767b8998d294b0252aa6024053dad0c63956ddd58b56a07a` |
|
||||
| `模板/1站立正反.blend` | 16,486,783 | `985dc61aeaa6eaaf5dc87ccbba6dfd4e1c5eb95468f7d0a9610d47aff14cb9dc` |
|
||||
|
||||
+365
@@ -0,0 +1,365 @@
|
||||
# 收款流程重构:从「半自动」到全自助
|
||||
|
||||
> 金钻工坊 · 自助模板渲染 · 设计文档
|
||||
> 版本 v1 · 2026-10-07 · 状态:设计稿(正式站代码未改动) · 范围:网页下单的付款与履约
|
||||
> 在线版(页面,内容相同):https://claude.ai/artifact/ErKjgvjU9fBipacGpuURuQ
|
||||
|
||||
## 目录
|
||||
|
||||
- [00 概要与决策](#00-概要与决策)
|
||||
- [01 总体架构](#01-总体架构)
|
||||
- [02 ① 支付渠道抽象层](#02--支付渠道抽象层)
|
||||
- [03 ② 爱发电主通道:全自动流程](#03--爱发电主通道全自动流程)
|
||||
- [04 ③ 当面付辅助通道](#04--当面付辅助通道)
|
||||
- [05 ④ 订单状态机](#05--订单状态机)
|
||||
- [06 ⑤ 对账与超时关单](#06--对账与超时关单)
|
||||
- [07 ⑥ 异常与人工兜底](#07--异常与人工兜底)
|
||||
- [08 付款区交互](#08-付款区交互)
|
||||
- [09 迁移与删除项](#09-迁移与删除项)
|
||||
- [10 分阶段实施](#10-分阶段实施)
|
||||
- [11 待金钻确认](#11-待金钻确认)
|
||||
- [附 原型(测试环境)](#附-原型测试环境)
|
||||
|
||||
---
|
||||
|
||||
## 00 概要与决策
|
||||
|
||||
**目标**:买家下单、付款、开始渲染,全程不需要金钻动手。人工只处理系统判断不了的异常,比如金额不对、重复付款、迟到很久的付款。
|
||||
|
||||
| 通道 | 说明 |
|
||||
|---|---|
|
||||
| **主通道 · 爱发电专链** | 合规、已开通。买家跳到爱发电付款;系统靠回调 + 主动对账自动确认到账。手续费约 6%。 |
|
||||
| **辅助通道 · 支付宝当面付** | 页面内直接显示二维码,扫码即付,到账秒级确认。手续费 0.6%。线上使用属于场景错配,有风控风险(见第 04 节)。 |
|
||||
|
||||
> **决策记录**:支付宝当面付官方定位是线下面对面收银,用在网站上可能被风控限额或关闭支付权限。金钻已知悉此风险,决定作为辅助通道使用,风险自担。设计上的应对:爱发电始终可用;当面付出现异常自动熔断、隐藏,不影响下单。
|
||||
|
||||
### 五条设计原则
|
||||
|
||||
- **到账只有一个入口。** 不管哪个渠道、回调还是对账,确认到账都调用同一个 `settle_payment()`,由它负责核对金额、去重、激活订单。
|
||||
- **先验真,再履约。** 回调内容一律不直接信:爱发电要验签并用接口精确反查;当面付要验 RSA2 签名并核对金额和应用号。
|
||||
- **天然幂等。** 同一笔渠道流水号只能入账一次;重复回调、回调和对账同时到达,都不会激活两次。
|
||||
- **回调会丢,所以要主动对账。** 后台定时查渠道,把漏掉的到账补上。
|
||||
- **订单内容和付款分开。** 订单记录买家要什么,支付单记录钱的往来。一张订单可以有多次付款尝试,比如换了渠道或二维码过期重来。
|
||||
|
||||
---
|
||||
|
||||
## 01 总体架构
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
B[买家·订单页] -->|1 提交订单| O[订单服务]
|
||||
O -->|2 选渠道 建支付单| G[渠道抽象层]
|
||||
G --> A[爱发电渠道]
|
||||
G --> Z[当面付渠道]
|
||||
A -->|专链 / 专链二维码| B
|
||||
Z -->|收款二维码| B
|
||||
A -.回调.-> N[回调入口]
|
||||
Z -.异步通知.-> N
|
||||
R[定时对账] -->|主动查单| A
|
||||
R -->|主动查单| Z
|
||||
B -->|轮询 / 付好了没反应| P[查单接口]
|
||||
P --> Z
|
||||
P --> A
|
||||
N --> S{{settle_payment 统一到账}}
|
||||
R --> S
|
||||
P --> S
|
||||
S -->|金额够·首次| ACT[激活订单 进渲染队列]
|
||||
S -->|金额不足·重复·迟到太久| TODO[后台待办 人工]
|
||||
```
|
||||
|
||||
下单内容(皮肤、模板、分辨率)、渲染机、确认收货、卡密下单这条路都**不变**。卡密本身就是已付款凭证,它的订单直接进入 `waiting`,不经过本设计的付款环节。
|
||||
|
||||
---
|
||||
|
||||
## 02 ① 支付渠道抽象层
|
||||
|
||||
每个渠道是一个独立模块,实现同一组接口。下单流程、状态机、对账任务只认这组接口,不关心具体是哪个渠道。以后加微信、个体户的官方网站支付、或者聚合支付,只需要新写一个模块。
|
||||
|
||||
| 接口 | 作用 | 爱发电实现 | 当面付实现 |
|
||||
|---|---|---|---|
|
||||
| `create(order, pay)` | 生成付款方式 | 拼专链:`order/create?user_id&custom_price&custom_order_id=pay_id&remark`,返回跳转链接 + 同一链接的二维码 | 调 `alipay.trade.precreate`,带 `out_trade_no=pay_id`、金额、`time_expire`、`notify_url`,返回 `qr_code` |
|
||||
| `verify_notify(req)` | 把回调变成「可信的到账事实」或拒绝 | 验 `data.sign`(官方公钥)→ 用 `out_trade_no` 调 `query-order` 精确反查 → 以反查结果为准 | 验 RSA2 签名(支付宝公钥)→ 核对 `app_id`、`out_trade_no` 存在、`trade_status` |
|
||||
| `query(pay)` | 主动查一笔支付单 | 扫最近的订单页,按 `custom_order_id` 找 | `alipay.trade.query` |
|
||||
| `close(pay)` | 关闭过期支付单 | 无法远程关闭,只在本地标记过期(迟到付款靠对账收回) | `alipay.trade.close`(未扫码的单可能返回「交易不存在」,视为已关) |
|
||||
| `refund(pay, amt)` | 退款(只在后台人工触发) | 不支持接口退款,提示去爱发电后台操作 | `alipay.trade.refund` |
|
||||
| `health()` | 渠道是否可用 | 配置齐全即可用 | 配置齐全且未熔断 |
|
||||
|
||||
### 统一到账入口 settle_payment()
|
||||
|
||||
```text
|
||||
settle_payment(channel, pay_id, trade_no, amount_paid, source)
|
||||
1. 在一个数据库事务里锁住这条支付单
|
||||
2. trade_no 已入账过 → 直接返回「已处理」(幂等)
|
||||
3. 支付单状态是 paid → 记为「重复付款」,进待办,返回
|
||||
4. amount_paid < amount_due → 支付单记 mismatch,进待办「金额不足」,返回
|
||||
5. 支付单记 paid(写 trade_no、实付、时间、来源)
|
||||
6. 看订单状态:
|
||||
unpaid → 激活:订单转 waiting,进渲染队列
|
||||
closed 且在宽限期内 → 恢复并激活(内容还在)
|
||||
closed 超过宽限期 → 进待办「迟到付款」,人工补单或退款
|
||||
已经是 waiting 之后 → 进待办「重复付款」(另一渠道已付过)
|
||||
7. 其他同一订单的未付支付单 → 关闭(当面付调 close)
|
||||
```
|
||||
|
||||
`source` 只用于留痕:`notify` / `reconcile` / `poll` / `buyer_check` / `admin`。
|
||||
|
||||
### 新增数据
|
||||
|
||||
| 表 | 字段 | 说明 |
|
||||
|---|---|---|
|
||||
| `payments` 支付单 | `pay_id`(主键,如 `YS7ZBZW6P1`)、`oid`、`channel`、`amount_due`、`state`、`created_at`、`expire_at`、`trade_no`(唯一)、`amount_paid`、`paid_at`、`last_query_at`、`note` | 一张订单可以有多条;`trade_no` 加唯一约束,是幂等的最后防线 |
|
||||
| `pay_events` 流水 | 时间、渠道、类型(notify/query/close/refund)、关联 pay_id、结果、原文摘要(截断 4KB) | 只追加不修改,用于对账和申诉 |
|
||||
| `pay_todo` 待办 | 类型、pay_id / 渠道流水号、金额、说明、处理人、处理结果 | 开单后台的「支付待办」列表 |
|
||||
|
||||
密钥(爱发电 token 与公钥、支付宝应用私钥与支付宝公钥)只放服务器配置文件,权限 600,不进仓库、不进前端。
|
||||
|
||||
---
|
||||
|
||||
## 03 ② 爱发电主通道:全自动流程
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant B as 买家
|
||||
participant S as 我方服务器
|
||||
participant F as 爱发电
|
||||
B->>S: 选「爱发电」付款
|
||||
S->>S: 建支付单 pay_id,应付金额锁定
|
||||
S-->>B: 专链(手机直接跳;电脑显示专链二维码)
|
||||
B->>F: 打开专链付款(custom_order_id = pay_id)
|
||||
F-->>S: Webhook 推送(可能延迟或丢失)
|
||||
S->>S: 验签 data.sign
|
||||
S->>F: query-order 按 out_trade_no 精确反查
|
||||
F-->>S: 订单详情(status、金额、custom_order_id)
|
||||
S->>S: settle_payment → 激活订单
|
||||
S-->>F: 回应 ec=200
|
||||
loop 页面可见时每 3 秒
|
||||
B->>S: 查订单状态
|
||||
end
|
||||
S-->>B: 已到账 · 排队中
|
||||
```
|
||||
|
||||
1. **生成专链。** 链接带 `custom_price`(本单应付)、`custom_order_id`(支付单号 pay_id)、`remark`(订单号,给买家和金钻看)。需要一个「自选金额」方案承载 `custom_price`。
|
||||
2. **展示。** 手机端直接跳转;电脑端显示专链二维码(本地生成,不用第三方二维码服务),手机扫码打开爱发电付款。买家回到订单页时页面开始轮询。
|
||||
3. **回调先落流水、马上回 200。** 收到推送后先写 `pay_events`,然后返回 `{"ec":200,"em":""}`。后续处理失败不影响这次应答,由对账补救。
|
||||
4. **验签。** 用爱发电官方公钥验 `data.sign`(2025 年 7 月起提供;待签字符串为 `out_trade_no + user_id + plan_id + total_amount`,SHA256,Base64)。验签失败直接丢弃,记流水。暂时拿不到公钥时,跳过这一步,以下一步为准。
|
||||
5. **精确反查。** 调用 `query-order` 并带 `out_trade_no`(接口支持按订单号查,不再翻页找)。之后**只用反查结果**里的状态、金额、`custom_order_id`。
|
||||
6. **认单。** `status == 2` 且 `custom_order_id` 对应得上本地支付单,调用 `settle_payment()`。
|
||||
没有 `custom_order_id`(买家直接在爱发电店铺下单,或用了旧链接),按现有逻辑当作购买卡密:按实付金额发码,通过爱发电自动回复给买家。**不再**用留言或金额唯一匹配去猜是哪张网页单。
|
||||
7. **金额闸门。** 买家可以在爱发电页面手动改金额,所以实付必须 ≥ 应付,否则支付单记为 mismatch,进待办。
|
||||
|
||||
---
|
||||
|
||||
## 04 ③ 当面付辅助通道
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant B as 买家
|
||||
participant S as 我方服务器
|
||||
participant A as 支付宝
|
||||
B->>S: 选「支付宝扫码」
|
||||
S->>S: 熔断检查 · 金额上限检查 · 建支付单
|
||||
S->>A: alipay.trade.precreate(out_trade_no=pay_id,time_expire=+15分钟)
|
||||
A-->>S: qr_code
|
||||
S-->>B: 页面显示二维码 + 15 分钟倒计时
|
||||
B->>A: 支付宝扫码付款
|
||||
par 异步通知
|
||||
A-->>S: notify(RSA2 签名)
|
||||
S->>S: 验签 → settle_payment → 回 "success"
|
||||
and 页面轮询
|
||||
loop 每 3 秒
|
||||
B->>S: 查支付单
|
||||
S->>A: trade.query(每单最多 5 秒查一次)
|
||||
end
|
||||
end
|
||||
S-->>B: 已到账 · 排队中
|
||||
```
|
||||
|
||||
1. **预下单。** 先检查熔断状态和金额上限(个人基础版单笔 ≤1000 元,建议再保守一点设 500 元,超过的只给爱发电)。调 `alipay.trade.precreate`,商品名统一写成中性文案,如「金钻工坊 渲染服务」,加订单号。
|
||||
2. **出码。** `qr_code` 在前端本地画成二维码,配 15 分钟倒计时;过期后显示「重新生成」,生成新支付单并关闭旧的。手机端加一个「打开支付宝付款」按钮,跳到支付宝扫这个码(不保证所有浏览器都能拉起,按钮仅作方便)。
|
||||
3. **异步通知。** 验 RSA2 签名 → 核对 `app_id`、`out_trade_no` 是本地支付单、`total_amount` 等于应付 → `trade_status` 为 `TRADE_SUCCESS` 或 `TRADE_FINISHED` 时调 `settle_payment()` → 回纯文本 `success`。验签失败回其他内容,支付宝会重试。
|
||||
4. **轮询查单。** 页面可见时每 3 秒问一次服务器;服务器对同一笔支付单最多每 5 秒调一次 `trade.query`,查到成功同样走 `settle_payment()`。页面切到后台就停轮询,回来立刻查一次。
|
||||
5. **过期关单。** 到期后先最后查一次,确认没付再 `trade.close`,本地记 closed。
|
||||
|
||||
### 线上使用的风控注意事项
|
||||
|
||||
- **场景错配。** 当面付是线下收银产品,签约时也按线下门店审核。线上使用可能被判场景不符,表现为:交易被拦、限额下调、要求补充材料,严重的关闭当面付权限,甚至影响支付宝账户。
|
||||
- **额度。** 无营业执照的基础版单笔 ≤1000 元、单日 ≤5 万元。
|
||||
- **资金。** 被风控时可能冻结一段时间的收款,要有心理准备,不能把它当唯一收款方式。
|
||||
|
||||
### 降低风险的做法
|
||||
|
||||
- **爱发电永远在。** 付款区默认推荐爱发电,当面付作为「也可以用支付宝扫码」的备选。
|
||||
- **自动熔断。** 预下单或查单连续失败 3 次,或返回风控、权限类错误码(如 `ACQ.ACCESS_FORBIDDEN`、`ACQ.SELLER_BEEN_BLOCKED` 一类),自动关闭当面付 6 小时,页面隐藏这个选项并通知金钻;之后由后台手动恢复。
|
||||
- **控制节奏。** 同一买家(同一 IP 或同一订单)10 分钟内最多生成 3 个二维码;全站同时未付款的当面付二维码不超过 20 个,超过就只给爱发电。
|
||||
- **控制金额。** 设单笔上限(建议 500 元),大单只走爱发电。
|
||||
- **交易信息真实一致。** 商品名、金额、订单号都是真实的,不伪装成线下消费;不使用营销类字眼。
|
||||
- **留证。** 每笔交易保留订单号、皮肤、成品和小票,被要求补材料或申诉时拿得出交易真实性证明。
|
||||
- **定期提现。** 当面付的钱实时进入支付宝余额,定期转出,降低冻结时的损失。
|
||||
|
||||
---
|
||||
|
||||
## 05 ④ 订单状态机
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> unpaid: 网页下单提交
|
||||
[*] --> waiting: 卡密下单提交
|
||||
unpaid --> waiting: 到账(settle_payment)
|
||||
unpaid --> closed: 超过 24 小时未付
|
||||
unpaid --> void: 后台注销
|
||||
closed --> waiting: 宽限期内迟到付款
|
||||
waiting --> working: 渲染机领单
|
||||
working --> done: 全部出图
|
||||
working --> failed: 渲染失败
|
||||
working --> waiting: 渲染机掉线回收
|
||||
failed --> waiting: 免费重渲 / 后台重试
|
||||
done --> waiting: 免费重渲(确认收货前)
|
||||
done --> [*]: 开放下载满 72 小时,卡密核销
|
||||
```
|
||||
|
||||
| 状态 | 含义 | 买家看到 | 变化 |
|
||||
|---|---|---|---|
|
||||
| `unpaid` | 已提交,等付款 | 付款区:渠道选择 / 二维码 / 倒计时 | 不变 |
|
||||
| `closed` | 超时未付,自动关闭;内容保留到清理期 | 「订单已关闭,重新下单」;宽限期内付款仍会自动恢复 | **新增** |
|
||||
| `void` | 后台人工注销 | 「订单已注销」 | 不变 |
|
||||
| `waiting` | 已付款(或卡密),排队 | 排队位置 | 不变 |
|
||||
| `working` / `done` / `failed` | 渲染流水线 | 同现在 | 不变 |
|
||||
| `paid` | 旧:买家申报「已付」等人工确认 | — | **删除**,改为订单上的标记 `buyer_claim_at`,只用于触发立即对账和提醒金钻 |
|
||||
|
||||
确认收货(`accepted`)、直发(`direct`)、免费重渲已用(`redo_used`)仍然是订单上的标记,不是状态。
|
||||
|
||||
### 支付单状态
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> created: 建单
|
||||
created --> paid: 到账且金额够
|
||||
created --> mismatch: 到账但金额不足
|
||||
created --> closed: 过期 / 订单已在别的渠道付过
|
||||
closed --> paid: 迟到付款(对账发现)
|
||||
paid --> refunded: 后台退款
|
||||
mismatch --> paid: 人工确认补齐
|
||||
mismatch --> refunded: 人工退款
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 06 ⑤ 对账与超时关单
|
||||
|
||||
服务器内一个后台调度线程(或 systemd 定时器调用 `admin.py`),每分钟运行一轮。每个任务各自加锁,同一时间只跑一个实例。
|
||||
|
||||
| 任务 | 频率 | 做什么 |
|
||||
|---|---|---|
|
||||
| 爱发电对账 | 有未结爱发电支付单时每 60 秒 | 从第一页往后拉 `query-order`,直到早于最老的未结支付单;按 `custom_order_id` 匹配,命中就 `settle_payment(source=reconcile)` |
|
||||
| 当面付补查 | 每 60 秒 | 对创建超过 1 分钟、30 秒内没查过的未结支付单调 `trade.query` |
|
||||
| 支付单过期 | 每 60 秒 | 到期的支付单最后查一次 → 没付就 `close`,记 closed |
|
||||
| 订单超时关闭 | 每 5 分钟 | `unpaid` 超过 24 小时且没有活跃支付单 → 订单转 `closed` |
|
||||
| 迟到付款扫描 | 每 10 分钟 | 对最近 72 小时内关闭的支付单再做一次对账,抓迟到付款 |
|
||||
| 日对账 | 每天 04:00 | 前一天两个渠道的成交笔数和金额 vs 本地 paid 支付单,有差异进待办 |
|
||||
|
||||
### 时间参数(可配置)
|
||||
|
||||
| 参数 | 建议值 | 说明 |
|
||||
|---|---|---|
|
||||
| 当面付二维码有效期 | 15 分钟 | 写进 `time_expire`,到期关单 |
|
||||
| 爱发电支付单有效期 | 2 小时 | 本地标记;过期后付款仍能被对账收回 |
|
||||
| 订单待付款保留 | 24 小时 | 之后转 `closed` |
|
||||
| 迟到付款宽限 | 关闭后 72 小时 | 宽限内到账自动恢复并激活;超过进待办 |
|
||||
| 页面轮询 | 3 秒,页面可见时 | 当面付二维码页最长 15 分钟;爱发电回到页面后最长 10 分钟 |
|
||||
|
||||
---
|
||||
|
||||
## 07 ⑥ 异常与人工兜底
|
||||
|
||||
所有需要人工的情况都进开单后台的「支付待办」,带上订单号、渠道流水号、应付和实付金额,以及推荐操作。
|
||||
|
||||
| 场景 | 系统自动做 | 人工做 |
|
||||
|---|---|---|
|
||||
| 回调丢失或延迟 | 【自动】对账补上 | 无 |
|
||||
| 伪造回调 | 【自动】验签失败或反查不到,丢弃并记流水 | 无 |
|
||||
| 买家点「付好了没反应」 | 【自动】立即对账一次;仍未找到,提示稍等并显示「呼叫金钻」 | 收到呼叫后在待办里核对 |
|
||||
| 金额不足(买家改了金额) | 【自动】不激活,支付单记 mismatch,页面提示差额 | 【人工】补差价后确认,或退款 |
|
||||
| 重复付款(两个渠道都付了 / 付了两次) | 【自动】只激活一次,第二笔进待办 | 【人工】退款:当面付后台一键退;爱发电去爱发电后台退 |
|
||||
| 订单关闭后付款(宽限内) | 【自动】恢复订单并激活 | 无 |
|
||||
| 订单关闭后付款(超过宽限) | 进待办 | 【人工】内容还在就手动激活,否则退款或联系买家 |
|
||||
| 爱发电成交没有 custom_order_id | 【自动】按购买卡密处理:按实付发码 | 实付不足一张时人工处理 |
|
||||
| 当面付被风控 / 接口连续失败 | 【自动】熔断 6 小时,页面隐藏,只剩爱发电 | 【人工】查看支付宝通知,处理后在后台恢复 |
|
||||
| 日对账有差异 | 进待办,列出差异明细 | 【人工】逐笔核对 |
|
||||
|
||||
### 开单后台新增
|
||||
|
||||
- 「支付待办」列表:确认补齐、退款(当面付)、手动激活、忽略并备注。
|
||||
- 「按渠道流水号认领」:输入爱发电订单号或支付宝交易号,指定到某张订单(取代现在买家自己填爱发电订单号的旧入口)。
|
||||
- 渠道开关:当面付熔断状态、手动关闭 / 恢复。
|
||||
- 保留现有「手动激活」,作为最后手段。
|
||||
|
||||
---
|
||||
|
||||
## 08 付款区交互
|
||||
|
||||
1. 提交订单后,付款区显示应付金额,以及两个选项:「爱发电付款(推荐)」和「支付宝扫码」。当面付熔断或金额超限时,只显示爱发电。
|
||||
2. 选爱发电:手机直接跳转;电脑显示专链二维码,并附「在本机打开」的链接。
|
||||
3. 选支付宝:显示二维码和倒计时;过期后显示「重新生成」。
|
||||
4. 付款期间页面自动轮询,到账后直接切到「已到账 · 排队中」,不需要买家点任何按钮。
|
||||
5. 「我已经付好了」改成「付好了没反应?」:点了立即对账,找不到再给「呼叫金钻」。
|
||||
6. 订单页始终能看到订单号和取件链接;不再附送未激活的卡密。
|
||||
|
||||
---
|
||||
|
||||
## 09 迁移与删除项
|
||||
|
||||
### 迁移
|
||||
|
||||
- 上线时现存的 `unpaid` 订单:为每单补建一条爱发电支付单,`pay_id` 就用订单号本身(旧专链里的 `custom_order_id` 本来就是订单号),老链接付款照样能对上。
|
||||
- 现存的 `paid` 订单(买家申报过):全部列进待办,人工逐笔核对后激活或关闭。
|
||||
- 已有的爱发电账本(`payplatform-orders`)保留只读,作为历史对账依据。
|
||||
|
||||
### 删除
|
||||
|
||||
- 回调里的「留言含兑换码」「留言含订单号」「金额唯一匹配」三层猜测。
|
||||
- 网页单提交时生成的未激活卡密(凭证统一为订单号 + 取件码)。
|
||||
- 没有页面在用的旧接口 `/api/activate`、`/api/activate-payplatform`。
|
||||
- 订单状态 `paid`。
|
||||
|
||||
---
|
||||
|
||||
## 10 分阶段实施
|
||||
|
||||
| 阶段 | 内容 | 上线标准 |
|
||||
|---|---|---|
|
||||
| 一 · 骨架 + 爱发电全自动 | 支付单与流水表、渠道接口、`settle_payment()`、爱发电验签和精确反查、对账任务、超时关单、`closed` 状态、页面轮询、迁移脚本 | 测试覆盖:重复回调、回调丢失、伪造回调、金额不足、重复付款、迟到付款、并发到账;在测试环境用真实小额爱发电订单跑通一次 |
|
||||
| 二 · 当面付 | 当面付渠道、二维码页、异步通知、轮询查单、关单、熔断、节奏和金额限制 | 先用支付宝沙箱跑通全部用例,再用正式应用付 0.01 元验证一次后开放 |
|
||||
| 三 · 后台与清理 | 支付待办、按流水号认领、退款按钮、渠道开关、日对账报告;删除旧逻辑和旧接口 | 后台各操作都有确认步骤和操作记录 |
|
||||
|
||||
每个阶段沿用现在的上线方式:先备份,队列为空时重启;前端单独上线,可随时回滚。
|
||||
|
||||
---
|
||||
|
||||
## 11 待金钻确认
|
||||
|
||||
1. 爱发电开发者后台的签名公钥(验签用),并确认有一个「自选金额」方案可承载 `custom_price`。
|
||||
2. 支付宝开放平台当面付应用:AppID、应用私钥(服务器生成后由他上传公钥)、支付宝公钥、异步通知地址。
|
||||
3. 时间参数是否按建议值:二维码 15 分钟、订单保留 24 小时、迟到宽限 72 小时。
|
||||
4. 当面付单笔上限:建议 500 元。
|
||||
5. 付款区默认推荐哪个渠道:建议爱发电。
|
||||
6. 现存的「已申报付款」订单由谁、何时核对。
|
||||
|
||||
---
|
||||
|
||||
## 附 原型(测试环境)
|
||||
|
||||
为验证上面的流程,按本设计做了一个可运行原型。**它只是测试环境,和正式站完全隔离:**
|
||||
|
||||
- 部署在甲骨文预览机(161.33.11.66),不在正式服务器上;正式站的下单、付款代码和数据都没有改动。
|
||||
- 爱发电、支付宝的账号与密钥全部是占位符,所有付款请求都发往原型内置的模拟网关,不连真实渠道、不会产生真实交易。
|
||||
- 原型有自己独立的 SQLite 数据库,不读写正式站的订单和卡密。
|
||||
- 后续开发也只在预览机上进行,不碰生产。
|
||||
|
||||
| 项 | 位置 |
|
||||
|---|---|
|
||||
| 付款页 | http://161.33.11.66/pay-proto/ |
|
||||
| 后台 | http://161.33.11.66/pay-proto/admin(口令在预览机 `/var/lib/jz-pay-proto/admin_token`) |
|
||||
| 代码 | 仓库 `backend/pay-proto/`(说明见其中 `README.md`) |
|
||||
| 测试 | `python3 backend/pay-proto/tests/test_proto.py`,24 个场景 |
|
||||
|
||||
依据:爱发电开发者文档(Webhook 无保证送达、需幂等并配合 query-order;2025-07 起 `data.sign` 可用官方公钥验签;下单链接支持 `custom_order_id` / `custom_price` / `remark`);支付宝开放平台当面付文档(precreate / query / close / 异步通知 RSA2 验签;产品定位为线下收银)。
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
/* 内容文件:由内容后台发布时生成(这是第一版:从网站原有内容导入)。别手改:下次发布会被覆盖。改内容请用内容后台。 */
|
||||
window.JZ_ORDER = {"v":1,"head":"传一张皮肤,选个模板,等一会儿就能拿到渲染图。","notice":{"on":false,"text":""},"templates":[{"k":"stand","n":"站立正反","s":"正面站立 · 干净背景","on":true},{"k":"standb","n":"站立正反(虚化)","s":"同款 + 景深虚化","on":true},{"k":"wheat","n":"麦田萤火","s":"麦田 · 暖光 · 萤火","on":true},{"k":"beach","n":"海边自拍","s":"海面 · 天光","on":true},{"k":"boom","n":"不看爆炸","s":"身后爆炸 · 不回头","on":true},{"k":"sakura","n":"飞跃樱花林","s":"樱花 · 动态","on":true},{"k":"airship","n":"空艇巡游","s":"飞空艇 · 巡航","on":true}]};
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"v": 1,
|
||||
"head": "传一张皮肤,选个模板,等一会儿就能拿到渲染图。",
|
||||
"notice": {
|
||||
"on": false,
|
||||
"text": ""
|
||||
},
|
||||
"templates": [
|
||||
{
|
||||
"k": "stand",
|
||||
"n": "站立正反",
|
||||
"s": "正面站立 · 干净背景",
|
||||
"on": true
|
||||
},
|
||||
{
|
||||
"k": "standb",
|
||||
"n": "站立正反(虚化)",
|
||||
"s": "同款 + 景深虚化",
|
||||
"on": true
|
||||
},
|
||||
{
|
||||
"k": "wheat",
|
||||
"n": "麦田萤火",
|
||||
"s": "麦田 · 暖光 · 萤火",
|
||||
"on": true
|
||||
},
|
||||
{
|
||||
"k": "beach",
|
||||
"n": "海边自拍",
|
||||
"s": "海面 · 天光",
|
||||
"on": true
|
||||
},
|
||||
{
|
||||
"k": "boom",
|
||||
"n": "不看爆炸",
|
||||
"s": "身后爆炸 · 不回头",
|
||||
"on": true
|
||||
},
|
||||
{
|
||||
"k": "sakura",
|
||||
"n": "飞跃樱花林",
|
||||
"s": "樱花 · 动态",
|
||||
"on": true
|
||||
},
|
||||
{
|
||||
"k": "airship",
|
||||
"n": "空艇巡游",
|
||||
"s": "飞空艇 · 巡航",
|
||||
"on": true
|
||||
}
|
||||
],
|
||||
"prices": {
|
||||
"per": 6.0,
|
||||
"tiers": []
|
||||
},
|
||||
"pay": {
|
||||
"payplatform": "",
|
||||
"payplatform_uid": "",
|
||||
"qr_img": "",
|
||||
"note": ""
|
||||
}
|
||||
}
|
||||
+760
-248
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>关于 · 金钻客栈</title>
|
||||
<meta name="description" content="金钻客栈是谁做的,用了哪些开源的东西。">
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<meta name="theme-color" content="#0D1020" media="(max-width: 760px) and (prefers-color-scheme: dark)">
|
||||
<link rel="icon" href="assets/gem.webp" type="image/webp">
|
||||
<link rel="preload" href="fonts/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="fonts/fusion-pixel-12.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=6">
|
||||
</head>
|
||||
<body data-page="about">
|
||||
<div class="jz-boot" id="jzBoot" aria-hidden="true"><div class="jz-boot-in"><canvas class="jz-boot-gem" width="168" height="168"></canvas><b class="jz-boot-name">金钻客栈</b><i class="jz-boot-bar"><i></i></i></div></div>
|
||||
<script>/* 加载动画:同一个标签页里只在第一次打开时放;系统要求「减少动效」就不放 */
|
||||
try{if(sessionStorage.getItem('jz-boot')||matchMedia('(prefers-reduced-motion: reduce)').matches){document.getElementById('jzBoot').remove()}else{document.documentElement.classList.add('booting')}}catch(e){document.getElementById('jzBoot').remove()}</script>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html">画展</a><a href="tools.html">工具与开源</a><a href="universe.html">金钻宇宙</a><a href="links.html">平台入口</a><a href="about.html" aria-current="page">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="/order/"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="admin/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head"><div class="zone num" aria-hidden="true" style="--zc:#E0533D;--zc2:#E8913A">05</div><div><h1>关于</h1><p>这个站是谁做的,用了哪些开源的东西。</p></div><div class="meta"><b>v3</b></div></div>
|
||||
<div class="about-grid">
|
||||
<article class="letter crystal"><h2>名字的由来</h2><div id="aStory"></div><div class="sign"><i class="gem-img" aria-hidden="true"></i>金钻</div></article>
|
||||
<div class="credits" id="aCredits"></div>
|
||||
</div>
|
||||
<p class="note" id="aFoot" style="margin-top:22px"></p>
|
||||
</main>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="/order/"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" aria-current="page" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a></div></footer>
|
||||
<script src="assets/site-info.js?v=5"></script>
|
||||
<!-- 网站内容:内容后台发布时生成 content/site.js(window.JZ_CONTENT) -->
|
||||
<script src="content/site.js"></script>
|
||||
<script>/* 预览草稿:内容后台点「预览」会带 ?preview=1 打开;只有登录了内容后台的浏览器拿得到草稿(拿不到就还是正式内容) */
|
||||
if(/[?&]preview=1(&|$)/.test(location.search)) document.write('<script src="/order/api/cms/draft.js"><\/script>');</script>
|
||||
<script src="assets/pages.js?v=5"></script>
|
||||
<script src="assets/site.js?v=5"></script>
|
||||
<script src="assets/boot.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,999 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN"><head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<meta name="referrer" content="same-origin">
|
||||
<title>金钻客栈 · 内容后台</title>
|
||||
<style>
|
||||
/* 金钻客栈 · 内容后台(2026-10-05)
|
||||
网站上所有展示内容在这里改:改动先存草稿(网站上看不到)→ 预览 → 发布。每次发布留一版,能一键回滚。
|
||||
接口:/order/api/cms/*(server.py → cms.py)。样子跟网站 / 开单后台同一套:白光 + 毛玻璃卡片 + MC 方块按钮 + 像素标题。 */
|
||||
@font-face{font-family:'JZ Pixel';src:url('pixel.woff2') format('woff2');font-display:swap}
|
||||
:root{--bg:#F5F7FB;--txt:#1E2440;--txt-2:#454B6B;--txt-3:#5E6482;--dim:#7E849C;
|
||||
--line:rgba(30,36,64,.13);--line-soft:rgba(30,36,64,.08);
|
||||
--glass:linear-gradient(160deg,rgba(255,255,255,.9),rgba(255,255,255,.7));
|
||||
--panel-shadow:inset 0 1px 0 #fff,0 22px 44px -28px rgba(100,110,190,.38);
|
||||
--mc:#3C8527;--mc-hi:#5BAA3C;--mc-lo:#1D4D13;--ok-t:#2F6E1F;
|
||||
--stone:#F3F4F6;--stone-lo:#B4B7BE;--stone-edge:#9EA2AA;
|
||||
--bad:#D2483A;--bad-t:#B33A2E;--warn-t:#9A6A0C;--info-t:#2D5BB8;
|
||||
--ease:cubic-bezier(.23,1,.32,1);
|
||||
--font:system-ui,-apple-system,"PingFang SC","Microsoft YaHei","Segoe UI",sans-serif;
|
||||
--pixel:'JZ Pixel',var(--font);
|
||||
--mono:ui-monospace,Consolas,"SF Mono",Menlo,monospace;color-scheme:light}
|
||||
*{box-sizing:border-box}
|
||||
[hidden]{display:none!important}
|
||||
html{-webkit-text-size-adjust:100%}
|
||||
body{margin:0;min-height:100vh;background:var(--bg);color:var(--txt);font:14px/1.6 var(--font);-webkit-font-smoothing:antialiased}
|
||||
body::before{content:"";position:fixed;inset:0;z-index:-1;pointer-events:none;background:
|
||||
radial-gradient(40% 34% at 6% 0%,rgba(150,215,255,.30),transparent 70%),radial-gradient(36% 30% at 100% 8%,rgba(255,176,204,.22),transparent 70%),
|
||||
radial-gradient(48% 38% at 72% 100%,rgba(255,214,150,.22),transparent 70%),radial-gradient(42% 36% at 0% 72%,rgba(170,235,200,.22),transparent 70%)}
|
||||
button,input,select,textarea{font:inherit;color:inherit}
|
||||
svg.i{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
||||
.gem{display:inline-block;width:30px;height:30px;flex:none;background:url("data:image/webp;base64,UklGRlANAABXRUJQVlA4WAoAAAAQAAAAxwAAxwAAQUxQSDoCAAABkOv/kyIp1T3DXYQ7xOchb6EZhETruzgp5O6PQLiOPcTJWoR7aNHJ9HRVNDV314LuZyNiAsCOIdxWK8rIFXUHQvDIEO5STEbGdM8/lBlqmJgMuOPBPXPuB+MBV7oo7XVzboDz7zUbzeRW4w2hGUhvG61mcqN530XvyMrvXbQURzFXm4MxN4o7LuqRJutq6g9FEWHKvp0GYUphp9RLduqA/QXsKJaKJWbxC6F9kL4WS8xiqbgThH0kzJKD50DaaDJSkeKinVBxIxVN2WkKCcmpSDg98t8/CQATLpoEKwZwatAZMPsvycGv+gNmZ3AaAjNCKJNnViA0JafXNNtFmr2m8+bkSZFHKiqM/PdbSwbc8aDocWnPeJuAI8eOHks+efQRxZ4WwAvy2E1Wjddirva4OsXkrcOEimKLYHtcFjat91zZc2BP8u49W72NaPkn99vPxxB4W9q2xyFbYd3j+DE1Rv4b8aCqI81F30DNjXRtY56RRz/fCAl3uovd5F7nM6FPIH3u9LrJi927INcvrYAsKZ9QlAMBRoaQ940ChCP//bWXVSuKG7soVtwVlTPnHHnmeVMkzOQzueR89ioSugUJr2XzueRMfhakGekPuOggWFKG3LFw1kVz4VjIlebwJUy5aBokWHcYxGSkIsVFO6HiRiqastMMOXjWRgIOVWvVGrP6k9A+SD9r3GqtehiEfdZxibR9NHXAiUHKvp0GQUphqbQ9O/XBwcOD+oT2QRq4aH51edW6y6sLBgFWUDgg8AoAAFBBAJ0BKsgAyAA+SR6MQ6Qhoxj89OxABISm7EwDx/hykX3/nOvLkf07+B/J3p4+iPDXyDY8uM/OZ4+/1f9Y/ar/TfNL+7/6P2T/6H1Bf8D/Mv8x1S/299Qf87/qX/R/xHvKf6L/l/2T3LegB/av6n6yX/U9mD+ef7L2AP4B/gP/N63H7CfC//X/+V+7Hs8/+rWNPQ/+e9e/QevO7pm8pPk8CrxhX9D9ADQ+zAEy7vut0+WL2jM7Bha+MYD2aOc5YhbsJABg57wPkCxqolVYOcpQF9LOnhFoDMTGFNb8XsZR1QuidGMH9rxELBPVFwDvaGTq1v2S3ganOlSXWhe4wAzrD0ZY13INjOzT2Nc5DYKVELo9f9I2sTeoLOtlMQnxxst+p3PX1BeWTuSFP20/Mhali6vIn5Vs2eCODZQ/fvb1A+l14CHYbMl0VY4/BeiWbXkTwfaHnDeph+PQvqP+Zv6OlW+KhwmyDqg/q62ZKqGeOutwActE9S8v8MwhRnNqj9rGBORE+0L0mVvGt6tm4q3XM9nam+/dumpfHXzhCK9jb+0BTpW8UQP9nvYHZ08lcHnD0ZxvPxerOuMhtvzzsleCfWutDMMiHduoZGYWdOv+YgFaFzq7Ef7T0Ofl9QcNUsvWlcVAz42y+c/ExsX8Js5MZgx5Qc5Y3WqbqDINSAoc5cgcsyYAZlLYCOF8rOR+WVGkQAD+/nyUQNMcDsKWY60EpsmdOrbkKGNmia2purWHJ0vmqHe/BkLJxUpHR+7juBJx2iZQxxdq1zwoStodPc75obDoZXqp7ZP/v0lQBYIQgndf5SQij6zQvIX9dGjGDd/imlYTF9Wlt/npmmkp56ISJW/kHUoXRXO3pfAsXysAD8MUqPhEJiQgPCQVir0g7EncdPv8KNirfpiLZ84u+fMo//HW35PvTp0koSewcP9TzrydyEtb1T29z/6WEJxC3fpySjEzpmkb13uRFXTjfqf5wifnpw1HS+r43ARxmkB1u832qhVohMFm7vKOX7/2xEsuMDEbjT8ULaBZb3fhstJpT/1nhpVe2l0VBnHCATpjvJNIbjWp4BzX2knTQebRF/6VQqCYjHuFDdXlBWfgAKGld1Qi1C18ycb9stQBsNyz7BDrHOg+a75d+//InufwSQ/2m4vpW1eqWBkBQS9niGKlAh+xzjfXO3HZLH//rmlm46+jRJdjiSEJrkr53/jUPgULeIuuSjVgl76sDZMyJ14NlKUPC5dFEJaF5E8BiPDAwAGo7SnKMczk76uDo4K5r2OeNoIm2pARSWj0F6m5y33eH/9oObOf/tmd0TiTzdJABh1X+HG+on0CtWb+oHsC/ZUy0R864Ph/pV9K0Ew9hxtDdun6gPhFl5xzCD0ywQd1kItQXUIzxT+1Blv5YSQqVJAdqgaH8Y6RvyBc+Re4Q14sif8cbwdmrrfKB0fXHedPAYugpiDWr5qrFncwGOxPIs02X0OZqj3+oJVjUIBkdf5Xw6AsOhqZfTL6UnZNUoTebXPy83DN9i2hT0sume3+Gxywrvgw3oWUn6yH1JXBfniiYuWmKMKNFRks4g7AYOgBHuIaQXZrNi1W2knYOw8p3LAm7AgFMwYGkW5EZ0sHq3ZZsnnve59BvnDfE7PWNIGlTSPrAKNgT88EG66gYgjzmJiVuBQPKo3GneKRrhnURA2h22Si4Ekf2yvmD//nfRBPkqThpVPgDfS8/j74RqP643+K1dNPWitHT6+VSfSU2/UFKGtDEUR70Q77CpWYzgvBT3hI1SSCAfdmRlPaJ/D9t38ujaJToPB+bDobN4TjQafzW9V66v/EwzQX/XmEjEXRP7So0yep+U869pYstdTrcOjwqP4mp0weGyZFYHHuogVxnxx2aOaLDlQwM4Oz1qHHXgvBX7sXUvUgvdB9G+K1pT5CYgSWMu18Or5kLW39Z2M2kEZXGHsAkQMiil+c1p5ebuU6y6/7roOxw8py5lPVyIXz2FZsDJVrjMR8AdGTtXJd+vHfaULvJGjNEDC00io2i6divF52Abpv4jzEl7mTauagA+iQtoevO7q2wfcl8gm/wOu994zq0kxiFYC9JqTPYz3QNFb0w/AIEC0pXLKWhslvQjFj3R64nlgFRrncXFaNJgcBfOOomKjlpbcZj/KtYjwGf30CatVYEftNb1Tj7sQftX3Ws5/7gztKrPweq2UgGzS3Wi6a5R3p2ruB5iOy9ytckR4MGd5pGX2zlzw8rAMdVzO1RwXHLnonYoiPoC59lYxrJ7fxt+cXg8vJdWl/yuuYoGe6Fcdzwk2g//zIeutbs2LS9xOO0NKCwAo0oWbbLCFli0OzgxxcK6pcPpSXykulZ2xqMukMJu8D+1qAX7gaW9v09fJrw0W3MgS8UIJbmoF1tz+LwtVPOrkd3VENK7nxJzDbKpCQ3KkEL+4KHEWpt18tNOwfFMU4+OB5YwDlw77Y2aw6RPUWZc4vqmsGRuSGl75KiaC6zzT9/F0wpCivVWx9vY9Qgl1gc2Po+wOvUqrQ4aDGgMahYoAW6gARpJ7j3xcvkI9XX9FxDM9Huh0/ZVA/uT1eeCa6UNUHBWf2Y89+wRHnang85AaOxl05UXP47FSfmR1TCa9OhrTO2aAtoafklBVuKTba2Ke2re5y7HHMhdEWxOef/WhN46DpvRIjr8h/yKv7NqkIxZKGpDNxUuhyo66fabimGxxhdOV4TxUHl+Kt2jCffg6qj0lLeEAsQ+IDTLe3f+sx53nv+N1trtOCJhSjfUaOqoK5b0Ep62tlPGUum0tvFZ9gxgofRAdzz8TzRM6DOpivt8C4jkSAnqroejgYnZRnC3i5U76dHcO4XkTgqf7vza5pxtuogH+bS73/4E0TLSItybu3z2BSAvtQBtcRJGz2AO2diaWJynBFU8YqaJW0qO7sdycAe5MFaJ8N8P+VLLxK1QlZzHEkQzhx9smACj0WpMhtAz1lAM4dzRFAMX19gRekfA1rKZbIQJFmsTJDLIn8qd5V/jjqEC0GSYexXE8M9I8BeMW6X+s17Kq6gMXn6+Bl41LfG+kkH7RH39JbLael+yBf4RZpWHTB4SxXZ2Z0SsAcKR2ng5kTgNlNEpvvwzNXfdu379QA/OYu2UbQl/L1nZfv/Ye55QzCAApJdDwWVgx5LZ9JAepjG4s614zvjuu8UURzoebCOVMJD84ABp0Tr9h5LQycoEM3G4UTRNVlg2WMM0BqyOTktvZzF2Nl3/5HRrNZj6fQO7oVhnt84+GWUWFlL1SL96XQv2UddBX/NyhDHtuwwBi6sxdNAjgE0u/71CbMzoraYbyM54yQfGFmgg7Owq4LWMab++ix44NDh8hmeBD291vV1KP2S0eOIL2T819Vgk068LoU4lLMhCGIBVckMvlcpoK06QCkOMbAqYJKaZyfnwHzLeCYooyzec29+j1EeBVr918YImIm6AT1i1fOmMoc9G//9f657Bugh1ehZQowlm9MBHiHeBhoKb8S0pkkLW0jkjdnPzX1vwAa8u+BZfinC2NL8YqJUPZBgUIs/rtk+twHUTRPAi/NrHcuDGti9vuS0Zw0QeJXzjy4Z/kqZl5dZb/bKnwu3iHt3aP+l1z7XzUjspXIyw/TAFXxiqmu8kttkTkG1fUcqUSyZaxgEFXshEJTrj/qdeSdliYqE4t3yF6tEtZ8axetYc1pTd3VXLE5AERYoAAHNepoxPYBAAg5PvWz/R+QRhnmJYAAAAA=") center/contain no-repeat;image-rendering:pixelated}
|
||||
.px{font-family:var(--pixel);font-weight:400;-webkit-font-smoothing:none;letter-spacing:.02em}
|
||||
code{font-family:var(--mono);font-size:.92em;background:rgba(30,36,64,.06);padding:0 4px;border-radius:3px}
|
||||
|
||||
/* ---------- 按钮 ---------- */
|
||||
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:38px;padding:0 14px 3px;border-radius:4px;cursor:pointer;white-space:nowrap;text-decoration:none;
|
||||
border:2px solid var(--stone-edge);background:var(--stone);color:var(--txt);font-weight:700;font-size:13.5px;
|
||||
box-shadow:inset 0 2px 0 #fff,inset 0 -4px 0 var(--stone-lo);transition:transform .08s linear,box-shadow .08s linear,background .12s}
|
||||
.btn:hover:not(:disabled){background:#fff}
|
||||
.btn:active:not(:disabled){transform:translateY(2px);box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 var(--stone-lo)}
|
||||
.btn.pri{border-color:var(--mc-lo);background:var(--mc);color:#fff;box-shadow:inset 0 2px 0 var(--mc-hi),inset 0 -4px 0 var(--mc-lo)}
|
||||
.btn.pri:hover:not(:disabled){background:#469A2E}
|
||||
.btn.pri:active:not(:disabled){box-shadow:inset 0 2px 0 var(--mc-hi),inset 0 -2px 0 var(--mc-lo)}
|
||||
.btn.sm{height:32px;padding:0 10px 2px;font-size:12.5px}
|
||||
.btn.bad{color:var(--bad-t)}
|
||||
.btn.wide{width:100%;height:44px;font-size:15px}
|
||||
.btn:disabled{opacity:.45;cursor:not-allowed;filter:saturate(.4)}
|
||||
.btn:focus-visible,.nav button:focus-visible,.seg button:focus-visible,.tile:focus-visible{outline:2px solid var(--mc-hi);outline-offset:2px}
|
||||
.link{border:0;background:none;padding:0;color:var(--mc);font-weight:700;cursor:pointer}
|
||||
.pubn{display:inline-grid;place-items:center;min-width:19px;height:19px;margin-left:2px;padding:0 5px;border-radius:4px;background:#FFD36E;color:#1E2440;font-size:11.5px;font-weight:800;line-height:1}
|
||||
|
||||
/* ---------- 登录 / 首次改密 ---------- */
|
||||
.gate{min-height:100vh;display:grid;place-items:center;padding:24px 16px}
|
||||
.gbox{width:100%;max-width:380px;padding:28px 26px 24px;border-radius:10px;background:var(--glass);border:2px solid #fff;box-shadow:var(--panel-shadow)}
|
||||
.gbox .gem{width:64px;height:64px;display:block;margin:0 auto 12px;border-radius:8px;background-color:#fff;background-size:38px;border:2px solid #fff;
|
||||
box-shadow:-5px 10px 18px -12px rgba(255,110,140,.4),5px 10px 18px -12px rgba(70,140,255,.4)}
|
||||
.gbox h1{margin:0;text-align:center;font-size:24px}
|
||||
.gbox .sub{margin:4px 0 20px;text-align:center;color:var(--txt-3);font-size:13px;line-height:1.7}
|
||||
.gmsg{min-height:20px;margin-top:12px;font-size:13px;color:var(--bad-t);text-align:center}
|
||||
.chk{display:flex;align-items:center;gap:8px;margin:2px 0 18px;font-size:13px;color:var(--txt-2);cursor:pointer;user-select:none}
|
||||
.chk input{width:18px;height:18px;accent-color:var(--mc)}
|
||||
.lockbar{display:flex;gap:10px;align-items:flex-start;padding:11px 12px;margin-bottom:18px;border-radius:6px;background:rgba(255,248,230,.95);border:1px solid rgba(214,160,40,.35);color:var(--warn-t);font-size:12.5px;line-height:1.7}
|
||||
.back{display:block;margin-top:16px;text-align:center;font-size:12.5px;color:var(--dim);text-decoration:none}
|
||||
.back:hover{color:var(--txt)}
|
||||
|
||||
/* ---------- 表单 ---------- */
|
||||
.fld{display:block;margin-bottom:14px}
|
||||
.fld>span{display:block;margin-bottom:6px;font-size:12.5px;font-weight:700;color:var(--txt-2)}
|
||||
.fld>span .h{font-weight:400;color:var(--dim)}
|
||||
.in{width:100%;height:40px;padding:0 11px;border-radius:4px;border:2px solid var(--line);background:#fff;outline:none;transition:border-color .12s}
|
||||
textarea.in{height:auto;min-height:84px;padding:9px 11px;line-height:1.7;resize:vertical}
|
||||
select.in{padding-right:28px}
|
||||
.in:focus{border-color:var(--mc)}
|
||||
.in.err{border-color:var(--bad)}
|
||||
.pw{position:relative}
|
||||
.pw .in{padding-right:44px}
|
||||
.pw button{position:absolute;right:4px;top:4px;height:32px;width:36px;border:0;background:none;color:var(--dim);cursor:pointer;border-radius:4px}
|
||||
.pw button:hover{color:var(--txt);background:rgba(30,36,64,.05)}
|
||||
|
||||
/* ---------- 顶栏 ---------- */
|
||||
.top{position:sticky;top:0;z-index:30;background:rgba(255,255,255,.74);border-bottom:1px solid rgba(255,255,255,.9);box-shadow:0 10px 30px -24px rgba(80,90,170,.45);
|
||||
-webkit-backdrop-filter:blur(14px) saturate(1.4);backdrop-filter:blur(14px) saturate(1.4)}
|
||||
.top-in{max-width:1320px;margin:0 auto;padding:10px 20px;display:flex;align-items:center;gap:12px}
|
||||
.brand{display:flex;align-items:center;gap:10px;margin-right:auto;min-width:0;color:inherit;text-decoration:none}
|
||||
.brand b{font-size:19px;white-space:nowrap}
|
||||
.brand small{display:block;font-size:11.5px;color:var(--dim);font-weight:400;white-space:nowrap}
|
||||
.saving{font-size:12px;color:var(--dim);white-space:nowrap}
|
||||
.saving.bad{color:var(--bad-t)}
|
||||
|
||||
/* ---------- 骨架 ---------- */
|
||||
.shell{max-width:1320px;margin:0 auto;padding:20px;display:grid;grid-template-columns:212px minmax(0,1fr);gap:22px;align-items:start}
|
||||
.nav{position:sticky;top:78px;display:flex;flex-direction:column;gap:2px;padding:8px;border-radius:8px;background:var(--glass);border:2px solid rgba(255,255,255,.95);box-shadow:var(--panel-shadow)}
|
||||
.nav .grp{margin:10px 10px 4px;font-size:11px;font-weight:700;letter-spacing:.12em;color:var(--dim)}
|
||||
.nav .grp:first-child{margin-top:4px}
|
||||
.nav button{display:flex;align-items:center;gap:10px;height:38px;padding:0 12px;border:0;border-radius:4px;background:none;cursor:pointer;color:var(--txt-2);font-size:14px;text-align:left}
|
||||
.nav button:hover{background:rgba(255,255,255,.9);color:var(--txt)}
|
||||
.nav button[aria-current=true]{background:#fff;color:var(--txt);font-weight:700;box-shadow:inset 3px 0 0 var(--mc),0 6px 16px -12px rgba(80,90,170,.5)}
|
||||
.nav .n{margin-left:auto;min-width:20px;height:19px;padding:0 6px;border-radius:4px;background:#C88A12;color:#fff;font-size:11px;font-weight:700;line-height:19px;text-align:center}
|
||||
.nav .n:empty{display:none}
|
||||
main{min-width:0}
|
||||
.pane{display:none}
|
||||
.pane.on{display:block;animation:paneIn .26s var(--ease)}
|
||||
@keyframes paneIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
|
||||
.ph{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:0 0 14px}
|
||||
.ph h1{margin:0;font-size:26px}
|
||||
.ph p{margin:2px 0 0;color:var(--txt-3);font-size:13px}
|
||||
.card{background:var(--glass);border:2px solid rgba(255,255,255,.95);border-radius:8px;box-shadow:var(--panel-shadow);padding:18px;margin-bottom:18px}
|
||||
.card>h2{display:flex;align-items:center;gap:8px;margin:0 0 12px;font-size:15.5px;flex-wrap:wrap}
|
||||
.card>h2 .sub{font-weight:400;font-size:12.5px;color:var(--dim)}
|
||||
.grid2{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:18px;align-items:start}
|
||||
.fgrid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:0 14px}
|
||||
.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:18px}
|
||||
.stat{padding:14px 16px;border-radius:8px;background:var(--glass);border:2px solid rgba(255,255,255,.95);box-shadow:var(--panel-shadow)}
|
||||
.stat .k{font-size:12px;color:var(--txt-3)}
|
||||
.stat .v{font-size:26px;font-weight:800;line-height:1.25;font-variant-numeric:tabular-nums}
|
||||
.stat .s{font-size:12px;color:var(--dim)}
|
||||
.stat.warn .v{color:var(--warn-t)}
|
||||
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
|
||||
.bar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:14px}
|
||||
.search{position:relative;flex:1;min-width:180px}
|
||||
.search .in{padding-left:34px}
|
||||
.search svg{position:absolute;left:10px;top:11px;color:var(--dim)}
|
||||
.seg{display:flex;gap:6px;flex-wrap:wrap}
|
||||
.seg button{min-height:34px;padding:4px 12px;border-radius:4px;border:2px solid var(--line);background:rgba(255,255,255,.7);cursor:pointer;font-size:13px;color:var(--txt-2)}
|
||||
.seg button.on{border-color:var(--mc);background:rgba(91,170,60,.1);color:var(--ok-t);font-weight:700}
|
||||
.list{display:flex;flex-direction:column;gap:8px}
|
||||
.item{display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:6px;background:rgba(255,255,255,.85);border:1px solid var(--line-soft);transition:border-color .15s}
|
||||
.item:hover{border-color:var(--line)}
|
||||
.item.dirty{border-color:rgba(214,160,40,.45);background:linear-gradient(90deg,rgba(255,240,200,.5),rgba(255,255,255,.85) 30%)}
|
||||
.item.off{opacity:.55}
|
||||
.item .body{flex:1;min-width:0}
|
||||
.item .t{font-weight:700;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
||||
.item .m{font-size:12.5px;color:var(--txt-3);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.item .acts{display:flex;gap:6px;flex:none}
|
||||
.tag{display:inline-flex;align-items:center;height:21px;padding:0 7px;border-radius:4px;font-size:11.5px;font-weight:700;background:rgba(30,36,64,.06);color:var(--txt-2);white-space:nowrap}
|
||||
.tag.g{background:rgba(91,170,60,.12);color:var(--ok-t)}
|
||||
.tag.y{background:rgba(214,160,40,.16);color:var(--warn-t)}
|
||||
.tag.r{background:rgba(210,72,58,.1);color:var(--bad-t)}
|
||||
.tag.b{background:rgba(70,110,220,.1);color:var(--info-t)}
|
||||
.sw{width:30px;height:30px;border-radius:6px;flex:none;box-shadow:inset 0 0 0 1px rgba(30,36,64,.1)}
|
||||
.sw.img{background:#0B1028 center/118% no-repeat}
|
||||
.empty{padding:24px 10px;text-align:center;color:var(--dim);font-size:13px}
|
||||
.h{font-size:12px;color:var(--dim);line-height:1.7}
|
||||
.errtxt{display:block;margin-top:4px;font-size:12px;color:var(--bad-t)}
|
||||
/* 画展网格 */
|
||||
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(172px,1fr));gap:12px}
|
||||
.tile{position:relative;display:block;padding:0;text-align:left;border-radius:8px;overflow:hidden;background:#fff;border:2px solid rgba(255,255,255,.95);cursor:pointer;
|
||||
box-shadow:0 12px 24px -20px rgba(80,90,170,.55);transition:transform .15s var(--ease),border-color .15s}
|
||||
.tile:hover{transform:translateY(-2px)}
|
||||
.tile.dirty{border-color:rgba(214,160,40,.6)}
|
||||
.tile.off .th{filter:grayscale(1);opacity:.5}
|
||||
.tile .th{aspect-ratio:4/3;background:#EEF1F6 center/cover no-repeat}
|
||||
.tile .cap{padding:8px 10px 10px}
|
||||
.tile .cap b{display:block;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.tile .cap span{font-size:11.5px;color:var(--dim)}
|
||||
.tile .flags{position:absolute;left:8px;top:8px;display:flex;gap:4px}
|
||||
.tile .flags .tag{background:rgba(255,255,255,.94);box-shadow:0 2px 6px -2px rgba(30,36,64,.35)}
|
||||
.drop{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:100%;border:2px dashed rgba(60,133,39,.35);border-radius:8px;background:rgba(255,255,255,.55);color:var(--mc);cursor:pointer;text-align:center;padding:16px;font-size:13px;font-weight:700}
|
||||
.drop:hover,.drop.over{border-color:var(--mc);background:rgba(91,170,60,.07)}
|
||||
.drop small{display:block;font-weight:400;color:var(--dim);margin-top:4px}
|
||||
.prog{height:6px;border-radius:3px;background:rgba(30,36,64,.08);overflow:hidden;margin-top:6px}
|
||||
.prog i{display:block;height:100%;background:var(--mc);width:0;transition:width .3s}
|
||||
/* 抽屉 */
|
||||
.scrim{position:fixed;inset:0;z-index:50;background:rgba(236,240,248,.55);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);opacity:0;pointer-events:none;transition:opacity .2s}
|
||||
.scrim.on{opacity:1;pointer-events:auto}
|
||||
.drawer{position:fixed;top:0;right:0;bottom:0;z-index:51;width:min(520px,100vw);display:flex;flex-direction:column;background:#fff;box-shadow:-30px 0 60px -30px rgba(40,50,110,.45);
|
||||
transform:translateX(104%);transition:transform .28s var(--ease)}
|
||||
.drawer.on{transform:none}
|
||||
.dh{display:flex;align-items:center;gap:10px;padding:16px 18px;border-bottom:1px solid var(--line-soft)}
|
||||
.dh h3{margin:0;font-size:17px;flex:1;min-width:0}
|
||||
.db{flex:1;overflow:auto;padding:18px}
|
||||
.df{display:flex;gap:10px;padding:14px 18px calc(14px + env(safe-area-inset-bottom));border-top:1px solid var(--line-soft)}
|
||||
.df .sp{flex:1}
|
||||
.x{width:36px;height:36px;border:0;border-radius:4px;background:none;cursor:pointer;color:var(--dim)}
|
||||
.x:hover{background:rgba(30,36,64,.06);color:var(--txt)}
|
||||
.dimg{aspect-ratio:16/10;border-radius:6px;background:#EEF1F6 center/contain no-repeat;margin-bottom:14px;border:1px solid var(--line-soft)}
|
||||
.swatches{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.swatches button{width:30px;height:30px;border-radius:6px;border:2px solid #fff;cursor:pointer;box-shadow:0 0 0 1px rgba(30,36,64,.15)}
|
||||
.swatches button.on{box-shadow:0 0 0 2px var(--mc)}
|
||||
.stage-mini{border-radius:8px;padding:14px 12px 12px;background:radial-gradient(70% 70% at 50% 40%,#1A2350,#070B1C);text-align:center;color:#C9D0F2;font-size:12px;margin-bottom:14px}
|
||||
.stage-mini canvas{width:150px;height:150px;display:block;margin:0 auto}
|
||||
.stage-mini b{display:block;color:#fff;font-size:16px;margin-top:6px}
|
||||
/* 外观预设 */
|
||||
.presets{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
|
||||
.pre{display:flex;flex-direction:column;align-items:center;gap:2px;padding:10px 8px 10px;border-radius:8px;background:radial-gradient(80% 70% at 50% 35%,#1A2350,#070B1C);color:#E8EBFA;text-align:center}
|
||||
.pre canvas{width:100%;max-width:150px;aspect-ratio:1/1}
|
||||
.pre b{font-size:13.5px}
|
||||
.pre code{font-size:11px;color:#8A92BE;background:none}
|
||||
.pre .btn{margin-top:6px;height:30px;font-size:12px}
|
||||
/* 弹窗 */
|
||||
.modal{position:fixed;inset:0;z-index:60;display:grid;place-items:center;padding:16px;background:rgba(236,240,248,.6);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);opacity:0;pointer-events:none;transition:opacity .18s}
|
||||
.modal.on{opacity:1;pointer-events:auto}
|
||||
.mbox{width:100%;max-width:520px;max-height:calc(100vh - 32px);overflow:auto;padding:22px;border-radius:10px;background:#fff;box-shadow:0 40px 80px -40px rgba(40,50,110,.6);transform:translateY(8px);transition:transform .2s var(--ease)}
|
||||
.modal.on .mbox{transform:none}
|
||||
.mbox h3{margin:0 0 6px;font-size:19px}
|
||||
.mbox p{margin:0 0 14px;color:var(--txt-3);font-size:13px;line-height:1.75}
|
||||
.chg{list-style:none;margin:0 0 14px;padding:0;border-radius:6px;border:1px solid var(--line-soft);overflow:hidden}
|
||||
.chg li{display:flex;justify-content:space-between;gap:10px;padding:9px 12px;font-size:13px;border-top:1px solid var(--line-soft)}
|
||||
.chg li:first-child{border-top:0}
|
||||
.chg li span{color:var(--dim)}
|
||||
.mf{display:flex;gap:10px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap}
|
||||
/* 时间线 */
|
||||
.ver{display:flex;gap:14px;padding:12px 0;border-top:1px solid var(--line-soft);align-items:center}
|
||||
.ver:first-child{border-top:0}
|
||||
.ver .dotc{flex:none;width:40px;height:34px;border-radius:6px;display:grid;place-items:center;background:var(--stone);border:2px solid var(--stone-edge);font:800 12px/1 var(--mono);box-shadow:inset 0 -3px 0 var(--stone-lo)}
|
||||
.ver.cur .dotc{background:var(--mc);border-color:var(--mc-lo);color:#fff;box-shadow:inset 0 -3px 0 var(--mc-lo)}
|
||||
.ver .body{flex:1;min-width:0}
|
||||
.ver .t{font-weight:700}
|
||||
.ver .m{font-size:12.5px;color:var(--txt-3)}
|
||||
/* 首页预览小窗 */
|
||||
.mini{border-radius:10px;padding:22px 20px;border:3px solid rgba(255,255,255,.95);box-shadow:0 20px 40px -26px rgba(80,100,170,.45);
|
||||
background:radial-gradient(60% 80% at 0% 0%,rgba(255,196,214,.55),transparent 70%),radial-gradient(60% 80% at 100% 10%,rgba(176,214,255,.6),transparent 70%),linear-gradient(160deg,#fff,#F6F8FE)}
|
||||
.mini h4{margin:0;font-size:34px}
|
||||
.mini p{margin:8px 0 14px;color:var(--txt-2);font-size:13.5px;line-height:1.8}
|
||||
.mini .notice{display:inline-block;margin-bottom:12px;padding:7px 10px;border-radius:4px;background:rgba(214,160,40,.14);color:var(--warn-t);font-size:12.5px;font-weight:700}
|
||||
.switch{position:relative;display:inline-flex;align-items:center;gap:10px;cursor:pointer;font-size:13px;color:var(--txt-2);user-select:none}
|
||||
.switch input{position:absolute;opacity:0}
|
||||
.switch i{width:40px;height:22px;border-radius:11px;background:rgba(30,36,64,.18);position:relative;transition:background .15s;flex:none}
|
||||
.switch i::after{content:"";position:absolute;left:3px;top:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .15s var(--ease);box-shadow:0 1px 3px rgba(0,0,0,.2)}
|
||||
.switch input:checked+i{background:var(--mc)}
|
||||
.switch input:checked+i::after{transform:translateX(18px)}
|
||||
.switch input:focus-visible+i{outline:2px solid var(--mc-hi);outline-offset:2px}
|
||||
.tbl{width:100%;border-collapse:collapse;font-size:13.5px}
|
||||
.tbl th{text-align:left;font-size:12px;color:var(--dim);font-weight:700;padding:0 8px 8px}
|
||||
.tbl td{padding:6px 8px;border-top:1px solid var(--line-soft);vertical-align:middle}
|
||||
.tbl .in{height:34px}
|
||||
#toast{position:fixed;left:50%;bottom:28px;z-index:80;max-width:min(92vw,560px);padding:10px 16px;border-radius:6px;background:#1E2440;color:#fff;font-size:13px;
|
||||
opacity:0;transform:translate(-50%,10px);pointer-events:none;transition:opacity .18s var(--ease),transform .18s var(--ease)}
|
||||
#toast.on{opacity:1;transform:translate(-50%,0)}
|
||||
#toast.bad{background:#8E2A20}
|
||||
.menu-btn{display:none}
|
||||
@media (max-width:1080px){.grid2{grid-template-columns:minmax(0,1fr)}}
|
||||
@media (max-width:880px){
|
||||
.top-in{padding:8px 12px;gap:8px}
|
||||
.top .bt,.saving{display:none}
|
||||
.brand b{font-size:17px}.brand small{font-size:10.5px}
|
||||
.menu-btn{display:inline-flex}
|
||||
.shell{grid-template-columns:minmax(0,1fr);padding:14px 12px 40px}
|
||||
.nav{position:fixed;left:0;top:0;bottom:0;z-index:55;width:248px;border-radius:0;transform:translateX(-104%);transition:transform .25s var(--ease);overflow:auto;background:#fff}
|
||||
.nav.open{transform:none}
|
||||
.stats{grid-template-columns:repeat(2,minmax(0,1fr))}
|
||||
.fgrid{grid-template-columns:minmax(0,1fr)}
|
||||
.card{padding:15px 13px}
|
||||
.ph h1{font-size:22px}
|
||||
.item{flex-wrap:wrap}
|
||||
.item .acts{width:100%;justify-content:flex-end}
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce){.pane.on{animation:none}.drawer,.nav,.modal,.mbox,#toast{transition:none}}
|
||||
</style></head><body>
|
||||
|
||||
<!-- ============ 登录 ============ -->
|
||||
<section class="gate" id="gLogin" hidden>
|
||||
<form class="gbox" id="loginForm" autocomplete="on">
|
||||
<i class="gem" aria-hidden="true"></i>
|
||||
<h1 class="px">内容后台</h1>
|
||||
<p class="sub">金钻客栈的网页内容都在这里改。<br>只给有账号的人用。</p>
|
||||
<label class="fld"><span>用户名或邮箱</span><input class="in" id="lgUser" autocomplete="username" required></label>
|
||||
<label class="fld"><span>密码</span><div class="pw"><input class="in" id="lgPw" type="password" autocomplete="current-password" required>
|
||||
<button type="button" class="eye" aria-label="显示密码"><svg class="i" viewBox="0 0 24 24"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg></button></div></label>
|
||||
<label class="chk"><input type="checkbox" id="lgRemember" checked>记住我(30 天内这台设备不用再输密码)</label>
|
||||
<button class="btn pri wide" type="submit" id="lgGo">登录</button>
|
||||
<div class="gmsg" id="lgMsg" role="alert"></div>
|
||||
<a class="back" href="../">← 回门户主页</a>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<!-- ============ 首次改密(初始账号必须先改,服务端也只放行改密 / 退出) ============ -->
|
||||
<section class="gate" id="gFirst" hidden>
|
||||
<form class="gbox" id="firstForm">
|
||||
<i class="gem" aria-hidden="true"></i>
|
||||
<h1 class="px">先改个密码</h1>
|
||||
<p class="sub">这是第一次用初始密码登录。<br>改完之前,后台别的功能都打不开。</p>
|
||||
<div class="lockbar"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
|
||||
<div>新密码至少 8 位,不能是 admin,也不能是 12345678 这类常见密码。改完要用新密码重新登录一次。</div></div>
|
||||
<label class="fld"><span>现在的密码</span><input class="in" id="fpOld" type="password" autocomplete="current-password"></label>
|
||||
<label class="fld"><span>新密码</span><input class="in" id="fpNew" type="password" autocomplete="new-password"></label>
|
||||
<label class="fld"><span>再输一遍</span><input class="in" id="fpAgain" type="password" autocomplete="new-password"></label>
|
||||
<button class="btn pri wide" type="submit">改好了</button>
|
||||
<div class="gmsg" id="fpMsg" role="alert"></div>
|
||||
<a class="back" href="#" id="fpOut">先退出</a>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<!-- ============ 后台 ============ -->
|
||||
<div id="app" hidden>
|
||||
<header class="top"><div class="top-in">
|
||||
<button class="btn sm menu-btn" id="menuBtn" type="button" aria-label="打开菜单"><svg class="i" viewBox="0 0 24 24"><path d="M4 6h16M4 12h16M4 18h16"/></svg></button>
|
||||
<a class="brand" href="../" title="回到门户主页"><i class="gem" aria-hidden="true"></i><div><b class="px">内容后台</b><small>点这里回门户主页</small></div></a>
|
||||
<span class="saving" id="saving" aria-live="polite"></span>
|
||||
<button class="btn sm" id="prevBtn" type="button" title="用草稿打开网站看看(只有你看得到)"><svg class="i" viewBox="0 0 24 24"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg><span class="bt">预览</span></button>
|
||||
<button class="btn sm pri" id="pubBtn" type="button" disabled><svg class="i" viewBox="0 0 24 24"><path d="M12 19V5M5 12l7-7 7 7"/></svg><span class="bt">发布</span><span class="pubn" id="pubN" hidden></span></button>
|
||||
</div></header>
|
||||
|
||||
<div class="shell">
|
||||
<nav class="nav" id="nav" aria-label="后台分区">
|
||||
<div class="grp">总览</div>
|
||||
<button type="button" data-p="home"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="9" rx="1"/><rect x="14" y="3" width="7" height="5" rx="1"/><rect x="14" y="12" width="7" height="9" rx="1"/><rect x="3" y="16" width="7" height="5" rx="1"/></svg>概览</button>
|
||||
<div class="grp">门户</div>
|
||||
<button type="button" data-p="hero"><svg class="i" viewBox="0 0 24 24"><path d="M3 10.5 12 3l9 7.5V21H3z"/></svg>首页文案<span class="n" data-n="hero"></span></button>
|
||||
<button type="button" data-p="gallery"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg>画展<span class="n" data-n="gallery"></span></button>
|
||||
<button type="button" data-p="apps"><svg class="i" viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.8-3.8a6 6 0 0 1-7.9 7.9l-6.9 6.9a2.1 2.1 0 0 1-3-3l6.9-6.9a6 6 0 0 1 7.9-7.9z"/></svg>工具与开源<span class="n" data-n="apps"></span></button>
|
||||
<button type="button" data-p="universe"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(-20 12 12)"/></svg>金钻宇宙<span class="n" data-n="universe"></span></button>
|
||||
<button type="button" data-p="links"><svg class="i" viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7"/><path d="M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7"/></svg>平台入口<span class="n" data-n="links"></span></button>
|
||||
<button type="button" data-p="about"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>关于<span class="n" data-n="about"></span></button>
|
||||
<div class="grp">下单页</div>
|
||||
<button type="button" data-p="tpl"><svg class="i" viewBox="0 0 24 24"><path d="M12 2.6 21 7.3v9.4L12 21.4 3 16.7V7.3z"/><path d="M3 7.3l9 4.7 9-4.7M12 12v9.4"/></svg>模板与文字<span class="n" data-n="tpl"></span></button>
|
||||
<button type="button" data-p="price"><svg class="i" viewBox="0 0 24 24"><path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>价格与付款<span class="n" data-n="price"></span></button>
|
||||
<div class="grp">系统</div>
|
||||
<button type="button" data-p="versions"><svg class="i" viewBox="0 0 24 24"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5M12 7v5l3 3"/></svg>发布记录</button>
|
||||
<button type="button" data-p="account"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg>账号与设备</button>
|
||||
</nav>
|
||||
|
||||
<main id="main">
|
||||
<!-- 概览 -->
|
||||
<section class="pane" id="p-home">
|
||||
<div class="ph"><div><h1 class="px">概览</h1><p>改动会自动存成草稿,网站上看不到;点右上角「发布」才会上线。</p></div></div>
|
||||
<div class="stats" id="stats"></div>
|
||||
<div class="grid2">
|
||||
<div class="card"><h2>还没发布的改动</h2><div class="list" id="dirtyList"></div></div>
|
||||
<div class="card"><h2>最近操作 <span class="sub">谁、什么时候、做了什么</span></h2><div class="list" id="auditList"></div></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 首页文案 -->
|
||||
<section class="pane" id="p-hero">
|
||||
<div class="ph"><div><h1 class="px">首页文案</h1><p>门户首屏那几句话、公告条,还有首页上各板块卡片的说明。</p></div></div>
|
||||
<div class="grid2">
|
||||
<div class="card">
|
||||
<label class="fld"><span>首屏一句话</span><textarea class="in" data-bind="site.hero.tagline" rows="3" maxlength="160"></textarea></label>
|
||||
<div class="fgrid">
|
||||
<label class="fld"><span>主按钮文字</span><input class="in" data-bind="site.hero.cta1" maxlength="12"></label>
|
||||
<label class="fld"><span>次按钮文字</span><input class="in" data-bind="site.hero.cta2" maxlength="12"></label>
|
||||
</div>
|
||||
<div class="fld"><span>公告条 <span class="h">(比如放假、涨价、新模板上线)</span></span>
|
||||
<label class="switch"><input type="checkbox" data-bind="site.hero.notice.on"><i></i>显示公告</label></div>
|
||||
<label class="fld"><span>公告内容</span><input class="in" data-bind="site.hero.notice.text" maxlength="80"></label>
|
||||
<div class="fgrid">
|
||||
<label class="fld"><span>从哪天开始 <span class="h">(空 = 马上)</span></span><input class="in" type="date" data-bind="site.hero.notice.from"></label>
|
||||
<label class="fld"><span>到哪天结束 <span class="h">(空 = 一直显示)</span></span><input class="in" type="date" data-bind="site.hero.notice.to"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card"><h2>门户首页上的样子</h2>
|
||||
<div class="mini" id="heroMini"></div>
|
||||
<p class="h" style="margin:12px 0 0">只是示意,正式效果点右上角「预览」。</p></div>
|
||||
</div>
|
||||
<div class="card"><h2>板块说明 <span class="sub">首页上各板块卡片里那段小字</span></h2>
|
||||
<div class="fgrid" id="boardFields"></div></div>
|
||||
</section>
|
||||
|
||||
<!-- 画展 -->
|
||||
<section class="pane" id="p-gallery">
|
||||
<div class="ph"><div><h1 class="px">画展</h1><p>拖图进来就能上传:服务器会核验图片、去掉照片里的隐私信息(拍摄地点等)、自动做缩略图。</p></div></div>
|
||||
<div class="card">
|
||||
<div class="bar">
|
||||
<label class="search"><svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg><input class="in" type="search" id="gSearch" placeholder="搜标题 / 说明 / 年份" aria-label="搜画展"></label>
|
||||
<div class="seg" id="gFilter"><button type="button" data-v="all" class="on">全部</button><button type="button" data-v="image">图片</button><button type="button" data-v="video">视频</button><button type="button" data-v="special">全景 / 壁纸</button><button type="button" data-v="hidden">已隐藏</button></div>
|
||||
<button class="btn sm" type="button" id="gVideo">加一个 B 站视频</button>
|
||||
</div>
|
||||
<div class="tiles" id="gTiles"></div>
|
||||
<input type="file" id="gFile" accept="image/png,image/jpeg,image/webp" multiple hidden>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 工具与开源 -->
|
||||
<section class="pane" id="p-apps">
|
||||
<div class="ph"><div><h1 class="px">工具与开源</h1><p>开源的和闭源的分两行显示;没填链接的会显示「待上架」。</p></div><button class="btn pri" type="button" id="appAdd">加一个</button></div>
|
||||
<div class="card"><div class="list" id="appList"></div></div>
|
||||
</section>
|
||||
|
||||
<!-- 金钻宇宙 -->
|
||||
<section class="pane" id="p-universe">
|
||||
<div class="ph"><div><h1 class="px">金钻宇宙</h1><p>每条世界线是星系图上的一颗星。档案写文字;外观在下拉里选。新点亮的会自动排到不挤的位置,连线接到附近的星上,已有的都不动。</p></div><button class="btn pri" type="button" id="uniAdd">点亮一条</button></div>
|
||||
<div class="grid2">
|
||||
<div class="card"><h2>世界线 <span class="sub" id="uniCount"></span></h2><div class="list" id="uniList"></div></div>
|
||||
<div class="card"><h2>空槽</h2>
|
||||
<p class="h" style="margin:0 0 10px">星系图外圈还没点亮的位置。点亮一条不占空槽数;想少显示几个就把数字调小。</p>
|
||||
<label class="fld"><span>留几个空槽</span><input class="in" type="number" min="0" max="20" data-bind="site.universe.empty" style="width:120px"></label></div>
|
||||
</div>
|
||||
<div class="card"><h2>外观预设 <span class="sub">编辑世界线时「星球风格」下拉里就是这些;这里是星系图上真正的样子,挑一个能直接用它点亮一条</span></h2>
|
||||
<div class="presets" id="presetGrid"><div class="empty">星球预设载入中…</div></div></div>
|
||||
</section>
|
||||
|
||||
<!-- 平台入口 -->
|
||||
<section class="pane" id="p-links">
|
||||
<div class="ph"><div><h1 class="px">平台入口</h1><p>链接只收 https:// 开头的网址和 mailto: 邮箱,别的会被拦下。</p></div><button class="btn pri" type="button" id="linkAdd">加一个</button></div>
|
||||
<div id="linkGroups"></div>
|
||||
</section>
|
||||
|
||||
<!-- 关于 -->
|
||||
<section class="pane" id="p-about">
|
||||
<div class="ph"><div><h1 class="px">关于</h1><p>名字的由来和署名卡片。写链接用 <code>[文字](https://网址)</code>,写代码样式用 <code>`文字`</code>,空一行是新段落;别的 HTML 都会原样显示成文字。</p></div><button class="btn pri" type="button" id="cardAdd">加一张卡片</button></div>
|
||||
<div class="card">
|
||||
<label class="fld"><span>名字的由来</span><textarea class="in" data-bind="site.about.story" rows="7" maxlength="1200"></textarea></label>
|
||||
<label class="fld"><span>页脚那句话</span><input class="in" data-bind="site.about.foot" maxlength="200"></label>
|
||||
</div>
|
||||
<div class="card"><h2>署名卡片</h2><div class="list" id="aboutCards"></div></div>
|
||||
</section>
|
||||
|
||||
<!-- 模板与文字 -->
|
||||
<section class="pane" id="p-tpl">
|
||||
<div class="ph"><div><h1 class="px">模板与文字</h1><p>下单页能选哪些模板、怎么介绍它们。模板文件本身和英文 key 不在这里改(渲染机认 key)。</p></div></div>
|
||||
<div class="grid2">
|
||||
<div class="card"><h2>模板 <span class="sub">关掉 = 下单页上不给选,已下的单不受影响</span></h2><div class="list" id="tplList"></div></div>
|
||||
<div class="card"><h2>页面上的文字</h2>
|
||||
<label class="fld"><span>页头那句话</span><input class="in" data-bind="order.head" maxlength="80"></label>
|
||||
<div class="fld"><span>下单页公告</span><label class="switch"><input type="checkbox" data-bind="order.notice.on"><i></i>显示公告</label></div>
|
||||
<label class="fld"><span>公告内容</span><input class="in" data-bind="order.notice.text" maxlength="120"></label>
|
||||
<p class="h">服务条款不在这里改:它和渲染机要用同一个版本号,改错会静默出问题,请照交接文档手动改。</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 价格与付款 -->
|
||||
<section class="pane" id="p-price">
|
||||
<div class="ph"><div><h1 class="px">价格与付款</h1><p>没配档位的张数按单价 × 张数算。发布后下单页的「应付」和付款按钮跟着变。</p></div></div>
|
||||
<div class="grid2">
|
||||
<div class="card"><h2>价格档位</h2>
|
||||
<label class="fld"><span>单价(元 / 张)</span><input class="in" type="number" min="0.01" step="0.01" data-bind="order.prices.per" style="width:120px"></label>
|
||||
<table class="tbl"><thead><tr><th>张数</th><th>价格(元)</th><th>爱发电商品链接</th><th></th></tr></thead><tbody id="tierRows"></tbody></table>
|
||||
<div class="row" style="margin-top:10px"><button class="btn sm" type="button" id="tierAdd">加一档</button></div>
|
||||
</div>
|
||||
<div class="card"><h2>付款方式</h2>
|
||||
<label class="fld"><span>爱发电主页链接</span><input class="in" data-bind="order.pay.payplatform" data-url placeholder="https://…"></label>
|
||||
<label class="fld"><span>爱发电创作者 ID <span class="h">(填了就能按订单金额生成专属付款链接)</span></span><input class="in" data-bind="order.pay.payplatform_uid" maxlength="40"></label>
|
||||
<label class="fld"><span>付款说明</span><textarea class="in" data-bind="order.pay.note" rows="3" maxlength="200"></textarea></label>
|
||||
<label class="fld"><span>收款码图片 <span class="h">(服务器上数据目录里的文件名,比如 payme.png)</span></span><input class="in" data-bind="order.pay.qr_img" maxlength="120"></label>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 发布记录 -->
|
||||
<section class="pane" id="p-versions">
|
||||
<div class="ph"><div><h1 class="px">发布记录</h1><p>每次发布都留一份完整的版本,可以一键回到任何一版(回滚本身也算一次发布,还能再回来)。</p></div></div>
|
||||
<div class="card" id="verList"></div>
|
||||
</section>
|
||||
|
||||
<!-- 账号与设备 -->
|
||||
<section class="pane" id="p-account">
|
||||
<div class="ph"><div><h1 class="px">账号与设备</h1><p id="meLine"></p></div><button class="btn" type="button" id="logoutBtn">退出</button></div>
|
||||
<div class="grid2">
|
||||
<form class="card" id="pwForm"><h2>改密码</h2>
|
||||
<label class="fld"><span>现在的密码</span><input class="in" type="password" id="pwOld" autocomplete="current-password"></label>
|
||||
<label class="fld"><span>新密码 <span class="h">(至少 8 位)</span></span><input class="in" type="password" id="pwNew" autocomplete="new-password"></label>
|
||||
<label class="fld"><span>再输一遍</span><input class="in" type="password" id="pwAgain" autocomplete="new-password"></label>
|
||||
<button class="btn pri" type="submit">改密码</button>
|
||||
<p class="h" style="margin:10px 0 0">改完后,除了这台,别的设备都会退出。忘了密码:在服务器上跑 <code>python3 admin.py user reset 账号</code>。</p></form>
|
||||
<div class="card"><h2>登录着的设备 <span class="sub">30 天没用会自动退出</span></h2>
|
||||
<div class="list" id="sessList"></div>
|
||||
<div class="row" style="margin-top:12px"><button class="btn bad" type="button" id="killAll">退出所有其它设备</button></div></div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 抽屉 / 弹窗 -->
|
||||
<div class="scrim" id="scrim"></div>
|
||||
<aside class="drawer" id="drawer" aria-modal="true" role="dialog" aria-labelledby="dTitle">
|
||||
<div class="dh"><h3 id="dTitle">编辑</h3><button class="x" type="button" id="dClose" aria-label="关闭"><svg class="i" viewBox="0 0 24 24"><path d="M18 6 6 18M6 6l12 12"/></svg></button></div>
|
||||
<div class="db" id="dBody"></div>
|
||||
<div class="df" id="dFoot"></div>
|
||||
</aside>
|
||||
<div class="modal" id="modal" role="dialog" aria-modal="true"><div class="mbox" id="mBox"></div></div>
|
||||
<div id="toast" role="status" aria-live="polite"></div>
|
||||
|
||||
<script type="module">
|
||||
/* 星球真实渲染:和星系图同一份 planets.js;只开一个 WebGL,画好再拷到各个小画布(浏览器能同时开的 WebGL 有限)。
|
||||
three.js 只在打开「金钻宇宙」这页时才下载。 */
|
||||
let ready = null;
|
||||
function boot() {
|
||||
if (ready) return ready;
|
||||
ready = Promise.all([import('../assets/vendor/three.module.min.js'), import('../assets/universe/planets.js?v=2')]).then(([THREE, P]) => {
|
||||
const SZ = 300, R = new THREE.WebGLRenderer({ antialias: true, alpha: true, preserveDrawingBuffer: true });
|
||||
R.setPixelRatio(1); R.setSize(SZ, SZ, false); R.setClearColor(0x000000, 0);
|
||||
const cam = new THREE.PerspectiveCamera(30, 1, 0.1, 100), L = new THREE.Vector3(-1, 0.6, 0.6).normalize();
|
||||
const thumbs = {}, live = new Map();
|
||||
const make = (style, seed) => { const s = new THREE.Scene(), p = P.makePlanet(THREE, { style, r: 1, seed: seed ?? 4.2, spin: 0.25 }); s.add(p.group); return { s, p, ring: style === 'ringed' }; };
|
||||
const draw = (it, ctx) => { cam.position.set(0, it.ring ? 1.5 : 0.4, it.ring ? 9.8 : 4.6); cam.lookAt(0, 0, 0); R.render(it.s, cam);
|
||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); ctx.drawImage(R.domElement, 0, 0, ctx.canvas.width, ctx.canvas.height); };
|
||||
let last = performance.now();
|
||||
(function frame(now) {
|
||||
const dt = Math.min(0.05, (now - last) / 1000); last = now;
|
||||
for (const [cv, x] of live) { if (!cv.isConnected) { live.delete(cv); continue; } x.it.p.update(dt, now / 1000, L); if (cv.offsetParent) draw(x.it, x.ctx); }
|
||||
requestAnimationFrame(frame);
|
||||
})(last);
|
||||
return {
|
||||
labels: P.STYLE_LABELS,
|
||||
thumb(style) { if (!thumbs[style]) { const it = make(style), c = document.createElement('canvas'); c.width = c.height = 96; it.p.update(0, 1, L); draw(it, c.getContext('2d')); thumbs[style] = c.toDataURL(); } return thumbs[style]; },
|
||||
live(cv, style) { const old = live.get(cv); if (old && old.style === style) return; live.set(cv, { style, it: make(style), ctx: cv.getContext('2d') }); },
|
||||
stop(cv) { live.delete(cv); },
|
||||
};
|
||||
}).catch(e => { console.warn('[内容后台] 星球预览没起来:', e); return null; });
|
||||
return ready;
|
||||
}
|
||||
window.__pp = { boot };
|
||||
</script>
|
||||
<script>
|
||||
'use strict';
|
||||
const API = '/order/api/cms/'; /* nginx:/order/api/ → server.py 的 /api/ */
|
||||
const $ = s => document.querySelector(s), $$ = s => [...document.querySelectorAll(s)];
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
const clone = o => JSON.parse(JSON.stringify(o));
|
||||
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
||||
function toast(t, bad) { const e = $('#toast'); e.textContent = t; e.classList.toggle('bad', !!bad); e.classList.add('on'); clearTimeout(e._t); e._t = setTimeout(() => e.classList.remove('on'), bad ? 5200 : 2600); }
|
||||
const fmt = ts => { if (!ts) return '—'; const d = new Date(ts * 1000); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0') + ' ' + d.toTimeString().slice(0, 5); };
|
||||
const today = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
||||
const rid = p => p + Math.random().toString(36).slice(2, 10);
|
||||
|
||||
/* ------------------------------------------------ 接口 */
|
||||
let CSRF = '', ME = null;
|
||||
async function api(path, body) {
|
||||
const opt = body === undefined ? { credentials: 'same-origin' }
|
||||
: { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', 'X-CSRF': CSRF }, body: JSON.stringify(body) };
|
||||
let r, j = {};
|
||||
try { r = await fetch(API + path, opt); } catch (e) { return { ok: false, error: '连不上服务器(网络断了?)', status: 0 }; }
|
||||
try { j = await r.json(); } catch (e) { j = { ok: false, error: '服务器回了看不懂的东西(' + r.status + ')' }; }
|
||||
j.status = r.status;
|
||||
if (r.status === 401 && path !== 'login' && path !== 'me') { ME = null; gate(); }
|
||||
if (r.status === 403 && j.must_change) { ME && (ME.must_change = true); gate(); }
|
||||
return j;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 登录 / 首次改密 / 退出 */
|
||||
function gate() {
|
||||
const inApp = ME && !ME.must_change;
|
||||
$('#gLogin').hidden = !!ME; $('#gFirst').hidden = !(ME && ME.must_change); $('#app').hidden = !inApp;
|
||||
if (!ME) setTimeout(() => $('#lgUser').focus(), 50);
|
||||
else if (ME.must_change) setTimeout(() => $('#fpOld').focus(), 50);
|
||||
}
|
||||
$$('.eye').forEach(b => b.onclick = () => { const i = b.parentNode.querySelector('input'); i.type = i.type === 'password' ? 'text' : 'password'; b.setAttribute('aria-label', i.type === 'password' ? '显示密码' : '隐藏密码'); });
|
||||
$('#loginForm').onsubmit = async e => {
|
||||
e.preventDefault();
|
||||
const b = $('#lgGo'); b.disabled = true; $('#lgMsg').textContent = '';
|
||||
const j = await api('login', { user: $('#lgUser').value.trim(), password: $('#lgPw').value, remember: $('#lgRemember').checked });
|
||||
b.disabled = false; $('#lgPw').value = '';
|
||||
if (!j.ok) { $('#lgMsg').textContent = j.error || '登录不了'; $('#lgPw').focus(); return; }
|
||||
CSRF = j.csrf; ME = { user: j.user, email: j.email, must_change: j.must_change };
|
||||
gate(); if (!ME.must_change) start();
|
||||
};
|
||||
$('#firstForm').onsubmit = async e => {
|
||||
e.preventDefault();
|
||||
const n = $('#fpNew').value;
|
||||
if (n !== $('#fpAgain').value) { $('#fpMsg').textContent = '两次输的新密码不一样'; return; }
|
||||
const j = await api('password', { old: $('#fpOld').value, new: n });
|
||||
if (!j.ok) { $('#fpMsg').textContent = j.error || '改不了'; return; }
|
||||
['#fpOld', '#fpNew', '#fpAgain'].forEach(s => $(s).value = ''); $('#fpMsg').textContent = '';
|
||||
ME = null; CSRF = ''; gate(); toast('密码改好了。所有登录都已作废,用新密码再登录一次');
|
||||
};
|
||||
$('#fpOut').onclick = async e => { e.preventDefault(); await api('logout', {}); ME = null; gate(); };
|
||||
$('#logoutBtn').onclick = async () => { await flush(); await api('logout', {}); ME = null; gate(); toast('已退出'); };
|
||||
|
||||
/* ------------------------------------------------ 内容:草稿自动保存 */
|
||||
let DOC = null, PUB = null, VERSION = 0, BASE = 0, CHANGES = [], saveTimer = 0, saving = null, dirtyLocal = false, TPLKEYS = [];
|
||||
async function loadContent() {
|
||||
const j = await api('content');
|
||||
if (!j.ok) { toast(j.error || '内容取不到', true); return false; }
|
||||
PUB = j.published; DOC = j.draft; VERSION = j.version; BASE = j.has_draft ? (j.draft_base || j.version) : j.version; CHANGES = j.changes || []; TPLKEYS = j.tpl_keys || [];
|
||||
if (j.has_draft && j.draft_base && j.draft_base !== j.version) toast('提醒:别人在你上次编辑之后发布过 v' + j.version + ',你的草稿是基于 v' + j.draft_base + ' 改的,发布前先核对一下', true);
|
||||
return true;
|
||||
}
|
||||
function mark() { /* 本地改了:画面先更新,800ms 后存草稿 */
|
||||
dirtyLocal = true; setSaving('…'); refreshCounts();
|
||||
clearTimeout(saveTimer); saveTimer = setTimeout(save, 800);
|
||||
}
|
||||
async function save() {
|
||||
if (saving) { await saving; }
|
||||
if (!dirtyLocal) return;
|
||||
dirtyLocal = false; setSaving('保存中…');
|
||||
/* 还在上传的图(没 src)先不发;存好后**不替换本地 DOC**(开着的编辑抽屉、上传回调都拿着本地对象的引用) */
|
||||
const doc = clone(DOC); doc.site.gallery = doc.site.gallery.filter(g => !g._up);
|
||||
saving = api('draft', { doc, base: BASE }).then(j => {
|
||||
saving = null;
|
||||
if (!j.ok) { dirtyLocal = true; setSaving('没存上', true); toast('草稿没存上:' + (j.error || '未知原因'), true); return false; }
|
||||
CHANGES = j.changes || []; setSaving('草稿已保存'); refreshCounts(); return true;
|
||||
});
|
||||
return saving;
|
||||
}
|
||||
async function flush() { clearTimeout(saveTimer); if (dirtyLocal) await save(); else if (saving) await saving; }
|
||||
function setSaving(t, bad) { const e = $('#saving'); e.textContent = t; e.classList.toggle('bad', !!bad); }
|
||||
function refreshCounts() {
|
||||
const n = CHANGES.reduce((s, c) => s + c[1] + c[2] + c[3], 0);
|
||||
$('#pubN').hidden = !n; $('#pubN').textContent = n; $('#pubBtn').disabled = !n && !dirtyLocal;
|
||||
$('#pubBtn').title = n ? n + ' 处改动还没发布' : '没有要发布的改动';
|
||||
const map = { '首页文案': 'hero', '板块说明': 'hero', '画展': 'gallery', '工具与开源': 'apps', '金钻宇宙': 'universe', '金钻宇宙 · 空槽': 'universe', '平台分组': 'links', '平台入口': 'links',
|
||||
'关于': 'about', '下单页模板': 'tpl', '下单页文字': 'tpl', '价格档位': 'price', '付款方式': 'price' };
|
||||
const per = {}; CHANGES.forEach(c => { const k = map[c[0]]; if (k) per[k] = (per[k] || 0) + c[1] + c[2] + c[3]; });
|
||||
$$('.nav .n').forEach(e => e.textContent = per[e.dataset.n] || '');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 导航 */
|
||||
let PANE = 'home';
|
||||
function go(p) {
|
||||
if (!document.getElementById('p-' + p)) p = 'home';
|
||||
PANE = p;
|
||||
$$('.pane').forEach(x => x.classList.toggle('on', x.id === 'p-' + p));
|
||||
$$('#nav button').forEach(b => b.setAttribute('aria-current', String(b.dataset.p === p)));
|
||||
try { history.replaceState(null, '', '#/' + p); } catch (e) {}
|
||||
$('#nav').classList.remove('open'); window.scrollTo({ top: 0 });
|
||||
if (p === 'home') renderHome();
|
||||
if (p === 'versions') renderVersions();
|
||||
if (p === 'account') renderAccount();
|
||||
if (p === 'universe') renderUni(true);
|
||||
}
|
||||
$('#nav').addEventListener('click', e => { const b = e.target.closest('button[data-p]'); if (b) go(b.dataset.p); });
|
||||
$('#menuBtn').onclick = e => { e.stopPropagation(); $('#nav').classList.toggle('open'); };
|
||||
document.addEventListener('click', e => { if (!e.target.closest('#nav') && !e.target.closest('#menuBtn')) $('#nav').classList.remove('open'); });
|
||||
|
||||
/* ------------------------------------------------ 简单字段绑定(data-bind="site.hero.tagline") */
|
||||
const getp = (o, p) => p.split('.').reduce((a, k) => a == null ? a : a[k], o);
|
||||
function setp(o, p, v) { const ks = p.split('.'); const last = ks.pop(); const t = ks.reduce((a, k) => (a[k] = a[k] || {}), o); t[last] = v; }
|
||||
const urlOk = u => /^https:\/\/[^\s<>"']+$/i.test(u) || /^mailto:[^\s@<>"']+@[^\s@<>"']+$/i.test(u);
|
||||
function bindFields() {
|
||||
$$('[data-bind]').forEach(el => {
|
||||
const p = el.dataset.bind, v = getp(DOC, p);
|
||||
if (el.type === 'checkbox') el.checked = !!v; else el.value = v == null ? '' : v;
|
||||
el.oninput = el.onchange = () => {
|
||||
let val = el.type === 'checkbox' ? el.checked : (el.type === 'number' ? (el.value === '' ? 0 : Number(el.value)) : el.value);
|
||||
if (el.hasAttribute('data-url')) { const ok = !val || /^https:\/\//i.test(val); el.classList.toggle('err', !ok); if (!ok) return; }
|
||||
setp(DOC, p, val); mark();
|
||||
if (p.startsWith('site.hero.')) renderHeroMini();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 概览 */
|
||||
async function renderHome() {
|
||||
const n = CHANGES.reduce((s, c) => s + c[1] + c[2] + c[3], 0), S = DOC.site;
|
||||
$('#stats').innerHTML =
|
||||
'<div class="stat ' + (n ? 'warn' : '') + '"><div class="k">没发布的改动</div><div class="v">' + n + '</div><div class="s">' + (n ? '网站上还看不到' : '草稿和网站一致') + '</div></div>'
|
||||
+ '<div class="stat"><div class="k">网站上是</div><div class="v">v' + VERSION + '</div><div class="s">点「发布记录」看历史</div></div>'
|
||||
+ '<div class="stat"><div class="k">画展作品</div><div class="v">' + S.gallery.filter(g => !g.hidden).length + '</div><div class="s">隐藏 ' + S.gallery.filter(g => g.hidden).length + ' 件</div></div>'
|
||||
+ '<div class="stat"><div class="k">世界线</div><div class="v">' + S.universe.items.length + '</div><div class="s">空槽 ' + S.universe.empty + ' 个</div></div>';
|
||||
const map = { '首页文案': 'hero', '板块说明': 'hero', '画展': 'gallery', '工具与开源': 'apps', '金钻宇宙': 'universe', '金钻宇宙 · 空槽': 'universe', '平台分组': 'links', '平台入口': 'links', '关于': 'about', '下单页模板': 'tpl', '下单页文字': 'tpl', '价格档位': 'price', '付款方式': 'price' };
|
||||
$('#dirtyList').innerHTML = CHANGES.length ? CHANGES.map(c => '<div class="item dirty"><div class="body"><div class="t">' + esc(c[0]) + '</div><div class="m">' + esc(dtxt(c)) + '</div></div><div class="acts"><button class="btn sm" type="button" data-jump="' + (map[c[0]] || 'home') + '">去看</button></div></div>').join('')
|
||||
+ '<div class="row" style="margin-top:6px"><button class="btn pri" type="button" id="homePub">发布这些改动</button><button class="btn bad" type="button" id="homeDiscard">全部丢掉</button></div>'
|
||||
: '<div class="empty">没有没发布的改动。改任何东西都会先存成草稿。</div>';
|
||||
$$('[data-jump]').forEach(b => b.onclick = () => go(b.dataset.jump));
|
||||
if ($('#homePub')) $('#homePub').onclick = openPublish;
|
||||
if ($('#homeDiscard')) $('#homeDiscard').onclick = discardAll;
|
||||
const a = await api('audit');
|
||||
$('#auditList').innerHTML = (a.audit || []).slice(0, 10).map(x => '<div class="item"><div class="body"><div class="t">' + esc(x.what) + '</div><div class="m">' + esc(fmt(x.at)) + ' · ' + esc(x.who) + ' · ' + esc(x.ip) + '</div></div></div>').join('') || '<div class="empty">还没有记录。</div>';
|
||||
}
|
||||
const dtxt = c => [c[1] && '新增 ' + c[1], c[2] && '改了 ' + c[2], c[3] && '删了 ' + c[3]].filter(Boolean).join(' · ');
|
||||
async function discardAll() {
|
||||
if (!confirm('丢掉所有没发布的改动?网站上的内容不受影响。')) return;
|
||||
clearTimeout(saveTimer); dirtyLocal = false;
|
||||
const j = await api('discard', {}); if (!j.ok) return toast(j.error || '丢不掉', true);
|
||||
await loadContent(); renderAll(); go('home'); toast('草稿已丢掉,回到网站上现在的内容');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 首页文案 */
|
||||
const BOARD_NAMES = { gallery: '画展', apps: '工具与开源', universe: '金钻宇宙', links: '平台入口', about: '关于' };
|
||||
function renderHeroMini() {
|
||||
const h = DOC.site.hero, N = h.notice || {}, on = N.on && N.text;
|
||||
$('#heroMini').innerHTML = (on ? '<div class="notice">' + esc(N.text) + '</div>' : '') + '<h4 class="px">金钻客栈</h4><p>' + esc(h.tagline) + '</p>'
|
||||
+ '<div class="row"><span class="btn pri sm">' + esc(h.cta1 || '逛画展') + '</span><span class="btn sm">' + esc(h.cta2 || '金钻宇宙') + '</span></div>';
|
||||
}
|
||||
function renderBoards() {
|
||||
DOC.site.boards = DOC.site.boards || {};
|
||||
$('#boardFields').innerHTML = Object.entries(BOARD_NAMES).map(([k, n]) => '<label class="fld"><span>' + esc(n) + '</span><textarea class="in" rows="2" maxlength="120" data-bind="site.boards.' + k + '"></textarea></label>').join('');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 抽屉 / 弹窗 */
|
||||
function openDrawer(title, html, foot) { $('#dTitle').textContent = title; $('#dBody').innerHTML = html; $('#dFoot').innerHTML = ''; foot.forEach(f => $('#dFoot').appendChild(f)); $('#scrim').classList.add('on'); $('#drawer').classList.add('on'); setTimeout(() => { const f = $('#dBody input,#dBody textarea'); if (f) f.focus(); }, 120); }
|
||||
function closeDrawer() { $('#scrim').classList.remove('on'); $('#drawer').classList.remove('on'); const cv = document.getElementById('uPlanetCv'); if (cv && PP) PP.stop(cv); }
|
||||
$('#dClose').onclick = closeDrawer; $('#scrim').onclick = closeDrawer;
|
||||
addEventListener('keydown', e => { if (e.key === 'Escape') { closeDrawer(); closeModal(); } });
|
||||
function openModal(html) { $('#mBox').innerHTML = html; $('#modal').classList.add('on'); }
|
||||
function closeModal() { $('#modal').classList.remove('on'); }
|
||||
$('#modal').onclick = e => { if (e.target.id === 'modal') closeModal(); };
|
||||
function bt(txt, cls, fn) { const b = document.createElement('button'); b.type = 'button'; b.className = 'btn ' + (cls || ''); b.textContent = txt; b.onclick = fn; return b; }
|
||||
function sp() { const s = document.createElement('span'); s.className = 'sp'; return s; }
|
||||
const fld = (label, inner, hint) => '<label class="fld"><span>' + label + (hint ? ' <span class="h">' + hint + '</span>' : '') + '</span>' + inner + '</label>';
|
||||
const inp = (id, v, extra) => '<input class="in" id="' + id + '" value="' + esc(v) + '" ' + (extra || '') + '>';
|
||||
const ta = (id, v, rows, extra) => '<textarea class="in" id="' + id + '" rows="' + (rows || 3) + '" ' + (extra || '') + '>' + esc(v) + '</textarea>';
|
||||
const sel = (id, opts, v) => '<select class="in" id="' + id + '">' + opts.map(o => '<option value="' + esc(o[0]) + '"' + (o[0] === v ? ' selected' : '') + '>' + esc(o[1]) + '</option>').join('') + '</select>';
|
||||
const val = id => document.getElementById(id).value;
|
||||
const dirtyIn = (list, key, item) => { const p = (list || []).find(x => x[key] === item[key]); return !p || !same(p, item); };
|
||||
function bad(id, msg) { const el = document.getElementById(id); if (el) { el.classList.add('err'); el.focus(); } toast(msg, true); return false; }
|
||||
|
||||
/* ------------------------------------------------ 画展 */
|
||||
let gF = 'all';
|
||||
const GTYPE = { image: '图片', video: '视频', pano: '全景', wall: '动态壁纸' };
|
||||
$('#gFilter').onclick = e => { const b = e.target.closest('button'); if (!b) return; gF = b.dataset.v; $$('#gFilter button').forEach(x => x.classList.toggle('on', x === b)); renderGallery(); };
|
||||
$('#gSearch').oninput = renderGallery;
|
||||
const imgUrl = p => p ? '../' + p.split('/').map(encodeURIComponent).join('/') : '';
|
||||
function renderGallery() {
|
||||
const kw = $('#gSearch').value.trim();
|
||||
const G = DOC.site.gallery;
|
||||
const rows = G.filter(g => (gF === 'all' ? true : gF === 'hidden' ? g.hidden : gF === 'special' ? (g.type === 'pano' || g.type === 'wall') : g.type === gF) && (!kw || (g.title + g.desc + g.date).includes(kw)))
|
||||
.sort((a, b) => String(b.date).localeCompare(String(a.date)));
|
||||
$('#gTiles').innerHTML = '<button type="button" class="drop" id="gDrop">+ 上传图片<small>拖到这里,或点一下选<br>PNG / JPEG / WebP,单张 ≤ 10MB</small></button>'
|
||||
+ rows.map(g => { const th = thumbOf(g);
|
||||
return '<button type="button" class="tile' + (dirtyIn(PUB.site.gallery, 'id', g) ? ' dirty' : '') + (g.hidden ? ' off' : '') + '" data-id="' + esc(g.id) + '">'
|
||||
+ '<div class="th" style="background-image:url("' + esc(imgUrl(th)) + '")"></div><div class="flags">' + (g.hidden ? '<span class="tag">隐藏</span>' : '') + (g.type !== 'image' ? '<span class="tag b">' + GTYPE[g.type] + '</span>' : '') + (g.owner === 'gift' ? '<span class="tag y">他人制作</span>' : '') + (g._up ? '<span class="tag g">处理中</span>' : '') + '</div>'
|
||||
+ '<div class="cap"><b>' + esc(g.title) + '</b><span>' + esc(g.date) + '</span>' + (g._up ? '<div class="prog"><i style="width:' + g._up + '%"></i></div>' : '') + '</div></button>'; }).join('');
|
||||
$('#gDrop').onclick = () => $('#gFile').click();
|
||||
const dz = $('#gDrop');
|
||||
['dragenter', 'dragover'].forEach(ev => dz.addEventListener(ev, e => { e.preventDefault(); dz.classList.add('over'); }));
|
||||
['dragleave', 'drop'].forEach(ev => dz.addEventListener(ev, e => { e.preventDefault(); dz.classList.remove('over'); }));
|
||||
dz.addEventListener('drop', e => upload([...e.dataTransfer.files]));
|
||||
$$('#gTiles .tile').forEach(t => t.onclick = () => { const g = DOC.site.gallery.find(x => x.id === t.dataset.id); if (g && !g._up) editGallery(g); });
|
||||
}
|
||||
$('#gFile').onchange = e => { upload([...e.target.files]); e.target.value = ''; };
|
||||
async function upload(files) {
|
||||
files = files.filter(f => /^image\/(png|jpeg|webp)$/.test(f.type));
|
||||
if (!files.length) return toast('只收 PNG / JPEG / WebP 图片', true);
|
||||
for (const f of files) {
|
||||
if (f.size > 10 * 1024 * 1024) { toast('「' + f.name + '」超过 10MB,没传', true); continue; }
|
||||
const tmp = { id: rid('g'), title: f.name.replace(/\.\w+$/, '').slice(0, 60), date: today(), type: 'image', owner: 'own', desc: '', hidden: false, _up: 10 };
|
||||
DOC.site.gallery.push(tmp); renderGallery();
|
||||
const data = await new Promise(res => { const r = new FileReader(); r.onload = () => res(r.result); r.onerror = () => res(''); r.readAsDataURL(f); });
|
||||
tmp._up = 45; renderGallery();
|
||||
const j = await api('upload', { name: f.name, data });
|
||||
const g = DOC.site.gallery.find(x => x.id === tmp.id);
|
||||
if (!j.ok) { DOC.site.gallery = DOC.site.gallery.filter(x => x.id !== tmp.id); renderGallery(); toast('「' + f.name + '」没传上:' + (j.error || ''), true); continue; }
|
||||
if (g) { delete g._up; Object.assign(g, { src: j.src, thumb: j.thumb, r: j.r }); }
|
||||
renderGallery(); mark(); toast('「' + tmp.title + '」传好了:核验通过、去掉了照片信息、缩略图已生成(存在草稿里,发布后上线)');
|
||||
}
|
||||
}
|
||||
$('#gVideo').onclick = () => { const g = { id: rid('g'), title: '', date: today(), type: 'video', owner: 'own', desc: '', url: '', hidden: false }; editGallery(g, true); };
|
||||
/* 作品的预览图:作品自带缩略图 → 离线缩略图索引(content 的 media)→ 封面 / 第一帧 → 原图(本站 mp4 不能当图片用) */
|
||||
function thumbOf(g) {
|
||||
const M = DOC.site.media || {}, first = g.poster || (g.frames && g.frames[0] && g.frames[0].src) || '';
|
||||
const isVid = /\.(mp4|webm)$/i.test(g.src || '');
|
||||
return g.thumb || (g.src && M[g.src] && M[g.src].t) || (first && M[first] && M[first].t) || first || (isVid ? '' : g.src) || '';
|
||||
}
|
||||
const localVid = g => g.type === 'video' && /\.(mp4|webm)$/i.test(g.src || '');
|
||||
function editGallery(g, isNew) {
|
||||
const th = thumbOf(g);
|
||||
openDrawer(isNew ? '加一个视频' : '编辑作品',
|
||||
(th ? '<div class="dimg" style="background-image:url("' + esc(imgUrl(th)) + '")"></div>' : '')
|
||||
+ fld('标题', inp('fTitle', g.title, 'maxlength="60"'))
|
||||
+ '<div class="fgrid">' + fld('日期', inp('fDate', g.date, 'type="date"')) + fld('类型', sel('fType', localVid(g) ? [['video', '视频(本站文件)']] : g.type === 'video' ? [['video', '视频(B 站)']] : (g.frames ? [['wall', '动态壁纸'], ['image', '图片']] : [['image', '图片'], ['pano', '全景(能拖着转一圈)']]), g.type)) + '</div>'
|
||||
+ fld('归属', sel('fOwner', [['own', '金钻制作'], ['gift', '他人制作(需授权)']], g.owner))
|
||||
+ fld('说明', ta('fDesc', g.desc, 3, 'maxlength="300"'), '(可空)')
|
||||
+ '<div id="fUrlWrap"' + (g.type === 'video' ? '' : ' hidden') + '>' + fld('B 站链接', inp('fUrl', g.url || '', 'placeholder="https://www.bilibili.com/video/BV…"'), localVid(g) ? '(本站视频,可空;填了就多一个「去 B 站看」)' : '(视频不上传,只填链接)') + '</div>'
|
||||
+ '<label class="switch"><input type="checkbox" id="fHidden"' + (g.hidden ? ' checked' : '') + '><i></i>在网站上隐藏</label>',
|
||||
[isNew ? sp() : bt('删掉', 'bad', () => { if (!confirm('删掉「' + g.title + '」?发布后网站上就没了(发布记录里还能找回)。')) return; DOC.site.gallery = DOC.site.gallery.filter(x => x.id !== g.id); closeDrawer(); renderGallery(); mark(); }), sp(), bt('取消', '', closeDrawer),
|
||||
bt('存进草稿', 'pri', () => {
|
||||
const t = val('fType'), u = val('fUrl').trim();
|
||||
if (!val('fTitle').trim()) return bad('fTitle', '标题不能空');
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(val('fDate'))) return bad('fDate', '日期要填完整');
|
||||
if (t === 'video' && !localVid(g) && !/^https:\/\//i.test(u)) return bad('fUrl', '视频要填 https:// 开头的 B 站链接');
|
||||
if (u && !/^https:\/\//i.test(u)) return bad('fUrl', '链接要 https:// 开头');
|
||||
Object.assign(g, { title: val('fTitle').trim(), date: val('fDate'), type: t, owner: val('fOwner'), desc: val('fDesc'), hidden: document.getElementById('fHidden').checked });
|
||||
if (t === 'video') g.url = u; else delete g.url;
|
||||
if (isNew) DOC.site.gallery.push(g); closeDrawer(); renderGallery(); mark(); toast('存进草稿了(发布后上线)'); })]);
|
||||
document.getElementById('fType').onchange = e => { document.getElementById('fUrlWrap').hidden = e.target.value !== 'video'; };
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 工具与开源 */
|
||||
function renderApps() {
|
||||
$('#appList').innerHTML = DOC.site.apps.map(a => '<div class="item' + (dirtyIn(PUB.site.apps, 'id', a) ? ' dirty' : '') + '"><div class="body"><div class="t">' + esc(a.name) + ' <span class="tag ' + (a.oss ? 'g' : 'b') + '">' + (a.oss ? '开源' : '闭源') + '</span>' + (a.type ? '<span class="tag">' + esc(a.type) + '</span>' : '') + (a.url ? '' : '<span class="tag y">待上架</span>') + '</div><div class="m">' + esc(a.desc) + '</div></div><div class="acts"><button class="btn sm" type="button" data-app="' + esc(a.id) + '">编辑</button></div></div>').join('') || '<div class="empty">还没有。</div>';
|
||||
$$('[data-app]').forEach(b => b.onclick = () => editApp(DOC.site.apps.find(a => a.id === b.dataset.app)));
|
||||
}
|
||||
$('#appAdd').onclick = () => editApp({ id: rid('a'), name: '', en: '', type: '小工具', oss: true, desc: '', ver: '', size: '', status: '待上架', url: '', repo: '' }, true);
|
||||
function editApp(a, isNew) {
|
||||
openDrawer(isNew ? '加一个工具' : '编辑工具',
|
||||
'<div class="fgrid">' + fld('名称', inp('aName', a.name, 'maxlength="30"')) + fld('英文名', inp('aEn', a.en, 'maxlength="40"'), '(标题旁的小字)') + '</div>'
|
||||
+ '<div class="fgrid">' + fld('类型', inp('aType', a.type, 'maxlength="12"')) + fld('开源 / 闭源', sel('aOss', [['1', '开源'], ['0', '闭源']], a.oss ? '1' : '0')) + '</div>'
|
||||
+ fld('一句话介绍', ta('aDesc', a.desc, 3, 'maxlength="300"'))
|
||||
+ '<div class="fgrid">' + fld('版本', inp('aVer', a.ver, 'maxlength="24"')) + fld('状态', inp('aStatus', a.status, 'maxlength="12"')) + '</div>'
|
||||
+ '<div class="fgrid">' + fld('大小', inp('aSize', a.size || '', 'maxlength="16"'), '(可空)') + fld('按钮文字', inp('aBtn', a.btn || '', 'maxlength="16" placeholder="下载 ↓"'), '(可空)') + '</div>'
|
||||
+ fld('打开链接', inp('aUrl', a.url, 'placeholder="https://… 或站内路径 /order/"'), '(空 = 待上架)')
|
||||
+ '<label class="switch" style="margin:-4px 0 14px"><input type="checkbox" id="aWeb"' + (a.web ? ' checked' : '') + '><i></i>是网页(按钮写「在线体验」,不是下载)</label>'
|
||||
+ fld('源码仓库', inp('aRepo', a.repo, 'placeholder="https://…"'), '(可空)'),
|
||||
[isNew ? sp() : bt('删掉', 'bad', () => { if (!confirm('删掉「' + a.name + '」?')) return; DOC.site.apps = DOC.site.apps.filter(x => x.id !== a.id); closeDrawer(); renderApps(); mark(); }), sp(), bt('取消', '', closeDrawer),
|
||||
bt('存进草稿', 'pri', () => {
|
||||
if (!val('aName').trim()) return bad('aName', '名称不能空');
|
||||
const u = val('aUrl').trim(), r = val('aRepo').trim();
|
||||
if (u && !/^https:\/\//i.test(u) && !/^\/[A-Za-z0-9_\-./]*$/.test(u)) return bad('aUrl', '链接要以 https:// 开头,或站内路径(/ 开头)');
|
||||
if (r && !/^https:\/\//i.test(r)) return bad('aRepo', '仓库链接要以 https:// 开头');
|
||||
Object.assign(a, { name: val('aName').trim(), en: val('aEn').trim(), type: val('aType').trim(), oss: val('aOss') === '1', desc: val('aDesc'), ver: val('aVer'), status: val('aStatus'), size: val('aSize'), url: u, repo: r, web: document.getElementById('aWeb').checked });
|
||||
const b = val('aBtn').trim(); if (b) a.btn = b; else delete a.btn;
|
||||
if (isNew) DOC.site.apps.push(a); closeDrawer(); renderApps(); mark(); toast('存进草稿了'); })]);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 金钻宇宙 */
|
||||
const STYLES = [['earth', '类地(卡通地球)'], ['ocean', '海洋'], ['jungle', '丛林'], ['desert', '荒漠'], ['tundra', '冻原'], ['ice', '冰封'], ['lava', '熔岩'], ['toxic', '毒雾'],
|
||||
['barren', '荒芜岩球'], ['gas', '气态巨星'], ['icegiant', '冰巨星'], ['ringed', '带环巨星'], ['crystal', '晶体'], ['paper', '铅笔纸面'], ['neon', '霓虹城'], ['duality', '善恶两半'], ['rock', '小行星']];
|
||||
const ENTERS = [['push', '推进'], ['zoom', '放大(长焦再推)'], ['rise', '升空俯冲'], ['warp', '跃迁'], ['orbit', '绕行']];
|
||||
const ACCENTS = ['#FFD36E', '#F6F1E4', '#9FE3FF', '#C9A6FF', '#FF9DB8', '#7FE0A8', '#FFB074', '#8E96C8'];
|
||||
let PP = null;
|
||||
async function ensurePP() { if (!PP && window.__pp) PP = await window.__pp.boot(); return PP; }
|
||||
async function renderUni(withPresets) {
|
||||
const U = DOC.site.universe;
|
||||
$('#uniCount').textContent = '已点亮 ' + U.items.length + ' 条';
|
||||
const pp = withPresets ? await ensurePP() : PP;
|
||||
$('#uniList').innerHTML = U.items.map(u => '<div class="item' + (dirtyIn(PUB.site.universe.items, 'no', u) ? ' dirty' : '') + '">'
|
||||
+ (pp ? '<span class="sw img" style="background-image:url(' + pp.thumb(u.look.style) + ')"></span>' : '<span class="sw" style="background:' + esc(u.look.accent) + '"></span>')
|
||||
+ '<div class="body"><div class="t"><span style="font-family:var(--mono);color:var(--dim);font-weight:600">' + esc(u.no) + '</span>' + esc(u.name) + '<span class="tag">' + esc(u.kind) + '</span></div><div class="m">' + esc(u.tag) + ' · ' + esc((STYLES.find(s => s[0] === u.look.style) || [, u.look.style])[1]) + (u.look.enter ? ' · 入场' + esc((ENTERS.find(s => s[0] === u.look.enter) || [, ''])[1]) : '') + '</div></div><div class="acts"><button class="btn sm" type="button" data-uni="' + esc(u.no) + '">编辑</button></div></div>').join('') || '<div class="empty">还没有点亮的世界线。</div>';
|
||||
$$('[data-uni]').forEach(b => b.onclick = () => editUni(DOC.site.universe.items.find(u => u.no === b.dataset.uni)));
|
||||
if (withPresets && pp && !$('#presetGrid canvas')) {
|
||||
const g = $('#presetGrid'); g.innerHTML = '';
|
||||
STYLES.forEach(([k, n]) => {
|
||||
const d = document.createElement('div'); d.className = 'pre';
|
||||
const cv = document.createElement('canvas'); cv.width = cv.height = 220; d.append(cv);
|
||||
d.insertAdjacentHTML('beforeend', '<b>' + esc(n) + '</b><code>' + esc(k) + '</code>');
|
||||
d.append(bt('用它点亮', 'sm', () => lightNew(k)));
|
||||
g.append(d); pp.live(cv, k);
|
||||
});
|
||||
} else if (withPresets && !pp) $('#presetGrid').innerHTML = '<div class="empty">这台设备打不开 3D 预览(下拉照样能选)。</div>';
|
||||
}
|
||||
function lightNew(style) {
|
||||
const nos = DOC.site.universe.items.map(u => +u.no);
|
||||
const no = String((nos.length ? Math.max(...nos) : -1) + 1).padStart(4, '0');
|
||||
editUni({ no, name: '', kind: '原创', tag: '', desc: '', tags: [], look: { style: style || 'earth', accent: '#7FE0A8', enter: 'push' } }, true);
|
||||
}
|
||||
$('#uniAdd').onclick = () => lightNew();
|
||||
async function editUni(u, isNew) {
|
||||
const L = u.look || {};
|
||||
openDrawer(isNew ? '点亮世界线 ' + u.no : '世界线 ' + u.no,
|
||||
(isNew ? '<p class="h" style="margin:0 0 10px">新点亮的会自动排到中圈一个不挤的位置,补给线接到附近的星上;已有的星系、卫星和连线都不动。</p>' : '')
|
||||
+ '<div class="stage-mini"><canvas id="uPlanetCv" width="300" height="300"></canvas>星系图上的样子<b id="uPName">' + esc(u.name || '未命名') + '</b></div>'
|
||||
+ '<div class="fgrid">' + fld('名字', inp('uName', u.name, 'maxlength="12"')) + fld('类型', sel('uKind', [['主宇宙', '主宇宙'], ['原创', '原创'], ['二创', '二创']], u.kind)) + '</div>'
|
||||
+ fld('一句话', inp('uTag', u.tag, 'maxlength="24"')) + fld('简介', ta('uDesc', u.desc, 4, 'maxlength="600"')) + fld('标签', inp('uTags', (u.tags || []).join(',')), '(用逗号隔开,最多 10 个)')
|
||||
+ '<div class="fgrid">' + fld('星球风格', sel('uStyle', STYLES, L.style)) + fld('入场运镜', sel('uEnter', ENTERS, L.enter || 'push'), '(点开这颗星时镜头怎么飞)') + '</div>'
|
||||
+ '<div class="fld"><span>主色 <span class="h">(名牌、档案卡左边那条线)</span></span><div class="swatches" id="uSw">' + ACCENTS.map(c => '<button type="button" data-c="' + c + '" style="background:' + c + '"' + (c === L.accent ? ' class="on"' : '') + ' aria-label="' + c + '"></button>').join('') + '</div></div>',
|
||||
[isNew ? sp() : bt('熄灭', 'bad', () => { if (!confirm('熄灭「' + u.name + '」?星系图上它会消失(发布记录里还能找回)。')) return; DOC.site.universe.items = DOC.site.universe.items.filter(x => x.no !== u.no); closeDrawer(); renderUni(); mark(); }), sp(), bt('取消', '', closeDrawer),
|
||||
bt('存进草稿', 'pri', () => {
|
||||
if (!val('uName').trim()) return bad('uName', '名字不能空');
|
||||
const tags = val('uTags').split(/[,,、]/).map(s => s.trim()).filter(Boolean);
|
||||
if (tags.length > 10) return bad('uTags', '标签最多 10 个');
|
||||
Object.assign(u, { name: val('uName').trim(), kind: val('uKind'), tag: val('uTag'), desc: val('uDesc'), tags });
|
||||
u.look = Object.assign({}, L, { style: val('uStyle'), enter: val('uEnter'), accent: pick });
|
||||
if (isNew) DOC.site.universe.items.push(u); closeDrawer(); renderUni(); mark(); toast('存进草稿了'); })]);
|
||||
let pick = L.accent || '#7FE0A8';
|
||||
const pp = await ensurePP();
|
||||
const paint = () => { const cv = document.getElementById('uPlanetCv'); if (cv && pp) pp.live(cv, val('uStyle'));
|
||||
const n = document.getElementById('uPName'); if (n) { n.textContent = val('uName') || '未命名'; n.style.color = pick; } };
|
||||
paint(); document.getElementById('uStyle').onchange = paint; document.getElementById('uName').oninput = paint;
|
||||
$('#uSw').onclick = e => { const b = e.target.closest('button'); if (!b) return; pick = b.dataset.c; $$('#uSw button').forEach(x => x.classList.toggle('on', x === b)); paint(); };
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 平台入口 */
|
||||
const ICONS = [['bili', '哔哩哔哩'], ['douyin', '抖音'], ['kuaishou', '快手'], ['xiaohongshu', '小红书'], ['cgmodel', 'CG模型网'], ['codemao', '编程猫'], ['steam', 'Steam'], ['lang', '语言包'], ['github', 'GitHub'], ['workshop', 'B站工坊'], ['xianyu', '闲鱼'], ['mail', '邮箱']];
|
||||
function renderLinks() {
|
||||
const S = DOC.site;
|
||||
$('#linkGroups').innerHTML = S.linkGroups.map(gr => {
|
||||
const ls = S.links.filter(l => l.group === gr.id);
|
||||
return '<div class="card"><h2>' + esc(gr.name) + ' <span class="sub">' + esc(gr.en) + ' · ' + ls.length + ' 个</span></h2><div class="list">'
|
||||
+ (ls.length ? ls.map((l, i) => '<div class="item' + (dirtyIn(PUB.site.links, 'id', l) ? ' dirty' : '') + '"><div class="body"><div class="t">' + esc(l.name) + '</div><div class="m">' + esc(l.desc) + ' · ' + esc(l.url) + '</div></div><div class="acts">'
|
||||
+ '<button class="btn sm" type="button" data-up="' + esc(l.id) + '"' + (i ? '' : ' disabled') + ' aria-label="往上挪">↑</button><button class="btn sm" type="button" data-dn="' + esc(l.id) + '"' + (i < ls.length - 1 ? '' : ' disabled') + ' aria-label="往下挪">↓</button><button class="btn sm" type="button" data-link="' + esc(l.id) + '">编辑</button></div></div>').join('')
|
||||
: '<div class="empty">这一组还没有。</div>') + '</div></div>';
|
||||
}).join('');
|
||||
$$('[data-link]').forEach(b => b.onclick = () => editLink(DOC.site.links.find(l => l.id === b.dataset.link)));
|
||||
const move = (id, d) => { const L = DOC.site.links, i = L.findIndex(l => l.id === id), g = L[i].group; let j = i + d; while (j >= 0 && j < L.length && L[j].group !== g) j += d; if (j < 0 || j >= L.length) return; [L[i], L[j]] = [L[j], L[i]]; renderLinks(); mark(); };
|
||||
$$('[data-up]').forEach(b => b.onclick = () => move(b.dataset.up, -1)); $$('[data-dn]').forEach(b => b.onclick = () => move(b.dataset.dn, 1));
|
||||
}
|
||||
$('#linkAdd').onclick = () => editLink({ id: rid('l'), group: (DOC.site.linkGroups[0] || {}).id || '', key: 'bili', name: '', en: '', desc: '', url: '' }, true);
|
||||
function editLink(l, isNew) {
|
||||
openDrawer(isNew ? '加一个入口' : '编辑入口',
|
||||
'<div class="fgrid">' + fld('分组', sel('lGroup', DOC.site.linkGroups.map(g => [g.id, g.name]), l.group)) + fld('图标', sel('lKey', ICONS.some(x => x[0] === l.key) ? ICONS : ICONS.concat([[l.key, l.key]]), l.key)) + '</div>'
|
||||
+ '<div class="fgrid">' + fld('名称', inp('lName', l.name, 'maxlength="20"')) + fld('英文名', inp('lEn', l.en, 'maxlength="24"')) + '</div>'
|
||||
+ fld('说明', inp('lDesc', l.desc, 'maxlength="40"'))
|
||||
+ fld('链接', inp('lUrl', l.url, 'placeholder="https://… 或 mailto:…"'), '(只收 https:// 和 mailto:)') + '<span class="errtxt" id="lErr"></span>',
|
||||
[isNew ? sp() : bt('删掉', 'bad', () => { if (!confirm('删掉「' + l.name + '」?')) return; DOC.site.links = DOC.site.links.filter(x => x.id !== l.id); closeDrawer(); renderLinks(); mark(); }), sp(), bt('取消', '', closeDrawer),
|
||||
bt('存进草稿', 'pri', () => {
|
||||
const u = val('lUrl').trim();
|
||||
if (!urlOk(u)) { $('#lErr').textContent = u.toLowerCase().startsWith('http://') ? '要用 https://(http 不安全,网站会拦下)' : '链接格式不对:只收 https:// 开头的网址或 mailto: 邮箱'; return bad('lUrl', '链接格式不对'); }
|
||||
if (!val('lName').trim()) return bad('lName', '名称不能空');
|
||||
Object.assign(l, { group: val('lGroup'), key: val('lKey'), name: val('lName').trim(), en: val('lEn').trim(), desc: val('lDesc').trim(), url: u });
|
||||
if (isNew) DOC.site.links.push(l); closeDrawer(); renderLinks(); mark(); toast('存进草稿了'); })]);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 关于 */
|
||||
function renderAbout() {
|
||||
const C = DOC.site.about.cards;
|
||||
$('#aboutCards').innerHTML = C.map((c, i) => '<div class="item' + (same(PUB.site.about.cards[i], c) ? '' : ' dirty') + '"><div class="body"><div class="t"><span class="tag">' + esc(c.k) + '</span>' + esc(c.h) + '</div><div class="m">' + esc(c.p) + '</div></div><div class="acts">'
|
||||
+ '<button class="btn sm" type="button" data-cu="' + i + '"' + (i ? '' : ' disabled') + ' aria-label="往上挪">↑</button><button class="btn sm" type="button" data-cd="' + i + '"' + (i < C.length - 1 ? '' : ' disabled') + ' aria-label="往下挪">↓</button><button class="btn sm" type="button" data-ab="' + i + '">编辑</button></div></div>').join('') || '<div class="empty">还没有卡片。</div>';
|
||||
$$('[data-ab]').forEach(b => b.onclick = () => editCard(C[+b.dataset.ab]));
|
||||
const mv = (i, d) => { const j = i + d; if (j < 0 || j >= C.length) return; [C[i], C[j]] = [C[j], C[i]]; renderAbout(); mark(); };
|
||||
$$('[data-cu]').forEach(b => b.onclick = () => mv(+b.dataset.cu, -1)); $$('[data-cd]').forEach(b => b.onclick = () => mv(+b.dataset.cd, 1));
|
||||
}
|
||||
$('#cardAdd').onclick = () => editCard({ k: '', h: '', p: '' }, true);
|
||||
function editCard(c, isNew) {
|
||||
openDrawer(isNew ? '加一张卡片' : '署名卡片', fld('小标题', inp('cK', c.k, 'maxlength="16"')) + fld('名字', inp('cH', c.h, 'maxlength="30"')) + fld('内容', ta('cP', c.p, 6, 'maxlength="600"'), '([文字](https://网址) 是链接,`文字` 是代码样式,空一行是新段落)'),
|
||||
[isNew ? sp() : bt('删掉', 'bad', () => { if (!confirm('删掉这张卡片?')) return; DOC.site.about.cards = DOC.site.about.cards.filter(x => x !== c); closeDrawer(); renderAbout(); mark(); }), sp(), bt('取消', '', closeDrawer),
|
||||
bt('存进草稿', 'pri', () => { if (!val('cH').trim()) return bad('cH', '名字不能空');
|
||||
Object.assign(c, { k: val('cK').trim(), h: val('cH').trim(), p: val('cP') }); if (isNew) DOC.site.about.cards.push(c); closeDrawer(); renderAbout(); mark(); toast('存进草稿了'); })]);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 下单页 */
|
||||
function renderTpl() {
|
||||
const T = DOC.order.templates;
|
||||
$('#tplList').innerHTML = T.map((t, i) => '<div class="item' + (t.on ? '' : ' off') + (same((PUB.order.templates || []).find(x => x.k === t.k), t) ? '' : ' dirty') + '"><label class="switch" title="在下单页上给买家选"><input type="checkbox" data-ton="' + i + '"' + (t.on ? ' checked' : '') + '><i></i></label><div class="body"><div class="t">' + esc(t.n) + ' <span class="tag" style="font-family:var(--mono)">' + esc(t.k) + '</span></div><div class="m">' + esc(t.s) + '</div></div><div class="acts"><button class="btn sm" type="button" data-tp="' + i + '">编辑</button></div></div>').join('');
|
||||
$$('[data-ton]').forEach(c => c.onchange = () => { const t = T[+c.dataset.ton];
|
||||
if (!c.checked && T.filter(x => x.on).length <= 1) { c.checked = true; return toast('至少要留一个模板上架', true); }
|
||||
t.on = c.checked; renderTpl(); mark(); });
|
||||
$$('[data-tp]').forEach(b => b.onclick = () => { const t = T[+b.dataset.tp];
|
||||
openDrawer('模板 ' + t.k, '<p class="h" style="margin:0 0 14px">英文 key「' + esc(t.k) + '」渲染机要认,这里改不了;只改下单页上显示的名字和说明。缩略图在 <code>/order/tpl/' + esc(t.k) + '.jpg</code>。</p>' + fld('显示名字', inp('tN', t.n, 'maxlength="12"')) + fld('一句话说明', inp('tS', t.s, 'maxlength="24"')),
|
||||
[sp(), bt('取消', '', closeDrawer), bt('存进草稿', 'pri', () => { if (!val('tN').trim()) return bad('tN', '名字不能空'); Object.assign(t, { n: val('tN').trim(), s: val('tS').trim() }); closeDrawer(); renderTpl(); mark(); toast('存进草稿了'); })]); });
|
||||
}
|
||||
function renderTiers() {
|
||||
const T = DOC.order.prices.tiers;
|
||||
$('#tierRows').innerHTML = T.map((t, i) => '<tr><td><input class="in" type="number" min="1" max="10" value="' + esc(t.n) + '" data-ti="' + i + '" data-k="n" style="width:70px" aria-label="张数"></td><td><input class="in" type="number" min="0" step="0.01" value="' + esc(t.price) + '" data-ti="' + i + '" data-k="price" style="width:90px" aria-label="价格"></td><td><input class="in" value="' + esc(t.url) + '" data-ti="' + i + '" data-k="url" placeholder="https://…" aria-label="链接"></td><td><button class="btn sm bad" type="button" data-tdel="' + i + '" aria-label="删掉这一档">删</button></td></tr>').join('')
|
||||
|| '<tr><td colspan="4" class="h">还没配档位:全部按单价 × 张数算。</td></tr>';
|
||||
$$('[data-ti]').forEach(el => el.oninput = () => { const t = T[+el.dataset.ti], k = el.dataset.k;
|
||||
if (k === 'url') { const ok = !el.value || /^https:\/\//i.test(el.value); el.classList.toggle('err', !ok); if (!ok) return; t.url = el.value; } else t[k] = Number(el.value || 0); mark(); });
|
||||
$$('[data-tdel]').forEach(b => b.onclick = () => { T.splice(+b.dataset.tdel, 1); renderTiers(); mark(); });
|
||||
}
|
||||
$('#tierAdd').onclick = () => { const T = DOC.order.prices.tiers; let n = 2; while (T.some(t => t.n === n) && n < 10) n++; T.push({ n, price: Math.round(DOC.order.prices.per * n), url: '' }); renderTiers(); mark(); };
|
||||
|
||||
/* ------------------------------------------------ 预览 / 发布 / 回滚 */
|
||||
$('#prevBtn').onclick = async () => {
|
||||
await flush();
|
||||
openModal('<h3>预览草稿</h3><p>用草稿内容打开网站,只有登录了内容后台的你看得到;访客看到的还是已发布的内容。</p>'
|
||||
+ '<div class="list"><a class="item" href="../?preview=1" target="_blank" rel="noopener"><div class="body"><div class="t">门户(草稿)</div><div class="m">首页 / 画展 / 工具 / 宇宙 / 平台入口 / 关于</div></div></a>'
|
||||
+ '<a class="item" href="/order/?preview=1" target="_blank" rel="noopener"><div class="body"><div class="t">下单页(草稿)</div><div class="m">模板上下架 / 名字说明、页头、公告(价格要发布后才变)</div></div></a></div>'
|
||||
+ '<div class="mf"><button class="btn" type="button" onclick="closeModal()">知道了</button></div>');
|
||||
};
|
||||
async function openPublish() {
|
||||
if (DOC.site.gallery.some(g => g._up)) return toast('还有图在上传,等传完再发布', true);
|
||||
await flush();
|
||||
if (dirtyLocal) return toast('最新的改动没存上(看右上角的提示),先改好再发布 —— 不然发出去的是上一次存上的草稿', true);
|
||||
if (!CHANGES.length) return toast('没有要发布的改动');
|
||||
openModal('<h3>发布这些改动</h3><p>发布后马上出现在网站上。每次发布都留一份完整版本,随时能回到之前的版本。</p>'
|
||||
+ '<ul class="chg">' + CHANGES.map(c => '<li><b>' + esc(c[0]) + '</b><span>' + esc(dtxt(c)) + '</span></li>').join('') + '</ul>'
|
||||
+ '<label class="fld"><span>这次改了什么 <span class="h">(可空,写给以后的自己看)</span></span><input class="in" id="pubNote" maxlength="60" placeholder="例:画展补了三张 / 换了国庆公告"></label>'
|
||||
+ '<div class="mf"><button class="btn" type="button" onclick="closeModal()">再看看</button><button class="btn pri" type="button" id="pubGo">发布 v' + (VERSION + 1) + '</button></div>');
|
||||
$('#pubGo').onclick = async () => {
|
||||
$('#pubGo').disabled = true;
|
||||
const j = await api('publish', { note: $('#pubNote').value.trim(), base: BASE });
|
||||
if (!j.ok) { $('#pubGo').disabled = false;
|
||||
if (j.conflict) { closeModal(); conflictModal(j.error); return; }
|
||||
return toast(j.error || '发布失败', true); }
|
||||
closeModal(); await loadContent(); renderAll(); go(PANE); toast('v' + j.version + ' 已发布,网站上已经是新内容');
|
||||
};
|
||||
}
|
||||
$('#pubBtn').onclick = openPublish;
|
||||
/* 别人在你编辑期间发布过:二选一 —— 丢掉自己的草稿看网站上现在的,或者确认后用自己的草稿覆盖发布 */
|
||||
function conflictModal(msg) {
|
||||
openModal('<h3>别人刚发布过</h3><p>' + esc(msg) + '</p><p>可以先去「发布记录」看对方改了什么。然后:</p>'
|
||||
+ '<div class="mf"><button class="btn" type="button" onclick="closeModal()">先不发</button><button class="btn bad" type="button" id="cfDrop">丢掉我的草稿</button><button class="btn pri" type="button" id="cfMine">用我的草稿覆盖发布</button></div>');
|
||||
$('#cfDrop').onclick = async () => { closeModal(); clearTimeout(saveTimer); dirtyLocal = false; await api('discard', {}); await loadContent(); renderAll(); go('home'); toast('已丢掉你的草稿,现在显示的是网站上的内容'); };
|
||||
$('#cfMine').onclick = async () => {
|
||||
if (!confirm('确定用你的草稿覆盖?对方那次发布的改动会被你的版本盖掉(发布记录里还能找回)。')) return;
|
||||
closeModal();
|
||||
const mine = clone(DOC); await loadContent(); DOC = mine; BASE = VERSION; dirtyLocal = true;
|
||||
if (!(await save())) return;
|
||||
const j = await api('publish', { note: '覆盖发布(基于 v' + VERSION + ')', base: VERSION });
|
||||
if (!j.ok) return toast(j.error || '发布失败', true);
|
||||
await loadContent(); renderAll(); go(PANE); toast('v' + j.version + ' 已发布');
|
||||
};
|
||||
}
|
||||
async function renderVersions() {
|
||||
const j = await api('versions');
|
||||
const V = j.versions || [];
|
||||
$('#verList').innerHTML = V.map((v, i) => '<div class="ver' + (i ? '' : ' cur') + '"><span class="dotc">v' + v.no + '</span><div class="body"><div class="t">' + esc(v.note || '(没写说明)') + (i ? '' : ' <span class="tag g">网站上是这一版</span>') + '</div><div class="m">' + esc(fmt(v.at)) + ' · ' + esc(v.by) + ' · ' + esc(v.chg) + '</div></div>'
|
||||
+ (i ? '<div class="acts"><button class="btn sm" type="button" data-rb="' + v.no + '">回到这一版</button></div>' : '') + '</div>').join('') || '<div class="empty">还没有发布过。</div>';
|
||||
$$('[data-rb]').forEach(b => b.onclick = () => { const no = +b.dataset.rb;
|
||||
openModal('<h3>回到 v' + no + '?</h3><p>会把 v' + no + ' 的内容当成新的一版(v' + (VERSION + 1) + ')发布出去;现在这版不会丢,还在记录里,随时能再回来。</p>'
|
||||
+ (CHANGES.length ? '<p style="color:var(--warn-t)">你还有没发布的改动,回滚会把它们一起丢掉。</p>' : '')
|
||||
+ '<div class="mf"><button class="btn" type="button" onclick="closeModal()">算了</button><button class="btn pri" type="button" id="rbGo">回到 v' + no + '</button></div>');
|
||||
$('#rbGo').onclick = async () => { $('#rbGo').disabled = true; clearTimeout(saveTimer); dirtyLocal = false;
|
||||
const r = await api('rollback', { no }); if (!r.ok) { $('#rbGo').disabled = false; return toast(r.error || '回不去', true); }
|
||||
closeModal(); await loadContent(); renderAll(); renderVersions(); toast('已回到 v' + no + '(记为 v' + r.version + ')'); }; });
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 账号与设备 */
|
||||
async function renderAccount() {
|
||||
$('#meLine').textContent = '登录账号:' + ME.user + (ME.email ? '(' + ME.email + ')' : '') + '。忘了密码在服务器上跑 admin.py user reset。';
|
||||
const j = await api('sessions');
|
||||
const S = j.sessions || [];
|
||||
$('#sessList').innerHTML = S.map(s => '<div class="item"><div class="body"><div class="t">' + esc(uaName(s.ua)) + (s.cur ? ' <span class="tag g">这台</span>' : '') + (s.remember ? ' <span class="tag">记住我</span>' : '') + '</div><div class="m">' + esc(s.ip) + ' · 最近 ' + esc(fmt(s.last)) + '</div></div>' + (s.cur ? '' : '<div class="acts"><button class="btn sm bad" type="button" data-kill="' + esc(s.id) + '">退出</button></div>') + '</div>').join('') || '<div class="empty">没有。</div>';
|
||||
$$('[data-kill]').forEach(b => b.onclick = async () => { const r = await api('sessions/revoke', { id: b.dataset.kill }); toast(r.ok ? '那台设备已退出' : (r.error || '退不掉'), !r.ok); renderAccount(); });
|
||||
$('#killAll').disabled = S.length < 2;
|
||||
}
|
||||
function uaName(ua) { ua = ua || ''; const os = /iPhone|iPad/.test(ua) ? 'iPhone / iPad' : /Android/.test(ua) ? '安卓' : /Mac OS/.test(ua) ? 'Mac' : /Windows/.test(ua) ? 'Windows' : /Linux/.test(ua) ? 'Linux' : '设备';
|
||||
const br = /Edg\//.test(ua) ? 'Edge' : /Chrome\//.test(ua) ? 'Chrome' : /Firefox\//.test(ua) ? 'Firefox' : /Safari\//.test(ua) ? 'Safari' : '浏览器'; return os + ' · ' + br; }
|
||||
$('#killAll').onclick = async () => { if (!confirm('退出除这台以外的所有设备?')) return; const r = await api('sessions/revoke', { others: true }); toast(r.ok ? '其它设备都已退出' : (r.error || '退不掉'), !r.ok); renderAccount(); };
|
||||
$('#pwForm').onsubmit = async e => {
|
||||
e.preventDefault();
|
||||
if ($('#pwNew').value !== $('#pwAgain').value) return toast('两次输的新密码不一样', true);
|
||||
const r = await api('password', { old: $('#pwOld').value, new: $('#pwNew').value });
|
||||
if (!r.ok) return toast(r.error || '改不了', true);
|
||||
e.target.reset(); renderAccount(); toast('密码改好了,其它设备都已退出');
|
||||
};
|
||||
|
||||
/* ------------------------------------------------ 启动 */
|
||||
function renderAll() { renderBoards(); bindFields(); renderHeroMini(); renderGallery(); renderApps(); renderUni(false); renderLinks(); renderAbout(); renderTpl(); renderTiers(); refreshCounts(); setSaving(''); }
|
||||
async function start() {
|
||||
if (!(await loadContent())) return;
|
||||
renderAll();
|
||||
let p = 'home'; try { p = (location.hash.match(/^#\/(\w+)/) || [])[1] || 'home'; } catch (e) {}
|
||||
go(p);
|
||||
}
|
||||
addEventListener('beforeunload', e => { if (dirtyLocal || saving) { e.preventDefault(); e.returnValue = ''; } });
|
||||
(async () => {
|
||||
const j = await api('me');
|
||||
if (j.ok) { CSRF = j.csrf; ME = { user: j.user, email: j.email, must_change: j.must_change }; gate(); if (!ME.must_change) start(); }
|
||||
else if (j.status === 403 && /https/.test(j.error || '')) { document.body.innerHTML = '<div class="gate"><div class="gbox"><h1>只能用 https 打开</h1><p class="sub">内容后台要输密码,必须走 https。请用 https:// 开头的地址重新打开。</p></div></div>'; }
|
||||
else { ME = null; gate(); }
|
||||
})();
|
||||
</script>
|
||||
</body></html>
|
||||
Binary file not shown.
@@ -0,0 +1,94 @@
|
||||
/* 金钻客栈 · 加载动画(2026-10-06 重做)
|
||||
---------------------------------------------------------------------------
|
||||
像素钻石一块一块从上面落下来、从底往上垒成形(像 MC 里堆方块)→ 一道白光扫过钻石 →「金钻客栈」逐字弹出
|
||||
→ 底下一条光谱色进度条跟着页面真实加载走 → 整块幕布往上收起,露出页面。
|
||||
· 只在这个标签页第一次打开网站时放(sessionStorage 记一下),之后站内换页不再放;
|
||||
· 系统设置了「减少动效」就完全不放(页面里那段内联脚本直接把幕布删掉);
|
||||
· 最少放 1.25 秒(垒完 + 白光扫过;太短一闪而过很怪),页面 3 秒还没加载完也照样收起,绝不卡人。 */
|
||||
(function () {
|
||||
'use strict';
|
||||
var boot = document.getElementById('jzBoot');
|
||||
if (!boot) return;
|
||||
var root = document.documentElement;
|
||||
var cv = boot.querySelector('canvas'), ctx = cv.getContext('2d'), bar = boot.querySelector('.jz-boot-bar i');
|
||||
var name = boot.querySelector('.jz-boot-name');
|
||||
var N = 14, CELL = cv.width / N, T0 = performance.now(), MIN = 1250, MAX = 3000, done = false, ready = false;
|
||||
var blocks = [];
|
||||
|
||||
/* 把每个字拆开,好一个个弹出来 */
|
||||
name.innerHTML = name.textContent.split('').map(function (c, i) { return '<span style="--i:' + i + '">' + c + '</span>'; }).join('');
|
||||
|
||||
/* 钻石原图是 14×14 的像素画:按格子中心取色,得到要垒的方块 */
|
||||
var src = new Image();
|
||||
src.onload = function () {
|
||||
var t = document.createElement('canvas'); t.width = t.height = N;
|
||||
var tc = t.getContext('2d'); tc.imageSmoothingEnabled = false; tc.drawImage(src, 0, 0, N, N);
|
||||
var d = tc.getImageData(0, 0, N, N).data;
|
||||
for (var y = 0; y < N; y++) for (var x = 0; x < N; x++) {
|
||||
var k = (y * N + x) * 4;
|
||||
if (d[k + 3] < 128) continue;
|
||||
/* 落下的先后:从底往上一层层垒,同一层里左右随机一点 */
|
||||
var order = (N - 1 - y) + Math.random() * 0.9;
|
||||
blocks.push({ x: x, y: y, c: 'rgb(' + d[k] + ',' + d[k + 1] + ',' + d[k + 2] + ')', t: order });
|
||||
}
|
||||
var maxT = 0; blocks.forEach(function (b) { if (b.t > maxT) maxT = b.t; });
|
||||
blocks.forEach(function (b) { b.t = b.t / maxT; }); // 0..1
|
||||
requestAnimationFrame(frame);
|
||||
};
|
||||
src.src = 'assets/gem.webp';
|
||||
|
||||
var BUILD = 620, FALL = 260; // 整颗垒完 620ms,每块落 260ms
|
||||
function frame(now) {
|
||||
var el = now - T0;
|
||||
ctx.clearRect(0, 0, cv.width, cv.height);
|
||||
var built = true;
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
var b = blocks[i], start = b.t * BUILD, k = (el - start) / FALL;
|
||||
if (k <= 0) { built = false; continue; }
|
||||
if (k < 1) built = false;
|
||||
k = Math.min(1, k);
|
||||
var e = 1 - Math.pow(1 - k, 3); // 落地减速
|
||||
var y = (b.y - (1 - e) * (b.y + 3)) * CELL;
|
||||
ctx.globalAlpha = Math.min(1, k * 2.2);
|
||||
ctx.fillStyle = b.c; ctx.fillRect(b.x * CELL, y, CELL, CELL);
|
||||
/* 每块顶上一道亮边、底下一道暗边:方块感 */
|
||||
ctx.globalAlpha *= 0.28;
|
||||
ctx.fillStyle = '#fff'; ctx.fillRect(b.x * CELL, y, CELL, 2);
|
||||
ctx.fillStyle = '#000'; ctx.fillRect(b.x * CELL, y + CELL - 2, CELL, 2);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
/* 垒完以后一道白光斜着扫过钻石 */
|
||||
var sw = (el - BUILD - FALL) / 520;
|
||||
if (sw > 0 && sw < 1) {
|
||||
ctx.save(); ctx.globalCompositeOperation = 'source-atop';
|
||||
var gx = -cv.width * 0.6 + sw * cv.width * 2.2;
|
||||
var g = ctx.createLinearGradient(gx, 0, gx + cv.width * 0.5, cv.height);
|
||||
g.addColorStop(0, 'rgba(255,255,255,0)'); g.addColorStop(0.5, 'rgba(255,255,255,.85)'); g.addColorStop(1, 'rgba(255,255,255,0)');
|
||||
ctx.fillStyle = g; ctx.fillRect(0, 0, cv.width, cv.height); ctx.restore();
|
||||
}
|
||||
if (built && !boot.classList.contains('built')) boot.classList.add('built'); // 字开始弹出
|
||||
/* 进度条:一半看时间(让动画走完),一半看页面真加载完没有 */
|
||||
var p = Math.min(1, el / (BUILD + FALL + 300)) * (ready ? 1 : 0.82);
|
||||
bar.style.transform = 'scaleX(' + Math.max(p, parseFloat(bar.dataset.p || 0)).toFixed(3) + ')';
|
||||
bar.dataset.p = p;
|
||||
if (boot.isConnected) requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
if (done) return;
|
||||
var el = performance.now() - T0;
|
||||
if (el < MIN) { setTimeout(finish, MIN - el); return; }
|
||||
done = true;
|
||||
bar.style.transform = 'scaleX(1)';
|
||||
try { sessionStorage.setItem('jz-boot', '1'); } catch (e) {}
|
||||
setTimeout(function () {
|
||||
boot.classList.add('leave'); root.classList.remove('booting'); root.classList.add('booted');
|
||||
setTimeout(function () { boot.remove(); }, 700);
|
||||
}, 160);
|
||||
}
|
||||
function onReady() { ready = true; finish(); }
|
||||
if (document.readyState === 'complete') onReady(); else addEventListener('load', onReady, { once: true });
|
||||
setTimeout(function () { ready = true; finish(); }, MAX);
|
||||
/* 点一下就跳过 */
|
||||
boot.addEventListener('click', function () { ready = true; T0 -= MIN; finish(); });
|
||||
})();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 285 B |
@@ -0,0 +1,362 @@
|
||||
/* 金钻客栈 · 画展(gallery.html)
|
||||
---------------------------------------------------------------------------
|
||||
样子按设计预览站:类型筛选条 + 左边年份 + 右边作品墙(.art 卡片)+ 白色毛玻璃大图层。
|
||||
功能沿用原来的单页版(一样都没少):
|
||||
· 筛选:类型(图片 / 视频 / 特殊 = 全景 + 动态壁纸)、谁做的、年份 → 月份;排序最新 / 最早;看过的放前 / 放后 / 不显示(记在本机)
|
||||
· 作品墙:按「当前最矮的一列」投放(时间顺序从左往右走,不会像 CSS 分栏那样竖着排);列表只放缩略图
|
||||
· 看作品:图片先铺缩略图,再换 hd_cache 轻量高清(2 秒没到就上原图);本站视频优先放网页版副本;B 站视频嵌播放器;
|
||||
全景 = 球面环视(拖动 / 双指缩放 / 滚轮缩放);动态壁纸 = 拖时间轴 / 左右拖画面 / 自动播放
|
||||
· 观展统计:点开一次打一个 /hit(服务器只记计数,IP 加盐哈希);view_stats.json 里有数就在卡片上显示「几人看过」
|
||||
要在 pages.js 之后、site.js 之前加载(site.js 会给这里画好的卡片挂倾斜 / 浮现动效)。 */
|
||||
(function () {
|
||||
'use strict';
|
||||
var P = window.JZP; if (!P) return;
|
||||
var esc = P.esc, fileUrl = P.fileUrl, thumbOf = P.thumbOf, ratioOf = P.ratioOf;
|
||||
var ALL = P.gallery || [];
|
||||
var $ = function (id) { return document.getElementById(id); };
|
||||
var wall = $('gWall'); if (!wall) return;
|
||||
var reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
var clamp = function (v, a, b) { return Math.min(b, Math.max(a, v)); };
|
||||
var store = { get: function (k) { try { return localStorage.getItem(k); } catch (e) { return null; } }, set: function (k, v) { try { localStorage.setItem(k, v); } catch (e) {} } };
|
||||
|
||||
var TYPE = { image: '图片', video: '视频', pano: '全景', wall: '动态壁纸' };
|
||||
var S = { type: 'all', owner: 'all', year: '', month: '', newest: true, seen: store.get('jz_gallery_seen') || 'off' };
|
||||
if (['off', 'first', 'last', 'hide'].indexOf(S.seen) < 0) S.seen = 'off';
|
||||
var view = [];
|
||||
|
||||
/* ---------- 看过的(本机记录:打开次数 / 最近打开) ---------- */
|
||||
var OPEN_KEY = 'jz_gallery_opens';
|
||||
var keyOf = function (g) { return g.src || (g.frames && g.frames[0] && g.frames[0].src) || g.title || ''; };
|
||||
function opens() { try { var o = JSON.parse(store.get(OPEN_KEY) || '{}'); return o && typeof o === 'object' ? o : {}; } catch (e) { return {}; } }
|
||||
function markOpen(g) {
|
||||
var k = keyOf(g); if (!k) return;
|
||||
var o = opens(), r = o[k] || { c: 0, t: 0 }; r.c = (r.c || 0) + 1; r.t = Date.now(); o[k] = r;
|
||||
var ks = Object.keys(o); if (ks.length > 400) { ks.sort(function (a, b) { return (o[a].t || 0) - (o[b].t || 0); }); ks.slice(0, ks.length - 400).forEach(function (x) { delete o[x]; }); }
|
||||
store.set(OPEN_KEY, JSON.stringify(o));
|
||||
}
|
||||
/* ---------- 观展统计 ---------- */
|
||||
var STATS = null;
|
||||
fetch('view_stats.json?_=' + Date.now(), { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (j) {
|
||||
if (!j) return; STATS = j;
|
||||
if (j.total && j.total.u) { $('gViewsU').textContent = j.total.u; $('gViews').hidden = false; }
|
||||
draw();
|
||||
}).catch(function () {});
|
||||
function hit(g) {
|
||||
var k = keyOf(g); if (!k) return;
|
||||
var u = 'hit?k=' + encodeURIComponent(k) + '&_=' + Date.now();
|
||||
try { if (navigator.sendBeacon) navigator.sendBeacon(u); else fetch(u, { keepalive: true, cache: 'no-store' }); } catch (e) {}
|
||||
}
|
||||
|
||||
/* ---------- 筛选 + 排序 ---------- */
|
||||
function isSp(g) { return g.type === 'pano' || g.type === 'wall'; }
|
||||
function match(g) {
|
||||
if (S.year && g.date.slice(0, 4) !== S.year) return false;
|
||||
if (S.month && g.date.slice(5, 7) !== S.month) return false;
|
||||
if (S.owner !== 'all' && (g.owner === 'gift' ? 'gift' : 'own') !== S.owner) return false;
|
||||
if (S.type === 'all') return true;
|
||||
if (S.type === 'special') return isSp(g);
|
||||
return g.type === S.type;
|
||||
}
|
||||
function sorted() {
|
||||
var arr = ALL.slice().sort(function (a, b) { return a.date < b.date ? -1 : a.date > b.date ? 1 : 0; });
|
||||
if (S.newest) arr.reverse();
|
||||
if (S.seen === 'off') return arr;
|
||||
var log = opens(), seen = function (g) { return !!log[keyOf(g)]; };
|
||||
if (S.seen === 'hide') return arr.filter(function (g) { return !seen(g); });
|
||||
var a = [], b = []; arr.forEach(function (g) { (seen(g) ? a : b).push(g); });
|
||||
return S.seen === 'first' ? a.concat(b) : b.concat(a);
|
||||
}
|
||||
|
||||
/* ---------- 卡片 ---------- */
|
||||
var PLAY = '<span class="art-play" aria-hidden="true"><svg width="22" height="22" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5.5v13l11-6.5z"/></svg></span>';
|
||||
var PH_ICON = { video: '<svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="5" width="19" height="14" rx="2"/><path d="m10 9.5 5 2.5-5 2.5z"/></svg>' };
|
||||
function stillOf(g) {
|
||||
if (g.type === 'video') return (g.src && /\.(mp4|webm)$/i.test(g.src)) ? (thumbOf(g.src) !== g.src ? thumbOf(g.src) : '') : (g.poster || '');
|
||||
return g.poster || (g.frames && g.frames[0] && g.frames[0].src) || g.src || '';
|
||||
}
|
||||
function card(g, i) {
|
||||
var t = g.type || 'image', still = stillOf(g), r = ratioOf(g.src) || ratioOf(still) || g.r || 0;
|
||||
var thumb = still ? (t === 'video' ? still : thumbOf(still)) : '';
|
||||
var media = thumb
|
||||
? '<img src="' + esc(fileUrl(thumb)) + '" alt="' + esc(g.title) + '" loading="lazy" decoding="async" draggable="false"' + (r ? ' style="aspect-ratio:' + (+r).toFixed(4) + '"' : '') + '>'
|
||||
: '<span class="ph" style="--ar:16/9">' + (PH_ICON[t] || '') + '<span>' + TYPE[t] + '</span></span>';
|
||||
var st = STATS && STATS.items && STATS.items[keyOf(g)];
|
||||
var o = opens()[keyOf(g)];
|
||||
var badge = (t === 'video' ? PLAY : '') + (isSp(g) ? '<span class="art-sp">' + (t === 'pano' ? '全景 · 可拖动' : '动态壁纸 · ' + ((g.frames || []).length || '') + ' 帧') + '</span>' : '')
|
||||
+ (g.owner === 'gift' ? '<span class="art-own">别人送的</span>' : '');
|
||||
var links = (g.links && g.links.length) ? g.links : (g.link ? [g.link] : []);
|
||||
return '<figure class="art crystal" data-type="' + (isSp(g) ? 'special' : t) + '">'
|
||||
+ '<button type="button" data-i="' + i + '" aria-label="看「' + esc(g.title) + '」">' + media + badge + '</button>'
|
||||
+ '<figcaption class="cap"><b>' + esc(g.title) + '</b>'
|
||||
+ (g.desc ? '<i class="art-desc">' + esc(g.desc) + '</i>' : '')
|
||||
+ '<span><span class="type">' + TYPE[t] + '</span><span class="num">' + esc(g.date) + '</span></span>'
|
||||
+ ((st && st.c) || o || links.length ? '<span class="art-meta">'
|
||||
+ (st && st.c ? '<em title="看过的人(同一个人多次只算一次)/ 点开总次数">' + (st.u || 0) + ' 人看过</em>' : '')
|
||||
+ (o ? '<em class="mine" title="你在这台设备上打开过的次数">你看过 ' + (o.c || 1) + ' 次</em>' : '')
|
||||
+ links.map(function (u) { return '<a href="' + esc(u) + '" target="_blank" rel="noopener noreferrer">' + esc(linkLabel(u, links.length)) + ' ↗</a>'; }).join('')
|
||||
+ '</span>' : '')
|
||||
+ '</figcaption></figure>';
|
||||
}
|
||||
function linkLabel(u, n) {
|
||||
if (/steamcommunity\.com|\/workshop/i.test(u)) return 'Steam 创意工坊';
|
||||
if (/cgmodel\.com|\/cgmodel/i.test(u)) return 'CG 模型网';
|
||||
if (/bilibili\.com|b23\.tv/i.test(u)) return 'B 站';
|
||||
return n > 1 ? '外链' : '原站';
|
||||
}
|
||||
|
||||
/* ---------- 作品墙:按最矮的一列投放(宽高比来自离线媒体索引,估得准) ---------- */
|
||||
function cols() {
|
||||
var w = wall.clientWidth || 900;
|
||||
if (innerWidth <= 760) return 2;
|
||||
return clamp(Math.floor((w + 16) / 276), 1, 3);
|
||||
}
|
||||
function draw() {
|
||||
var all = sorted();
|
||||
var cnt = function (f) { return all.filter(f).length; };
|
||||
$('gN').textContent = ALL.length;
|
||||
$('cAll').textContent = all.length; $('cImage').textContent = cnt(function (g) { return g.type === 'image'; });
|
||||
$('cVideo').textContent = cnt(function (g) { return g.type === 'video'; }); $('cSpecial').textContent = cnt(isSp);
|
||||
$('cOwn').textContent = cnt(function (g) { return g.owner !== 'gift'; }); $('cGift').textContent = cnt(function (g) { return g.owner === 'gift'; });
|
||||
view = all.filter(match);
|
||||
var n = cols(), colH = [], html = [];
|
||||
for (var c = 0; c < n; c++) { colH.push(0); html.push(''); }
|
||||
view.forEach(function (g, i) {
|
||||
var r = ratioOf(g.src) || ratioOf(stillOf(g)) || g.r || 1.4;
|
||||
var t = 0; for (var j = 1; j < n; j++) if (colH[j] < colH[t] - 1e-6) t = j;
|
||||
html[t] += card(g, i); colH[t] += 1 / r + 0.32;
|
||||
});
|
||||
wall.innerHTML = view.length ? html.map(function (h) { return '<div class="wall-col">' + h + '</div>'; }).join('')
|
||||
: '<p class="note" style="padding:30px 0">这个筛选下还没有作品。</p>';
|
||||
wall.style.setProperty('--cols', n);
|
||||
syncBar(); drawYears();
|
||||
}
|
||||
function syncBar() {
|
||||
[['gType', 'f', S.type], ['gOwner', 'o', S.owner], ['gSeen', 's', S.seen]].forEach(function (x) {
|
||||
var box = $(x[0]); if (!box) return;
|
||||
box.querySelectorAll('button').forEach(function (b) { b.setAttribute('aria-pressed', String(b.getAttribute('data-' + x[1]) === x[2])); });
|
||||
});
|
||||
var sb = $('gSort'); sb.querySelector('span').textContent = S.newest ? '最新的在前' : '最早的在前'; sb.setAttribute('aria-pressed', String(S.newest));
|
||||
$('gClear').hidden = !(S.type !== 'all' || S.owner !== 'all' || S.year || S.month);
|
||||
}
|
||||
function drawYears() {
|
||||
var years = {}, months = {};
|
||||
ALL.forEach(function (g) { var y = g.date.slice(0, 4); if (y) years[y] = (years[y] || 0) + 1; if (S.year && y === S.year) { var m = g.date.slice(5, 7); months[m] = (months[m] || 0) + 1; } });
|
||||
var ys = Object.keys(years).sort().reverse();
|
||||
var h = '<b>年份</b><a href="#" data-y=""' + (S.year ? '' : ' class="on"') + '>全部<em class="num">' + ALL.length + '</em></a>';
|
||||
ys.forEach(function (y) {
|
||||
h += '<a href="#" data-y="' + y + '"' + (S.year === y ? ' class="on"' : '') + '>' + y + '<em class="num">' + years[y] + '</em></a>';
|
||||
if (S.year === y) Object.keys(months).sort().reverse().forEach(function (m) {
|
||||
h += '<a href="#" class="mon' + (S.month === m ? ' on' : '') + '" data-y="' + y + '" data-m="' + m + '">' + (+m) + ' 月<em class="num">' + months[m] + '</em></a>';
|
||||
});
|
||||
});
|
||||
$('gYears').innerHTML = h;
|
||||
var hm = $('gYearsM');
|
||||
if (hm) hm.innerHTML = '<button type="button" data-y="" aria-pressed="' + !S.year + '">全部</button>' + ys.map(function (y) { return '<button type="button" data-y="' + y + '" aria-pressed="' + (S.year === y) + '">' + y + '</button>'; }).join('');
|
||||
}
|
||||
|
||||
/* ---------- 工具条 ---------- */
|
||||
function on(id, attr, fn) { var el = $(id); if (el) el.addEventListener('click', function (e) { var b = e.target.closest('[data-' + attr + ']'); if (b) { e.preventDefault(); fn(b.getAttribute('data-' + attr), b); draw(); } }); }
|
||||
on('gType', 'f', function (v) { S.type = v; });
|
||||
on('gOwner', 'o', function (v) { S.owner = v; });
|
||||
on('gSeen', 's', function (v) { S.seen = v; store.set('jz_gallery_seen', v); });
|
||||
on('gYears', 'y', function (v, b) { S.year = v; S.month = b.getAttribute('data-m') || ''; });
|
||||
on('gYearsM', 'y', function (v) { S.year = v; S.month = ''; });
|
||||
$('gSort').addEventListener('click', function () { S.newest = !S.newest; draw(); });
|
||||
$('gClear').addEventListener('click', function () { S.type = 'all'; S.owner = 'all'; S.year = ''; S.month = ''; draw(); });
|
||||
$('gMore').addEventListener('click', function () { var p = $('gMorePanel'), o = p.hidden; p.hidden = !o; this.setAttribute('aria-expanded', String(o)); });
|
||||
var rt = 0, lastCols = 0;
|
||||
addEventListener('resize', function () { clearTimeout(rt); rt = setTimeout(function () { if (cols() !== lastCols) { lastCols = cols(); draw(); } }, 160); }, { passive: true });
|
||||
|
||||
/* ================================================================ 看作品 */
|
||||
var box = $('gbox'), stage = $('gbStage'), img = $('gbImg'), vid = $('gbVid'), vwrap = $('gbVidWrap'), bf = $('gbBiliFrame'),
|
||||
pano = $('gbPano'), wimg = $('gbWall'), load = $('gbLoad'), lastBtn = null, ctl = null, blobUrl = '';
|
||||
function showOnly(el) { [img, vwrap, bf, pano, wimg].forEach(function (x) { x.hidden = x !== el; }); }
|
||||
function openBox(g) {
|
||||
$('gbT').textContent = g.title || ''; $('gbD').textContent = [TYPE[g.type || 'image'], g.date, g.owner === 'gift' ? '别人送的' : ''].filter(Boolean).join(' · ') + (g.desc ? ' — ' + g.desc : '');
|
||||
$('gbOrig').hidden = true; $('gbBili').hidden = true; $('gbWallBar').hidden = true; $('gbHint').textContent = ''; load.hidden = true;
|
||||
var links = (g.links && g.links.length) ? g.links : (g.link ? [g.link] : []);
|
||||
$('gbLinks').innerHTML = links.map(function (u) { return '<a class="btn btn-crystal btn-sm" href="' + esc(u) + '" target="_blank" rel="noopener noreferrer">' + esc(linkLabel(u, links.length)) + ' ↗</a>'; }).join('');
|
||||
box.hidden = false; box.classList.add('open'); document.documentElement.classList.add('gbox-on');
|
||||
$('gbClose').focus();
|
||||
}
|
||||
function closeBox() {
|
||||
if (box.hidden) return;
|
||||
if (ctl) { try { ctl.destroy(); } catch (e) {} ctl = null; }
|
||||
vid.pause(); vid.removeAttribute('src'); vid.load();
|
||||
bf.removeAttribute('src'); img.removeAttribute('src'); wimg.removeAttribute('src');
|
||||
if (blobUrl) { URL.revokeObjectURL(blobUrl); blobUrl = ''; }
|
||||
box.classList.remove('open'); box.hidden = true; document.documentElement.classList.remove('gbox-on');
|
||||
if (lastBtn) lastBtn.focus();
|
||||
}
|
||||
$('gbClose').addEventListener('click', closeBox);
|
||||
/* 点空白处关闭:按下和松手都得在空白处才算(拖全景 / 拖动态壁纸拖出画框松手,click 会落在空白处,不能把人关出去) */
|
||||
var downOnBlank = false;
|
||||
box.addEventListener('pointerdown', function (e) { downOnBlank = (e.target === box || e.target === stage); });
|
||||
box.addEventListener('click', function (e) { if (downOnBlank && (e.target === box || e.target === stage)) closeBox(); downOnBlank = false; });
|
||||
addEventListener('keydown', function (e) { if (e.key === 'Escape') closeBox(); });
|
||||
|
||||
/* ---------- 图片:缩略图秒显 → hd_cache 轻量高清(通常 0.2~0.5MB)→ 2 秒没到就上原图 ---------- */
|
||||
var HDC = null, hdcWait = [];
|
||||
(window.__hdcEarly || fetch('hd_cache/manifest.json', { cache: 'force-cache' }))
|
||||
.then(function (r) { return r && r.ok ? r.json() : null; })
|
||||
.then(function (m) { HDC = m || {}; }, function () { HDC = {}; })
|
||||
.then(function () { var q = hdcWait; hdcWait = []; q.forEach(function (f) { f(); }); });
|
||||
var whenHdc = function (f) { if (HDC) f(); else hdcWait.push(f); };
|
||||
var hdcOf = function (src) { return (HDC && HDC[src]) || ''; };
|
||||
var cache = {}; // 打开过 / 预取过的高清图(第二次秒开)
|
||||
function fetchImg(u, cb) {
|
||||
var im = cache[u];
|
||||
if (im && im.ok) { cb && cb(true); return; }
|
||||
if (im && im.bad) { cb && cb(false); return; } // 之前预取就失败了:直接走下一档,别干等
|
||||
if (!im) { im = cache[u] = new Image(); im.decoding = 'async'; }
|
||||
if (cb) { im.addEventListener('load', function () { cb(true); }, { once: true }); im.addEventListener('error', function () { cb(false); }, { once: true }); }
|
||||
if (!im.src) { im.onload = function () { im.ok = true; }; im.onerror = function () { im.bad = true; }; im.src = fileUrl(u); }
|
||||
}
|
||||
function openImage(g, btn) {
|
||||
openBox(g); showOnly(img);
|
||||
var thumbEl = btn && btn.querySelector('img'), src = g.src;
|
||||
var have = thumbEl && thumbEl.complete && thumbEl.naturalWidth > 0;
|
||||
img.alt = g.title || '';
|
||||
/* 先铺缩略图(列表里的还没下完也照样先铺它:几十 KB,比干等高清快得多),高清到了原地换 */
|
||||
if (have) img.src = thumbEl.currentSrc || thumbEl.src; else { img.src = fileUrl(thumbOf(src)); load.hidden = false; }
|
||||
$('gbOrig').href = fileUrl(src); $('gbOrig').hidden = false;
|
||||
var shown = false;
|
||||
var put = function (u) { if (box.hidden || shown) return; shown = true; img.src = fileUrl(u); load.hidden = true; };
|
||||
var orig = function () { fetchImg(src, function (ok) { if (ok) put(src); else load.hidden = true; }); };
|
||||
whenHdc(function () {
|
||||
var h = hdcOf(src);
|
||||
if (h && h !== src) { fetchImg(h, function (ok) { if (ok) put(h); else orig(); }); setTimeout(function () { if (!shown && !box.hidden) orig(); }, 2000); }
|
||||
else orig();
|
||||
});
|
||||
if (!HDC) setTimeout(function () { if (!HDC && !shown && !box.hidden) orig(); }, 900);
|
||||
}
|
||||
/* 鼠标停在卡片上就先悄悄拉高清,点开更快 */
|
||||
wall.addEventListener('pointerover', function (e) {
|
||||
var b = e.target.closest && e.target.closest('button[data-i]'); if (!b || b._pf) return; b._pf = 1;
|
||||
var g = view[+b.getAttribute('data-i')]; if (!g || g.type !== 'image' || !g.src) return;
|
||||
whenHdc(function () { fetchImg(hdcOf(g.src) || g.src); });
|
||||
});
|
||||
|
||||
/* ---------- 视频 ---------- */
|
||||
function biliId(g) { var m = String(g.bvid || g.url || '').match(/BV[0-9A-Za-z]{10}/); return m ? m[0] : ''; }
|
||||
function openVideo(g) {
|
||||
openBox(g);
|
||||
var bv = biliId(g), local = g.src && /\.(mp4|webm)$/i.test(g.src);
|
||||
if (local) {
|
||||
showOnly(vwrap); vid.src = fileUrl(g.web || g.src); // 网页版副本更小、手机也能放
|
||||
$('gbWm').textContent = g.owner === 'gift' ? '别人做的' : '金钻做的';
|
||||
try { vid.play().catch(function () {}); } catch (e) {}
|
||||
if (bv || g.url) { $('gbBili').href = g.url || ('https://www.bilibili.com/video/' + bv); $('gbBili').hidden = false; }
|
||||
} else if (bv) {
|
||||
showOnly(bf); bf.src = 'https://player.bilibili.com/player.html?bvid=' + bv + '&page=1&autoplay=0';
|
||||
$('gbBili').href = g.url || ('https://www.bilibili.com/video/' + bv); $('gbBili').hidden = false;
|
||||
} else if (g.url) { closeBox(); window.open(g.url, '_blank', 'noopener'); }
|
||||
}
|
||||
|
||||
/* ---------- 全景:等距柱状图贴到球面上环视(拖动看四周;滚轮 / 双指捏合缩放;往上拖 = 低头) ---------- */
|
||||
function openPano(g) {
|
||||
openBox(g); showOnly(pano);
|
||||
$('gbHint').textContent = '拖动看四周 · 往上拖是低头、往下拖是抬头 · 滚轮或双指缩放';
|
||||
var off = document.createElement('canvas'), octx = off.getContext('2d');
|
||||
var sample = document.createElement('canvas'), sctx = sample.getContext('2d', { willReadFrequently: true });
|
||||
var px = null, iw = 1, ih = 1, yaw = 0, pitch = 0, fov = 1.25, raf = 0, drag = false, lx = 0, ly = 0, pinch = 0, pf = 0, gotHD = false;
|
||||
function use(im, hd) {
|
||||
if (gotHD && !hd) return; if (hd) gotHD = true;
|
||||
iw = im.naturalWidth; ih = im.naturalHeight; if (!iw || !ih) return;
|
||||
sample.width = iw; sample.height = ih; sctx.drawImage(im, 0, 0);
|
||||
try { px = sctx.getImageData(0, 0, iw, ih).data; } catch (e) { px = null; }
|
||||
render();
|
||||
}
|
||||
function src(u, hd) { var im = new Image(); im.onload = function () { if (ctl === me) use(im, hd); }; im.src = fileUrl(u); }
|
||||
function render() {
|
||||
if (!px) return;
|
||||
var cw = Math.max(240, stage.clientWidth || 640), ch = Math.max(180, stage.clientHeight || 360);
|
||||
var rw = Math.round(clamp(cw / 2.4, 280, 560)), rh = Math.max(2, Math.round(rw * ch / cw));
|
||||
if (off.width !== rw || off.height !== rh) { off.width = rw; off.height = rh; pano.width = rw; pano.height = rh; }
|
||||
var out = octx.createImageData(rw, rh), d = out.data, asp = rw / rh, tf = Math.tan(fov / 2);
|
||||
var cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch), TAU = Math.PI * 2, p = 0;
|
||||
for (var y = 0; y < rh; y++) {
|
||||
var ny = -(((y + 0.5) / rh) * 2 - 1) * tf;
|
||||
for (var x = 0; x < rw; x++) {
|
||||
var nx = (((x + 0.5) / rw) * 2 - 1) * tf * asp;
|
||||
var x1 = nx * cy + ny * sp * sy + cp * sy, y1 = ny * cp - sp, z1 = -nx * sy + ny * sp * cy + cp * cy;
|
||||
var len = Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1) || 1;
|
||||
var lat = Math.asin(clamp(y1 / len, -1, 1)), lon = Math.atan2(x1, z1) / TAU + 0.5; lon -= Math.floor(lon);
|
||||
var u = (lon * iw) | 0, v = clamp(Math.round((0.5 - lat / Math.PI) * ih), 0, ih - 1), si = (v * iw + (u >= iw ? iw - 1 : u)) * 4;
|
||||
d[p++] = px[si]; d[p++] = px[si + 1]; d[p++] = px[si + 2]; d[p++] = 255;
|
||||
}
|
||||
}
|
||||
octx.putImageData(out, 0, 0);
|
||||
var c = pano.getContext('2d'); c.imageSmoothingEnabled = true; c.imageSmoothingQuality = 'high'; c.drawImage(off, 0, 0, pano.width, pano.height);
|
||||
}
|
||||
var sched = function () { if (!raf) raf = requestAnimationFrame(function () { raf = 0; render(); }); };
|
||||
var dist = function (t) { return Math.hypot(t[0].clientX - t[1].clientX, t[0].clientY - t[1].clientY) || 1; };
|
||||
function down(e) { var t = e.touches; if (t && t.length > 1) { pinch = dist(t); pf = fov; drag = false; return; } drag = true; lx = t ? t[0].clientX : e.clientX; ly = t ? t[0].clientY : e.clientY; }
|
||||
function move(e) {
|
||||
var t = e.touches;
|
||||
if (t && t.length > 1) { if (!pinch) { pinch = dist(t); pf = fov; } fov = clamp(pf * pinch / dist(t), 0.6, 2); e.cancelable && e.preventDefault(); sched(); return; }
|
||||
if (!drag) return;
|
||||
var x = t ? t[0].clientX : e.clientX, y = t ? t[0].clientY : e.clientY;
|
||||
yaw -= (x - lx) * 0.0045; pitch = clamp(pitch - (y - ly) * 0.0038, -1.05, 1.05); lx = x; ly = y;
|
||||
e.cancelable && e.preventDefault(); sched();
|
||||
}
|
||||
function up(e) { var t = e.touches; if (t && t.length === 1) { pinch = 0; drag = true; lx = t[0].clientX; ly = t[0].clientY; return; } drag = false; pinch = 0; }
|
||||
function wheel(e) { fov = clamp(fov + (e.deltaY > 0 ? 0.12 : -0.12), 0.6, 2); e.preventDefault(); sched(); }
|
||||
function dbl() { yaw = 0; pitch = 0; fov = 1.25; sched(); }
|
||||
pano.addEventListener('mousedown', down); pano.addEventListener('touchstart', down, { passive: true });
|
||||
addEventListener('mousemove', move); pano.addEventListener('touchmove', move, { passive: false });
|
||||
addEventListener('mouseup', up); addEventListener('touchend', up); pano.addEventListener('wheel', wheel, { passive: false }); pano.addEventListener('dblclick', dbl);
|
||||
var me = ctl = { destroy: function () {
|
||||
cancelAnimationFrame(raf); px = null;
|
||||
pano.removeEventListener('mousedown', down); pano.removeEventListener('touchstart', down); removeEventListener('mousemove', move); pano.removeEventListener('touchmove', move);
|
||||
removeEventListener('mouseup', up); removeEventListener('touchend', up); pano.removeEventListener('wheel', wheel); pano.removeEventListener('dblclick', dbl);
|
||||
} };
|
||||
src(thumbOf(g.src), false);
|
||||
whenHdc(function () { src(hdcOf(g.src) || g.src, true); });
|
||||
}
|
||||
|
||||
/* ---------- 动态壁纸:拖时间轴 / 在画面上左右拖 / 自动播放 ---------- */
|
||||
function openWall(g) {
|
||||
var F = g.frames || []; if (!F.length) return;
|
||||
openBox(g); showOnly(wimg); $('gbWallBar').hidden = false;
|
||||
$('gbHint').textContent = '左右拖画面或拖时间轴换帧';
|
||||
var n = F.length, i = 0, tid = 0, range = $('gbRange'), lbl = $('gbLbl'), play = $('gbPlay'), pre = {};
|
||||
range.max = String(n - 1);
|
||||
function show(k) {
|
||||
i = ((k % n) + n) % n; var f = F[i];
|
||||
wimg.src = fileUrl(thumbOf(f.src)); wimg.alt = f.label || '';
|
||||
if (thumbOf(f.src) !== f.src) { var im = pre[f.src] || (pre[f.src] = new Image()); if (im.complete && im.naturalWidth) wimg.src = fileUrl(f.src); else { im.onload = function () { if (F[i] === f) wimg.src = fileUrl(f.src); }; if (!im.src) im.src = fileUrl(f.src); } }
|
||||
[1, 2].forEach(function (d) { var nx = F[(i + d) % n]; var p = new Image(); p.src = fileUrl(thumbOf(nx.src)); });
|
||||
range.value = String(i); lbl.textContent = (f.label || '#' + (i + 1)) + ' · ' + (i + 1) + '/' + n;
|
||||
}
|
||||
function stop() { clearInterval(tid); tid = 0; play.textContent = '▶'; }
|
||||
function start() { stop(); play.textContent = '❚❚'; tid = setInterval(function () { show(i + 1); }, 1600); }
|
||||
range.oninput = function () { stop(); show(+range.value || 0); };
|
||||
play.onclick = function () { tid ? stop() : start(); };
|
||||
var dragX = null, acc = 0;
|
||||
function d(e) { dragX = (e.touches ? e.touches[0] : e).clientX; acc = 0; stop(); }
|
||||
function m(e) { if (dragX == null) return; var x = (e.touches ? e.touches[0] : e).clientX, step = Math.max(52, stage.clientWidth * 0.075); acc += x - dragX; dragX = x; var s = Math.round(acc / step); if (s) { acc -= s * step; show(i + s); } e.cancelable && e.preventDefault(); }
|
||||
function u() { dragX = null; }
|
||||
wimg.addEventListener('mousedown', d); wimg.addEventListener('touchstart', d, { passive: true });
|
||||
addEventListener('mousemove', m); wimg.addEventListener('touchmove', m, { passive: false }); addEventListener('mouseup', u); addEventListener('touchend', u);
|
||||
show(0); if (!reduce) start();
|
||||
ctl = { destroy: function () { stop(); wimg.removeEventListener('mousedown', d); wimg.removeEventListener('touchstart', d); removeEventListener('mousemove', m); wimg.removeEventListener('touchmove', m); removeEventListener('mouseup', u); removeEventListener('touchend', u); } };
|
||||
}
|
||||
|
||||
/* ---------- 点卡片:按类型分发 ---------- */
|
||||
wall.addEventListener('click', function (e) {
|
||||
if (e.target.closest('a')) return; // 卡片里的外链自己跳
|
||||
var b = e.target.closest('button[data-i]'); if (!b) return;
|
||||
var g = view[+b.getAttribute('data-i')]; if (!g) return;
|
||||
lastBtn = b; markOpen(g); hit(g);
|
||||
if (g.type === 'video') openVideo(g);
|
||||
else if (g.type === 'pano') openPano(g);
|
||||
else if (g.type === 'wall') openWall(g);
|
||||
else if (g.src) openImage(g, b);
|
||||
});
|
||||
|
||||
/* 作品图别被右键另存 / 拖走(和原来一样,挡一下顺手党) */
|
||||
document.addEventListener('contextmenu', function (e) { if (e.target.closest && e.target.closest('.wall img,#gbox img,#gbox canvas,#gbox video')) e.preventDefault(); });
|
||||
|
||||
lastCols = cols(); draw();
|
||||
})();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@@ -0,0 +1,255 @@
|
||||
/* 金钻客栈 · 各页内容渲染(2026-10-06 起以设计预览站为准)
|
||||
---------------------------------------------------------------------------
|
||||
内容来源:content/site.js(window.JZ_CONTENT,内容后台发布时生成);后台点「预览」带 ?preview=1 时换成草稿。
|
||||
站点固定信息:assets/site-info.js(window.JZ_SITE:域名 / QQ 群 / 备案号 / 邮箱)。
|
||||
这个文件只负责「把内容填进页面」,标记和预览站一模一样;动效 / 交互在 assets/site.js(预览站原版),
|
||||
画展的筛选 / 大图 / 视频 / 全景 / 动态壁纸在 assets/gallery.js。
|
||||
顺序很重要:本文件要在 site.js 之前跑完,site.js 才能给填好的卡片挂上倾斜 / 浮现 / 翻牌动效。 */
|
||||
(function () {
|
||||
'use strict';
|
||||
var C = window.JZ_CONTENT || {}, SITE = window.JZ_SITE || {};
|
||||
var page = document.body.getAttribute('data-page') || '';
|
||||
var $ = function (s, r) { return (r || document).querySelector(s); };
|
||||
var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); };
|
||||
var ARROW = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg>';
|
||||
var ARROW_SM = ARROW.replace(/width="16" height="16"/, 'width="14" height="14"');
|
||||
var DIAG = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7"/><path d="M8 7h9v9"/></svg>';
|
||||
/* 板块色:和各页大号数字同一套(预览站) */
|
||||
var ZC = { gallery: ['#F2C14D', '#E8913A'], tools: ['#4F86E8', '#2E5BD8'], universe: ['#9A6BE0', '#3FC9C4'], links: ['#22B573', '#3C8527'], about: ['#E0533D', '#E8913A'] };
|
||||
var zc = function (k) { return '--zc:' + ZC[k][0] + ';--zc2:' + ZC[k][1]; };
|
||||
window.JZP = { esc: esc, ARROW: ARROW, DIAG: DIAG, ZC: ZC };
|
||||
|
||||
/* 站内文件地址:路径里有空格 / 中文 / 括号,按段编码(# ? 之类也不会被当成网址的一部分) */
|
||||
function fileUrl(p) { return p ? String(p).split('/').map(encodeURIComponent).join('/') : ''; }
|
||||
var MEDIA = C.media || {};
|
||||
function thumbOf(src) { var m = src && MEDIA[src]; return (m && m.t) || src || ''; }
|
||||
function ratioOf(src) { var m = src && MEDIA[src]; return (m && m.r > 0) ? m.r : 0; }
|
||||
window.JZP.fileUrl = fileUrl; window.JZP.thumbOf = thumbOf; window.JZP.ratioOf = ratioOf;
|
||||
|
||||
/* 「关于」里的简易写法:只认 [文字](https://…) 链接 和 `代码`,其余一律纯文本;空行分段 */
|
||||
function mini(text) {
|
||||
return String(text || '').split(/\n{2,}/).map(function (para) {
|
||||
var out = '', re = /\[([^\]\n]{1,80})\]\((https:\/\/[^\s)]{1,800}|mailto:[^\s)]{1,120})\)|`([^`\n]{1,80})`/g, last = 0, m;
|
||||
while ((m = re.exec(para))) {
|
||||
out += esc(para.slice(last, m.index));
|
||||
out += m[3] != null ? '<code>' + esc(m[3]) + '</code>' : '<a href="' + esc(m[2]) + '" target="_blank" rel="noopener noreferrer">' + esc(m[1]) + '</a>';
|
||||
last = re.lastIndex;
|
||||
}
|
||||
return '<p>' + (out + esc(para.slice(last))).replace(/\n/g, '<br>') + '</p>';
|
||||
}).join('');
|
||||
}
|
||||
window.JZP.mini = mini;
|
||||
|
||||
/* ---------- 全站:页脚 / 「更多」面板 / 公告 / 预览草稿提示 ---------- */
|
||||
(function shell() {
|
||||
var dom = esc(SITE.domain || ''), qq = esc(SITE.qq || ''), qn = esc(SITE.qqName || 'QQ 群');
|
||||
var qqTxt = 'QQ 群:' + qn + ' ' + qq;
|
||||
var foot = $('.foot-in');
|
||||
if (foot) foot.innerHTML = '<a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a>'
|
||||
+ '<span>© ' + new Date().getFullYear() + ' ' + dom + '</span>'
|
||||
+ (SITE.qqUrl ? '<a class="foot-qq" href="' + esc(SITE.qqUrl) + '" target="_blank" rel="noopener noreferrer">' + qqTxt + '</a>' : '<span>' + qqTxt + '</span>')
|
||||
+ '<span class="sp"></span><a class="foot-icp" href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer">' + esc(SITE.icp || '') + '</a>';
|
||||
var mq = $('.more-qq'); if (mq) mq.textContent = 'QQ 群:' + (SITE.qqName || '') + ' ' + (SITE.qq || '');
|
||||
/* 首页公告:后台「公告」打开且在日期范围内才出 */
|
||||
var n = C.hero && C.hero.notice, today = new Date(Date.now() + 8 * 3600e3).toISOString().slice(0, 10);
|
||||
if (n && n.on && n.text && (!n.from || n.from <= today) && (!n.to || n.to >= today) && page === 'home') {
|
||||
var r = document.createElement('div'); r.className = 'ribbon notice'; r.setAttribute('role', 'status');
|
||||
r.innerHTML = '<span><span class="bar" aria-hidden="true"></span>' + esc(n.text) + '</span>';
|
||||
document.body.insertBefore(r, $('header.top'));
|
||||
}
|
||||
if (window.JZ_PREVIEW) {
|
||||
var b = document.createElement('div'); b.className = 'ribbon preview-bar';
|
||||
b.innerHTML = '<span><b>预览草稿</b>:只有你看得到,访客看到的还是已发布的内容 · <a href="admin/">回内容后台</a></span>';
|
||||
document.body.insertBefore(b, document.body.firstChild);
|
||||
/* 站内跳转带上 ?preview=1,换页也继续看草稿 */
|
||||
document.addEventListener('click', function (e) {
|
||||
var a = e.target.closest && e.target.closest('a[href]'); if (!a) return;
|
||||
var h = a.getAttribute('href');
|
||||
if (/^[a-z]+\.html(#.*)?$/.test(h)) a.setAttribute('href', h.replace(/(#.*)?$/, function (x) { return '?preview=1' + x; }));
|
||||
}, true);
|
||||
}
|
||||
})();
|
||||
|
||||
/* ---------- 旧链接兼容:原来的单页版地址(#/gallery、#/universe、#0001 …)跳到对应的新页面 ---------- */
|
||||
function legacy() {
|
||||
var h = location.hash.replace(/^#\/?/, '').replace(/\/+$/, '');
|
||||
var map = { gallery: 'gallery.html', apps: 'tools.html', universe: 'universe.html', rack: 'universe.html', links: 'links.html', about: 'about.html' };
|
||||
if (map[h]) location.replace(map[h] + location.search);
|
||||
else if (/^\d{4}$/.test(h)) location.replace('universe.html' + location.search + '#' + h);
|
||||
}
|
||||
if (page === 'home') { if (location.hash) legacy(); addEventListener('hashchange', legacy); } // 在首页上改地址栏的 # 也要跳
|
||||
|
||||
/* ---------- 共用小件 ---------- */
|
||||
var GALLERY = (C.gallery || []).filter(function (g) { return !g.hidden; });
|
||||
function dateOf(g) { // 以「分类/日期子目录」为准(和原来一致),路径没日期就用 date
|
||||
var src = g.src || (g.frames && g.frames[0] && g.frames[0].src) || '';
|
||||
var m = /(\d{4})(\d{2})(\d{2})/.exec(src);
|
||||
if (m) { var d = new Date(Date.UTC(+m[1], Math.min(12, Math.max(1, +m[2])) - 1, 1)); d.setUTCDate(+m[3]); return d.toISOString().slice(0, 10); }
|
||||
return g.date || '';
|
||||
}
|
||||
GALLERY.forEach(function (g) { g.date = dateOf(g); });
|
||||
window.JZP.gallery = GALLERY;
|
||||
function latestStills(n) { // 最新的几张「能当封面」的作品(图片 / 全景 / 视频首帧)
|
||||
return GALLERY.slice().sort(function (a, b) { return a.date < b.date ? 1 : a.date > b.date ? -1 : 0; })
|
||||
.map(function (g) { var s = g.src || (g.frames && g.frames[0] && g.frames[0].src) || ''; return { g: g, img: thumbOf(s) }; })
|
||||
.filter(function (x) { return x.img && !/\.(mp4|webm)$/i.test(x.img); }).slice(0, n);
|
||||
}
|
||||
var U = window.JZ_UNIVERSE || {};
|
||||
function universes() {
|
||||
var list = (C.universe && C.universe.UNIVERSES) || U.UNIVERSES || [];
|
||||
var looks = (C.universe && C.universe.LOOKS) || U.LOOKS || {};
|
||||
return { lit: list.filter(function (u) { return !u.empty; }), empty: list.filter(function (u) { return u.empty; }), looks: looks };
|
||||
}
|
||||
window.JZP.universes = universes;
|
||||
function linkRow(l) {
|
||||
var mail = /^mailto:/i.test(l.url || '');
|
||||
return '<a class="board-row flip" href="' + esc(l.url) + '"' + (mail ? '' : ' target="_blank" rel="noopener noreferrer"') + '>'
|
||||
+ '<span class="dest"><b>' + esc(l.name) + '</b></span><span class="kind">' + esc(l.desc || '') + '</span><span></span>'
|
||||
+ '<span class="act">' + (mail ? '写信 ' + ARROW_SM : '打开 ' + DIAG) + '</span></a>';
|
||||
}
|
||||
function setText(sel, v) { var el = $(sel); if (el && v) el.textContent = v; }
|
||||
|
||||
/* ================================================================ 首页 */
|
||||
if (page === 'home') {
|
||||
var hero = C.hero || {};
|
||||
setText('#hTagline', hero.tagline); setText('#hCta1 .t', hero.cta1); setText('#hCta2', hero.cta2);
|
||||
|
||||
/* 手机:最新作品两张 */
|
||||
var duo = $('#homeDuo');
|
||||
if (duo) duo.innerHTML = latestStills(2).map(function (x) {
|
||||
return '<a class="crystal" href="gallery.html"><img src="' + esc(fileUrl(x.img)) + '" alt="' + esc(x.g.title) + '" loading="lazy" decoding="async">'
|
||||
+ '<span class="cap">' + esc(x.g.title) + '<small>' + esc(x.g.date) + '</small></span></a>';
|
||||
}).join('');
|
||||
|
||||
/* 桌面:「都有些什么」五间屋 */
|
||||
var dir = $('#homeDir');
|
||||
if (dir) {
|
||||
var st = latestStills(2), first = st[0] && st[0].g;
|
||||
var apps = C.apps || [];
|
||||
var uv = universes();
|
||||
var links = C.links || [];
|
||||
var story = (C.about && C.about.story) || '';
|
||||
var q = (story.match(/^[^。!?]*[。!?]?/) || [story])[0] || story; // 第一句(别用后行断言:老 iOS Safari 不认,整个脚本会挂)
|
||||
var rack = uv.lit.map(function (u) { var t = u.tone || ((uv.looks[u.no] || {}).accent) || '#E6E1D6'; return '<i class="lit" style="--t:' + esc(t) + '"></i>'; }).join('')
|
||||
+ uv.empty.map(function () { return '<i></i>'; }).join('');
|
||||
var cloud = links.slice(0, 6).map(function (l) { return '<span class="chip">' + esc(l.name) + '</span>'; }).join('')
|
||||
+ (links.length > 6 ? '<span class="chip">+' + (links.length - 6) + '</span>' : '');
|
||||
dir.innerHTML =
|
||||
'<a class="room big crystal" href="gallery.html" style="' + zc('gallery') + '"><span class="no num">01</span><h3>画展</h3>'
|
||||
+ '<p class="desc">' + esc((C.boards && C.boards.gallery) || '画的图、渲染图和视频,按时间排好了。') + '</p>'
|
||||
+ '<div class="peek">' + st.map(function (x) { return '<img src="' + esc(fileUrl(x.img)) + '" alt="作品:' + esc(x.g.title) + '" loading="lazy" decoding="async">'; }).join('') + '</div>'
|
||||
+ (first ? '<div class="peek-cap"><span>最新:' + esc(first.title) + '</span><span class="num">' + esc(first.date) + '</span></div>' : '')
|
||||
+ '<div class="foot"><span>' + GALLERY.length + ' 件</span><span class="go">去看看 ' + ARROW_SM + '</span></div></a>'
|
||||
+ '<a class="room crystal" href="tools.html" style="' + zc('tools') + '"><span class="no num">02</span><h3>工具与开源</h3><ul class="mini-list">'
|
||||
+ apps.slice(0, 4).map(function (a) { return '<li>' + esc(a.name) + '<span class="chip">' + esc(a.status || (a.oss ? '开源' : '')) + '</span></li>'; }).join('')
|
||||
+ '</ul><div class="foot"><span>' + apps.length + ' 个</span><span class="go">去看看 ' + ARROW_SM + '</span></div></a>'
|
||||
+ '<a class="room crystal" href="universe.html" style="' + zc('universe') + '"><span class="no num">03</span><h3>金钻宇宙</h3>'
|
||||
+ '<p class="desc">金钻自己编的平行世界,已经写了 ' + uv.lit.length + ' 个。</p><div class="mini-rack" aria-hidden="true">' + rack + '</div>'
|
||||
+ '<div class="foot"><span>' + (uv.empty.length ? '还空着 ' + uv.empty.length + ' 个' : '都写满了') + '</span><span class="go">去看看 ' + ARROW_SM + '</span></div></a>'
|
||||
+ '<a class="room crystal" href="links.html" style="' + zc('links') + '"><span class="no num">04</span><h3>平台入口</h3><div class="plat-cloud">' + cloud + '</div>'
|
||||
+ '<div class="foot"><span>' + links.length + ' 个平台</span><span class="go">去看看 ' + ARROW_SM + '</span></div></a>'
|
||||
+ '<a class="room crystal" href="about.html" style="' + zc('about') + '"><span class="no num">05</span><h3>关于</h3>'
|
||||
+ '<p class="quote">' + esc(q.length > 40 ? q.slice(0, 38) + '……' : q) + '</p>'
|
||||
+ '<div class="foot"><span>名字由来、交流群</span><span class="go">去看看 ' + ARROW_SM + '</span></div></a>';
|
||||
}
|
||||
|
||||
/* 在别的平台找金钻:挑几个常用的(没有就按顺序取前 6 个) */
|
||||
var hb = $('#homeBoard');
|
||||
if (hb) {
|
||||
var L = C.links || [], pick = ['bili', 'douyin', 'xiaohongshu', 'steam', 'github', 'workshop'];
|
||||
var rows = pick.map(function (k) { return L.filter(function (l) { return l.key === k; })[0]; }).filter(Boolean);
|
||||
if (rows.length < 4) rows = L.slice(0, 6);
|
||||
hb.innerHTML = rows.map(linkRow).join('');
|
||||
}
|
||||
|
||||
/* 自助渲染:渲染机在不在线、每张多少钱(读下单那边的接口 / 内容文件,拿不到就不写) */
|
||||
(function desk() {
|
||||
var s = $('#deskStatus'), p = $('#deskPrice');
|
||||
/* 价格读下单页公开的价格接口(内容后台的原始 order.json 不对外,2026-10-06 安全加固) */
|
||||
fetch('/order/api/payinfo', { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (o) {
|
||||
var per = o && o.per;
|
||||
if (p && per) p.textContent = '每张 ' + per + ' 元起,一般 40 秒左右出图';
|
||||
}).catch(function () {});
|
||||
fetch('/order/api/status', { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (j) {
|
||||
if (!s) return;
|
||||
if (!j) { s.hidden = true; return; }
|
||||
s.textContent = j.online ? '渲染机在线' : '渲染机暂时离线(下的单会排队,开机就做)';
|
||||
s.classList.toggle('off', !j.online);
|
||||
}).catch(function () { if (s) s.hidden = true; }); // 查不到就不说,别一直挂着「查询中」
|
||||
})();
|
||||
}
|
||||
|
||||
/* ================================================================ 工具与开源 */
|
||||
if (page === 'tools') {
|
||||
var A = C.apps || [];
|
||||
setText('#tN', String(A.length));
|
||||
var types = ['全部'].concat(A.map(function (a) { return a.type; }).filter(function (t, i, arr) { return t && arr.indexOf(t) === i; }));
|
||||
var seg = $('#tSeg'), box = $('#tRows'), cur = '全部';
|
||||
function toolCard(a) {
|
||||
var chips = [a.type, a.status].filter(Boolean).map(function (t) { return '<span class="chip">' + esc(t) + '</span>'; }).join('');
|
||||
var kv = (a.ver ? '<span>版本 <b class="num">' + esc(a.ver) + '</b></span>' : '') + (a.size && a.size !== '—' ? '<span>大小 <b class="num">' + esc(a.size) + '</b></span>' : '');
|
||||
var acts = '';
|
||||
if (a.url) {
|
||||
var ext = /^https?:/i.test(a.url);
|
||||
acts += '<a class="btn btn-prism btn-sm" href="' + esc(a.url) + '"' + (ext ? ' target="_blank" rel="noopener noreferrer"' : '') + (a.web || !ext ? '' : ' download') + '>' + esc((a.btn || (a.web ? '打开' : '下载')).replace(/\s*[→↓]\s*$/, '')) + ' ' + ARROW_SM + '</a>';
|
||||
}
|
||||
if (a.repo) acts += '<a class="btn btn-crystal btn-sm" href="' + esc(a.repo) + '" target="_blank" rel="noopener noreferrer">看代码 ' + DIAG + '</a>';
|
||||
if (!acts) acts = '<span class="btn btn-crystal btn-sm" aria-disabled="true" style="opacity:.55;cursor:default">还没上架</span>';
|
||||
return '<article class="tool crystal"><h3>' + esc(a.name) + '</h3><div class="chips">' + chips + '</div><p>' + esc(a.desc || '') + '</p>'
|
||||
+ (kv ? '<div class="kv">' + kv + '</div>' : '') + '<div class="acts">' + acts + '</div></article>';
|
||||
}
|
||||
function draw() {
|
||||
var pick = function (a) { return cur === '全部' || a.type === cur; };
|
||||
var groups = [['开源', function (a) { return a.oss; }], ['在线使用', function (a) { return !a.oss && a.web; }], ['闭源工具', function (a) { return !a.oss && !a.web; }]];
|
||||
box.innerHTML = groups.map(function (g) {
|
||||
var list = A.filter(function (a) { return g[1](a) && pick(a); });
|
||||
return list.length ? '<div class="row-title">' + g[0] + '</div><div class="shelf">' + list.map(toolCard).join('') + '</div>' : '';
|
||||
}).join('') || '<p class="note">这一类还没有东西。</p>';
|
||||
seg.querySelectorAll('button').forEach(function (b) { b.setAttribute('aria-pressed', String(b.getAttribute('data-t') === cur)); });
|
||||
}
|
||||
if (seg) {
|
||||
seg.innerHTML = types.map(function (t) { return '<button type="button" data-t="' + esc(t) + '" aria-pressed="false">' + esc(t) + '</button>'; }).join('');
|
||||
seg.addEventListener('click', function (e) { var b = e.target.closest('button'); if (!b) return; cur = b.getAttribute('data-t'); draw(); });
|
||||
}
|
||||
if (box) draw();
|
||||
}
|
||||
|
||||
/* ================================================================ 平台入口 */
|
||||
if (page === 'links') {
|
||||
var LL = C.links || [], G = C.linkGroups || [];
|
||||
setText('#lN', String(LL.length));
|
||||
var bd = $('#lBoard');
|
||||
if (bd) bd.innerHTML = G.map(function (g) {
|
||||
var items = LL.filter(function (l) { return l.group === g.id; });
|
||||
return items.length ? '<div class="board-group flip">' + esc(g.name) + '</div>' + items.map(linkRow).join('') : '';
|
||||
}).join('') + LL.filter(function (l) { return !G.some(function (g) { return g.id === l.group; }); }).map(linkRow).join('');
|
||||
}
|
||||
|
||||
/* ================================================================ 关于 */
|
||||
if (page === 'about') {
|
||||
var AB = C.about || {};
|
||||
var story = $('#aStory'); if (story && AB.story) story.innerHTML = mini(AB.story);
|
||||
var cr = $('#aCredits');
|
||||
if (cr && AB.cards && AB.cards.length) cr.innerHTML = AB.cards.map(function (c) {
|
||||
return '<section class="credit crystal"><span class="k">' + esc(c.k) + '</span><h3>' + esc(c.h) + '</h3>' + mini(c.p) + '</section>';
|
||||
}).join('');
|
||||
var ft = $('#aFoot'); if (ft && AB.foot) ft.innerHTML = mini(AB.foot).replace(/^<p>|<\/p>$/g, '');
|
||||
}
|
||||
|
||||
/* ================================================================ 金钻宇宙:下面的档案卡片(星系图在页面自己的模块脚本里) */
|
||||
if (page === 'universe') {
|
||||
var uv2 = universes();
|
||||
var meta = $('.room-head .meta'); if (meta) meta.innerHTML = '写好 <b>' + uv2.lit.length + '</b> 个<br>空着 ' + uv2.empty.length + ' 个';
|
||||
/* 卡片左上角的小色块:预览站按星球风格配的颜色;后来新加的风格就用这条世界线自己的主色 */
|
||||
var SW = { crystal: '#7FE7FF', paper: '#F6F1E4', ice: '#BFE4FF', neon: '#5A3FB0', duality: '#F2B84B' };
|
||||
var ul = $('#uniList');
|
||||
if (ul) ul.innerHTML = uv2.lit.map(function (u) {
|
||||
var lk = uv2.looks[u.no] || {};
|
||||
return '<button type="button" class="ucell" data-no="' + esc(u.no) + '" style="--sw:' + esc(SW[lk.style] || lk.accent || u.tone || '#9AA0B4') + '">'
|
||||
+ '<span class="sw" aria-hidden="true"></span><span class="no">' + esc(u.no) + ' · ' + esc(u.kind || '') + '</span><h3>' + esc(u.name) + '</h3>'
|
||||
+ '<span class="tg">' + esc(u.tag || '') + '</span><span class="go">在星图里看 →</span></button>';
|
||||
}).join('');
|
||||
var us = $('#uniSlots');
|
||||
if (us) { us.innerHTML = uv2.empty.map(function (u) { return '<button type="button" data-no="' + esc(u.no) + '"><b>' + esc(u.no) + '</b>空槽</button>'; }).join(''); us.hidden = !uv2.empty.length; }
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,10 @@
|
||||
/* 站点信息:全站页脚 / 「更多」面板 / 关于页用的几项固定信息,只在这一个文件里写。
|
||||
仓库里是占位;正式服务器上换成真实值的这一份(部署时只替换这个文件,别去改各个页面)。 */
|
||||
window.JZ_SITE = {
|
||||
domain: 'example.com', // 页脚 © 后面的域名
|
||||
qq: '123456789', // QQ 群号
|
||||
qqName: '屑钻小窝', // QQ 群名
|
||||
qqUrl: 'https://example.com/group-invite', // 加群链接(空 = 不给链接)
|
||||
icp: '备案号(已移除)', // 备案号(页脚链到 beian.miit.gov.cn)
|
||||
mail: 'feedback@example.com' // 反馈邮箱
|
||||
};
|
||||
@@ -0,0 +1,935 @@
|
||||
/* 金钻客栈 · 全站样式(2026-10-06 起以设计预览站为准)—— 白光藏色 × MC 方块。
|
||||
一眼看过去是白的;颜色只藏在亮部:晶体边缘的淡彩细边、扫过的高光、钻石折射出的光谱。
|
||||
按钮是一块三棱镜:白色晶体 + 棱角两端 + 底部折射光谱,投下的不是灰影,而是红蓝分开的淡彩焦散光。 */
|
||||
|
||||
@font-face{font-family:'OPPO Sans';src:url('../fonts/OPPOSans-R.woff2') format('woff2');font-weight:400;font-display:swap}
|
||||
@font-face{font-family:'OPPO Sans';src:url('../fonts/OPPOSans-B.woff2') format('woff2');font-weight:700;font-display:swap}
|
||||
|
||||
:root{
|
||||
--ink:#1E2440; --ink-2:#4A5070; --ink-3:#737891;
|
||||
--bg:#FAFBFE; --white:#FFFFFF;
|
||||
--line:rgba(30,36,64,.08); --line-2:rgba(30,36,64,.14);
|
||||
/* 藏起来的颜色:低饱和光谱 */
|
||||
--spec:linear-gradient(90deg,#FF9BB0 0%,#FFCC7A 25%,#94E3B4 50%,#8CC8FF 75%,#B9A2FF 100%);
|
||||
--edge:linear-gradient(125deg,rgba(255,150,172,.55) 0%,rgba(255,210,135,.5) 26%,rgba(150,228,186,.5) 50%,rgba(140,200,255,.58) 74%,rgba(190,165,255,.58) 100%);
|
||||
--edge-strong:linear-gradient(125deg,#FFB3C3 0%,#FFD99A 26%,#A9EBC6 50%,#A6D5FF 74%,#CDB9FF 100%);
|
||||
--lift:0 1px 0 rgba(255,255,255,1) inset,0 18px 36px -24px rgba(110,130,220,.38),0 12px 26px -22px rgba(255,140,120,.28);
|
||||
--lift-hi:0 1px 0 rgba(255,255,255,1) inset,0 26px 48px -26px rgba(110,130,220,.45),0 16px 32px -24px rgba(255,140,120,.34);
|
||||
--r-xl:30px; --r-lg:22px; --r:18px; --r-sm:12px;
|
||||
--ease:cubic-bezier(.23,1,.32,1);
|
||||
--font:'OPPO Sans',-apple-system,BlinkMacSystemFont,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif;
|
||||
--wrap:1200px;
|
||||
--sparks:#FFB3C3 #FFD99A #A9EBC6 #A6D5FF #CDB9FF #FFC2D0 #B5DCFF;
|
||||
}
|
||||
*{box-sizing:border-box}
|
||||
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
|
||||
body{margin:0;min-height:100vh;color:var(--ink);font:16px/1.7 var(--font);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;
|
||||
background:
|
||||
radial-gradient(38% 30% at 4% 0%,rgba(150,215,255,.16) 0%,transparent 70%),
|
||||
radial-gradient(34% 28% at 100% 6%,rgba(255,170,200,.13) 0%,transparent 70%),
|
||||
radial-gradient(46% 36% at 70% 100%,rgba(255,215,150,.12) 0%,transparent 70%),
|
||||
radial-gradient(40% 34% at 0% 70%,rgba(170,235,200,.10) 0%,transparent 70%),
|
||||
var(--bg)}
|
||||
img{max-width:100%;display:block}
|
||||
a{color:inherit}
|
||||
button{font:inherit;color:inherit}
|
||||
.wrap{max-width:var(--wrap);margin:0 auto;padding:0 24px}
|
||||
.num{font-variant-numeric:tabular-nums}
|
||||
:focus-visible{outline:2px solid #8CC8FF;outline-offset:3px;border-radius:10px}
|
||||
.gem-img{background:url('gem.webp') center/contain no-repeat;image-rendering:pixelated}
|
||||
|
||||
/* ===== 晶体面板:白色主体 + 淡彩细边 + 带色的柔光(不是灰影) ===== */
|
||||
.crystal{position:relative;border:1px solid rgba(255,255,255,.78);
|
||||
background:linear-gradient(160deg,rgba(255,255,255,.80) 0%,rgba(255,255,255,.56) 100%);
|
||||
box-shadow:inset 0 1px 0 rgba(255,255,255,.95),inset 0 -1px 0 rgba(255,255,255,.35),0 22px 44px -28px rgba(100,110,190,.38)}
|
||||
|
||||
/* 毛玻璃后面的彩光:几团缓慢漂动的柔光,玻璃把它们模糊成淡淡的颜色 */
|
||||
.orbs{position:fixed;inset:-12%;z-index:-2;overflow:hidden;pointer-events:none;translate:calc(var(--mx,0) * -36px) calc(var(--my,0) * -28px)}
|
||||
.orbs i{position:absolute;border-radius:50%;will-change:transform;animation:var(--path) var(--t,22s) ease-in-out infinite alternate}
|
||||
.orbs .o1{width:62vmax;height:62vmax;left:-14vmax;top:-18vmax;background:radial-gradient(circle,rgba(255,182,204,.78) 0%,rgba(255,182,204,0) 66%);--path:p1;--t:19s}
|
||||
.orbs .o2{width:70vmax;height:70vmax;right:-22vmax;top:-6vmax;background:radial-gradient(circle,rgba(160,206,255,.78) 0%,rgba(160,206,255,0) 66%);--path:p2;--t:24s}
|
||||
.orbs .o3{width:56vmax;height:56vmax;left:-6vmax;top:42%;background:radial-gradient(circle,rgba(170,238,204,.72) 0%,rgba(170,238,204,0) 66%);--path:p3;--t:21s}
|
||||
.orbs .o4{width:64vmax;height:64vmax;right:-10vmax;bottom:-24vmax;background:radial-gradient(circle,rgba(255,214,160,.78) 0%,rgba(255,214,160,0) 66%);--path:p4;--t:27s}
|
||||
.orbs .o5{width:50vmax;height:50vmax;left:34%;top:18%;background:radial-gradient(circle,rgba(206,188,255,.72) 0%,rgba(206,188,255,0) 66%);--path:p5;--t:17s}
|
||||
@keyframes p1{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(18vw,10vh,0) scale(1.12)}100%{transform:translate3d(6vw,26vh,0) scale(.94)}}
|
||||
@keyframes p2{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(-20vw,14vh,0) scale(.9)}100%{transform:translate3d(-8vw,30vh,0) scale(1.1)}}
|
||||
@keyframes p3{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(24vw,-12vh,0) scale(1.1)}100%{transform:translate3d(36vw,6vh,0) scale(.92)}}
|
||||
@keyframes p4{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(-26vw,-16vh,0) scale(1.08)}100%{transform:translate3d(-12vw,-30vh,0) scale(.95)}}
|
||||
@keyframes p5{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(-14vw,20vh,0) scale(1.15)}100%{transform:translate3d(12vw,-10vh,0) scale(.9)}}
|
||||
/* ===== 灵动:卡片随鼠标轻微倾斜,玻璃上一块跟着鼠标走的柔光;滚动时依次浮现 ===== */
|
||||
.fx{transform:perspective(1000px) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)) translateY(var(--ty,0px));transition:transform .55s var(--ease),box-shadow .3s var(--ease)}
|
||||
.fx.on{transition:transform .12s linear,box-shadow .3s var(--ease)}
|
||||
.fx::after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .35s var(--ease);
|
||||
background:radial-gradient(380px circle at var(--px,50%) var(--py,50%),rgba(255,255,255,.7) 0%,rgba(255,255,255,0) 46%)}
|
||||
.fx.on::after{opacity:.55}
|
||||
.js .rv{opacity:0;translate:0 22px}
|
||||
/* ⚠️ 2026-10-07:这条优先级比 .room/.tool/.art/.path 自己的 transition 高,原来只写了 opacity/translate ——
|
||||
卡片一浮现完,悬停上浮、跟鼠标倾斜、阴影、描边全都没了过渡(画展大卡最明显:进出都是"跳")。
|
||||
浮现那两项照旧带依次延迟;悬停相关的几项不带延迟,补回来。 */
|
||||
.js .rv.in{opacity:1;translate:0 0;transition:opacity .7s var(--ease) var(--d,0ms),translate .7s var(--ease) var(--d,0ms),transform .45s var(--ease),box-shadow .35s var(--ease),border-color .35s var(--ease)}
|
||||
|
||||
/* ---------- 预览提示条 ---------- */
|
||||
.ribbon{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px 14px;padding:8px 16px;font-size:12.5px;color:var(--ink-2);background:rgba(255,255,255,.45);border-bottom:1px solid rgba(255,255,255,.7)}
|
||||
.ribbon b{color:var(--ink)}
|
||||
.ribbon .bar{display:inline-block;width:38px;height:3px;border-radius:2px;background:var(--spec);vertical-align:middle;margin-right:8px}
|
||||
|
||||
/* ---------- 顶栏 ---------- */
|
||||
.top{position:sticky;top:0;z-index:50;background:rgba(255,255,255,.48);-webkit-backdrop-filter:saturate(1.4) blur(10px);backdrop-filter:saturate(1.4) blur(10px);box-shadow:inset 0 -1px 0 rgba(255,255,255,.8)}
|
||||
.top::after{content:"";position:absolute;left:0;right:0;bottom:0;height:1px;background:rgba(30,36,64,.06)}
|
||||
.top-in{display:flex;align-items:center;gap:20px;min-height:66px}
|
||||
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;flex:none}
|
||||
.brand i{width:30px;height:30px;filter:drop-shadow(-2px 3px 4px rgba(255,110,140,.25)) drop-shadow(2px 3px 4px rgba(70,140,255,.25))}
|
||||
.brand b{font-size:18px;letter-spacing:.04em}
|
||||
.nav{display:flex;gap:2px;flex:1;min-width:0;overflow-x:auto;scrollbar-width:none}
|
||||
.nav::-webkit-scrollbar{display:none}
|
||||
.nav a{position:relative;display:flex;align-items:center;gap:8px;height:40px;padding:0 13px;border-radius:999px;text-decoration:none;font-size:15px;color:var(--ink-2);white-space:nowrap;transition:background .18s var(--ease),color .18s var(--ease)}
|
||||
.nav a:hover{background:rgba(255,255,255,.95);color:var(--ink)}
|
||||
.nav a .dm{width:8px;height:8px;border-radius:2px;transform:rotate(45deg);background:linear-gradient(135deg,var(--zc),var(--zc2,var(--zc)));opacity:.8;flex:none}
|
||||
.nav a[aria-current=page]{color:var(--ink);font-weight:700;border:1px solid transparent;background:linear-gradient(#fff,#fff) padding-box,var(--edge) border-box;box-shadow:0 8px 18px -12px rgba(110,130,220,.45)}
|
||||
.nav a[aria-current=page]::after{content:"";position:absolute;left:16px;right:16px;bottom:4px;height:2px;border-radius:2px;background:var(--spec)}
|
||||
.desk-btn{flex:none}
|
||||
.btn-pill{display:inline-flex;align-items:center;gap:9px;height:44px;padding:0 18px 0 6px;border-radius:999px;text-decoration:none;font-size:14.5px;font-weight:700;color:var(--ink);
|
||||
background:rgba(255,255,255,.82);border:1px solid rgba(255,255,255,.95);
|
||||
box-shadow:inset 0 1px 0 #fff,0 12px 26px -16px rgba(120,110,230,.6),0 8px 18px -14px rgba(255,140,170,.55);transition:transform .2s var(--ease),box-shadow .2s var(--ease),background .2s var(--ease)}
|
||||
.btn-pill .ic{width:32px;height:32px;border-radius:50%;background:#fff url('gem.webp') center/19px no-repeat;image-rendering:pixelated;box-shadow:0 2px 8px -2px rgba(110,120,220,.45)}
|
||||
.btn-pill svg{opacity:.55;transition:transform .2s var(--ease),opacity .2s var(--ease)}
|
||||
.btn-pill:hover{background:rgba(255,255,255,.78);transform:translateY(-1px);box-shadow:inset 0 1px 0 #fff,0 16px 30px -16px rgba(120,110,230,.7),0 10px 22px -14px rgba(255,140,170,.6)}
|
||||
.btn-pill:hover svg{transform:translateX(2px);opacity:.9}
|
||||
.btn-pill:active{transform:translateY(1px)}
|
||||
|
||||
/* ===== 按钮:统一毛玻璃胶囊(和顶栏「自助渲染」同一套) ===== */
|
||||
.btn{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:46px;padding:0 22px;border-radius:999px;
|
||||
font-size:15px;font-weight:700;color:var(--ink);text-decoration:none;cursor:pointer;white-space:nowrap;
|
||||
border:1px solid rgba(255,255,255,.9);
|
||||
transition:transform .2s var(--ease),box-shadow .2s var(--ease),background .2s var(--ease)}
|
||||
.btn svg{flex:none;transition:transform .2s var(--ease)}
|
||||
.btn:hover svg{transform:translateX(2px)}
|
||||
.btn:active{transform:translateY(1px)}
|
||||
/* 主按钮:更实一点的白玻璃 + 淡彩投影 */
|
||||
.btn-prism{background:rgba(255,255,255,.8);
|
||||
box-shadow:inset 0 1px 0 #fff,0 12px 26px -16px rgba(120,110,230,.6),0 8px 18px -14px rgba(255,140,170,.55)}
|
||||
.btn-prism:hover{background:rgba(255,255,255,.95);transform:translateY(-1px);
|
||||
box-shadow:inset 0 1px 0 #fff,0 16px 30px -16px rgba(120,110,230,.7),0 10px 22px -14px rgba(255,140,170,.6)}
|
||||
/* 次按钮:更透一点 */
|
||||
.btn-crystal{background:rgba(255,255,255,.6);font-weight:600;
|
||||
box-shadow:inset 0 1px 0 rgba(255,255,255,.9),0 8px 20px -16px rgba(110,120,200,.45)}
|
||||
.btn-crystal:hover{background:rgba(255,255,255,.7);transform:translateY(-1px)}
|
||||
.btn-sm{height:40px;padding:0 16px;font-size:14px}
|
||||
.btn[disabled]{opacity:.55;cursor:not-allowed;transform:none;filter:none}
|
||||
|
||||
/* ---------- 小部件 ---------- */
|
||||
.chip{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 11px;border-radius:999px;border:1px solid rgba(255,255,255,.85);background:rgba(255,255,255,.6);font-size:12.5px;color:var(--ink-2);white-space:nowrap}
|
||||
.chip::before{display:none}
|
||||
.chip.ok{--c:#3CC985} .chip.wait{--c:#F5B23E} .chip.oss{--c:#45B8E0} .chip.plain::before{display:none}
|
||||
.status{display:inline-flex;align-items:center;gap:8px;font-size:13.5px;color:var(--ink-2)}
|
||||
.status::before{display:none}
|
||||
.dm-big{display:inline-block;width:16px;height:16px;border-radius:4px;transform:rotate(45deg);background:var(--edge-strong);box-shadow:-3px 4px 8px -2px rgba(255,110,140,.35),3px 4px 8px -2px rgba(70,140,255,.35)}
|
||||
|
||||
/* ---------- 大堂首屏:白色观景窗,钻石把白光折射成光谱 ---------- */
|
||||
.hero{padding:28px 0 4px}
|
||||
.window{border-radius:var(--r-xl);padding:10px}
|
||||
.sky{position:relative;overflow:hidden;border-radius:22px;min-height:500px;display:grid;grid-template-columns:1.15fr .85fr;align-items:center;isolation:isolate;
|
||||
background:radial-gradient(60% 70% at 12% 18%,rgba(255,196,214,.34) 0%,transparent 70%),radial-gradient(55% 65% at 88% 26%,rgba(176,212,255,.38) 0%,transparent 70%),radial-gradient(50% 60% at 55% 105%,rgba(255,222,176,.32) 0%,transparent 70%),linear-gradient(165deg,rgba(255,255,255,.84) 0%,rgba(255,255,255,.70) 100%)}
|
||||
.sky canvas{position:absolute;inset:0;width:100%;height:100%;z-index:-1}
|
||||
.beam{position:absolute;z-index:-2;left:-12%;top:40%;width:86%;height:150px;transform:rotate(-14deg);transform-origin:100% 50%;
|
||||
background:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,.95) 70%,rgba(255,255,255,.4) 100%);filter:blur(6px)}
|
||||
.fan{position:absolute;z-index:-1;left:72%;top:46%;width:1100px;height:1100px;transform:translate(-50%,-50%);
|
||||
background:conic-gradient(from 68deg at 50% 50%,transparent 0deg,rgba(255,120,150,.55) 7deg,rgba(255,196,95,.55) 15deg,rgba(110,214,150,.5) 23deg,rgba(95,175,255,.55) 31deg,rgba(165,125,255,.55) 39deg,transparent 48deg,transparent 360deg);
|
||||
-webkit-mask:radial-gradient(circle,rgba(0,0,0,.9) 8%,rgba(0,0,0,.45) 28%,transparent 50%);mask:radial-gradient(circle,rgba(0,0,0,.9) 8%,rgba(0,0,0,.45) 28%,transparent 50%);
|
||||
filter:blur(8px);opacity:.9;will-change:transform;animation:sway 9s ease-in-out infinite alternate}
|
||||
@keyframes sway{0%{rotate:-7deg;scale:.96}100%{rotate:6deg;scale:1.05}}
|
||||
.hero-copy{padding:56px 56px 76px;display:flex;flex-direction:column;gap:20px;align-items:flex-start;translate:calc(var(--mx,0) * -6px) calc(var(--my,0) * -4px);transition:translate .2s linear}
|
||||
.tag-l{display:inline-flex;align-items:center;gap:8px;height:32px;padding:0 14px;border-radius:999px;border:1px solid rgba(255,255,255,.85);background:rgba(255,255,255,.6);font-size:13px;font-weight:700;color:var(--ink-2)}
|
||||
.tag-l i{width:8px;height:8px;border-radius:2px;transform:rotate(45deg);background:var(--spec)}
|
||||
.hero h1{margin:0;font-size:clamp(52px,7.4vw,92px);line-height:1.02;letter-spacing:.03em}
|
||||
.hero p{margin:0;font-size:17.5px;line-height:1.8;color:var(--ink-2);max-width:27em;text-wrap:pretty}
|
||||
.hero .cta{display:flex;flex-wrap:wrap;gap:14px;padding-top:6px}
|
||||
.emblem{position:relative;justify-self:center;width:min(320px,74%);aspect-ratio:1;translate:calc(var(--mx,0) * 16px) calc(var(--my,0) * 12px);transition:translate .2s linear}
|
||||
.emblem .halo{position:absolute;inset:6%;border-radius:50%;background:radial-gradient(circle,#FFFFFF 0%,rgba(255,255,255,.85) 40%,rgba(255,255,255,0) 70%)}
|
||||
.emblem .ring{position:absolute;inset:0;border-radius:50%;padding:2px;background:var(--edge-strong);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);opacity:.95;animation:spin 48s linear infinite}
|
||||
.emblem .ring.r2{inset:13%;opacity:.55;padding:1.5px;animation-duration:70s;animation-direction:reverse}
|
||||
.emblem .ring.r3{inset:-9%;opacity:.35;padding:1px}
|
||||
.emblem .gem{position:absolute;inset:27%;filter:drop-shadow(-6px 12px 14px rgba(255,110,140,.28)) drop-shadow(6px 12px 14px rgba(70,140,255,.28));animation:float 7s ease-in-out infinite}
|
||||
.telemetry{position:absolute;left:56px;right:56px;bottom:22px;display:flex;flex-wrap:wrap;gap:6px 22px;font-size:12.5px;color:var(--ink-3)}
|
||||
.telemetry b{color:var(--ink);font-weight:700}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
@keyframes float{50%{transform:translateY(-9px)}}
|
||||
|
||||
/* ---------- 区块标题 ---------- */
|
||||
.sec{padding:60px 0 6px}
|
||||
.sec-h{display:flex;align-items:flex-end;justify-content:space-between;gap:12px 24px;flex-wrap:wrap;margin-bottom:22px}
|
||||
.sec-h h2{margin:0;font-size:30px;line-height:1.2}
|
||||
.sec-h p{margin:6px 0 0;color:var(--ink-3);font-size:15px}
|
||||
.sec-h a{font-size:15px;font-weight:700;text-decoration:none;display:inline-flex;align-items:center;gap:6px}
|
||||
.sec-h a:hover{text-decoration:underline;text-decoration-color:#8CC8FF;text-underline-offset:4px}
|
||||
|
||||
/* ---------- 楼层导览 ---------- */
|
||||
.dir{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-auto-rows:minmax(232px,auto);gap:16px}
|
||||
.room{display:flex;flex-direction:column;gap:10px;padding:24px;border-radius:var(--r-lg);text-decoration:none;overflow:hidden;transition:transform .22s var(--ease),box-shadow .22s var(--ease)}
|
||||
.room:hover{--ty:-4px;box-shadow:var(--lift-hi)}
|
||||
.room::before{content:"";position:absolute;right:-70px;top:-70px;width:200px;height:200px;border-radius:50%;background:radial-gradient(circle,var(--zc) 0%,transparent 68%);opacity:.16;pointer-events:none;transition:opacity .3s var(--ease)}
|
||||
.room:hover::before{opacity:.28}
|
||||
.room .no{font-size:13px;font-weight:700;color:var(--ink-3);letter-spacing:.1em}
|
||||
.room h3{margin:0;font-size:23px;line-height:1.25}
|
||||
.room .desc{margin:0;font-size:14.5px;line-height:1.7;color:var(--ink-2)}
|
||||
.room .foot{margin-top:auto;padding-top:8px;display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:13px;color:var(--ink-3)}
|
||||
.room .go{display:inline-flex;align-items:center;gap:6px;font-weight:700;color:var(--ink);white-space:nowrap;transition:gap .2s var(--ease)}
|
||||
.room:hover .go{gap:10px}
|
||||
.room.big{grid-column:span 2;grid-row:span 2}
|
||||
.room.big .peek{flex:1;min-height:200px}
|
||||
.room.big .peek img{aspect-ratio:auto;height:100%}
|
||||
.peek{display:grid;grid-template-columns:1.25fr 1fr;gap:10px;margin:6px 0 2px}
|
||||
.peek img{width:100%;height:100%;aspect-ratio:4/3;object-fit:cover;border-radius:14px;border:3px solid #fff;box-shadow:-4px 10px 18px -12px rgba(255,110,140,.35),4px 10px 18px -12px rgba(70,140,255,.35)}
|
||||
.peek-cap{display:flex;flex-wrap:wrap;gap:8px;align-items:center;font-size:13px;color:var(--ink-3)}
|
||||
.mini-list{list-style:none;margin:2px 0 0;padding:0;display:flex;flex-direction:column;gap:8px}
|
||||
.mini-list li{display:flex;justify-content:space-between;align-items:center;gap:10px;font-size:14px;font-weight:700}
|
||||
.mini-rack{display:grid;grid-template-columns:repeat(11,minmax(0,1fr));gap:4px;margin-top:4px}
|
||||
.mini-rack i{height:34px;border-radius:5px;background:#fff;border:1px dashed var(--line-2)}
|
||||
.mini-rack i.lit{border:0;background:linear-gradient(180deg,#fff 0%,var(--t) 100%);box-shadow:0 8px 14px -8px var(--t)}
|
||||
.plat-cloud{display:flex;flex-wrap:wrap;gap:6px;margin-top:2px}
|
||||
.quote{margin:2px 0 0;font-size:14.5px;line-height:1.8;color:var(--ink-2)}
|
||||
|
||||
/* ---------- 服务台 ---------- */
|
||||
.desk{display:grid;grid-template-columns:auto 1fr auto;gap:24px;align-items:center;padding:26px 28px;border-radius:var(--r-lg);overflow:hidden}
|
||||
.desk-ic,.svc-ic,.uni-tile{position:relative;display:grid;place-items:center;border:1px solid transparent;background:linear-gradient(160deg,#fff,#F3F5FF) padding-box,var(--edge-strong) border-box;box-shadow:-5px 10px 18px -12px rgba(255,110,140,.4),5px 10px 18px -12px rgba(70,140,255,.4)}
|
||||
.desk-ic{width:66px;height:66px;border-radius:20px}
|
||||
.desk-ic i{width:38px;height:38px}
|
||||
.desk h3{margin:0 0 4px;font-size:21px}
|
||||
.desk p{margin:0;font-size:14.5px;color:var(--ink-2)}
|
||||
.desk .meta{display:flex;flex-wrap:wrap;gap:8px 18px;margin-top:10px;font-size:13.5px;color:var(--ink-3)}
|
||||
.desk .acts{display:flex;flex-wrap:wrap;gap:14px;justify-content:flex-end;align-items:center}
|
||||
|
||||
/* ---------- 出发信息屏(白色晶体版) ---------- */
|
||||
.board{border-radius:var(--r-lg);overflow:hidden}
|
||||
.board-title{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:18px 24px 14px;border-bottom:1px solid var(--line)}
|
||||
.board-title b{font-size:16px;letter-spacing:.06em}
|
||||
.board-title span{font-size:12.5px;color:var(--ink-3)}
|
||||
.board-head,.board-row{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1.2fr) minmax(0,.8fr) auto;gap:16px;align-items:center;padding:0 24px}
|
||||
.board-head{height:40px;font-size:12px;color:var(--ink-3);letter-spacing:.12em;border-bottom:1px solid var(--line)}
|
||||
.board-row{position:relative;min-height:62px;border-bottom:1px solid var(--line);text-decoration:none;color:inherit;transition:background .18s var(--ease)}
|
||||
.board-row:hover{background:rgba(255,255,255,.55)}
|
||||
.board-row:last-child{border-bottom:0}
|
||||
.board-row .dest{display:flex;align-items:baseline;gap:10px;min-width:0}
|
||||
.board-row .dest b{font-size:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.board-row .dest small{font-size:11px;color:var(--ink-3);letter-spacing:.12em;white-space:nowrap}
|
||||
.board-row .kind{font-size:14px;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.board-row .gate{justify-self:start;display:inline-flex;align-items:center;height:26px;padding:0 10px;border-radius:999px;font-size:12.5px;color:var(--ink-2);border:1px solid transparent;background:linear-gradient(#fff,#fff) padding-box,var(--edge) border-box}
|
||||
.board-row .act{display:inline-flex;align-items:center;gap:6px;height:34px;padding:0 14px;border-radius:999px;font-size:13px;font-weight:700;color:var(--ink);background:rgba(255,255,255,.7);border:1px solid rgba(255,255,255,.95);box-shadow:inset 0 1px 0 #fff,0 6px 14px -10px rgba(110,120,200,.5);transition:background .2s var(--ease),box-shadow .2s var(--ease)}
|
||||
.board-row:hover .act{background:#fff;box-shadow:inset 0 1px 0 #fff,0 10px 18px -10px rgba(120,110,230,.55)}
|
||||
.board-group{padding:12px 24px 8px;font-size:12px;font-weight:700;letter-spacing:.14em;color:var(--ink-3);border-bottom:1px solid var(--line);background:linear-gradient(90deg,rgba(255,240,245,.6),rgba(240,248,255,.6))}
|
||||
.flip{opacity:0}
|
||||
.flip.in{animation:flipIn .55s var(--ease) both}
|
||||
@keyframes flipIn{from{opacity:0;transform:perspective(700px) rotateX(-75deg);transform-origin:50% 0}to{opacity:1;transform:none}}
|
||||
|
||||
/* ---------- 页脚 ---------- */
|
||||
.foot-site{position:relative;margin-top:80px;background:rgba(255,255,255,.45)}
|
||||
.foot-site::before{content:"";position:absolute;left:0;right:0;top:0;height:1px;background:rgba(255,255,255,.85)}
|
||||
.foot-in{display:flex;flex-wrap:wrap;gap:14px 36px;align-items:center;padding:26px 24px 34px;font-size:13.5px;color:var(--ink-3)}
|
||||
.foot-in .brand b{font-size:16px;color:var(--ink)}
|
||||
.foot-in .brand i{width:24px;height:24px}
|
||||
.foot-in .sp{flex:1}
|
||||
|
||||
/* ---------- 屋子门头 ---------- */
|
||||
.room-head{position:relative;display:grid;grid-template-columns:auto 1fr auto;gap:28px;align-items:end;padding:44px 0 26px;margin-bottom:28px}
|
||||
.room-head::after{content:"";position:absolute;left:0;right:0;bottom:0;height:1px;background:var(--edge)}
|
||||
.zone{position:relative;justify-self:start;font-size:clamp(64px,8vw,108px);line-height:.9;font-weight:700;letter-spacing:-.02em;background:linear-gradient(135deg,var(--zc) 0%,var(--zc2,var(--zc)) 100%);-webkit-background-clip:text;background-clip:text;color:transparent;opacity:.78;filter:drop-shadow(-4px 8px 10px rgba(255,110,140,.18)) drop-shadow(4px 8px 10px rgba(70,140,255,.18))}
|
||||
.zone .dm-big{position:absolute;right:-12px;top:-8px}
|
||||
.room-head h1{margin:0;font-size:clamp(32px,4vw,46px);line-height:1.15}
|
||||
.room-head p{margin:8px 0 0;color:var(--ink-2);max-width:42em}
|
||||
.room-head .meta{text-align:right;font-size:13.5px;line-height:1.9;color:var(--ink-3)}
|
||||
.room-head .meta b{color:var(--ink);font-size:20px}
|
||||
|
||||
/* ---------- 画展 ---------- */
|
||||
.tools-bar{display:flex;flex-wrap:wrap;gap:12px 16px;align-items:center;margin-bottom:22px}
|
||||
.seg{display:inline-flex;flex-wrap:wrap;padding:4px;border-radius:999px}
|
||||
.seg button{position:relative;height:38px;padding:0 16px;border:0;background:transparent;border-radius:999px;font-size:14.5px;color:var(--ink-2);cursor:pointer;transition:background .16s var(--ease),color .16s var(--ease)}
|
||||
.seg button:hover{color:var(--ink)}
|
||||
.seg button[aria-pressed=true]{color:var(--ink);font-weight:700;background:linear-gradient(180deg,#fff,#F3F5FF);box-shadow:-3px 6px 12px -8px rgba(255,110,140,.45),3px 6px 12px -8px rgba(70,140,255,.45),inset 0 0 0 1px rgba(160,180,255,.35)}
|
||||
.seg button[aria-pressed=true]::after{content:"";position:absolute;left:14px;right:14px;bottom:5px;height:2px;border-radius:2px;background:var(--spec)}
|
||||
.seg button em{font-style:normal;opacity:.6;margin-left:4px;font-variant-numeric:tabular-nums}
|
||||
.gal{display:grid;grid-template-columns:150px minmax(0,1fr);gap:28px}
|
||||
.years{position:sticky;top:96px;align-self:start;display:flex;flex-direction:column;gap:6px}
|
||||
.years b{font-size:12px;letter-spacing:.14em;color:var(--ink-3);font-weight:700;margin-bottom:4px}
|
||||
.years a{display:flex;justify-content:space-between;align-items:center;height:40px;padding:0 14px;border-radius:12px;text-decoration:none;font-size:15px;color:var(--ink-2);border:1px solid transparent}
|
||||
.years a.on{background:linear-gradient(#fff,#fff) padding-box,var(--edge) border-box;color:var(--ink);font-weight:700;box-shadow:0 10px 20px -14px rgba(110,130,220,.5)}
|
||||
.years a em{font-style:normal;font-size:12px;color:var(--ink-3)}
|
||||
.wall{columns:3 260px;column-gap:16px}
|
||||
.art{break-inside:avoid;margin:0 0 16px;border-radius:var(--r);overflow:hidden;transition:transform .22s var(--ease),box-shadow .22s var(--ease)}
|
||||
.art:hover{--ty:-4px;box-shadow:var(--lift-hi)}
|
||||
.art button{display:block;width:100%;padding:0;border:0;background:none;cursor:zoom-in;text-align:left}
|
||||
.art img{width:100%;height:auto}
|
||||
.art .cap{padding:12px 14px 14px;display:flex;flex-direction:column;gap:8px}
|
||||
.art .cap b{font-size:15px}
|
||||
.art .cap span{display:flex;justify-content:space-between;align-items:center;font-size:12.5px;color:var(--ink-3)}
|
||||
.ph{position:relative;overflow:hidden;aspect-ratio:var(--ar,4/3);display:grid;place-items:center;align-content:center;gap:8px;background:linear-gradient(165deg,#F6F8FD,#FBFAFF);color:var(--ink-3);font-size:13px;isolation:isolate}
|
||||
.ph::after{content:"";position:absolute;z-index:-1;right:-30%;top:-40%;width:90%;height:160%;transform:rotate(24deg);background:linear-gradient(90deg,rgba(255,150,172,.16),rgba(255,210,135,.16),rgba(150,228,186,.16),rgba(140,200,255,.18),rgba(190,165,255,.18));filter:blur(14px)}
|
||||
.ph::before{content:"";position:absolute;inset:10px;border:1.5px dashed rgba(140,150,190,.35);border-radius:12px}
|
||||
.ph svg{color:var(--ink-3);opacity:.6}
|
||||
.type{display:inline-flex;align-items:center;height:24px;padding:0 9px;border-radius:999px;font-size:12px;font-weight:700;border:1px solid transparent;background:linear-gradient(#fff,#fff) padding-box,var(--edge) border-box;color:var(--ink-2)}
|
||||
.note{margin:6px 0 0;font-size:13.5px;color:var(--ink-3)}
|
||||
.lb{position:fixed;inset:0;z-index:100;display:none;place-items:center;padding:24px;background:rgba(250,251,255,.86);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px)}
|
||||
.lb.open{display:grid}
|
||||
.lb img{max-width:min(1100px,94vw);max-height:80vh;border-radius:18px;border:4px solid #fff;box-shadow:-10px 26px 50px -26px rgba(255,110,140,.5),10px 26px 50px -26px rgba(70,140,255,.5)}
|
||||
.lb .lb-cap{margin-top:14px;text-align:center;color:var(--ink-2);font-size:14px;font-weight:700}
|
||||
.lb button{position:absolute;top:18px;right:18px}
|
||||
|
||||
/* ---------- 工具与开源 ---------- */
|
||||
.row-title{display:flex;align-items:center;gap:10px;margin:8px 0 14px;font-size:15px;font-weight:700;color:var(--ink-2)}
|
||||
.row-title::after{content:"";flex:1;height:1px;background:var(--edge);opacity:.8}
|
||||
.shelf{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:16px;margin-bottom:34px}
|
||||
.tool{display:flex;flex-direction:column;gap:12px;padding:24px;border-radius:var(--r-lg);overflow:hidden;transition:transform .22s var(--ease),box-shadow .22s var(--ease)}
|
||||
.tool:hover{--ty:-3px;box-shadow:var(--lift-hi)}
|
||||
.tool .en{font-size:12px;letter-spacing:.14em;color:var(--ink-3)}
|
||||
.tool h3{margin:0;font-size:23px}
|
||||
.tool p{margin:0;font-size:14.5px;line-height:1.75;color:var(--ink-2)}
|
||||
.tool .chips{display:flex;flex-wrap:wrap;gap:8px}
|
||||
.kv{display:flex;flex-wrap:wrap;gap:6px 22px;padding-top:12px;margin-top:auto;border-top:1px solid var(--line);font-size:13px;color:var(--ink-3)}
|
||||
.kv b{color:var(--ink)}
|
||||
.tool .acts{display:flex;gap:14px;flex-wrap:wrap;align-items:center}
|
||||
|
||||
/* ---------- 金钻宇宙(也是白光:星云只藏在亮部) ---------- */
|
||||
body.uni{background:
|
||||
radial-gradient(40% 34% at 10% 8%,rgba(185,160,255,.20) 0%,transparent 70%),
|
||||
radial-gradient(36% 30% at 92% 18%,rgba(140,205,255,.20) 0%,transparent 70%),
|
||||
radial-gradient(44% 36% at 60% 96%,rgba(255,175,205,.16) 0%,transparent 70%),
|
||||
#F8F9FF}
|
||||
.space-bg{position:fixed;inset:0;z-index:-1;width:100%;height:100%;pointer-events:none}
|
||||
.uni-intro{display:flex;gap:20px;align-items:center;margin-bottom:26px;padding:16px 20px;border-radius:var(--r)}
|
||||
.uni-intro p{margin:0;color:var(--ink-2);font-size:15.5px;line-height:1.85}
|
||||
.uni-tile{width:76px;height:76px;flex:none;border-radius:20px}
|
||||
.logo-ink{display:block;width:62%;height:62%;background:linear-gradient(140deg,#7C6CFF 0%,#4AA8FF 45%,#E46C9A 100%);-webkit-mask-position:center;mask-position:center;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}
|
||||
.rack{display:flex;flex-direction:column;gap:12px}
|
||||
.disk{border-radius:var(--r);overflow:hidden;transition:transform .2s var(--ease),box-shadow .2s var(--ease)}
|
||||
.disk:hover{box-shadow:var(--lift-hi)}
|
||||
.disk[open]::before{content:"";position:absolute;left:18px;right:18px;top:0;height:2px;border-radius:2px;background:var(--spec)}
|
||||
.disk summary{list-style:none;display:grid;grid-template-columns:64px minmax(0,1fr) auto;gap:18px;align-items:center;padding:16px 20px;cursor:pointer}
|
||||
.disk summary::-webkit-details-marker{display:none}
|
||||
.disk .emb{position:relative;display:grid;place-items:center;width:64px;height:64px;border-radius:18px;border:1px solid transparent;background:linear-gradient(160deg,#fff,#F3F5FF) padding-box,var(--edge-strong) border-box;box-shadow:-4px 8px 14px -10px rgba(255,110,140,.45),4px 8px 14px -10px rgba(70,140,255,.45)}
|
||||
.disk .dno{font-size:12px;letter-spacing:.16em;color:var(--ink-3)}
|
||||
.disk h3{margin:2px 0 0;font-size:20px}
|
||||
.disk .tagline{font-size:13.5px;color:var(--ink-2)}
|
||||
.disk .kind{display:inline-flex;align-items:center;height:28px;padding:0 12px;border-radius:999px;border:1px solid transparent;background:linear-gradient(#fff,#fff) padding-box,var(--edge) border-box;font-size:12.5px;color:var(--ink-2)}
|
||||
.disk .more{padding:0 20px 20px 102px;color:var(--ink-2);font-size:14.5px;line-height:1.9}
|
||||
.disk .tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
||||
.disk .tags span{height:26px;display:inline-flex;align-items:center;padding:0 10px;border-radius:999px;background:#F5F7FD;border:1px solid var(--line);font-size:12px;color:var(--ink-2)}
|
||||
.slots{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;margin-top:4px}
|
||||
.slot{height:58px;border-radius:14px;border:1.5px dashed rgba(140,150,200,.4);background:rgba(255,255,255,.6);display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:12px;color:var(--ink-3)}
|
||||
.slot b{font-size:14px;color:var(--ink-2);font-variant-numeric:tabular-nums}
|
||||
|
||||
/* ---------- 关于 ---------- */
|
||||
.about-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:20px;align-items:start}
|
||||
.letter{padding:36px 40px;border-radius:var(--r-lg);overflow:hidden}
|
||||
.letter .k{font-size:13px;letter-spacing:.14em;color:var(--ink-3);font-weight:700}
|
||||
.letter h2{margin:6px 0 16px;font-size:26px}
|
||||
.letter p{margin:0;font-size:16.5px;line-height:2.05;color:var(--ink-2)}
|
||||
.letter .sign{display:flex;justify-content:flex-end;align-items:center;gap:10px;margin-top:20px;font-weight:700}
|
||||
.letter .sign i{width:26px;height:26px}
|
||||
.credits{display:flex;flex-direction:column;gap:12px}
|
||||
.credit{padding:18px 22px;border-radius:var(--r);overflow:hidden}
|
||||
.credit::after{display:none}
|
||||
.credit .k{font-size:12px;letter-spacing:.12em;color:var(--ink-3)}
|
||||
.credit h3{margin:2px 0 6px;font-size:19px}
|
||||
.credit p{margin:0;font-size:14px;line-height:1.75;color:var(--ink-2)}
|
||||
.credit code{font-family:inherit;font-weight:700;background:#F5F7FD;border:1px solid var(--line);border-radius:6px;padding:1px 6px}
|
||||
|
||||
/* ---------- 服务台(自助模板渲染) ---------- */
|
||||
.back{display:inline-flex;align-items:center;gap:6px;font-size:14px;color:var(--ink-2);text-decoration:none;height:40px;padding:0 12px;border-radius:999px}
|
||||
.back:hover{background:#fff;color:var(--ink)}
|
||||
.svc-ic{width:84px;height:84px;border-radius:26px}
|
||||
.svc-ic i{width:48px;height:48px}
|
||||
.paths{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
|
||||
.path{display:flex;flex-direction:column;gap:12px;padding:26px;border-radius:var(--r-lg);text-decoration:none;overflow:hidden;transition:transform .22s var(--ease),box-shadow .22s var(--ease)}
|
||||
.path:hover{--ty:-4px;box-shadow:var(--lift-hi)}
|
||||
.path .pi{width:50px;height:50px;border-radius:16px;display:grid;place-items:center;border:1px solid transparent;background:linear-gradient(160deg,#fff,#F3F5FF) padding-box,var(--edge-strong) border-box;color:var(--ink);box-shadow:-4px 8px 14px -10px rgba(255,110,140,.45),4px 8px 14px -10px rgba(70,140,255,.45)}
|
||||
.path h3{margin:0;font-size:22px}
|
||||
.path .flow{display:flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:14px;color:var(--ink-2)}
|
||||
.path .flow span{display:inline-flex;align-items:center;height:28px;padding:0 10px;border-radius:10px;background:#F6F8FD;border:1px solid var(--line)}
|
||||
.path .flow i{font-style:normal;color:var(--ink-3)}
|
||||
.path .hint{margin-top:auto;display:flex;justify-content:space-between;align-items:center;font-size:14px;font-weight:700}
|
||||
.path .hint em{font-style:normal;color:#12804C}
|
||||
.path.code .hint em{color:#1D63C2}
|
||||
.pickup{display:flex;flex-wrap:wrap;align-items:center;gap:10px 16px;margin-top:16px;padding:16px 20px;border-radius:var(--r);border:1.5px dashed rgba(140,150,200,.4);background:rgba(255,255,255,.6);font-size:14.5px;color:var(--ink-2)}
|
||||
.pickup .sp{flex:1}
|
||||
.tpl-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(148px,1fr));gap:12px}
|
||||
.tpl{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:var(--r-sm)}
|
||||
.tpl .sw{height:70px;border-radius:10px;background:linear-gradient(180deg,rgba(255,255,255,.4),rgba(255,255,255,0)),var(--c);position:relative;overflow:hidden;opacity:.85}
|
||||
.tpl .sw::after{content:"";position:absolute;left:0;right:0;bottom:0;height:32%;background:rgba(0,0,0,.1)}
|
||||
.tpl b{font-size:15px}
|
||||
.tpl span{font-size:12.5px;color:var(--ink-3)}
|
||||
.res{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
|
||||
.pass{display:grid;grid-template-columns:minmax(0,1fr) 240px;border-radius:var(--r-lg)}
|
||||
.pass .main{padding:26px 28px;display:flex;flex-direction:column;gap:14px;min-width:0}
|
||||
.pass .row{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
|
||||
.pass .lbl{font-size:12px;letter-spacing:.12em;color:var(--ink-3)}
|
||||
.pass .code{font-size:24px;font-weight:700;letter-spacing:.06em;font-variant-numeric:tabular-nums}
|
||||
.state{display:inline-flex;align-items:center;gap:8px;height:32px;padding:0 14px;border-radius:999px;background:#EDF4FF;color:#1D58C2;font-size:13.5px;font-weight:700}
|
||||
.state::before{display:none}
|
||||
@keyframes pulse{50%{opacity:.3}}
|
||||
.prog{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
|
||||
.prog i{height:8px;border-radius:4px;background:#EEF1F8}
|
||||
.prog i.on{background:var(--spec)}
|
||||
.prog i.run{background:repeating-linear-gradient(90deg,rgba(255,255,255,.95) 0 8px,rgba(255,255,255,.35) 8px 16px),var(--spec);background-size:32px 100%,100% 100%;animation:run 1s linear infinite}
|
||||
@keyframes run{to{background-position:32px 0,0 0}}
|
||||
.pass .stub{position:relative;padding:26px 24px;border-left:2px dashed rgba(140,150,200,.35);background:linear-gradient(180deg,rgba(248,250,255,.9),rgba(252,249,255,.9));border-radius:0 var(--r-lg) var(--r-lg) 0;display:flex;flex-direction:column;gap:12px;align-items:flex-start}
|
||||
.pass .stub::before,.pass .stub::after{content:"";position:absolute;left:-13px;width:24px;height:24px;border-radius:50%;background:var(--bg);box-shadow:inset 0 2px 4px rgba(30,36,64,.08)}
|
||||
.pass .stub::before{top:-13px}.pass .stub::after{bottom:-13px}
|
||||
.barcode{align-self:stretch;height:54px;border-radius:6px;background:repeating-linear-gradient(90deg,#2B3256 0 2px,transparent 2px 5px,#2B3256 5px 6px,transparent 6px 9px,#2B3256 9px 12px,transparent 12px 14px,#2B3256 14px 15px,transparent 15px 19px);opacity:.75}
|
||||
.previews{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
|
||||
.previews figure{margin:0;position:relative;border-radius:14px;overflow:hidden;border:3px solid #fff;aspect-ratio:1;box-shadow:-4px 10px 18px -12px rgba(255,110,140,.4),4px 10px 18px -12px rgba(70,140,255,.4)}
|
||||
.previews img{width:100%;height:100%;object-fit:cover}
|
||||
.previews .wait{display:grid;place-items:center;align-content:center;gap:6px;background:#F6F8FD;font-size:12.5px;color:var(--ink-3);border:2px dashed rgba(140,150,200,.35);box-shadow:none}
|
||||
.previews figcaption{position:absolute;left:8px;bottom:8px;height:24px;padding:0 9px;border-radius:999px;display:inline-flex;align-items:center;background:rgba(255,255,255,.92);color:var(--ink);font-size:12px;font-weight:700}
|
||||
.after{margin-top:14px;padding:14px 18px;border-radius:var(--r-sm);background:linear-gradient(90deg,rgba(255,244,214,.75),rgba(255,236,242,.65));border:1px solid rgba(255,214,140,.7);font-size:14px;line-height:1.75;color:#5A4410}
|
||||
|
||||
/* ---------- 响应式 ---------- */
|
||||
@media (max-width:980px){
|
||||
.dir{grid-template-columns:repeat(2,minmax(0,1fr))}
|
||||
.gal{grid-template-columns:1fr}
|
||||
.years{position:static;flex-direction:row;flex-wrap:wrap}
|
||||
.years b{width:100%}
|
||||
.about-grid{grid-template-columns:1fr}
|
||||
}
|
||||
@media (max-width:860px){
|
||||
.sky{grid-template-columns:1fr;min-height:0}
|
||||
.hero-copy{padding:36px 24px 8px}
|
||||
.emblem{width:210px;margin:10px auto 70px}
|
||||
.fan{left:50%;top:auto;bottom:-430px}
|
||||
.telemetry{left:24px;right:24px}
|
||||
.desk{grid-template-columns:auto 1fr}
|
||||
.desk .acts{grid-column:1/-1;justify-content:flex-start}
|
||||
.slots{grid-template-columns:repeat(3,minmax(0,1fr))}
|
||||
}
|
||||
@media (max-width:760px){
|
||||
.top-in{flex-wrap:wrap;gap:6px 12px;padding-top:10px}
|
||||
.top .desk-btn{margin-left:auto}
|
||||
.btn-pill{height:40px;font-size:14px;padding-right:14px}
|
||||
.btn-pill .ic{width:28px;height:28px;background-size:16px}
|
||||
.nav{order:3;flex-basis:100%;margin:0 -24px;padding:0 20px 8px;-webkit-mask-image:linear-gradient(90deg,#000 88%,transparent);mask-image:linear-gradient(90deg,#000 88%,transparent)}
|
||||
.room-head{grid-template-columns:1fr;gap:10px;padding-top:30px}
|
||||
.room-head .meta{text-align:left}
|
||||
.zone{font-size:64px}
|
||||
.paths{grid-template-columns:1fr}
|
||||
.pass{grid-template-columns:1fr}
|
||||
.pass .stub{border-left:0;border-top:2px dashed rgba(140,150,200,.35);border-radius:0 0 var(--r-lg) var(--r-lg)}
|
||||
.pass .stub::before{top:-13px;left:-13px}
|
||||
.pass .stub::after{top:-13px;bottom:auto;left:auto;right:-13px}
|
||||
}
|
||||
@media (max-width:620px){
|
||||
.wrap{padding:0 16px}
|
||||
.ribbon > span:last-child{display:none}
|
||||
.svc-ic{width:64px;height:64px;border-radius:20px}
|
||||
.svc-ic i{width:36px;height:36px}
|
||||
.nav{margin:0 -16px;padding:0 12px 8px}
|
||||
.dir{grid-template-columns:1fr;grid-auto-rows:auto}
|
||||
.room.big{grid-column:auto;grid-row:auto}
|
||||
.room.big .peek{flex:none;min-height:0}
|
||||
.room.big .peek img{aspect-ratio:4/3;height:auto}
|
||||
.sec{padding-top:44px}
|
||||
.sec-h h2{font-size:25px}
|
||||
.board-head{display:none}
|
||||
.board-row{grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:12px 18px}
|
||||
.board-row .kind{grid-column:1;grid-row:2;font-size:13px}
|
||||
.board-row .gate{display:none}
|
||||
.board-row .act{grid-column:2;grid-row:1/3}
|
||||
.board-title,.board-group{padding-left:18px;padding-right:18px}
|
||||
.desk{padding:22px 20px}
|
||||
.letter{padding:28px 22px}
|
||||
.disk summary{grid-template-columns:52px minmax(0,1fr);gap:14px}
|
||||
.disk .emb{width:52px;height:52px}
|
||||
.disk .kind{display:none}
|
||||
.disk .more{padding:0 18px 18px}
|
||||
.uni-tile{width:60px;height:60px;border-radius:16px}
|
||||
.foot-in{padding:22px 16px 30px}
|
||||
}
|
||||
/* ===== 整页动态背景:WebGL 流动渐变(低分辨率渲染、30fps、看不见就暂停);不支持时退回彩光色团 ===== */
|
||||
.bg-gl{position:fixed;inset:0;width:100%;height:100%;z-index:-3;pointer-events:none;display:block}
|
||||
.has-gl .orbs{display:none}
|
||||
|
||||
/* ===== 手机端:底部悬浮导航 + 更多面板(桌面隐藏) ===== */
|
||||
.tabbar,.sheet,.m-only,.order-cta{display:none}
|
||||
@media (max-width:760px){
|
||||
.d-only{display:none !important}
|
||||
.m-only{display:block}
|
||||
/* 顶栏只留 logo,导航交给底部 */
|
||||
.top-in{min-height:56px;flex-wrap:nowrap;padding-top:0}
|
||||
.top .nav,.top .desk-btn{display:none}
|
||||
body{padding-bottom:calc(92px + env(safe-area-inset-bottom))}
|
||||
body.flow{padding-bottom:calc(96px + env(safe-area-inset-bottom))}
|
||||
.tabbar{position:fixed;left:12px;right:12px;bottom:calc(10px + env(safe-area-inset-bottom));z-index:60;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;height:64px;padding:0 4px;border-radius:24px;
|
||||
background:rgba(255,255,255,.78);-webkit-backdrop-filter:blur(10px) saturate(1.4);backdrop-filter:blur(10px) saturate(1.4);border:1px solid rgba(255,255,255,.95);
|
||||
box-shadow:0 16px 34px -18px rgba(100,110,190,.55),0 2px 8px rgba(30,36,64,.06)}
|
||||
.tabbar a,.tabbar button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;height:64px;padding:0;border:0;background:none;font-family:inherit;font-size:11px;color:var(--ink-3);text-decoration:none;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:color .2s var(--ease),transform .15s var(--ease)}
|
||||
.tabbar a:active,.tabbar button:active{transform:scale(.92)}
|
||||
.tabbar svg{width:23px;height:23px}
|
||||
.tabbar [aria-current=page]{color:var(--ink);font-weight:700}
|
||||
.tabbar .mid{position:relative;top:-14px;height:auto;gap:4px;color:var(--ink);font-weight:700}
|
||||
.tabbar .mid i{width:54px;height:54px;border-radius:50%;background:#fff url('gem.webp') center/28px no-repeat;image-rendering:pixelated;
|
||||
box-shadow:0 0 0 4px rgba(255,255,255,.85),0 12px 24px -10px rgba(120,110,230,.65),0 8px 18px -12px rgba(255,140,170,.6)}
|
||||
|
||||
/* 首页首屏:钻石在上,文字居中(背景不动) */
|
||||
.sky{display:flex;flex-direction:column;align-items:center;min-height:0}
|
||||
.emblem{order:-1;width:150px;margin:30px auto 0}
|
||||
.hero-copy{padding:18px 22px 28px;align-items:center;text-align:center;gap:14px}
|
||||
.hero h1{font-size:44px}
|
||||
.hero p{font-size:15px;line-height:1.75}
|
||||
.hero .cta{width:100%;gap:10px;padding-top:4px}
|
||||
.hero .cta .btn{flex:1}
|
||||
.fan{left:64%;top:104px;width:760px;height:760px}
|
||||
.tag-l{height:28px;font-size:12px}
|
||||
|
||||
/* 金刚区:5 个入口一排 */
|
||||
.kk{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;margin-top:18px;padding:14px 6px 10px;border-radius:22px}
|
||||
.kk a{display:flex;flex-direction:column;align-items:center;gap:7px;text-decoration:none;font-size:12.5px;color:var(--ink-2);-webkit-tap-highlight-color:transparent}
|
||||
.kk a:active i{transform:scale(.92)}
|
||||
.kk i{width:48px;height:48px;border-radius:16px;display:grid;place-items:center;color:var(--ink);transition:transform .15s var(--ease);background:#EEF1FA;
|
||||
background:linear-gradient(140deg,color-mix(in srgb,var(--zc) 26%,#fff) 0%,color-mix(in srgb,var(--zc2) 22%,#fff) 100%);
|
||||
box-shadow:inset 0 1px 0 #fff,0 8px 16px -10px color-mix(in srgb,var(--zc) 70%,transparent)}
|
||||
.kk svg{width:23px;height:23px}
|
||||
|
||||
/* 首页:双列最新作品 */
|
||||
.m-sec{padding-top:30px}
|
||||
.m-sec .sec-h{margin-bottom:12px}
|
||||
.m-sec .sec-h h2{font-size:21px}
|
||||
.duo{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
|
||||
.duo a{display:block;border-radius:16px;overflow:hidden;text-decoration:none}
|
||||
.duo img{width:100%;aspect-ratio:3/4;object-fit:cover}
|
||||
.duo .cap{display:block;padding:8px 10px 10px;font-size:13px;font-weight:700}
|
||||
.duo .cap small{display:block;font-size:11.5px;font-weight:400;color:var(--ink-3);margin-top:2px}
|
||||
.desk{grid-template-columns:auto 1fr;gap:14px;padding:18px}
|
||||
.desk-ic{width:52px;height:52px;border-radius:16px}
|
||||
.desk-ic i{width:30px;height:30px}
|
||||
.desk h3{font-size:18px}
|
||||
.desk p{font-size:13.5px}
|
||||
.desk .meta{margin-top:6px;font-size:12.5px}
|
||||
.desk .acts{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;gap:10px}
|
||||
.desk .acts .btn{width:100%}
|
||||
|
||||
/* 各屋门头:编号和标题并排,紧凑 */
|
||||
.room-head{grid-template-columns:auto 1fr;gap:4px 14px;align-items:center;padding:22px 0 18px;margin-bottom:18px}
|
||||
.room-head .zone{font-size:46px !important}
|
||||
.room-head h1{font-size:28px}
|
||||
.room-head p{grid-column:1/-1;margin-top:6px;font-size:14.5px}
|
||||
.room-head .meta{display:none}
|
||||
.svc-ic{width:56px;height:56px;border-radius:18px}
|
||||
.svc-ic i{width:32px;height:32px}
|
||||
|
||||
/* 筛选条:横向滑动 + 吸顶 */
|
||||
.tools-bar{position:sticky;top:56px;z-index:20;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;margin:0 -16px 14px;padding:8px 16px;background:linear-gradient(rgba(250,251,254,.92),rgba(250,251,254,.78))}
|
||||
.tools-bar::-webkit-scrollbar{display:none}
|
||||
.tools-bar > *{flex:none}
|
||||
.seg{flex-wrap:nowrap}
|
||||
.seg button{height:34px;padding:0 13px;font-size:14px}
|
||||
|
||||
/* 画展:小红书式双列瀑布流 */
|
||||
.years{display:none}
|
||||
.wall{columns:2;column-gap:10px}
|
||||
.art{margin-bottom:10px;border-radius:14px}
|
||||
.art .cap{padding:8px 10px 10px;gap:5px}
|
||||
.art .cap b{font-size:13px}
|
||||
.art .cap span{font-size:11px}
|
||||
.type{height:20px;padding:0 7px;font-size:11px}
|
||||
.ph{font-size:12px}
|
||||
.ph svg{width:24px;height:24px}
|
||||
|
||||
/* 其它 */
|
||||
.sec{padding-top:34px}
|
||||
.sec-h h2{font-size:21px}
|
||||
.row-title{margin:4px 0 10px}
|
||||
.shelf{gap:12px;margin-bottom:22px}
|
||||
.tool{padding:18px}
|
||||
.tool h3{font-size:20px}
|
||||
.foot-site{margin-top:44px}
|
||||
.foot-in{flex-direction:column;align-items:flex-start;gap:6px;padding:20px 16px 24px;font-size:12.5px}
|
||||
.foot-in .sp{display:none}
|
||||
|
||||
/* 下单页:不显示底部导航,底部固定两个大按钮 */
|
||||
.order-cta{position:fixed;left:12px;right:12px;bottom:calc(10px + env(safe-area-inset-bottom));z-index:60;display:grid;grid-template-columns:1.3fr 1fr;gap:10px;padding:8px;border-radius:24px;
|
||||
background:rgba(255,255,255,.82);-webkit-backdrop-filter:blur(10px) saturate(1.4);backdrop-filter:blur(10px) saturate(1.4);border:1px solid rgba(255,255,255,.95);box-shadow:0 16px 34px -18px rgba(100,110,190,.55)}
|
||||
.order-cta .btn{height:50px;width:100%;font-size:15.5px}
|
||||
.tpl-grid{grid-auto-flow:column;grid-template-columns:none;grid-auto-columns:40%;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;margin:0 -16px;padding:4px 16px 12px;scroll-padding:0 16px}
|
||||
.tpl-grid::-webkit-scrollbar{display:none}
|
||||
.tpl{scroll-snap-align:start}
|
||||
}
|
||||
/* ===== MC 风格层(参考 Minecraft Ore UI):方块按钮、像素标题、物品栏格子、矿石配色 ===== */
|
||||
@font-face{font-family:'Fusion Pixel';src:url('../fonts/fusion-pixel-12.woff2') format('woff2');font-display:swap}
|
||||
:root{
|
||||
--r-xl:14px; --r-lg:10px; --r:8px; --r-sm:6px;
|
||||
--mc-green:#3C8527; --mc-green-hi:#5BAA3C; --mc-green-lo:#1D4D13;
|
||||
--stone:#F3F4F6; --stone-lo:#B4B7BE; --stone-edge:#9EA2AA;
|
||||
--pixel:'Fusion Pixel',var(--font);
|
||||
--sparks:#4FD8D2 #5CC97B #F2C14D #6F9BFF #B48CF2 #9FE6F0;
|
||||
}
|
||||
/* 像素标题:12px 字形按整数倍放大,边缘才清楚 */
|
||||
.hero h1,.room-head h1,.sec-h h2,.zone,.room h3,.room .no,.desk h3,.tool h3,.disk h3,.disk .dno,.path h3,.letter h2,.credit h3,.brand b,.tabbar span,.kk a{
|
||||
font-family:var(--pixel);font-weight:400;letter-spacing:0;-webkit-font-smoothing:none}
|
||||
.hero h1{font-size:72px;line-height:1.1}
|
||||
.room-head h1{font-size:36px;line-height:1.2}
|
||||
.sec-h h2{font-size:24px}
|
||||
.zone{font-size:96px;line-height:1;filter:none}
|
||||
.room h3,.desk h3,.tool h3,.disk h3,.path h3,.letter h2,.credit h3{font-size:24px;line-height:1.25}
|
||||
.room .no,.disk .dno{font-size:12px;letter-spacing:.06em}
|
||||
.brand b{font-size:24px}
|
||||
|
||||
/* 面板:方一点,白色玻璃框;悬停像物品栏格子一样变绿 */
|
||||
.crystal{border:2px solid rgba(255,255,255,.95);box-shadow:inset 0 0 0 1px rgba(30,36,64,.05),0 18px 36px -26px rgba(60,80,120,.38)}
|
||||
.room:hover,.tool:hover,.path:hover,.art:hover,.disk:hover,.tpl:hover{border-color:var(--mc-green-hi);box-shadow:0 0 0 2px rgba(91,170,60,.25),0 22px 40px -26px rgba(60,80,120,.42)}
|
||||
.room::before{opacity:.12}
|
||||
|
||||
/* 按钮:Ore UI 方块按钮(主按钮绿、次按钮白石;底边有厚度,按下会沉) */
|
||||
.btn{border-radius:4px;border:2px solid;height:46px;padding:0 20px 3px;font-weight:700;transition:transform .08s linear,box-shadow .08s linear,background .15s var(--ease),filter .15s var(--ease)}
|
||||
.btn:hover{transform:none}
|
||||
.btn:active{transform:translateY(2px)}
|
||||
.btn-prism{background:var(--mc-green);color:#fff;border-color:var(--mc-green-lo);
|
||||
box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -4px 0 var(--mc-green-lo),0 8px 16px -10px rgba(29,77,19,.55)}
|
||||
.btn-prism:hover{background:#469A2E;transform:none;box-shadow:inset 0 2px 0 #74C455,inset 0 -4px 0 var(--mc-green-lo),0 10px 18px -10px rgba(29,77,19,.6)}
|
||||
.btn-prism:active{box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -2px 0 var(--mc-green-lo)}
|
||||
.btn-crystal{background:var(--stone);color:var(--ink);border-color:var(--stone-edge);font-weight:700;
|
||||
box-shadow:inset 0 2px 0 #fff,inset 0 -4px 0 var(--stone-lo),0 8px 16px -12px rgba(60,70,100,.45)}
|
||||
.btn-crystal:hover{background:#fff;transform:none}
|
||||
.btn-crystal:active{box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 var(--stone-lo)}
|
||||
.btn-sm{height:40px;padding:0 14px 3px}
|
||||
.btn[disabled]{opacity:.5}
|
||||
.btn-pill{border-radius:4px;height:44px;padding:0 14px 3px 6px;color:#fff;background:var(--mc-green);border:2px solid var(--mc-green-lo);
|
||||
box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -4px 0 var(--mc-green-lo),0 8px 16px -10px rgba(29,77,19,.55)}
|
||||
.btn-pill:hover{background:#469A2E;transform:none;box-shadow:inset 0 2px 0 #74C455,inset 0 -4px 0 var(--mc-green-lo),0 10px 18px -10px rgba(29,77,19,.6)}
|
||||
.btn-pill:active{transform:translateY(2px)}
|
||||
.btn-pill .ic{width:28px;height:28px;border-radius:3px;background-color:#fff;background-size:18px;box-shadow:inset 0 -2px 0 #C9CDD4}
|
||||
.btn-pill svg{opacity:.9}
|
||||
.board-row .act{border-radius:4px;height:34px;padding:0 12px 2px;background:var(--stone);border:2px solid var(--stone-edge);box-shadow:inset 0 2px 0 #fff,inset 0 -3px 0 var(--stone-lo)}
|
||||
.board-row:hover .act{background:var(--mc-green);color:#fff;border-color:var(--mc-green-lo);box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -3px 0 var(--mc-green-lo)}
|
||||
|
||||
/* 小部件:方角 */
|
||||
.chip,.type,.tag-l,.disk .kind,.board-row .gate{border-radius:4px}
|
||||
.nav a{border-radius:4px}
|
||||
.nav a[aria-current=page]{border:0;background:#fff;box-shadow:inset 0 -3px 0 var(--mc-green),0 6px 14px -10px rgba(60,70,100,.5)}
|
||||
.nav a[aria-current=page]::after{display:none}
|
||||
.seg{border-radius:8px}
|
||||
.seg button{border-radius:4px}
|
||||
.seg button[aria-pressed=true]{color:#fff;background:var(--mc-green);box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -3px 0 var(--mc-green-lo)}
|
||||
.seg button[aria-pressed=true]::after{display:none}
|
||||
.years a{border-radius:6px}
|
||||
.years a.on{box-shadow:inset 0 -3px 0 var(--mc-green),0 10px 20px -14px rgba(60,70,100,.5)}
|
||||
.prog i.on{background:var(--mc-green)}
|
||||
.prog i.run{background:repeating-linear-gradient(90deg,#8BCB6E 0 8px,#C9E8B9 8px 16px);background-size:32px 100%}
|
||||
.desk-ic,.svc-ic,.uni-tile,.disk .emb,.path .pi{border-radius:8px}
|
||||
.peek img,.previews figure{border-radius:6px}
|
||||
.state{border-radius:4px}
|
||||
|
||||
/* 背景:像素化的流动色块(矿石色),粒子是方形的 */
|
||||
.orbs .o1{background:radial-gradient(circle,rgba(120,220,150,.6) 0%,rgba(120,220,150,0) 66%)}
|
||||
.orbs .o2{background:radial-gradient(circle,rgba(110,220,225,.6) 0%,rgba(110,220,225,0) 66%)}
|
||||
.orbs .o3{background:radial-gradient(circle,rgba(245,205,95,.55) 0%,rgba(245,205,95,0) 66%)}
|
||||
.orbs .o4{background:radial-gradient(circle,rgba(120,160,255,.55) 0%,rgba(120,160,255,0) 66%)}
|
||||
.orbs .o5{background:radial-gradient(circle,rgba(185,150,240,.5) 0%,rgba(185,150,240,0) 66%)}
|
||||
|
||||
@media (max-width:760px){
|
||||
.hero h1{font-size:48px}
|
||||
.room-head h1{font-size:24px}
|
||||
.zone{font-size:48px !important}
|
||||
.room h3,.desk h3,.tool h3,.disk h3,.path h3,.letter h2,.credit h3{font-size:24px}
|
||||
.sec-h h2,.m-sec .sec-h h2{font-size:24px}
|
||||
/* 底部导航做成 MC 快捷栏:一格一个,当前格子高亮 */
|
||||
body{padding-bottom:calc(100px + env(safe-area-inset-bottom))}
|
||||
.tabbar{border-radius:8px;height:72px;padding:6px;gap:6px;border:2px solid rgba(255,255,255,.95);background:rgba(255,255,255,.86)}
|
||||
.tabbar a,.tabbar button{height:56px;border-radius:4px;background:rgba(30,36,64,.04);box-shadow:inset 0 0 0 2px rgba(30,36,64,.08)}
|
||||
.tabbar [aria-current=page]{background:#fff;color:var(--ink);box-shadow:inset 0 0 0 3px var(--mc-green)}
|
||||
.tabbar span{font-size:12px}
|
||||
.tabbar .mid{top:0;height:56px;gap:2px;color:#fff;background:var(--mc-green);box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -4px 0 var(--mc-green-lo)}
|
||||
.tabbar .mid i{width:28px;height:28px;border-radius:3px;background-color:#fff;background-size:20px;box-shadow:inset 0 -2px 0 #C9CDD4}
|
||||
.kk{border-radius:10px}
|
||||
.kk i{border-radius:6px;box-shadow:inset 0 2px 0 rgba(255,255,255,.9),inset 0 -3px 0 rgba(30,36,64,.14)}
|
||||
.kk a{font-size:12px}
|
||||
.order-cta{border-radius:8px}
|
||||
.duo a{border-radius:8px}
|
||||
}
|
||||
/* 首屏:桌面保留「观景窗」外框,内圆角跟外框对齐;手机只留一层,不做框里套框 */
|
||||
.sky{border-radius:8px}
|
||||
.hero .window{padding:4px;border-radius:12px}
|
||||
/* 桌面:首屏和首页各段跟顶栏同宽(之前 padding 简写把 .wrap 的左右留白清掉了) */
|
||||
@media (min-width:761px){.hero,.sec.wrap{padding-left:24px;padding-right:24px}}
|
||||
@media (max-width:760px){
|
||||
.hero{padding-top:14px}
|
||||
.hero .window{padding:0;border:0;background:none;box-shadow:none}
|
||||
.hero .sky{border-radius:var(--r-lg);border:2px solid rgba(255,255,255,.95);box-shadow:inset 0 0 0 1px rgba(30,36,64,.05),0 18px 36px -26px rgba(60,80,120,.38)}
|
||||
}
|
||||
/* ===== 下单页(手机):两条路改成图标 + 标题并排 ===== */
|
||||
@media (max-width:760px){
|
||||
.paths{gap:12px}
|
||||
.path{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 12px;align-items:center;padding:16px}
|
||||
.path .pi{grid-row:1/3;width:44px;height:44px}
|
||||
.path h3{font-size:24px}
|
||||
.path p{grid-column:2;font-size:13.5px !important;line-height:1.6 !important}
|
||||
.path .hint{display:none}
|
||||
}
|
||||
.btn-pill[aria-current=page]{box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -4px 0 var(--mc-green-lo),0 0 0 3px rgba(91,170,60,.28)}
|
||||
.svc-head .svc-line{margin-top:4px;font-size:13.5px;color:var(--ink-3)}
|
||||
@media (max-width:760px){.svc-head .svc-line{grid-column:auto;margin-top:2px;font-size:12.5px}}
|
||||
/* ===== 手机「更多」:从底栏上方弹出一排格子,底栏一直在;再点一次「更多」/点空白/返回键都能收起 ===== */
|
||||
@media (max-width:760px){
|
||||
.sheet{position:fixed;inset:0;z-index:55;display:block;pointer-events:none;touch-action:none}
|
||||
.sheet::before{content:"";position:absolute;inset:0;background:rgba(30,36,64,.16);opacity:0;transition:opacity .22s var(--ease)}
|
||||
.sheet .panel{position:absolute;left:12px;right:12px;bottom:calc(90px + env(safe-area-inset-bottom));padding:6px;border-radius:8px;border:2px solid #fff;background:#fff;
|
||||
box-shadow:0 16px 34px -18px rgba(100,110,190,.55),0 2px 8px rgba(30,36,64,.06);opacity:0;transform:translateY(12px);transition:opacity .2s var(--ease),transform .22s var(--ease)}
|
||||
.sheet[hidden]{display:none !important}
|
||||
.sheet.open{pointer-events:auto}
|
||||
.sheet.open::before{opacity:1}
|
||||
.sheet.open .panel{opacity:1;transform:none}
|
||||
.more-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
|
||||
.more-grid a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;height:84px;border-radius:4px;text-decoration:none;-webkit-tap-highlight-color:transparent;
|
||||
font-size:13.5px;font-weight:700;color:var(--ink);transition:transform .12s var(--ease);
|
||||
background:#F1F4FA;background:linear-gradient(160deg,color-mix(in srgb,var(--zc) 20%,#fff),color-mix(in srgb,var(--zc2) 10%,#fff));
|
||||
box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--zc) 28%,transparent)}
|
||||
.more-grid a:active{transform:scale(.95)}
|
||||
.more-grid a[aria-current=page]{box-shadow:inset 0 0 0 3px var(--zc)}
|
||||
.more-grid i{display:grid;place-items:center;color:var(--ink)}
|
||||
.more-grid svg{width:24px;height:24px}
|
||||
.more-qq{margin:0;padding:10px 8px 4px;font-size:13px;color:var(--ink-3)}
|
||||
.tabbar button i{display:block;line-height:0}
|
||||
.tabbar .ic-b,.tabbar .lb-b,.tabbar [aria-expanded=true] .ic-a,.tabbar [aria-expanded=true] .lb-a{display:none}
|
||||
.tabbar [aria-expanded=true] .ic-b{display:block}
|
||||
.tabbar [aria-expanded=true] .lb-b{display:inline}
|
||||
.tabbar [aria-expanded=true]{background:#fff;color:var(--ink);font-weight:700;box-shadow:inset 0 0 0 3px var(--mc-green)}
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce){
|
||||
*,*::before,*::after{animation-duration:1ms!important;animation-iteration-count:1!important;transition-duration:1ms!important;scroll-behavior:auto!important}
|
||||
.flip{opacity:1}
|
||||
.orbs i{animation:none}
|
||||
.orbs,.hero-copy,.emblem{translate:none}
|
||||
.fan{animation:none}
|
||||
.js .rv{opacity:1;translate:none}
|
||||
.fx{transform:none}
|
||||
.sheet .panel,.sheet::before{transition:none}
|
||||
}
|
||||
|
||||
/* ---------- 内容后台入口:顶栏最右边一个不带字的铅笔图标 —— 淡、虚,不抢眼;hover 才稍微亮一点(店主 2026-10-05) ---------- */
|
||||
.cms-ent{flex:none;display:inline-grid;place-items:center;width:36px;height:36px;border-radius:999px;color:var(--ink);text-decoration:none;
|
||||
opacity:.32;background:transparent;border:0;transition:opacity .18s,background .18s}
|
||||
.cms-ent:hover,.cms-ent:focus-visible{opacity:.72;background:rgba(255,255,255,.55)}
|
||||
.cms-ent:focus-visible{outline:2px solid #6FA8F0;outline-offset:3px}
|
||||
.desk-btn+.cms-ent{margin-left:-8px}
|
||||
@media (max-width:760px){
|
||||
.top .cms-ent{margin-left:auto}
|
||||
}
|
||||
|
||||
/* 「都有些什么」卡片编号:跟各单页大号数字同色(--zc → --zc2 渐变) */
|
||||
.room .no{background:linear-gradient(135deg,var(--zc,var(--ink-3)) 0%,var(--zc2,var(--zc,var(--ink-3))) 100%);-webkit-background-clip:text;background-clip:text;color:transparent;justify-self:start;align-self:flex-start;font-size:18px;letter-spacing:.04em}
|
||||
|
||||
/* PC 窄窗(单列堆叠时):钻石在上、标题文字居中,跟钻石对齐 */
|
||||
@media (min-width:761px) and (max-width:860px){
|
||||
.sky{display:flex;flex-direction:column;align-items:center}
|
||||
.emblem{order:-1;width:190px;margin:36px auto 0}
|
||||
.hero-copy{padding:20px 40px 52px;align-items:center;text-align:center}
|
||||
.hero .cta{justify-content:center}
|
||||
.fan{left:64%;top:120px;bottom:auto}
|
||||
}
|
||||
|
||||
/* =====================================================================================
|
||||
以下是正式站在预览站样式之上补的部分(2026-10-06):预览里只有样子、没有真功能的地方
|
||||
===================================================================================== */
|
||||
|
||||
/* ---------- 公告 / 预览草稿提示条(复用预览站的 .ribbon) ---------- */
|
||||
.ribbon.notice,.ribbon.preview-bar{position:relative;z-index:51}
|
||||
.ribbon.preview-bar{background:linear-gradient(90deg,rgba(255,244,214,.9),rgba(255,236,242,.85));color:#5A4410}
|
||||
.ribbon.preview-bar a{color:inherit;font-weight:700}
|
||||
@media (max-width:620px){.ribbon.notice > span,.ribbon.preview-bar > span{display:inline}}
|
||||
/* 页脚:QQ 群、备案号能点 */
|
||||
.foot-in a:not(.brand){color:inherit;text-decoration:none}
|
||||
.foot-in a:not(.brand):hover{color:var(--ink);text-decoration:underline;text-underline-offset:3px}
|
||||
/* 首页服务台:渲染机离线时颜色淡一点 */
|
||||
.status.off{color:#A0662A}
|
||||
|
||||
/* ---------- 加载动画:像素钻石垒成形 → 白光扫过 → 店名逐字弹出 → 幕布收起 ---------- */
|
||||
.jz-boot{position:fixed;inset:0;z-index:200;display:grid;place-items:center;cursor:pointer;
|
||||
background:radial-gradient(40% 34% at 30% 30%,rgba(255,196,214,.35) 0%,transparent 70%),radial-gradient(42% 36% at 72% 64%,rgba(166,213,255,.38) 0%,transparent 70%),radial-gradient(36% 30% at 50% 100%,rgba(255,222,176,.32) 0%,transparent 70%),#FAFBFE;
|
||||
transition:transform .62s cubic-bezier(.7,0,.2,1),opacity .5s ease .12s}
|
||||
.jz-boot-in{display:flex;flex-direction:column;align-items:center;gap:18px}
|
||||
.jz-boot-gem{width:168px;height:168px;image-rendering:pixelated;filter:drop-shadow(-8px 16px 18px rgba(255,110,140,.28)) drop-shadow(8px 16px 18px rgba(70,140,255,.28))}
|
||||
.jz-boot-name{font:400 36px/1 var(--pixel);letter-spacing:.06em;color:var(--ink);-webkit-font-smoothing:none;display:flex;gap:2px;min-height:36px}
|
||||
.jz-boot-name span{display:inline-block;opacity:0;transform:translateY(14px) scale(.6)}
|
||||
.jz-boot.built .jz-boot-name span{animation:jzPop .42s cubic-bezier(.34,1.56,.64,1) both;animation-delay:calc(var(--i) * 70ms)}
|
||||
@keyframes jzPop{to{opacity:1;transform:none}}
|
||||
.jz-boot-bar{position:relative;display:block;width:200px;height:6px;border-radius:2px;background:rgba(30,36,64,.07);overflow:hidden;box-shadow:inset 0 0 0 1px rgba(255,255,255,.8)}
|
||||
.jz-boot-bar i{position:absolute;inset:0;background:var(--spec);transform-origin:0 50%;transform:scaleX(0);transition:transform .25s linear}
|
||||
.jz-boot.leave{transform:translateY(-100%);opacity:0;pointer-events:none}
|
||||
.jz-boot.leave .jz-boot-in{transition:transform .5s cubic-bezier(.7,0,.2,1);transform:translateY(-30px) scale(.92)}
|
||||
html.booting body{overflow:hidden}
|
||||
/* 幕布收起时,页面主体跟着轻轻浮上来 */
|
||||
html.booted main,html.booted .hero{animation:jzRise .7s cubic-bezier(.23,1,.32,1) both}
|
||||
@keyframes jzRise{from{opacity:.001;transform:translateY(18px)}to{opacity:1;transform:none}}
|
||||
|
||||
/* ---------- 画展:作品墙按列投放(预览站是 CSS 分栏,顺序会竖着走;这里改成 JS 投列,样子不变) ---------- */
|
||||
.wall{columns:auto;display:grid;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));gap:16px;align-items:start}
|
||||
.wall-col{display:flex;flex-direction:column;gap:16px;min-width:0}
|
||||
.wall-col .art{margin:0}
|
||||
.art button{position:relative}
|
||||
.art img{background:linear-gradient(165deg,#F2F4FA,#FAF9FF)}
|
||||
.art-play{position:absolute;left:50%;top:50%;width:52px;height:52px;margin:-26px 0 0 -26px;display:grid;place-items:center;border-radius:6px;color:#fff;background:rgba(30,36,64,.42);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);box-shadow:inset 0 0 0 2px rgba(255,255,255,.55);transition:transform .2s var(--ease),background .2s var(--ease)}
|
||||
.art:hover .art-play{transform:scale(1.08);background:var(--mc-green)}
|
||||
.art-play svg{margin-left:3px}
|
||||
.art-sp,.art-own{position:absolute;top:10px;height:24px;display:inline-flex;align-items:center;padding:0 8px;border-radius:4px;font-size:12px;font-weight:700;color:var(--ink);background:rgba(255,255,255,.9);box-shadow:0 4px 10px -6px rgba(30,36,64,.4)}
|
||||
.art-sp{left:10px}
|
||||
.art-own{right:10px;color:#8A5A12;background:rgba(255,246,224,.95)}
|
||||
.art .cap .art-desc{font-style:normal;font-size:13px;line-height:1.6;color:var(--ink-2)}
|
||||
.art .cap .art-meta{display:flex;flex-wrap:wrap;justify-content:flex-start;gap:6px 12px;font-size:12px}
|
||||
.art-meta em{font-style:normal;color:var(--ink-3)}
|
||||
.art-meta em.mine{color:#2E7D32}
|
||||
.art-meta a{color:var(--ink-2);font-weight:700;text-decoration:none;border-bottom:1px dotted currentColor}
|
||||
.art-meta a:hover{color:var(--ink)}
|
||||
.years a.mon{height:34px;margin-left:12px;font-size:14px}
|
||||
.years a.mon.on{box-shadow:inset 3px 0 0 var(--mc-green)}
|
||||
/* 更多筛选 */
|
||||
.g-more{display:flex;flex-direction:column;gap:10px;margin:-8px 0 22px;padding:14px 16px;border-radius:var(--r)}
|
||||
.g-more[hidden]{display:none}
|
||||
.g-more-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px}
|
||||
.g-more-row > b{min-width:4em;font-size:13px;color:var(--ink-3)}
|
||||
.g-more .seg{background:rgba(255,255,255,.55)}
|
||||
.g-more .seg button{height:34px;padding:0 12px;font-size:13.5px}
|
||||
.m-years{display:none}
|
||||
@media (max-width:760px){
|
||||
.wall{gap:10px}
|
||||
.wall-col{gap:10px}
|
||||
.m-years{display:flex}
|
||||
.art-play{width:40px;height:40px;margin:-20px 0 0 -20px}
|
||||
.art-sp,.art-own{top:6px;height:20px;font-size:11px;padding:0 6px}
|
||||
.art-sp{left:6px}.art-own{right:6px}
|
||||
.art .cap .art-desc{display:none}
|
||||
.g-more{margin:-4px 0 14px;padding:12px}
|
||||
}
|
||||
|
||||
/* ---------- 看作品:白色毛玻璃大图层(预览站 .lb 的样子,多了视频 / B 站 / 全景 / 动态壁纸) ---------- */
|
||||
.gbox{position:fixed;inset:0;z-index:100;display:flex;flex-direction:column;gap:12px;padding:18px 24px 20px;background:rgba(250,251,255,.9);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);opacity:0;transition:opacity .2s var(--ease)}
|
||||
.gbox[hidden]{display:none}
|
||||
.gbox.open{opacity:1}
|
||||
html.gbox-on{overflow:hidden}
|
||||
.gbox-bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
||||
.gbox-t{flex:1;min-width:0;display:flex;flex-direction:column}
|
||||
.gbox-t b{font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.gbox-t span{font-size:13px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.gbox-stage{position:relative;flex:1;min-height:0;display:grid;place-items:center;overflow:hidden}
|
||||
.gbox-stage > *{grid-area:1/1}
|
||||
.gbox-stage img,.gbox-vid,.gbox-stage iframe,.gbox-stage canvas{max-width:min(1400px,100%);max-height:100%;border-radius:8px;border:4px solid #fff;
|
||||
box-shadow:-10px 26px 50px -26px rgba(255,110,140,.5),10px 26px 50px -26px rgba(70,140,255,.5);background:#fff}
|
||||
/* 长图 / 宽图都整张放进窗口里(网格行高是 auto,百分比 max-height 不生效,所以按视口算:顶栏 + 底栏 + 边距约 170px) */
|
||||
.gbox-stage img{object-fit:contain;width:auto;height:auto;max-width:100%;max-height:calc(100vh - 170px);max-height:calc(100dvh - 170px)}
|
||||
.gbox-stage canvas{max-height:calc(100vh - 170px);max-height:calc(100dvh - 170px)}
|
||||
.gbox-vid{position:relative;display:flex;background:#0d1020;overflow:hidden}
|
||||
.gbox-vid[hidden]{display:none}
|
||||
.gbox-vid video{display:block;max-width:100%;max-height:calc(100vh - 170px)}
|
||||
.gbox .v-wm{position:absolute;right:12px;bottom:46px;padding:3px 8px;border-radius:4px;font-size:12px;font-weight:700;color:rgba(255,255,255,.82);background:rgba(0,0,0,.28);pointer-events:none}
|
||||
.gbox-stage iframe{width:min(1100px,100%);aspect-ratio:16/9;height:auto;background:#000}
|
||||
.gbox-stage canvas{width:min(1200px,100%);aspect-ratio:2/1;height:auto;cursor:grab;touch-action:none}
|
||||
.gbox-stage canvas:active{cursor:grabbing}
|
||||
#gbWall{cursor:ew-resize;touch-action:pan-y;user-select:none}
|
||||
.gbox-load{padding:10px 16px;border-radius:6px;background:#fff;font-size:14px;color:var(--ink-2);box-shadow:0 10px 24px -14px rgba(60,80,120,.5)}
|
||||
.gbox-load[hidden]{display:none}
|
||||
.gbox-foot{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:10px 18px;min-height:20px}
|
||||
.gbox-hint{font-size:13px;color:var(--ink-3)}
|
||||
.gbox-wallbar{display:flex;align-items:center;gap:12px;width:min(640px,100%)}
|
||||
.gbox-wallbar[hidden]{display:none}
|
||||
.gbox-wallbar input{flex:1;accent-color:var(--mc-green)}
|
||||
.gbox-wallbar span{font-size:13px;color:var(--ink-2);white-space:nowrap}
|
||||
.g-links{display:flex;flex-wrap:wrap;gap:8px}
|
||||
@media (max-width:760px){
|
||||
.gbox{padding:12px 10px calc(14px + env(safe-area-inset-bottom))}
|
||||
.gbox-bar .btn{height:36px;padding:0 10px 2px;font-size:13px}
|
||||
.gbox-stage img,.gbox-vid,.gbox-stage iframe,.gbox-stage canvas{border-width:2px}
|
||||
.gbox-stage img{max-height:calc(100vh - 150px);max-height:calc(100dvh - 150px)}
|
||||
.gbox-stage canvas{aspect-ratio:4/5}
|
||||
}
|
||||
|
||||
/* ---------- 工具卡:按钮里的小箭头 ---------- */
|
||||
.tool .acts .btn svg{margin-left:2px}
|
||||
.about-grid .letter p + p{margin-top:14px}
|
||||
.credit p + p{margin-top:6px}
|
||||
.credit a,.letter a{color:var(--ink);font-weight:700;text-decoration:underline;text-decoration-color:rgba(60,133,39,.5);text-underline-offset:3px}
|
||||
/* hidden 属性永远说了算(.btn / .seg 等自带 display 的不能把它顶掉) */
|
||||
[hidden]{display:none !important}
|
||||
|
||||
|
||||
/* =====================================================================================
|
||||
手机深色模式(2026-10-06):系统设成深色时,手机上整站换成「夜里的同一家店」——
|
||||
还是那套晶体面板 / MC 方块按钮 / 光谱藏色,只是底换成深蓝黑、面板换成深色玻璃、字换成浅色。
|
||||
只在手机宽度生效(店主要求);要让电脑也跟随,把下面的 (max-width:760px) and 去掉即可。
|
||||
流动背景的深色版在 site.js 的着色器里(uDark)。
|
||||
===================================================================================== */
|
||||
@media (max-width:760px) and (prefers-color-scheme:dark){
|
||||
:root{color-scheme:dark;
|
||||
--ink:#E9ECF7; --ink-2:#B8BED8; --ink-3:#8A91AE; --bg:#0D1020;
|
||||
--line:rgba(255,255,255,.08); --line-2:rgba(255,255,255,.14);
|
||||
--stone:#2A3046; --stone-lo:#161A2A; --stone-edge:#3D4462;
|
||||
--lift-hi:0 0 0 1px rgba(255,255,255,.06),0 22px 40px -24px rgba(0,0,0,.7);
|
||||
--dk-glass:linear-gradient(160deg,rgba(34,39,62,.86) 0%,rgba(24,28,46,.74) 100%);
|
||||
--dk-edge:rgba(255,255,255,.09);
|
||||
}
|
||||
body,body.uni{background:radial-gradient(40% 30% at 10% 0%,rgba(80,120,220,.22) 0%,transparent 70%),radial-gradient(36% 28% at 100% 10%,rgba(200,90,150,.16) 0%,transparent 70%),radial-gradient(44% 34% at 70% 100%,rgba(60,160,120,.14) 0%,transparent 70%),var(--bg)}
|
||||
::selection{background:rgba(91,170,60,.45);color:#fff}
|
||||
/* 面板:深色玻璃 */
|
||||
.crystal,body .ucell{border-color:var(--dk-edge) !important;background:var(--dk-glass);box-shadow:inset 0 1px 0 rgba(255,255,255,.05),0 18px 36px -24px rgba(0,0,0,.75)}
|
||||
.room::before{opacity:.2}
|
||||
/* 顶栏 / 底栏 / 更多面板 */
|
||||
.top{background:rgba(13,16,32,.72);box-shadow:inset 0 -1px 0 rgba(255,255,255,.06)}
|
||||
.top::after{background:rgba(255,255,255,.05)}
|
||||
.cms-ent{color:var(--ink);opacity:.4}
|
||||
.tabbar{background:rgba(20,24,42,.88);border-color:rgba(255,255,255,.08);box-shadow:0 16px 34px -14px rgba(0,0,0,.8)}
|
||||
.tabbar a,.tabbar button{background:rgba(255,255,255,.04);box-shadow:inset 0 0 0 2px rgba(255,255,255,.06);color:var(--ink-3)}
|
||||
.tabbar [aria-current=page],.tabbar [aria-expanded=true]{background:#1C2136;color:var(--ink)}
|
||||
.tabbar .mid i,.btn-pill .ic{background-color:#F3F5FA}
|
||||
.sheet::before{background:rgba(0,0,0,.45)}
|
||||
.sheet .panel{background:#161A2C;border-color:#232842}
|
||||
.more-grid a{color:var(--ink);background:linear-gradient(160deg,color-mix(in srgb,var(--zc) 22%,#161A2C),color-mix(in srgb,var(--zc2) 12%,#161A2C));box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--zc) 40%,transparent)}
|
||||
.more-grid i{color:var(--ink)}
|
||||
/* 首屏 */
|
||||
.sky{background:radial-gradient(60% 70% at 12% 18%,rgba(255,120,160,.16) 0%,transparent 70%),radial-gradient(55% 65% at 88% 26%,rgba(90,140,255,.22) 0%,transparent 70%),radial-gradient(50% 60% at 55% 105%,rgba(255,190,110,.12) 0%,transparent 70%),linear-gradient(165deg,#181C31 0%,#12152A 100%) !important}
|
||||
.hero .sky{border-color:var(--dk-edge) !important}
|
||||
.beam{background:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(180,200,255,.18) 70%,rgba(180,200,255,.05) 100%)}
|
||||
.fan{opacity:.55}
|
||||
.emblem .halo{background:radial-gradient(circle,rgba(160,190,255,.28) 0%,rgba(120,150,255,.12) 40%,rgba(0,0,0,0) 70%)}
|
||||
.tag-l,.chip,.type{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.1);color:var(--ink-2)}
|
||||
.type{background:linear-gradient(#1C2136,#1C2136) padding-box,var(--edge) border-box}
|
||||
.kk i{color:var(--ink);background:linear-gradient(140deg,color-mix(in srgb,var(--zc) 30%,#1A1F35) 0%,color-mix(in srgb,var(--zc2) 22%,#1A1F35) 100%);box-shadow:inset 0 2px 0 rgba(255,255,255,.08),inset 0 -3px 0 rgba(0,0,0,.3)}
|
||||
.kk a{color:var(--ink-2)}
|
||||
/* 按钮:白石头换深石头(绿按钮不变) */
|
||||
.btn-crystal{background:var(--stone);color:var(--ink);border-color:var(--stone-edge);box-shadow:inset 0 2px 0 rgba(255,255,255,.08),inset 0 -4px 0 var(--stone-lo),0 8px 16px -10px rgba(0,0,0,.6)}
|
||||
.btn-crystal:hover{background:#323953}
|
||||
.board-row .act{background:var(--stone);border-color:var(--stone-edge);color:var(--ink);box-shadow:inset 0 2px 0 rgba(255,255,255,.08),inset 0 -3px 0 var(--stone-lo)}
|
||||
.board-group{background:linear-gradient(90deg,rgba(255,110,150,.08),rgba(90,150,255,.08));color:var(--ink-3)}
|
||||
.board-row:hover{background:rgba(255,255,255,.03)}
|
||||
.desk-ic,.svc-ic,.uni-tile,.disk .emb,.path .pi{background:linear-gradient(160deg,#20253D,#181C30) padding-box,var(--edge-strong) border-box}
|
||||
/* 筛选条 / 年份 / 更多筛选 */
|
||||
.tools-bar{background:linear-gradient(rgba(13,16,32,.94),rgba(13,16,32,.8))}
|
||||
.g-more .seg{background:rgba(255,255,255,.04)}
|
||||
.seg button{color:var(--ink-2)}
|
||||
/* 画展卡片 / 占位 */
|
||||
.art img{background:linear-gradient(165deg,#1A1E33,#151829)}
|
||||
.ph{background:linear-gradient(165deg,#1A1E33,#161A2C);color:var(--ink-3)}
|
||||
.ph::before{border-color:rgba(160,170,220,.22)}
|
||||
.art-sp,.art-own{background:rgba(16,19,34,.85);color:var(--ink)}
|
||||
.art-own{color:#F2C97A}
|
||||
.art-meta em.mine{color:#7BD45A}
|
||||
/* 关于 / 工具 */
|
||||
.credit code{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.1)}
|
||||
.credit a,.letter a{color:var(--ink)}
|
||||
.kv{border-color:rgba(255,255,255,.08)}
|
||||
.row-title::after,.room-head::after{opacity:.5}
|
||||
/* 看作品 */
|
||||
.gbox{background:rgba(8,10,20,.92)}
|
||||
.gbox-stage img,.gbox-vid,.gbox-stage iframe,.gbox-stage canvas{border-color:#262B44;background:#111426;box-shadow:0 26px 50px -26px rgba(0,0,0,.9)}
|
||||
.gbox-load{background:#1C2136;color:var(--ink-2)}
|
||||
/* 页脚 / 提示条 */
|
||||
.foot-site{background:rgba(255,255,255,.03)}
|
||||
.foot-site::before{background:rgba(255,255,255,.06)}
|
||||
.ribbon{background:rgba(255,255,255,.04);border-color:rgba(255,255,255,.06);color:var(--ink-2)}
|
||||
.ribbon.preview-bar{background:linear-gradient(90deg,rgba(120,90,20,.45),rgba(120,40,70,.4));color:#FFE3A6}
|
||||
.status.off{color:#E3A85A}
|
||||
/* 加载动画的幕布 */
|
||||
.jz-boot{background:radial-gradient(40% 34% at 30% 30%,rgba(255,110,150,.16) 0%,transparent 70%),radial-gradient(42% 36% at 72% 64%,rgba(90,140,255,.2) 0%,transparent 70%),#0D1020}
|
||||
.jz-boot-bar{background:rgba(255,255,255,.08);box-shadow:inset 0 0 0 1px rgba(255,255,255,.06)}
|
||||
/* 金钻宇宙页:星图窗框、档案卡、空槽、开场星门 */
|
||||
body .skywin{background:rgba(30,34,56,.8);border-color:#262B44}
|
||||
body .skywin .panel .card{background:rgba(22,26,44,.97);border-color:#2A3050;color:var(--ink)}
|
||||
body .skywin .panel .card .tags span{background:rgba(255,255,255,.07)}
|
||||
body .uslots button{background:rgba(255,255,255,.04);border-color:rgba(160,170,220,.25);color:var(--ink-3)}
|
||||
body .ugate{background:radial-gradient(46% 52% at 50% 46%,rgba(26,30,52,.97) 0%,rgba(16,19,36,.95) 55%,rgba(10,12,26,.94) 100%)}
|
||||
body .ugate-slots i{background:rgba(255,255,255,.05);border-color:rgba(160,170,220,.3)}
|
||||
body .ugate-slots i.l{background:#20253D;box-shadow:inset 0 0 0 2px rgba(255,255,255,.06)}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
/* 金钻客栈 · 全站交互(设计预览站原版,2026-10-06 搬进仓库):流动背景、手机「更多」、视差、卡片倾斜、滚动浮现、星尘、翻牌 */
|
||||
(function () {
|
||||
'use strict';
|
||||
var reduce = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
var finePointer = window.matchMedia && matchMedia('(hover: hover) and (pointer: fine)').matches;
|
||||
document.documentElement.classList.add('js');
|
||||
|
||||
/* ---------- 整页动态背景:WebGL 流动渐变(低分辨率、30fps、标签页不可见时浏览器自动暂停) ---------- */
|
||||
var mouseX = 0, mouseY = 0;
|
||||
(function glBackground() {
|
||||
var c = document.createElement('canvas');
|
||||
c.className = 'bg-gl'; c.setAttribute('aria-hidden', 'true');
|
||||
var gl = null;
|
||||
try { gl = c.getContext('webgl', { antialias: false, alpha: false, depth: false, stencil: false, powerPreference: 'low-power' }); } catch (e) {}
|
||||
if (!gl) return;
|
||||
var VS = 'attribute vec2 p;void main(){gl_Position=vec4(p,0.0,1.0);}';
|
||||
var FS = [
|
||||
'precision mediump float;uniform vec2 uRes;uniform float uTime;uniform vec2 uMouse;uniform float uUni;uniform float uDark;',
|
||||
'vec3 m289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 m289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}',
|
||||
'vec4 perm(vec4 x){return m289(((x*34.0)+1.0)*x);}vec4 tis(vec4 r){return 1.79284291400159-0.85373472095314*r;}',
|
||||
'float sn(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);',
|
||||
'vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;',
|
||||
'vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;',
|
||||
'i=m289(i);vec4 p=perm(perm(perm(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));',
|
||||
'float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);',
|
||||
'vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);',
|
||||
'vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;',
|
||||
'vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);',
|
||||
'vec4 nm=tis(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=nm.x;p1*=nm.y;p2*=nm.z;p3*=nm.w;',
|
||||
'vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;',
|
||||
'return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}',
|
||||
'void main(){vec2 uv=gl_FragCoord.xy/uRes;vec2 q=vec2(uv.x*uRes.x/uRes.y,uv.y)*1.25+uMouse*0.09;float t=uTime*0.085;',
|
||||
'float n1=sn(vec3(q*0.85,t));float n2=sn(vec3(q*1.4+vec2(3.1,1.7),t*1.25));float n3=sn(vec3(q*0.6-vec2(5.2,2.3),t*0.8));float n4=sn(vec3(q*1.1+vec2(-2.7,4.4),t*1.1));',
|
||||
'vec3 pink=vec3(0.55,0.90,0.90);vec3 blue=vec3(0.58,0.72,1.0);vec3 mint=vec3(0.56,0.88,0.64);vec3 peach=vec3(1.0,0.86,0.48);vec3 lav=vec3(0.76,0.66,0.98);',
|
||||
'vec3 col=mix(pink,blue,smoothstep(-0.55,0.55,n1));col=mix(col,mint,smoothstep(0.05,0.85,n2)*0.85);',
|
||||
'col=mix(col,peach,smoothstep(0.15,0.9,n3)*0.75);col=mix(col,lav,smoothstep(0.2,0.95,n4)*0.7);col=mix(col,lav,0.28*uUni);',
|
||||
'float w=0.74+0.14*sn(vec3(q*0.45,t*0.6));vec3 lite=mix(col,vec3(0.975,0.98,0.985),clamp(w,0.6,0.9));',
|
||||
/* 手机深色模式:同一团流动的彩光,压暗后往深蓝黑里混(uDark 0 → 1) */
|
||||
'vec3 dark=mix(col*0.34,vec3(0.05,0.06,0.12),clamp(w,0.6,0.9)*0.9);gl_FragColor=vec4(mix(lite,dark,uDark),1.0);}'
|
||||
].join('');
|
||||
function sh(type, src) { var o = gl.createShader(type); gl.shaderSource(o, src); gl.compileShader(o); return gl.getShaderParameter(o, gl.COMPILE_STATUS) ? o : null; }
|
||||
var v = sh(gl.VERTEX_SHADER, VS), f = sh(gl.FRAGMENT_SHADER, FS);
|
||||
if (!v || !f) return;
|
||||
var prog = gl.createProgram(); gl.attachShader(prog, v); gl.attachShader(prog, f); gl.linkProgram(prog);
|
||||
if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) return;
|
||||
gl.useProgram(prog);
|
||||
var buf = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
|
||||
var loc = gl.getAttribLocation(prog, 'p'); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
|
||||
var uRes = gl.getUniformLocation(prog, 'uRes'), uTime = gl.getUniformLocation(prog, 'uTime'),
|
||||
uMouse = gl.getUniformLocation(prog, 'uMouse'), uUni = gl.getUniformLocation(prog, 'uUni'), uDark = gl.getUniformLocation(prog, 'uDark');
|
||||
/* 深色模式:只在手机宽度跟系统走(和 site.css 里那段一致);切换时实时换 */
|
||||
var mqDark = window.matchMedia ? matchMedia('(max-width: 760px) and (prefers-color-scheme: dark)') : null;
|
||||
function setDark() { gl.uniform1f(uDark, mqDark && mqDark.matches ? 1 : 0); }
|
||||
setDark();
|
||||
if (mqDark) { var onDark = function () { setDark(); draw(performance.now()); }; if (mqDark.addEventListener) mqDark.addEventListener('change', onDark); else if (mqDark.addListener) mqDark.addListener(onDark); }
|
||||
gl.uniform1f(uUni, document.body.classList.contains('uni') ? 1 : 0);
|
||||
document.body.insertBefore(c, document.body.firstChild);
|
||||
document.documentElement.classList.add('has-gl');
|
||||
var scale = window.innerWidth < 760 ? 0.25 : 0.18, t0 = performance.now(), last = 0;
|
||||
function resize() {
|
||||
var w = Math.max(16, Math.round(window.innerWidth * scale)), h = Math.max(16, Math.round(window.innerHeight * scale));
|
||||
c.width = w; c.height = h; gl.viewport(0, 0, w, h); gl.uniform2f(uRes, w, h); draw(performance.now());
|
||||
}
|
||||
function draw(now) {
|
||||
gl.uniform1f(uTime, (now - t0) / 1000 + 20);
|
||||
gl.uniform2f(uMouse, mouseX, -mouseY);
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
||||
}
|
||||
function loop(now) { requestAnimationFrame(loop); if (now - last < 33) return; last = now; draw(now); }
|
||||
resize();
|
||||
window.addEventListener('resize', function () { clearTimeout(c._rt); c._rt = setTimeout(resize, 150); });
|
||||
if (!reduce) requestAnimationFrame(loop);
|
||||
})();
|
||||
|
||||
/* ---------- 手机:「更多」——底栏按钮开/关,底栏保持可点;返回键、点空白、Esc 都能收起 ---------- */
|
||||
(function sheet() {
|
||||
var sh = document.getElementById('more'), btn = document.querySelector('[data-sheet="more"]'), bar = btn && btn.parentNode, pushed = false, timer;
|
||||
if (!sh || !btn) return;
|
||||
function isOpen() { return btn.getAttribute('aria-expanded') === 'true'; }
|
||||
function open(kb) {
|
||||
clearTimeout(timer); sh.hidden = false; btn.setAttribute('aria-expanded', 'true');
|
||||
requestAnimationFrame(function () { requestAnimationFrame(function () { sh.classList.add('open'); }); });
|
||||
if (kb) { var a = sh.querySelector('a'); if (a) a.focus(); }
|
||||
try { history.pushState({ jzMore: 1 }, ''); pushed = true; } catch (e) {}
|
||||
}
|
||||
function close(fromPop) {
|
||||
if (!isOpen()) return;
|
||||
sh.classList.remove('open'); btn.setAttribute('aria-expanded', 'false');
|
||||
timer = setTimeout(function () { sh.hidden = true; }, reduce ? 0 : 240);
|
||||
if (pushed) { pushed = false; if (!fromPop) history.back(); }
|
||||
}
|
||||
btn.addEventListener('click', function (e) { if (isOpen()) close(); else open(e.detail === 0); });
|
||||
sh.addEventListener('click', function (e) { if (e.target === sh) close(); });
|
||||
window.addEventListener('popstate', function () { if (pushed) { pushed = false; close(true); } });
|
||||
document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && isOpen()) { close(); btn.focus(); } });
|
||||
/* 开着面板时点链接跳走:替换掉多出来的那条历史,免得返回时要按两次 */
|
||||
document.addEventListener('click', function (e) {
|
||||
if (!pushed || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
||||
var a = e.target.closest('a[href]');
|
||||
if (!a || a.target === '_blank' || !(sh.contains(a) || bar.contains(a))) return;
|
||||
e.preventDefault(); location.replace(a.href);
|
||||
});
|
||||
window.addEventListener('pageshow', function (e) {
|
||||
if (e.persisted && isOpen()) { pushed = false; sh.classList.remove('open'); sh.hidden = true; btn.setAttribute('aria-expanded', 'false'); }
|
||||
});
|
||||
})();
|
||||
|
||||
/* ---------- 鼠标视差:背景彩光、首屏钻石跟着鼠标轻轻错位(只改 CSS 变量,GPU 合成) ---------- */
|
||||
if (!reduce && finePointer) {
|
||||
var tx = 0, ty = 0, cx = 0, cy = 0, pr = 0, docEl = document.documentElement;
|
||||
window.addEventListener('pointermove', function (e) {
|
||||
tx = (e.clientX / window.innerWidth) * 2 - 1;
|
||||
ty = (e.clientY / window.innerHeight) * 2 - 1;
|
||||
mouseX = tx; mouseY = ty;
|
||||
if (!pr) pr = requestAnimationFrame(follow);
|
||||
}, { passive: true });
|
||||
function follow() {
|
||||
cx += (tx - cx) * 0.08; cy += (ty - cy) * 0.08;
|
||||
docEl.style.setProperty('--mx', cx.toFixed(4));
|
||||
docEl.style.setProperty('--my', cy.toFixed(4));
|
||||
pr = (Math.abs(tx - cx) > 0.001 || Math.abs(ty - cy) > 0.001) ? requestAnimationFrame(follow) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 卡片:随鼠标轻微倾斜 + 玻璃上跟着鼠标的柔光 ---------- */
|
||||
if (!reduce && finePointer) {
|
||||
Array.prototype.forEach.call(document.querySelectorAll('.room, .tool, .path, .tpl, .art'), function (el) {
|
||||
el.classList.add('fx');
|
||||
var raf = 0, lx = 0, ly = 0;
|
||||
el.addEventListener('pointermove', function (e) {
|
||||
var r = el.getBoundingClientRect();
|
||||
lx = (e.clientX - r.left) / r.width; ly = (e.clientY - r.top) / r.height;
|
||||
if (raf) return;
|
||||
raf = requestAnimationFrame(function () {
|
||||
raf = 0;
|
||||
var max = el.classList.contains('big') ? 3 : 5;
|
||||
el.style.setProperty('--px', (lx * 100).toFixed(1) + '%');
|
||||
el.style.setProperty('--py', (ly * 100).toFixed(1) + '%');
|
||||
el.style.setProperty('--ry', ((lx - 0.5) * max * 2).toFixed(2) + 'deg');
|
||||
el.style.setProperty('--rx', ((0.5 - ly) * max * 2).toFixed(2) + 'deg');
|
||||
});
|
||||
});
|
||||
el.addEventListener('pointerenter', function () { el.classList.add('on'); });
|
||||
el.addEventListener('pointerleave', function () {
|
||||
el.classList.remove('on');
|
||||
el.style.setProperty('--rx', '0deg'); el.style.setProperty('--ry', '0deg');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- 滚动时内容依次浮现 ---------- */
|
||||
if (!reduce && 'IntersectionObserver' in window) {
|
||||
var targets = document.querySelectorAll('.sec-h, .room, .desk, .board, .tool, .row-title, .disk, .uni-intro, .slots, .letter, .credit, .path, .pickup, .tpl, .pass, .art, .tools-bar');
|
||||
var groups = new Map();
|
||||
Array.prototype.forEach.call(targets, function (el) {
|
||||
var k = el.parentNode, n = groups.get(k) || 0; groups.set(k, n + 1);
|
||||
el.style.setProperty('--d', Math.min(n, 6) * 70 + 'ms');
|
||||
el.classList.add('rv');
|
||||
});
|
||||
var rio = new IntersectionObserver(function (es) {
|
||||
es.forEach(function (e) { if (e.isIntersecting) { e.target.classList.add('in'); rio.unobserve(e.target); } });
|
||||
}, { threshold: 0.08, rootMargin: '0px 0px -6% 0px' });
|
||||
Array.prototype.forEach.call(targets, function (el) { rio.observe(el); });
|
||||
}
|
||||
|
||||
/* ---------- 配色切换(记在本机浏览器里;也可用 ?theme=dawn 直接打开某套) ---------- */
|
||||
var root = document.documentElement;
|
||||
var listeners = [];
|
||||
function sparkPalette() {
|
||||
var v = getComputedStyle(root).getPropertyValue('--sparks').trim();
|
||||
return v ? v.split(/\s+/) : ['#FFFFFF'];
|
||||
}
|
||||
function markTheme() {
|
||||
var cur = root.getAttribute('data-theme') || 'navy';
|
||||
Array.prototype.forEach.call(document.querySelectorAll('[data-theme-btn]'), function (b) {
|
||||
b.setAttribute('aria-pressed', b.getAttribute('data-theme-btn') === cur ? 'true' : 'false');
|
||||
});
|
||||
}
|
||||
document.addEventListener('click', function (e) {
|
||||
var b = e.target.closest('[data-theme-btn]'); if (!b) return;
|
||||
var t = b.getAttribute('data-theme-btn');
|
||||
root.setAttribute('data-theme', t);
|
||||
try { localStorage.setItem('jz-theme', t); } catch (err) {}
|
||||
markTheme();
|
||||
listeners.forEach(function (fn) { fn(); });
|
||||
});
|
||||
markTheme();
|
||||
|
||||
/* ---------- 星尘:观景窗 / 宇宙背景里缓慢漂浮的光点 ---------- */
|
||||
function stars(canvas) {
|
||||
var ctx = canvas.getContext('2d');
|
||||
var dpr = Math.min(window.devicePixelRatio || 1, 2);
|
||||
var w = 0, h = 0, pts = [], raf = 0, visible = true;
|
||||
var density = +canvas.getAttribute('data-density') || 1;
|
||||
var PAL = sparkPalette();
|
||||
listeners.push(function () { PAL = sparkPalette(); pts.forEach(function (p) { p.c = PAL[(Math.random() * PAL.length) | 0]; }); draw(performance.now()); });
|
||||
function resize() {
|
||||
var r = canvas.getBoundingClientRect();
|
||||
w = r.width; h = r.height;
|
||||
canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr);
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
var n = Math.round((w * h) / 5200 * density * (w < 600 ? 0.6 : 1));
|
||||
pts = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
pts.push({
|
||||
x: Math.random() * w, y: Math.random() * h,
|
||||
r: Math.random() < 0.85 ? Math.random() * 1.3 + 0.5 : Math.random() * 2 + 1.6,
|
||||
c: PAL[(Math.random() * PAL.length) | 0],
|
||||
a: Math.random() * 0.6 + 0.25,
|
||||
vx: (Math.random() - 0.5) * 0.12, vy: -(Math.random() * 0.16 + 0.03),
|
||||
tw: Math.random() * Math.PI * 2
|
||||
});
|
||||
}
|
||||
draw(0);
|
||||
}
|
||||
function draw(t) {
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
for (var i = 0; i < pts.length; i++) {
|
||||
var p = pts[i];
|
||||
if (!reduce) {
|
||||
p.x += p.vx; p.y += p.vy;
|
||||
if (p.y < -4) { p.y = h + 4; p.x = Math.random() * w; }
|
||||
if (p.x < -4) p.x = w + 4; else if (p.x > w + 4) p.x = -4;
|
||||
}
|
||||
var a = reduce ? p.a : p.a * (0.65 + 0.35 * Math.sin(t / 900 + p.tw));
|
||||
ctx.globalAlpha = a;
|
||||
ctx.fillStyle = p.c;
|
||||
var sz = p.r > 1.9 ? 4 : (p.r > 1.1 ? 3 : 2);
|
||||
ctx.fillRect(Math.round(p.x), Math.round(p.y), sz, sz);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
function loop(t) { raf = requestAnimationFrame(loop); if (visible) draw(t); }
|
||||
resize();
|
||||
window.addEventListener('resize', function () { clearTimeout(canvas._rt); canvas._rt = setTimeout(resize, 150); });
|
||||
if ('IntersectionObserver' in window) {
|
||||
new IntersectionObserver(function (es) { visible = es[0].isIntersecting; }).observe(canvas);
|
||||
}
|
||||
if (!reduce) raf = requestAnimationFrame(loop);
|
||||
}
|
||||
Array.prototype.forEach.call(document.querySelectorAll('canvas.stars'), stars);
|
||||
|
||||
/* ---------- 出发屏:进入视口时逐行翻牌 ---------- */
|
||||
var rows = document.querySelectorAll('.flip');
|
||||
function flipIn(list) {
|
||||
Array.prototype.forEach.call(list, function (el, i) {
|
||||
el.style.animationDelay = (i * 70) + 'ms';
|
||||
el.classList.add('in');
|
||||
});
|
||||
}
|
||||
if (rows.length) {
|
||||
if (reduce || !('IntersectionObserver' in window)) { flipIn(rows); }
|
||||
else {
|
||||
var boards = document.querySelectorAll('.board');
|
||||
var io = new IntersectionObserver(function (es) {
|
||||
es.forEach(function (e) {
|
||||
if (e.isIntersecting) { flipIn(e.target.querySelectorAll('.flip')); io.unobserve(e.target); }
|
||||
});
|
||||
}, { threshold: 0.15 });
|
||||
Array.prototype.forEach.call(boards, function (b) { io.observe(b); });
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 画展:类型筛选 ---------- */
|
||||
var seg = document.querySelector('[data-filter-group]');
|
||||
if (seg) {
|
||||
seg.addEventListener('click', function (e) {
|
||||
var b = e.target.closest('button[data-f]'); if (!b) return;
|
||||
Array.prototype.forEach.call(seg.querySelectorAll('button'), function (x) { x.setAttribute('aria-pressed', x === b ? 'true' : 'false'); });
|
||||
var f = b.getAttribute('data-f');
|
||||
Array.prototype.forEach.call(document.querySelectorAll('.wall .art'), function (a) {
|
||||
a.hidden = !(f === 'all' || a.getAttribute('data-type') === f);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- 画展:看大图(切到深色,突出作品) ---------- */
|
||||
var lb = document.querySelector('.lb');
|
||||
if (lb) {
|
||||
var img = lb.querySelector('img'), cap = lb.querySelector('.lb-cap'), closeBtn = lb.querySelector('button');
|
||||
var last = null;
|
||||
document.addEventListener('click', function (e) {
|
||||
var t = e.target.closest('[data-full]'); if (!t) return;
|
||||
last = t;
|
||||
img.src = t.getAttribute('data-full'); img.alt = t.getAttribute('data-title') || '';
|
||||
cap.textContent = t.getAttribute('data-title') || '';
|
||||
lb.classList.add('open'); closeBtn.focus();
|
||||
});
|
||||
function close() { lb.classList.remove('open'); img.removeAttribute('src'); if (last) last.focus(); }
|
||||
closeBtn.addEventListener('click', close);
|
||||
lb.addEventListener('click', function (e) { if (e.target === lb) close(); });
|
||||
document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && lb.classList.contains('open')) close(); });
|
||||
}
|
||||
|
||||
/* ---------- 手机:当前屋子滚进导航可视区 ---------- */
|
||||
var cur = document.querySelector('.nav a[aria-current=page]');
|
||||
if (cur && cur.scrollIntoView) { try { cur.scrollIntoView({ block: 'nearest', inline: 'center' }); } catch (e) {} }
|
||||
})();
|
||||
@@ -61,7 +61,20 @@ window.JZ_UNIVERSE = {
|
||||
nebula: [['#2F4BD8', '#4FB8E8'], ['#4A35B8', '#7C6BFF'], ['#1C7A8C', '#4FD1C5'], ['#5B3FB8', '#9B8BFF']],
|
||||
coreNebula: ['#FFC97A', '#B98CFF'], line: '#7F8BC8', ui: '#FFD36E',
|
||||
},
|
||||
firstSlot: 5, // 空槽从几号开始按编号排到外圈固定槽位(排布规则见 layout.js)
|
||||
intro: 'random', // 开场运镜:sweep 盘旋落下 / dive 垂直坠入 / random 每次随机
|
||||
sectors: ['S-01 · 晨线', 'S-02 · 冰原', 'S-03 · 霓虹', 'S-04 · 衡天', 'S-05 · 未测绘', 'S-06 · 未测绘'],
|
||||
},
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 内容后台发布的世界线(2026-10-05):门户先加载 content/site.js(window.JZ_CONTENT),
|
||||
* 里面有 universe.UNIVERSES / LOOKS 就用它的 —— 上面写死的两份只是兜底(内容文件读不到时用)。
|
||||
* 星系整体(GALAXY)和空槽外观(EMPTY_LOOK)不归后台管,还是改这个文件。
|
||||
* --------------------------------------------------------------------------- */
|
||||
(function () {
|
||||
var C = window.JZ_CONTENT && window.JZ_CONTENT.universe, U = window.JZ_UNIVERSE;
|
||||
if (!C || !U) return;
|
||||
if (Array.isArray(C.UNIVERSES)) U.UNIVERSES = C.UNIVERSES; // 后台把世界线删光了也照实显示(不退回兜底)
|
||||
if (C.LOOKS && typeof C.LOOKS === 'object') U.LOOKS = C.LOOKS;
|
||||
})();
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* 返回 { fly(no), home(), resize() }。画面滚出视口时自动暂停渲染。
|
||||
* ============================================================================= */
|
||||
import * as THREE from 'three';
|
||||
import { makePlanet } from './planets.js?v=1';
|
||||
import { makePlanet } from './planets.js?v=2';
|
||||
import { layoutSystems } from './layout.js?v=3';
|
||||
|
||||
export function mountGalaxy(el) {
|
||||
const CFG = window.JZ_UNIVERSE, G = CFG.GALAXY, C = G.colors;
|
||||
@@ -29,6 +30,8 @@ export function mountGalaxy(el) {
|
||||
const rnd = (a = 0, b = 1) => a + Math.random() * (b - a);
|
||||
const gauss = () => { let u = 0, v = 0; while (!u) u = Math.random(); while (!v) v = Math.random(); return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v); };
|
||||
const armAngle = (r, arm) => arm * Math.PI * 2 / ARMS + r * G.twist;
|
||||
// 名牌 / 档案卡里的文字一律转义(内容来自后台,不能当 HTML 拼)
|
||||
const esc = x => String(x == null ? '' : x).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
const LIGHT = new THREE.Vector3(-1, 0.55, 0.6).normalize();
|
||||
|
||||
// ============================================================ 旋臂星系(粒子)—— 星点大小有上限,离镜头很近的也不会糊成大光斑
|
||||
@@ -97,27 +100,26 @@ export function mountGalaxy(el) {
|
||||
// ============================================================ 星系(每条世界线一颗卡通星球 + 卫星)
|
||||
const systems = [], planets = [];
|
||||
const lit = CFG.UNIVERSES.filter(u => !u.empty), empty = CFG.UNIVERSES.filter(u => u.empty);
|
||||
CFG.UNIVERSES.forEach((u, i) => {
|
||||
const ei = empty.indexOf(u);
|
||||
const L = Object.assign({}, CFG.EMPTY_LOOK, CFG.LOOKS[u.no] || {});
|
||||
if (!CFG.LOOKS[u.no]) L.orbit = [R * (0.8 + 0.12 * (ei % 2)), ei % ARMS]; // 空槽放在外圈,按顺序分到各条旋臂
|
||||
const [r, arm] = L.orbit || [R * 0.85, i % ARMS];
|
||||
const a = r ? armAngle(r, arm) + (u.empty ? 0.32 * Math.floor(ei / ARMS) : 0) : 0;
|
||||
const g = new THREE.Group(); g.position.set(Math.cos(a) * r, 0, Math.sin(a) * r); scene.add(g);
|
||||
// 位置和补给线由 layout.js 算(写死的 / 空槽按编号 / 新点亮的自动排位,规则见那个文件开头)
|
||||
const LAY = layoutSystems(CFG), byNo = new Map();
|
||||
LAY.forEach((ly, i) => {
|
||||
const u = ly.u, L = ly.look;
|
||||
const g = new THREE.Group(); g.position.set(ly.x, 0, ly.z); scene.add(g);
|
||||
const p = makePlanet(THREE, Object.assign({ seed: i * 7.3 + 1 }, L)); g.add(p.group); planets.push(p);
|
||||
const moons = (L.moons || []).map((m, k) => { const piv = new THREE.Group(); piv.rotation.x = 0.35 - k * 0.2; piv.rotation.y = k * 2.1; g.add(piv);
|
||||
const mp = makePlanet(THREE, Object.assign({ seed: i * 13 + k * 3.1, spin: 0.4 }, m)); mp.group.position.x = m.d; piv.add(mp.group); planets.push(mp); return { piv, speed: Math.abs(m.speed || 0.3) }; }); // 卫星一律同一个方向转(和星系自转同向)
|
||||
const tag = document.createElement('button'); tag.type = 'button'; tag.className = 'tag' + (u.empty ? ' empty' : ''); tag.style.setProperty('--c', L.accent || C.ui);
|
||||
tag.innerHTML = '<span class="t"><b>' + (u.empty ? '空槽' : u.name) + '</b><em>' + u.no + (u.empty ? ' · 未点亮' : ' · ' + u.kind) + '</em></span>';
|
||||
tag.innerHTML = '<span class="t"><b>' + esc(u.empty ? '空槽' : u.name) + '</b><em>' + esc(u.no) + (u.empty ? ' · 未点亮' : ' · ' + esc(u.kind)) + '</em></span>';
|
||||
labels.appendChild(tag);
|
||||
const s = { u, L, g, planet: p, moons, tag }; p.body.userData.s = s; systems.push(s);
|
||||
const s = { u, L, g, planet: p, moons, tag, parent: ly.parent }; p.body.userData.s = s; systems.push(s); byNo.set(u.no, s);
|
||||
tag.addEventListener('click', () => fly(s));
|
||||
});
|
||||
// 补给线:核心 → 每个星系,虚线往外流
|
||||
// 补给线:从「上一站」(核心或更靠里的那颗星)连过来,虚线往外流;空槽的线很淡
|
||||
const supply = [];
|
||||
for (const s of systems) { if (s.u.no === '0000') continue;
|
||||
const b = s.g.position.clone(), mid = b.clone().multiplyScalar(0.5); mid.y += b.length() * 0.12;
|
||||
const l = new THREE.Line(new THREE.BufferGeometry().setFromPoints(new THREE.QuadraticBezierCurve3(new THREE.Vector3(), mid, b).getPoints(80)),
|
||||
for (const s of systems) { if (s.u.no === '0000' || !s.g.position.lengthSq()) continue;
|
||||
const a = s.parent && byNo.has(s.parent) ? byNo.get(s.parent).g.position.clone() : new THREE.Vector3();
|
||||
const b = s.g.position.clone(), mid = a.clone().add(b).multiplyScalar(0.5); mid.y += a.distanceTo(b) * 0.12;
|
||||
const l = new THREE.Line(new THREE.BufferGeometry().setFromPoints(new THREE.QuadraticBezierCurve3(a, mid, b).getPoints(80)),
|
||||
new THREE.LineDashedMaterial({ color: s.u.empty ? lineCol : new THREE.Color(C.ui), dashSize: 0.9, gapSize: 0.8, transparent: true, opacity: s.u.empty ? 0.14 : 0.42, depthWrite: false }));
|
||||
l.computeLineDistances(); l.userData.op = l.material.opacity; scene.add(l); supply.push(l); }
|
||||
// 散落的无名星球(只是让星系看起来有人住;不进档案、不能点)
|
||||
@@ -225,10 +227,9 @@ export function mountGalaxy(el) {
|
||||
for (const s of systems) { s.g.getWorldPosition(tmp).project(camera); const d = Math.hypot((tmp.x - ptr.x) * r.width / 2, (tmp.y - ptr.y) * r.height / 2); if (d < bd && tmp.z < 1) { bd = d; best = s; } }
|
||||
return best;
|
||||
}
|
||||
const esc = x => String(x || '').replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
function card(s) { const u = s.u, nav = '<div class="nav"><button class="btn" type="button" data-s="-1">上一个</button><button class="btn" type="button" data-s="1">下一个</button></div>';
|
||||
if (u.empty) return '<div class="card" style="--pc:' + (s.L.accent) + '"><div class="k">UNIVERSE ' + u.no + ' · 未点亮</div><h2>空槽</h2><div class="tg">这条世界线还没写出来,星系还没被点亮。</div><div class="acts">' + nav + '<button class="btn" type="button" data-home>回到星系图</button></div></div>';
|
||||
return '<div class="card" style="--pc:' + s.L.accent + '"><div class="k">UNIVERSE ' + u.no + ' · ' + esc(u.kind) + ' · 已点亮</div><h2>' + esc(u.name) + '</h2><div class="tg">' + esc(u.tag) + '</div>' +
|
||||
if (u.empty) return '<div class="card" style="--pc:' + esc(s.L.accent) + '"><div class="k">UNIVERSE ' + esc(u.no) + ' · 未点亮</div><h2>空槽</h2><div class="tg">这条世界线还没写出来,星系还没被点亮。</div><div class="acts">' + nav + '<button class="btn" type="button" data-home>回到星系图</button></div></div>';
|
||||
return '<div class="card" style="--pc:' + esc(s.L.accent) + '"><div class="k">UNIVERSE ' + esc(u.no) + ' · ' + esc(u.kind) + ' · 已点亮</div><h2>' + esc(u.name) + '</h2><div class="tg">' + esc(u.tag) + '</div>' +
|
||||
'<p class="ds">' + esc(u.desc) + '</p><div class="tags">' + (u.tags || []).map(t => '<span>' + esc(t) + '</span>').join('') + '</div><div class="acts">' + nav + '<button class="btn pri" type="button" data-home>回到星系图</button></div></div>'; }
|
||||
panel && panel.addEventListener('click', e => { const b = e.target.closest('[data-s]'); if (b) step(+b.dataset.s); if (e.target.closest('[data-home]')) home(); });
|
||||
function step(d) { const i = systems.indexOf(focus); fly(systems[(i + d + systems.length) % systems.length]); }
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* 金钻宇宙 · 开场「星门」(2026-10-06 重做,替换原来的「星图载入中…」一行字)
|
||||
---------------------------------------------------------------------------
|
||||
three.js 在下载 / 星系在生成的这段时间,星图窗里是一道星门:
|
||||
· 中间像素钻石,外面三圈光环反向慢转;底下一排格子 = 全部世界线(写好的 + 空槽);
|
||||
· 一道光沿着格子来回扫,写好的世界线按编号一格一格点亮成它自己的颜色(空槽保持虚线);
|
||||
· 星系第一帧画好(galaxy.js 的 onReady)→ JZGate.open():光环向外炸开、格子散开、星门淡出,
|
||||
正好接上 galaxy.js 自己的镜头俯冲入场;
|
||||
· 打不开 3D(老设备 / 没 WebGL)→ JZGate.fail(说明):星门停住,换成说明文字,下面的档案照样能看;
|
||||
· 系统要求「减少动效」:不扫、不炸,直接淡出。 */
|
||||
(function () {
|
||||
'use strict';
|
||||
var gate = document.getElementById('uGate'); if (!gate) return;
|
||||
var reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
var msg = document.getElementById('uGateMsg'), slots = document.getElementById('uGateSlots');
|
||||
var uv = window.JZP && window.JZP.universes ? window.JZP.universes() : { lit: [], empty: [], looks: {} };
|
||||
var all = uv.lit.concat(uv.empty).sort(function (a, b) { return a.no < b.no ? -1 : 1; });
|
||||
slots.innerHTML = all.map(function (u, i) {
|
||||
var lk = uv.looks[u.no] || {}, c = u.empty ? '' : (lk.accent || u.tone || '#9A6BE0');
|
||||
var e = window.JZP ? window.JZP.esc : function (x) { return String(x).replace(/[&<>"']/g, ''); };
|
||||
return '<i class="' + (u.empty ? 'e' : 'l') + '" style="--i:' + i + (c ? ';--c:' + e(c) : '') + '" title="' + e(u.no) + '"></i>';
|
||||
}).join('');
|
||||
gate.style.setProperty('--n', all.length);
|
||||
gate.classList.add('scan');
|
||||
var t0 = performance.now(), opened = false;
|
||||
/* 下载慢的时候换几句话,别让人以为卡死了 */
|
||||
var lines = ['正在打开星门…', '正在装载星系引擎…', '正在排布 ' + all.length + ' 条世界线…', '马上就好…'];
|
||||
var li = 0, lt = setInterval(function () { if (!opened && li < lines.length - 1) msg.textContent = lines[++li]; }, 1400);
|
||||
window.JZGate = {
|
||||
open: function () {
|
||||
if (opened) return; opened = true; clearInterval(lt);
|
||||
/* 至少让扫描走完一轮(约 1.1 秒),太快打开反而像闪了一下 */
|
||||
var wait = reduce ? 0 : Math.max(0, 1100 - (performance.now() - t0));
|
||||
setTimeout(function () {
|
||||
msg.textContent = '已点亮 ' + uv.lit.length + ' 条世界线';
|
||||
gate.classList.add('open');
|
||||
setTimeout(function () { gate.remove(); }, reduce ? 300 : 1300);
|
||||
}, wait);
|
||||
},
|
||||
fail: function (text) {
|
||||
opened = true; clearInterval(lt);
|
||||
gate.classList.remove('scan'); gate.classList.add('failed'); msg.textContent = text;
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,150 @@
|
||||
/* =============================================================================
|
||||
* 金钻宇宙 · 星系图排布(layout.js)—— 纯计算,不依赖 three.js,可以单独测试
|
||||
* -----------------------------------------------------------------------------
|
||||
* 决定每条世界线的星球放在哪、补给线从哪连过来。规则(2026-10-05):
|
||||
*
|
||||
* 1. 在 LOOKS 里写了 orbit: [离核心多远, 第几条旋臂] 的 —— 就放在那儿,补给线从核心连过去。(现在的 0000–0004)
|
||||
* 2. 空槽(empty: true)—— 按**编号**放在外圈的固定槽位(从 GALAXY.firstSlot 号起,轮流分到各条旋臂)。
|
||||
* 只看自己的编号,点亮其中一个,别的空槽不会挪。空槽的淡虚线接到离它最近、又不穿过别的星的那颗已点亮的星
|
||||
* (没有就接核心)—— 这条淡线会随着新点亮的星「找到更近的落脚点」,空槽本身不动。
|
||||
* 3. 已点亮、但没写 orbit 的(内容后台里「点亮一条」新加的)—— **自动排位**:
|
||||
* · 在中圈的旋臂上挑一个位置:跟核心、已有星系(连同它的卫星轨道)都留足距离,尽量让各条旋臂均匀;
|
||||
* · 补给线连到「比它更靠近核心、又离它最近」的那颗星(没有合适的就连核心),
|
||||
* 而且这条线不能从别的星系中间穿过;
|
||||
* · 按编号从小到大一颗一颗排,每一颗只看排在它前面的 —— 所以**新加一条,已有的星和线都不动**。
|
||||
* · 中圈排满(二十来条以后)才会去外圈空槽之间找位置;那一档要避开空槽,所以改「空槽数」可能让这几颗挪一挪。
|
||||
*
|
||||
* 用法:import { layoutSystems } from './layout.js';
|
||||
* const L = layoutSystems(window.JZ_UNIVERSE) → [{ u, look, x, z, kind, parent }]
|
||||
* kind = 'pinned' | 'slot' | 'auto';parent = 补给线起点的编号,null = 核心
|
||||
* ============================================================================= */
|
||||
|
||||
export const armAngle = (r, arm, G) => arm * Math.PI * 2 / G.arms + r * G.twist;
|
||||
|
||||
/** 一个星系「占的地方」半径:星球本身 + 最外面那颗卫星的轨道 */
|
||||
export function footprint(look) {
|
||||
const moons = (look.moons || []).map(m => (m.d || 0) + (m.r || 0));
|
||||
return (look.r || 1) * 2.2 + (moons.length ? Math.max(...moons) : 0);
|
||||
}
|
||||
|
||||
const dist = (a, b) => { const dx = a.x - b.x, dz = a.z - b.z; return Math.sqrt(dx * dx + dz * dz); }; // 别用 Math.hypot:V8 里慢好几倍
|
||||
/** 点到线段的距离(补给线按直线近似;实际画的是稍微拱起来的弧,水平投影还是这条线) */
|
||||
function segDist(p, a, b) {
|
||||
const vx = b.x - a.x, vz = b.z - a.z, L2 = vx * vx + vz * vz || 1;
|
||||
const t = Math.max(0, Math.min(1, ((p.x - a.x) * vx + (p.z - a.z) * vz) / L2));
|
||||
const dx = p.x - (a.x + vx * t), dz = p.z - (a.z + vz * t);
|
||||
return Math.sqrt(dx * dx + dz * dz);
|
||||
}
|
||||
|
||||
export function layoutSystems(CFG) {
|
||||
const G = CFG.GALAXY, R = G.radius, ARMS = G.arms, first = G.firstSlot ?? 5;
|
||||
const LOOKS = CFG.LOOKS || {};
|
||||
const lookOf = u => Object.assign({}, CFG.EMPTY_LOOK, LOOKS[u.no] || {});
|
||||
const num = u => parseInt(u.no, 10) || 0;
|
||||
const list = [...CFG.UNIVERSES].sort((a, b) => num(a) - num(b));
|
||||
const CORE = { x: 0, z: 0, fp: 12, no: null };
|
||||
const out = new Map();
|
||||
const put = (u, look, r, a, kind, parent) => {
|
||||
const s = { u, look, x: Math.cos(a) * r, z: Math.sin(a) * r, r, kind, parent, fp: footprint(look), no: u.no };
|
||||
out.set(u.no, s); return s;
|
||||
};
|
||||
|
||||
// 1) 写死位置的
|
||||
for (const u of list) {
|
||||
const o = (LOOKS[u.no] || {}).orbit;
|
||||
if (!o) continue;
|
||||
const [r, arm] = o;
|
||||
put(u, lookOf(u), r, r ? armAngle(r, arm, G) : 0, 'pinned', null);
|
||||
}
|
||||
// 2) 空槽:按编号固定在外圈
|
||||
for (const u of list) {
|
||||
if (!u.empty || out.has(u.no)) continue;
|
||||
const e = Math.max(0, num(u) - first);
|
||||
const r = R * (0.8 + 0.12 * (e % 2));
|
||||
put(u, lookOf(u), r, armAngle(r, e % ARMS, G) + 0.32 * Math.floor(e / ARMS), 'slot', null);
|
||||
}
|
||||
// 3) 自动排位:只避开「核心 + 写死的 + 排在前面的自动星」(空槽在外圈,自动星只用中圈,互不影响)
|
||||
const placed = [...out.values()].filter(s => s.kind === 'pinned' && s.r > 0);
|
||||
const armCount = new Array(ARMS).fill(0);
|
||||
for (const s of placed) {
|
||||
const a = Math.atan2(s.z, s.x);
|
||||
let best = 0, bd = Infinity;
|
||||
for (let k = 0; k < ARMS; k++) { const d = Math.abs(Math.atan2(Math.sin(a - armAngle(s.r, k, G)), Math.cos(a - armAngle(s.r, k, G)))); if (d < bd) { bd = d; best = k; } }
|
||||
armCount[best]++;
|
||||
}
|
||||
const rMin = 16, rMax = R * 0.68, mid = R * 0.5; // 自动星只用中圈:外圈(0.8R 往外)留给空槽,两圈之间留出空隙
|
||||
|
||||
// 给一个候选位置挑补给线起点:比它更靠近核心的星(或核心),线不能穿过别的星系
|
||||
function parentFor(c, others) {
|
||||
const cands = [CORE, ...others.filter(o => o.r < c.r - 4)];
|
||||
let best = null;
|
||||
for (const p of cands) {
|
||||
const len = dist(p, c);
|
||||
let clear = Infinity;
|
||||
for (const o of others) { if (o === p) continue; clear = Math.min(clear, segDist(o, p, c) - o.fp); }
|
||||
if (clear < 1.5) continue;
|
||||
// 同样不穿的情况下挑短的;连核心稍微加一点「距离」,让新星更愿意接在附近的星上,连线成网而不是全扎向中心
|
||||
const score = len + (p === CORE ? 6 : 0);
|
||||
if (!best || score < best.score) best = { p, score, clear };
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
// 候选位置:按「够不够宽敞」先粗筛打分(便宜),再只给排在前面的几十个检查补给线会不会穿星(贵)—— 40 条世界线也很快。
|
||||
// 中圈排满了就分档放宽:到外圈空槽之间找位置(这时也要避开空槽)、间距要求逐步降低;最后兜底也保证不叠在别人身上。
|
||||
const slots = [...out.values()].filter(s => s.kind === 'slot');
|
||||
const PASSES = [
|
||||
{ rMax: R * 0.68, need: 4, offs: [-0.2, -0.1, 0, 0.1, 0.2], slots: false },
|
||||
{ rMax: R * 0.96, need: 3, offs: [-0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3], slots: true },
|
||||
{ rMax: R * 0.98, need: 1.2, offs: [-0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4], slots: true },
|
||||
];
|
||||
function place(fp, pass) {
|
||||
const others = pass.slots ? placed.concat(slots) : placed, cands = [];
|
||||
for (let arm = 0; arm < ARMS; arm++) {
|
||||
for (let r = rMin; r <= pass.rMax; r += 1.25) {
|
||||
for (const off of pass.offs) {
|
||||
const a = armAngle(r, arm, G) + off;
|
||||
const c = { x: Math.cos(a) * r, z: Math.sin(a) * r, r };
|
||||
let clear = r - CORE.fp - fp;
|
||||
for (const o of others) clear = Math.min(clear, dist(o, c) - o.fp - fp);
|
||||
if (clear < pass.need) continue;
|
||||
// 分数:够宽敞(封顶,不为了宽敞跑到边上)、靠近中圈、所在旋臂人少、在旋臂正中更好
|
||||
cands.push({ c, a, r, arm, clear, score: Math.min(clear, 12) - 0.08 * Math.abs(r - mid) - 2.2 * armCount[arm] - 3 * Math.abs(off) });
|
||||
}
|
||||
}
|
||||
}
|
||||
cands.sort((x, y) => y.score - x.score || x.r - y.r || x.a - y.a);
|
||||
let best = null;
|
||||
for (const k of cands.slice(0, 60)) {
|
||||
const par = parentFor(k.c, placed);
|
||||
if (!par) continue;
|
||||
const s = k.score + Math.min(par.clear, 6) * 0.3;
|
||||
if (!best || s > best.s + 1e-9) best = { s, k, parent: par.p };
|
||||
}
|
||||
if (best) return best;
|
||||
return cands.length ? { k: cands[0], parent: CORE } : null; // 线怎么都会擦到别的星:就近连核心,至少星不叠
|
||||
}
|
||||
|
||||
for (const u of list) {
|
||||
if (u.empty || out.has(u.no)) continue;
|
||||
const look = lookOf(u), fp = footprint(look);
|
||||
let got = null;
|
||||
for (const pass of PASSES) { got = place(fp, pass); if (got) break; }
|
||||
if (!got) { // 整张图都满了(几十条以后):退到最外圈,按编号错开
|
||||
const e = Math.max(0, num(u) - first), r = R * 1.02 + 2 * Math.floor(e / ARMS);
|
||||
placed.push(put(u, look, r, armAngle(r, e % ARMS, G) + 0.16, 'auto', null));
|
||||
continue;
|
||||
}
|
||||
const s = put(u, look, got.k.r, got.k.a, 'auto', got.parent.no);
|
||||
armCount[got.k.arm]++;
|
||||
placed.push(s);
|
||||
}
|
||||
// 4) 空槽的淡线:接到最近的、不穿星的已点亮星(或核心)
|
||||
const litNow = [...out.values()].filter(s => !s.u.empty && s.r > 0);
|
||||
for (const s of out.values()) {
|
||||
if (s.kind !== 'slot') continue;
|
||||
const par = parentFor(s, litNow);
|
||||
s.parent = par && par.p !== CORE ? par.p.no : null;
|
||||
}
|
||||
return list.map(u => out.get(u.no));
|
||||
}
|
||||
@@ -147,6 +147,129 @@ const STYLES = {
|
||||
base = mix(base, uC2, cr); base = mix(base, uC3, aline(snoise(vP*5.0 + uSeed*2.0) - 0.42, 1.5)*0.7);
|
||||
gl_FragColor = vec4(shade(base, N, V), uAlpha); }`,
|
||||
},
|
||||
/* ===== 2026-10-05 加的预设(游戏美术里最常见的几类卡通星球;画法同上:三档明暗 + 墨线 + 轮廓光) ===== */
|
||||
/* 类地(卡通地球):蓝海 + 绿色大陆 + 沙漠块 + 极冠 + 慢慢飘的白云,海岸一圈墨线 */
|
||||
earth: {
|
||||
defaults: { colors: ['#3E8EDB', '#5DBB63', '#E8C77A', '#FFFFFF'], shadow: '#4A55A0', rim: '#BFE6FF', outline: '#14284A', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float h = fbm(vP*1.5 + uSeed) + 0.22*snoise(vP*4.0 + uSeed);
|
||||
float land = smoothstep(0.03, 0.05, h), shallow = smoothstep(-0.14, 0.03, h)*(1.0 - land);
|
||||
vec3 water = mix(uC0, mix(uC0, vec3(1.0), 0.32), shallow);
|
||||
float dry = smoothstep(0.1, 0.35, snoise(vP*2.2 + uSeed + 5.0)) * (1.0 - smoothstep(0.45, 0.75, abs(vP.y)));
|
||||
vec3 base = mix(water, mix(uC1, uC2, dry*0.85), land);
|
||||
base = mix(base, uC3, smoothstep(0.80, 0.84, abs(vP.y) + 0.06*snoise(vP*5.0)));
|
||||
vec3 c = shade(base, N, V);
|
||||
c = mix(c, uC1*0.35, aline(h - 0.04, 1.2)*0.7);
|
||||
float cl = smoothstep(0.32, 0.38, fbm(vP*2.2 + vec3(uT*0.015, 9.0, uSeed)));
|
||||
float lit = smoothstep(-0.1, 0.12, dot(N, normalize(uL)));
|
||||
c = mix(c, mix(uC3*0.72, uC3, lit), cl*0.85);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 海洋:几乎全是水,深浅两色 + 零星小岛 + 一圈圈浪线 + 条状云 */
|
||||
ocean: {
|
||||
defaults: { colors: ['#1F5FB8', '#3FB5E6', '#F2D49B', '#FFFFFF'], shadow: '#3A4A9A', rim: '#B8EEFF', outline: '#0F2148', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float h = fbm(vP*1.8 + uSeed);
|
||||
float isl = smoothstep(0.40, 0.43, h);
|
||||
vec3 base = mix(mix(uC0, uC1, smoothstep(0.05, 0.38, h)), uC2, isl);
|
||||
vec3 c = shade(base, N, V);
|
||||
c = mix(c, uC3, aline(h - 0.34 - 0.02*sin(uT*0.8), 1.2)*0.6*(1.0 - isl));
|
||||
float st = smoothstep(0.30, 0.36, snoise(vec3(vP.x*1.4, vP.y*6.0, vP.z*1.4) + vec3(uSeed, 0.0, uT*0.01)));
|
||||
c = mix(c, uC3, st*0.8*smoothstep(-0.2, 0.2, dot(N, normalize(uL))) + st*0.15);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 丛林:深浅两层绿 + 一团团树冠 + 弯弯的河 + 飘着的雾 */
|
||||
jungle: {
|
||||
defaults: { colors: ['#2F7D4A', '#6CC46A', '#3FA7D6', '#E9F7E4'], shadow: '#355A6E', rim: '#CFFFD8', outline: '#11301E', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float n = fbm(vP*2.4 + uSeed);
|
||||
vec3 base = mix(uC0, uC1, smoothstep(-0.1, 0.35, n));
|
||||
base = mix(base, uC1*1.12, smoothstep(0.5, 0.56, snoise(vP*4.0 + uSeed))*0.5);
|
||||
float rv = fbm(vP*1.1 + uSeed*1.3);
|
||||
base = mix(base, uC2, aline(rv, 1.5)*smoothstep(0.75, 0.3, abs(vP.y))*0.9);
|
||||
vec3 c = shade(base, N, V);
|
||||
c = mix(c, uC3, smoothstep(0.35, 0.5, fbm(vP*1.6 + vec3(0.0, uT*0.015, 20.0)))*0.5);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 荒漠:弯曲的沙丘条纹 + 红色台地(带墨线轮廓)+ 一点点极冠 */
|
||||
desert: {
|
||||
defaults: { colors: ['#F2C38B', '#E09A5A', '#B5623E', '#FFF4E2'], shadow: '#8A5A7A', rim: '#FFE2BF', outline: '#3A1E24', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float b = 0.5 + 0.5*sin((vP.y*6.0 + 1.2*fbm(vP*1.8 + uSeed))*3.14159);
|
||||
vec3 base = mix(uC0, uC1, smoothstep(0.35, 0.65, b));
|
||||
float m = snoise(vP*3.0 + uSeed + 3.0);
|
||||
base = mix(base, uC2, smoothstep(0.42, 0.46, m));
|
||||
base = mix(base, uC3, smoothstep(0.86, 0.9, abs(vP.y)));
|
||||
vec3 c = shade(base, N, V);
|
||||
c = mix(c, uC2*0.6, aline(m - 0.44, 1.2)*0.7);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 冻原:霜白和青灰 + 一片片深色针叶林 + 结冰的湖 */
|
||||
tundra: {
|
||||
defaults: { colors: ['#E9F3F2', '#9CC9C1', '#4E7F7A', '#BFE8FF'], shadow: '#6A7FA8', rim: '#E4FBFF', outline: '#173233', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
vec3 base = mix(uC0, uC1, smoothstep(0.0, 0.4, fbm(vP*2.0 + uSeed)));
|
||||
base = mix(base, uC2, smoothstep(0.5, 0.56, snoise(vP*5.5 + uSeed))*smoothstep(0.75, 0.4, abs(vP.y)));
|
||||
float lk = snoise(vP*3.0 + uSeed + 9.0);
|
||||
base = mix(base, uC3, smoothstep(0.62, 0.66, lk));
|
||||
vec3 c = shade(base, N, V);
|
||||
c = mix(c, uC2, aline(lk - 0.64, 1.2)*0.6);
|
||||
c += uC3 * pow(max(dot(reflect(-normalize(uL), N), V), 0.0), 30.0) * 0.35;
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 熔岩:深色岩壳 + 发光的裂缝和岩浆池(慢慢呼吸) */
|
||||
lava: {
|
||||
defaults: { colors: ['#2A1E2E', '#4A3340', '#FF7A2F', '#FFD36E'], shadow: '#3A2A4A', rim: '#FF9A5A', outline: '#120A14', glow: 0.9 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float n = snoise(vP*3.0 + uSeed), n2 = snoise(vP*7.0 + uSeed*2.0);
|
||||
float crack = max(1.0 - smoothstep(0.0, 0.07, abs(n)), (1.0 - smoothstep(0.0, 0.045, abs(n2)))*0.7);
|
||||
float pool = smoothstep(0.5, 0.55, fbm(vP*1.6 + uSeed + 4.0));
|
||||
vec3 c = shade(mix(uC0, uC1, smoothstep(-0.3, 0.4, fbm(vP*2.5 + uSeed))), N, V);
|
||||
vec3 hot = mix(uC2, uC3, 0.35 + 0.25*sin(uT*1.4 + n*6.0));
|
||||
c = mix(c, hot, max(crack, pool)*uGlow);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 毒雾:酸绿和黄绿的扭曲气流 + 一点紫色 + 冒泡的亮点 */
|
||||
toxic: {
|
||||
defaults: { colors: ['#B8E04A', '#6FBF3A', '#5B3F8C', '#F4FF9E'], shadow: '#4E3F7A', rim: '#E6FF9A', outline: '#1A1A2E', glow: 0.5 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float w = fbm(vP*2.0 + vec3(uT*0.02, 0.0, uSeed));
|
||||
float w2 = fbm(vP*2.0 + w*1.6 + uSeed);
|
||||
vec3 base = mix(uC0, uC1, smoothstep(-0.2, 0.3, w2));
|
||||
base = mix(base, uC2, smoothstep(0.35, 0.5, w2)*0.6);
|
||||
vec3 c = shade(base, N, V);
|
||||
vec3 cell = floor(vP*28.0);
|
||||
float bub = step(0.94, fract(sin(dot(cell, vec3(12.9898, 78.233, 37.719)) + uSeed)*43758.5453));
|
||||
c += uC3 * bub * (0.5 + 0.5*sin(uT*2.0 + cell.x)) * 0.4 * uGlow;
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 荒芜岩球(像月球):灰色岩面 + 大小两层陨坑,坑沿一圈墨线、坑底更暗 */
|
||||
barren: {
|
||||
defaults: { colors: ['#C9C6CF', '#9F9AA8', '#6E6878', '#ECEAF2'], shadow: '#5F5A78', rim: '#E6E2FF', outline: '#1C1A26', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
vec3 base = mix(uC0, uC1, smoothstep(-0.2, 0.35, fbm(vP*2.2 + uSeed)));
|
||||
float a = snoise(vP*3.6 + uSeed), b = snoise(vP*9.0 + uSeed*3.0);
|
||||
base = mix(base, uC2, smoothstep(0.46, 0.56, a));
|
||||
base = mix(base, uC2, smoothstep(0.58, 0.66, b)*0.8);
|
||||
vec3 c = shade(base, N, V);
|
||||
c = mix(c, uC3, max(aline(a - 0.46, 1.4), aline(b - 0.58, 1.1)*0.6)*0.55*smoothstep(-0.2, 0.3, dot(N, normalize(uL))));
|
||||
c = mix(c, uC2*0.6, max(aline(a - 0.47, 1.0), aline(b - 0.59, 0.8)*0.5)*0.5);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 冰巨星(像海王星):蓝色细条纹 + 一个深色风暴眼 + 几道白色流云 */
|
||||
icegiant: {
|
||||
defaults: { colors: ['#8FD3FF', '#4E8FE8', '#2B3F9E', '#FFFFFF'], shadow: '#3C4C9E', rim: '#CFF0FF', outline: '#101C48', glow: 0 },
|
||||
frag: `void main(){ vec3 V = normalize(cameraPosition - vW); vec3 N = normalize(vN);
|
||||
float w = vP.y*7.0 + 0.35*snoise(vec3(vP.x*2.0, vP.y*5.0, vP.z*2.0) + uSeed);
|
||||
float b = 0.5 + 0.5*sin(w*3.14159);
|
||||
vec3 base = mix(uC0, uC1, smoothstep(0.35, 0.65, b));
|
||||
float spot = 1.0 - smoothstep(0.1, 0.15, length((vP - normalize(vec3(0.7, -0.3, 0.62)))*vec3(1.0, 1.7, 1.0)));
|
||||
base = mix(base, uC2, spot*0.9);
|
||||
vec3 c = shade(base, N, V);
|
||||
float streak = smoothstep(0.55, 0.62, snoise(vec3(vP.x*1.2, vP.y*14.0, vP.z*1.2) + vec3(uT*0.02, 0.0, uSeed)));
|
||||
c = mix(c, uC3, streak*0.75);
|
||||
gl_FragColor = vec4(c, uAlpha); }`,
|
||||
},
|
||||
/* 未点亮:半透明全息线框球 —— 空槽 */
|
||||
ghost: {
|
||||
transparent: true,
|
||||
@@ -159,7 +282,21 @@ const STYLES = {
|
||||
},
|
||||
};
|
||||
|
||||
/* 带环巨星:气态巨星 + 一圈卡通扁环(光环默认不加,只有这个预设自带;颜色压低,不发光) */
|
||||
STYLES.ringed = {
|
||||
defaults: { colors: ['#F4E1B8', '#D9A26C', '#9C6B9E', '#FFF6DE'], shadow: '#7A6A9E', rim: '#FFE9C4', outline: '#241A36', glow: 0,
|
||||
ring: { inner: 1.45, outer: 2.05, color: '#F2E3C2', color2: '#C99E72' }, tilt: 0.42 },
|
||||
frag: STYLES.gas.frag,
|
||||
};
|
||||
|
||||
export const STYLE_NAMES = Object.keys(STYLES);
|
||||
/* 每种风格的中文名(内容后台的下拉、交接文档都用这一份) */
|
||||
export const STYLE_LABELS = {
|
||||
crystal: '晶体', paper: '铅笔纸面', ice: '冰封', neon: '霓虹城', duality: '善恶两半',
|
||||
earth: '类地(卡通地球)', ocean: '海洋', jungle: '丛林', desert: '荒漠', tundra: '冻原',
|
||||
lava: '熔岩', toxic: '毒雾', barren: '荒芜岩球', gas: '气态巨星', icegiant: '冰巨星', ringed: '带环巨星',
|
||||
rock: '小行星', ghost: '未点亮(空槽)',
|
||||
};
|
||||
|
||||
/**
|
||||
* 造一颗卡通星球。look 里能写:
|
||||
@@ -210,7 +347,7 @@ export function makePlanet(THREE, look = {}) {
|
||||
vertexShader: `varying vec3 vP; void main(){ vP = position; gl_Position = projectionMatrix*modelViewMatrix*vec4(position,1.0); }`,
|
||||
fragmentShader: `uniform vec3 uA; uniform vec3 uB; uniform float uIn; uniform float uOut; varying vec3 vP;
|
||||
void main(){ float t = (length(vP.xy)-uIn)/(uOut-uIn); float b = step(0.5, fract(t*5.0));
|
||||
float a = (0.55 + 0.25*b) * smoothstep(0.0, 0.06, t) * smoothstep(1.0, 0.94, t); gl_FragColor = vec4(mix(uA, uB, b*0.6 + t*0.3), a); }` }));
|
||||
float a = (0.42 + 0.2*b) * smoothstep(0.0, 0.06, t) * smoothstep(1.0, 0.94, t); gl_FragColor = vec4(mix(uA, uB, b*0.6 + t*0.3), a); }` }));
|
||||
ring.rotation.x = -Math.PI / 2 + 0.38; ring.rotation.y = 0.12; group.add(ring);
|
||||
}
|
||||
const spin = o.spin ?? 0.15;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* 金钻宇宙板块:白色客栈页面里开一扇「观星窗」,窗里是星系图;窗下是世界线档案列表(和星图联动)
|
||||
像素字 / 按钮 / 墨色都沿用门户 jz-2026 层的变量(--pixel --ink --mc-green --stone …),这里只管星图自己的东西。 */
|
||||
.skywin{--sky:#070B1C;--ui:#FFD36E;--line:rgba(127,139,200,.35);
|
||||
/* 金钻宇宙页:白色客栈页面里开一扇「观星窗」,窗里是星系图;窗下是世界线档案列表(和星图联动) */
|
||||
.skywin{--sky:#070B1C;--ui:#FFD36E;--line:rgba(127,139,200,.35);--pixel:'Fusion Pixel','OPPO Sans',sans-serif;
|
||||
position:relative;margin:6px 0 26px;padding:6px;border-radius:12px;background:rgba(255,255,255,.75);border:2px solid #fff;
|
||||
box-shadow:0 30px 60px -36px rgba(40,50,110,.55)}
|
||||
.skywin .stage{position:relative;height:min(72vh,660px);min-height:440px;border-radius:8px;overflow:hidden;background:var(--sky);color:#E8EBFA;isolation:isolate}
|
||||
@@ -26,7 +25,7 @@
|
||||
.skywin .panel .card{position:relative;padding:20px 20px 16px 24px;border-radius:8px;background:rgba(255,255,255,.96);border:2px solid #fff;color:var(--ink);box-shadow:0 30px 70px -30px rgba(0,0,0,.6)}
|
||||
.skywin .panel .card::before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;border-radius:8px 0 0 8px;background:var(--pc,#FFD36E)}
|
||||
.skywin .panel .card .k{font:600 12px/1 var(--font,inherit);letter-spacing:.06em;color:var(--ink-3)}
|
||||
.skywin .panel .card h2{margin:8px 0 2px;font:400 28px/1.2 var(--pixel);-webkit-font-smoothing:none}
|
||||
.skywin .panel .card h2{margin:8px 0 2px;font:400 28px/1.2 'Fusion Pixel','OPPO Sans',sans-serif;-webkit-font-smoothing:none}
|
||||
.skywin .panel .card .tg{color:var(--ink-2);font-size:14px}
|
||||
.skywin .panel .card .ds{margin:10px 0 0;font-size:14px;line-height:1.8;color:var(--ink-2)}
|
||||
.skywin .panel .card .tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
||||
@@ -37,9 +36,6 @@
|
||||
/* 窗角按钮 */
|
||||
.skywin .ctl{position:absolute;right:14px;top:12px;display:flex;gap:8px}
|
||||
.skywin .ctl .btn{height:34px;font-size:13px;padding:0 12px 3px}
|
||||
/* 档案卡里「回到星系图」是主按钮:门户的 .btn 是石头白方块,这里补一个绿色 .pri(同 .btn-solid) */
|
||||
.skywin .btn.pri{background:var(--mc-green);border-color:var(--mc-green-lo);color:#fff;box-shadow:inset 0 2px 0 var(--mc-green-hi),inset 0 -4px 0 var(--mc-green-lo)}
|
||||
.skywin .btn.pri:hover{background:#469A2E}
|
||||
.skywin #uBack{display:none} .skywin .stage.focus #uBack{display:inline-flex}
|
||||
.skywin .tip{position:absolute;left:18px;bottom:14px;margin:0;font-size:12px;color:#7C84B4;pointer-events:none;transition:opacity .3s}
|
||||
.skywin .stage.focus .tip{opacity:0}
|
||||
@@ -48,7 +44,6 @@
|
||||
.skywin.full .stage{position:fixed;inset:0;z-index:300;height:auto;min-height:0;border-radius:0}
|
||||
body.sky-full{overflow:hidden}
|
||||
/* 窗下:世界线列表 */
|
||||
.uni-title{margin:4px 0 14px;font-size:24px;line-height:1.3;color:var(--ink)}
|
||||
.sky-hint{display:none}
|
||||
.uni-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:12px;margin-bottom:14px}
|
||||
.ucell{position:relative;display:flex;flex-direction:column;gap:4px;padding:16px 16px 14px;border-radius:8px;border:2px solid rgba(255,255,255,.95);text-align:left;cursor:pointer;font:inherit;color:var(--ink);
|
||||
@@ -56,7 +51,7 @@ body.sky-full{overflow:hidden}
|
||||
.ucell:hover{transform:translateY(-2px)}
|
||||
.ucell[aria-current=true]{box-shadow:inset 0 0 0 3px var(--mc-green,#3C8527),0 18px 36px -26px rgba(80,90,170,.45)}
|
||||
.ucell .no{font:600 11px/1 ui-monospace,Menlo,monospace;letter-spacing:.14em;color:var(--ink-3)}
|
||||
.ucell h3{margin:2px 0 0;font:400 22px/1.25 var(--pixel);-webkit-font-smoothing:none}
|
||||
.ucell h3{margin:2px 0 0;font:400 22px/1.25 'Fusion Pixel','OPPO Sans',sans-serif;-webkit-font-smoothing:none}
|
||||
.ucell .tg{font-size:13px;color:var(--ink-2)}
|
||||
.ucell .go{margin-top:6px;font-size:12.5px;font-weight:700;color:var(--mc-green,#3C8527)}
|
||||
.ucell .sw{position:absolute;right:14px;top:14px;width:26px;height:26px;border-radius:50%;background:var(--sw);box-shadow:inset -5px -5px 0 rgba(0,0,0,.18),0 0 0 2px #fff}
|
||||
@@ -94,3 +89,50 @@ body.sky-full{overflow:hidden}
|
||||
.uslots{grid-template-columns:repeat(3,minmax(0,1fr))}
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce){.skywin .panel,.skywin .labels,.skywin .hud,.ucell{transition:none;animation:none}}
|
||||
|
||||
/* ===== 开场星门(2026-10-06,替换「星图载入中…」):钻石 + 三圈光环 + 一排世界线格子,星系画好就向外炸开 ===== */
|
||||
.ugate{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:22px;pointer-events:none;
|
||||
background:radial-gradient(46% 52% at 50% 46%,rgba(255,255,255,.96) 0%,rgba(246,247,255,.9) 55%,rgba(238,240,255,.86) 100%);transition:opacity .9s ease .25s}
|
||||
.ugate-core{position:relative;width:150px;height:150px;display:grid;place-items:center}
|
||||
.ugate-core i{width:62px;height:62px;filter:drop-shadow(-6px 12px 14px rgba(255,110,140,.3)) drop-shadow(6px 12px 14px rgba(70,140,255,.3));animation:ugFloat 2.6s ease-in-out infinite}
|
||||
.ugate-ring{position:absolute;inset:0;border-radius:50%;padding:2px;background:conic-gradient(from 0deg,#FFB3C3,#FFD99A,#A9EBC6,#A6D5FF,#CDB9FF,#FFB3C3);
|
||||
-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);
|
||||
animation:ugSpin 6s linear infinite;transition:transform .9s cubic-bezier(.2,.7,.2,1),opacity .8s ease}
|
||||
.ugate-ring.r2{inset:16%;opacity:.7;animation-duration:4.2s;animation-direction:reverse}
|
||||
.ugate-ring.r3{inset:-18%;opacity:.4;padding:1px;animation-duration:9s;border-radius:50%}
|
||||
.ugate-txt{display:flex;flex-direction:column;align-items:center;gap:6px;transition:opacity .4s ease,transform .6s ease}
|
||||
.ugate-txt b{font:400 28px/1 var(--pixel,inherit);letter-spacing:.08em;color:var(--ink,#1E2440);-webkit-font-smoothing:none}
|
||||
.ugate-txt span{font-size:13px;color:var(--ink-3,#737891)}
|
||||
.ugate-slots{display:grid;grid-template-columns:repeat(var(--n,11),18px);gap:6px;transition:opacity .5s ease}
|
||||
.ugate-slots i{position:relative;height:28px;border-radius:3px;border:1.5px dashed rgba(140,150,200,.45);background:rgba(255,255,255,.6);transition:transform .7s cubic-bezier(.2,.7,.2,1),opacity .6s ease}
|
||||
.ugate-slots i.l{border:0;background:#fff;box-shadow:inset 0 0 0 2px rgba(30,36,64,.08)}
|
||||
.ugate.scan .ugate-slots i.l{animation:ugLight .5s ease both;animation-delay:calc(180ms + var(--i) * 90ms)}
|
||||
.ugate.scan .ugate-slots::after{content:"";grid-row:1;grid-column:1/-1;height:28px;border-radius:3px;pointer-events:none;
|
||||
background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,.95) 50%,transparent 100%);background-size:40% 100%;background-repeat:no-repeat;mix-blend-mode:screen;animation:ugScan 1.4s ease-in-out infinite}
|
||||
@keyframes ugLight{to{background:linear-gradient(180deg,#fff 0%,var(--c) 100%);box-shadow:0 8px 14px -6px var(--c)}}
|
||||
@keyframes ugScan{0%{background-position:-40% 0}100%{background-position:140% 0}}
|
||||
@keyframes ugSpin{to{transform:rotate(360deg)}}
|
||||
@keyframes ugFloat{50%{transform:translateY(-6px)}}
|
||||
/* 打开:光环向外炸开、格子往两边散、钻石一亮,整块淡出 —— 正好接上星系图自己的镜头俯冲 */
|
||||
.ugate.open{opacity:0}
|
||||
.ugate.open .ugate-ring{opacity:0;animation-play-state:paused}
|
||||
.ugate.open .ugate-ring.r1{transform:scale(4.2)}
|
||||
.ugate.open .ugate-ring.r2{transform:scale(5.4)}
|
||||
.ugate.open .ugate-ring.r3{transform:scale(3.4)}
|
||||
.ugate.open .ugate-core i{animation:ugFlash .7s ease forwards}
|
||||
@keyframes ugFlash{30%{transform:scale(1.25);filter:brightness(1.6) drop-shadow(0 0 22px #fff)}100%{transform:scale(.4);opacity:0}}
|
||||
.ugate.open .ugate-txt{opacity:0;transform:translateY(12px)}
|
||||
.ugate.open .ugate-slots i{opacity:0;transform:translateX(calc((var(--i) - var(--n) / 2) * 26px)) translateY(-40px) scale(.6)}
|
||||
.ugate.failed .ugate-core i,.ugate.failed .ugate-ring{animation:none}
|
||||
.ugate.failed .ugate-txt span{max-width:30em;text-align:center;color:var(--ink-2,#4A5070)}
|
||||
@media (max-width:760px){
|
||||
.ugate{gap:16px}
|
||||
.ugate-core{width:110px;height:110px}
|
||||
.ugate-core i{width:46px;height:46px}
|
||||
.ugate-slots{grid-template-columns:repeat(var(--n,11),14px);gap:4px}
|
||||
.ugate-slots i{height:22px}
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce){
|
||||
.ugate-ring,.ugate-core i,.ugate.scan .ugate-slots::after{animation:none}
|
||||
.ugate.scan .ugate-slots i.l{animation:none;background:linear-gradient(180deg,#fff 0%,var(--c) 100%)}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# 交接说明 · 金钻宇宙星系图(`portal/assets/universe/`)
|
||||
|
||||
> 状态:**已接进门户**(2026-10-05):`portal/index.html` 的「金钻宇宙」板块就是它,原来的启动仪式 / 盘符机架 / 读盘舱已删除。
|
||||
> 状态:**已接进门户**(2026-10-05);2026-10-06 起门户是多页,星系图在 `portal/universe.html`(样子按设计预览站),开场是 `gate.js` 的「星门」(星系第一帧画好才打开,接上下面的镜头俯冲)。
|
||||
> 风格参考:《绝地潜兵 2》银河战争地图 —— 旋臂星系 + 星云 + 扇区 + 补给线;每条世界线是一个星系,点进去是一颗卡通星球 + 档案卡。
|
||||
|
||||
---
|
||||
@@ -13,7 +13,7 @@
|
||||
| `assets/universe/planets.js` | 卡通星球材质库(每种「风格」= 一段着色器 + 默认参数) | 加新风格时改 |
|
||||
| `assets/universe/galaxy.js` | 引擎:画星系、星云、补给线、名牌,处理拖动 / 缩放 / 点击 / 档案卡 / 运镜 | 一般不用动 |
|
||||
| `assets/universe/universe.css` | 观星窗、档案卡、窗下世界线卡片、手机布局的样式 | 改版式时改 |
|
||||
| `portal/index.html` 里 `#view-universe` + 底部那段 `<script type="module">` | 板块骨架(窗户 / 名牌层 / HUD / 档案卡 / 卡片列表)和接线代码 | 改交互时改 |
|
||||
| `portal/universe.html`(`#skywin` + 底部那段 `<script type="module">`)+ `universe-page.css` + `gate.js` | 页面骨架(窗户 / 名牌层 / HUD / 档案卡 / 卡片列表)、接线代码、开场星门 | 改交互时改 |
|
||||
| `assets/vendor/three.module.min.js` | three.js r170(MIT,自托管,不连外网) | 不动 |
|
||||
|
||||
**没有任何贴图、模型文件**:星球、星云、星点全是着色器实时生成的,所以没有版权问题,也不用担心图片加载慢。
|
||||
@@ -23,6 +23,13 @@
|
||||
## 2. 常见改动
|
||||
|
||||
### 加一条新世界线
|
||||
|
||||
> **2026-10-05 起推荐用内容后台**(门户顶栏最右边的铅笔 →「金钻宇宙」→「点亮一条」):填档案、下拉选外观,预览、发布就上线。
|
||||
> 后台发布的内容写在 `portal/content/site.js`(`window.JZ_CONTENT.universe`),`config.js` 末尾会用它**覆盖**下面写死的
|
||||
> `UNIVERSES` / `LOOKS`;`config.js` 里那两份只是兜底(内容文件读不到时用)。`GALAXY`、`EMPTY_LOOK` 不归后台管,还是改这个文件。
|
||||
>
|
||||
> 不用后台、直接改文件的话(比如本地调试):
|
||||
|
||||
1. `config.js` → `UNIVERSES` 里把对应的空槽(比如 `{ no: '0005', empty: true }`)换成完整档案:
|
||||
```js
|
||||
{ no: '0005', name: '名字', kind: '原创', tag: '一句话副标题', tags: ['标签1', '标签2'], desc: '档案正文' },
|
||||
@@ -37,8 +44,17 @@
|
||||
moons: [{ style: 'rock', r: 0.3, d: 2.6, speed: 0.5 }], // 可选:卫星(纯装饰)
|
||||
why: '为什么长这样(写给后来的人看)' },
|
||||
```
|
||||
- `orbit: [离中心距离, 第几条旋臂]`:距离 0~60,旋臂 0~3。别和别的星系放太近(差 8 以上比较好看)。
|
||||
- `orbit: [离中心距离, 第几条旋臂]`:距离 0~60,旋臂 0~3。**可以不写** —— 不写就交给 `layout.js` 自动排位(见下)。
|
||||
- 不写 `LOOKS` 的世界线会自动用 `EMPTY_LOOK`(全息线框的「未点亮」样子),放在外圈。
|
||||
|
||||
### 位置和补给线是怎么排的(`layout.js`,纯计算,可单独测试)
|
||||
1. **写了 `orbit` 的**(现在的 0000–0004):就放在那儿,补给线从核心连过去。
|
||||
2. **空槽**:按**编号**放在外圈固定槽位(从 `GALAXY.firstSlot` 号起,轮流分到各条旋臂)。只看自己的编号,点亮一个,别的空槽不挪。
|
||||
空槽的淡虚线接到离它最近、又不穿过别的星的那颗已点亮的星(没有就接核心)。
|
||||
3. **已点亮但没写 `orbit` 的**(后台新点亮的):自动在中圈的旋臂上挑位置 —— 跟核心、已有星系(连同卫星轨道)留足距离,
|
||||
各条旋臂尽量均匀;补给线接到「比它更靠近核心、离它最近」的那颗星,而且不能从别的星中间穿过。
|
||||
按编号从小到大一颗颗排,每颗只看排在前面的,所以**新加一条,已有的星和线都不动**。
|
||||
实测:连续点亮 10 条,已有的一次都没动,两两不挤,线不穿星。
|
||||
3. 刷新页面即可。HUD 上的「世界线 / 已点亮 / 空槽」数字是自动数的。
|
||||
|
||||
### 只换一颗星球的颜色
|
||||
@@ -54,18 +70,30 @@
|
||||
|
||||
---
|
||||
|
||||
## 3. 现有的星球风格(`planets.js` → `STYLES`)
|
||||
## 3. 现有的星球风格(`planets.js` → `STYLES`,中文名在 `STYLE_LABELS`)
|
||||
|
||||
| 风格 | 长什么样 | 四个颜色依次是 | 现在给谁用 / 为什么 |
|
||||
|---|---|---|---|
|
||||
| `crystal` | 多面体切面、每面颜色随朝向变、内部发光脉络 | 主色 / 副色 / 高光色 / 闪点 | 零号宇宙:晶钻超算本体 |
|
||||
| `paper` | 米白纸面、铅笔等高线、暗面排线、红笔圈、淡蓝涂色 | 纸色 / 铅笔色 / 红笔色 / 涂色 | 火柴人宇宙:小时候课上画的 |
|
||||
| `ice` | 纬向冰带、极冠、冰裂纹、冰面高光 | 冰白 / 冰蓝 / 裂纹色 / 极冠色 | 极寒世界:冰河期、-50℃ |
|
||||
| `neon` | 深紫地表、霓虹街区网格、闪烁窗灯 | 地表 / 霓虹 A / 霓虹 B / 窗灯 | 没落赛博城 |
|
||||
| `duality` | 一半白昼一半夜空,交界一条发光波浪线 | 白昼 / 云 / 夜空 / 夜云 | 善恶等级(设定还在酝酿,先按名字做;定了再换) |
|
||||
| `gas` | 卡通条纹气态行星 + 风暴眼 | 条纹 A / 条纹 B / 深色带 / 风暴 | 散落的无名星球、卫星 |
|
||||
| `rock` | 卡通陨坑岩石星 | 亮面 / 暗面 / 坑底 / 坑沿 | 散落的无名星球、卫星 |
|
||||
| `ghost` | 半透明全息线框球 | 线色 / 边缘色 / - / - | 空槽(未点亮) |
|
||||
内容后台「金钻宇宙」页的「星球风格」下拉、「外观预设」一览都来自这里(一览里是真实渲染)。2026-10-05 加了带「新」的 10 种。
|
||||
|
||||
| 风格 | 长什么样 | 现在给谁用 |
|
||||
|---|---|---|
|
||||
| `earth` 新 · 类地(卡通地球) | 蓝海 + 绿色大陆 + 沙漠块 + 极冠 + 慢慢飘的白云,海岸一圈墨线 | 后台新点亮的默认 |
|
||||
| `ocean` 新 · 海洋 | 几乎全是水,深浅两色 + 零星小岛 + 岛边浪线 + 条状云 | — |
|
||||
| `jungle` 新 · 丛林 | 深浅两层绿 + 一团团树冠 + 弯弯的河 + 雾 | — |
|
||||
| `desert` 新 · 荒漠 | 弯曲沙丘条纹 + 红色台地(墨线轮廓)+ 一点极冠 | — |
|
||||
| `tundra` 新 · 冻原 | 霜白和青灰 + 深色针叶林 + 结冰的湖 | — |
|
||||
| `ice` · 冰封 | 纬向冰带、极冠、冰裂纹、冰面高光 | 极寒世界 |
|
||||
| `lava` 新 · 熔岩 | 深色岩壳 + 发光裂缝和岩浆池(慢慢呼吸) | — |
|
||||
| `toxic` 新 · 毒雾 | 酸绿 / 黄绿扭曲气流 + 一点紫 + 冒泡亮点 | — |
|
||||
| `barren` 新 · 荒芜岩球 | 灰色岩面 + 大小两层陨坑(坑沿墨线、坑底更暗) | — |
|
||||
| `gas` · 气态巨星 | 卡通条纹 + 风暴眼 | 散落的无名星球、卫星 |
|
||||
| `icegiant` 新 · 冰巨星 | 蓝色细条纹 + 深色风暴眼 + 白色流云 | — |
|
||||
| `ringed` 新 · 带环巨星 | 气态巨星 + 一圈压低颜色的卡通扁环(**只有这个预设自带光环**) | — |
|
||||
| `crystal` · 晶体 | 多面体切面、每面颜色随朝向变、内部发光脉络 | 零号宇宙 |
|
||||
| `paper` · 铅笔纸面 | 米白纸面、铅笔等高线、暗面排线、红笔圈 | 火柴人宇宙 |
|
||||
| `neon` · 霓虹城 | 深紫地表、霓虹街区网格、闪烁窗灯 | 没落赛博城 |
|
||||
| `duality` · 善恶两半 | 一半白昼一半夜空,交界发光波浪线 | 善恶等级 |
|
||||
| `rock` · 小行星 | 卡通陨坑岩石 | 卫星、散落星球 |
|
||||
| `ghost` · 未点亮 | 半透明全息线框球 | 空槽 |
|
||||
|
||||
所有风格共用:三档卡通明暗(亮 / 中 / 暗)+ 冷色阴影(`shadow`)+ 很弱的轮廓光(`rim`)+ 墨线描边(`outline`,写 `null` 不描边)。
|
||||
大气辉光(`atm`)和光环(`ring`)都是**可选**的,默认关 —— 用户反馈过「罩子」「环」很突兀、辉光太曝。
|
||||
@@ -183,6 +211,6 @@ myStyle: {
|
||||
|
||||
## 10. 部署注意(踩过的坑)
|
||||
|
||||
- 静态文件可能被缓存。**改了 JS / CSS 一定要换版本号**,四处一起换:`portal/index.html` 里的 `universe.css?v=`、`config.js?v=`、底部模块脚本里的 `galaxy.js?v=`,以及 `galaxy.js` 里的 `import './planets.js?v='`。
|
||||
- 静态文件可能被缓存。**改了 JS / CSS 一定要换版本号**,几处一起换:`portal/universe.html` 里的 `universe-page.css?v=`、`gate.js?v=`、`config.js?v=`、底部模块脚本里的 `galaxy.js?v=`,以及 `galaxy.js` 里的 `import './planets.js?v='` / `'./layout.js?v='`。
|
||||
2026-10-05 踩过:一个坏掉的 galaxy.js 被缓存住,修好之后打开还是「加载不出来」。
|
||||
- 检查语法要按 ES 模块检查(把文件拷成 `.mjs` 再 `node --check`),按普通脚本检查会漏掉「重复声明」这类错误。
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,459 @@
|
||||
{
|
||||
"v": 1,
|
||||
"hero": {
|
||||
"tagline": "金钻的画、做的小工具、写的宇宙设定,还有各个平台的主页,都放在这儿了。随便逛逛。",
|
||||
"cta1": "逛画展",
|
||||
"cta2": "金钻宇宙",
|
||||
"notice": {
|
||||
"on": false,
|
||||
"text": "",
|
||||
"from": "",
|
||||
"to": ""
|
||||
}
|
||||
},
|
||||
"boards": {
|
||||
"home": "整个网站的大框架与内容总入口:板块总览、快捷切换。",
|
||||
"gallery": "金钻一路画下的画稿、渲染影像与特殊图片,随年份安静地排在一起,可自由翻看。",
|
||||
"apps": "开源的项目与闭源的工具分两行列出,并可按类型筛选。",
|
||||
"universe": "金钻编的平行世界,每一条是一个星系:点星系飞过去,看那条世界线的设定。",
|
||||
"links": "视频、图文、模型创作、开源、小店与邮箱;这些地方也能找到金钻。",
|
||||
"about": "网站制作者与所用开源组件鸣谢:金钻(内容 / 创作者)、苏达与大肥鱼(构建),以及 Lucide 图标库、OPPO Sans 字体。"
|
||||
},
|
||||
"gallery": [
|
||||
{
|
||||
"id": "g1",
|
||||
"type": "image",
|
||||
"date": "2024-02-29",
|
||||
"title": "(作品占位)",
|
||||
"desc": "素材已在交付版脱敏移除",
|
||||
"owner": "own",
|
||||
"hidden": false,
|
||||
"src": "exhibition/渲染与动画/20240229/没有图片.webp",
|
||||
"r": 1.5241
|
||||
}
|
||||
],
|
||||
"apps": [
|
||||
{
|
||||
"id": "a1",
|
||||
"name": "待会儿办",
|
||||
"en": "DO IT LATER",
|
||||
"type": "网页应用",
|
||||
"oss": true,
|
||||
"desc": "家庭共用的待办 / 提醒小应用:发布端一次录入,接收端点一下完成,两边实时同步;安卓端与网页面同源。",
|
||||
"ver": "v0.1",
|
||||
"size": "—",
|
||||
"status": "待上架",
|
||||
"url": "",
|
||||
"repo": "https://github.com/example-org/family-todo"
|
||||
},
|
||||
{
|
||||
"id": "a2",
|
||||
"name": "Juno 简中语言包",
|
||||
"en": "JUNO ZH-CN",
|
||||
"type": "游戏汉化",
|
||||
"oss": true,
|
||||
"desc": "《Juno: New Origins》非官方简体中文语言包:9,271 条全量译文 + 配套字体 + 可复现的校验工具链。译文由 DeepSeek 生成,仅对该游戏版本做过测试。",
|
||||
"ver": "1.4.105.0c",
|
||||
"size": "9.4 MB",
|
||||
"status": "开源仓库",
|
||||
"url": "https://github.com/example-org/juno-zh-cn",
|
||||
"repo": "",
|
||||
"btn": "前往仓库 →"
|
||||
},
|
||||
{
|
||||
"id": "a3",
|
||||
"name": "自助模板渲染",
|
||||
"en": "TEMPLATE RENDER",
|
||||
"type": "渲染出图",
|
||||
"oss": false,
|
||||
"desc": "传皮肤、挑模板,渲染出成品大图(标准压缩 + 无压缩)。支持卡密下单与在线支付,下完自动排队出图。",
|
||||
"ver": "v1",
|
||||
"size": "—",
|
||||
"status": "在线",
|
||||
"url": "/order/",
|
||||
"repo": "",
|
||||
"web": true
|
||||
}
|
||||
],
|
||||
"linkGroups": [
|
||||
{
|
||||
"id": "video",
|
||||
"name": "视频",
|
||||
"en": "VIDEO"
|
||||
},
|
||||
{
|
||||
"id": "feed",
|
||||
"name": "图文",
|
||||
"en": "FEED"
|
||||
},
|
||||
{
|
||||
"id": "create",
|
||||
"name": "模型 / 创作",
|
||||
"en": "CREATE"
|
||||
},
|
||||
{
|
||||
"id": "oss",
|
||||
"name": "开源",
|
||||
"en": "OPEN SOURCE"
|
||||
},
|
||||
{
|
||||
"id": "used",
|
||||
"name": "小店",
|
||||
"en": "SHOP"
|
||||
},
|
||||
{
|
||||
"id": "contact",
|
||||
"name": "联系 / 其他",
|
||||
"en": "CONTACT"
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"id": "bili",
|
||||
"group": "video",
|
||||
"key": "bili",
|
||||
"name": "哔哩哔哩",
|
||||
"en": "BILIBILI",
|
||||
"desc": "长视频",
|
||||
"url": "https://example.com/space"
|
||||
},
|
||||
{
|
||||
"id": "douyin",
|
||||
"group": "video",
|
||||
"key": "douyin",
|
||||
"name": "抖音",
|
||||
"en": "DOUYIN",
|
||||
"desc": "短视频",
|
||||
"url": "https://example.com/douyin"
|
||||
},
|
||||
{
|
||||
"id": "kuaishou",
|
||||
"group": "video",
|
||||
"key": "kuaishou",
|
||||
"name": "快手",
|
||||
"en": "KUAISHOU",
|
||||
"desc": "短视频",
|
||||
"url": "https://example.com/kuaishoutw"
|
||||
},
|
||||
{
|
||||
"id": "xiaohongshu",
|
||||
"group": "feed",
|
||||
"key": "xiaohongshu",
|
||||
"name": "小红书",
|
||||
"en": "REDNOTE",
|
||||
"desc": "图文 · 记录",
|
||||
"url": "https://example.com/xhs"
|
||||
},
|
||||
{
|
||||
"id": "cgmodel",
|
||||
"group": "create",
|
||||
"key": "cgmodel",
|
||||
"name": "CG模型网",
|
||||
"en": "CGMODEL",
|
||||
"desc": "3D模型 · 展示",
|
||||
"url": "https://example.com/cgmodel"
|
||||
},
|
||||
{
|
||||
"id": "codemao",
|
||||
"group": "create",
|
||||
"key": "codemao",
|
||||
"name": "编程猫社区",
|
||||
"en": "CODEMAO",
|
||||
"desc": "编程 · 作品集",
|
||||
"url": "https://example.com/codemao"
|
||||
},
|
||||
{
|
||||
"id": "steam",
|
||||
"group": "create",
|
||||
"key": "steam",
|
||||
"name": "Steam",
|
||||
"en": "STEAM",
|
||||
"desc": "壁纸引擎工坊",
|
||||
"url": "https://example.com/steam/"
|
||||
},
|
||||
{
|
||||
"id": "lang",
|
||||
"group": "oss",
|
||||
"key": "lang",
|
||||
"name": "Juno 简中语言包",
|
||||
"en": "JUNO ZH-CN",
|
||||
"desc": "游戏汉化 · 开源",
|
||||
"url": "https://github.com/example-org/juno-zh-cn"
|
||||
},
|
||||
{
|
||||
"id": "github",
|
||||
"group": "oss",
|
||||
"key": "github",
|
||||
"name": "GitHub",
|
||||
"en": "GITHUB",
|
||||
"desc": "开源",
|
||||
"url": "https://github.com/example-org"
|
||||
},
|
||||
{
|
||||
"id": "workshop",
|
||||
"group": "used",
|
||||
"key": "workshop",
|
||||
"name": "B站工坊",
|
||||
"en": "WORKSHOP",
|
||||
"desc": "模板定制 · 创意工坊 · 模型壁纸",
|
||||
"url": "https://example.com/workshop"
|
||||
},
|
||||
{
|
||||
"id": "xianyu",
|
||||
"group": "used",
|
||||
"key": "xianyu",
|
||||
"name": "闲鱼",
|
||||
"en": "GOOFISH",
|
||||
"desc": "模板定制 · 小店 · 工坊小物",
|
||||
"url": "https://example.com/xianyu"
|
||||
},
|
||||
{
|
||||
"id": "mail",
|
||||
"group": "contact",
|
||||
"key": "mail",
|
||||
"name": "邮箱",
|
||||
"en": "EMAIL",
|
||||
"desc": "feedback@example.com",
|
||||
"url": "mailto:feedback@example.com"
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"story": "「金钻」这名字,其实是一场小时候的误会。那会儿在《我的世界》里,钻石又硬又稀有,是我眼里最好用的矿物;又觉着现实里的黄金稀罕、不好置换。就这么一拍脑袋,把「游戏里最宝贝」和「现实里稀有」捏成了一个词——金钻。(如今倒是不怎么用「最」这个词了。)图标那抹彩色,是光的三原色和色彩的三原色——红黄蓝绿,凑到一块儿;从定下那天起就一直没改过,像把当年的心思原样锁在里头。回头再看:游戏里最强的早换成了下界合金,现实里比黄金稀少的金属也一抓一大把,毕竟人外有人、天外有天,很多东西的情况都是权衡来的。可这名字,是小时候的我起的——那就一直留着,延用下去吧。",
|
||||
"foot": "版权 © EXAMPLE.COM · 保留所有权利。金钻客栈为个人作品展示站;站外链接内容归各自平台与作者所有。",
|
||||
"cards": [
|
||||
{
|
||||
"k": "制作者",
|
||||
"h": "金钻",
|
||||
"p": "网站创作者 / 内容作者。画展、金钻宇宙、工具与开源内容与各平台入口的内容与设定都出自金钻。"
|
||||
},
|
||||
{
|
||||
"k": "网站构建",
|
||||
"h": "苏达 · 大肥鱼",
|
||||
"p": "苏达(Hermes 智能体)负责实现与部署;大肥鱼(DeepSeek Harness)协助页面核验与修复。前端为原生 HTML / CSS / JS 单文件,无构建工具。\n\n主站、自助模板渲染、待会儿办、本地开单后台共用同一套设计语言与动效规范;动效规范参考 Emil Kowalski 的 [skills](https://github.com/emilkowalski/skills)(MIT)。"
|
||||
},
|
||||
{
|
||||
"k": "图标库鸣谢",
|
||||
"h": "Lucide",
|
||||
"p": "全站线性图标来自 [Lucide](https://lucide.dev)(ISC License),以 inline `<symbol>` 方式内联,保持单文件、无外网依赖、24×24 线性 currentColor。"
|
||||
},
|
||||
{
|
||||
"k": "字体",
|
||||
"h": "OPPO Sans",
|
||||
"p": "正文使用 OPPO Sans(OPPO 免费商用字体),自托管 GB2312 子集 woff2(Regular / Bold);等宽字仍取系统字体栈。"
|
||||
},
|
||||
{
|
||||
"k": "像素字体",
|
||||
"h": "缝合像素字体",
|
||||
"p": "标题用的像素字是 TakWolf 的[缝合像素字体](https://github.com/TakWolf/fusion-pixel-font)(SIL OFL 1.1),只打包了页面上用到的字,协议原文在 `fonts/jz-pixel-OFL.txt`。"
|
||||
},
|
||||
{
|
||||
"k": "交流群",
|
||||
"h": "屑钻小窝",
|
||||
"p": "官方 QQ 群,群号 `123456789`。做图、下单、售后、闲聊都在这儿,欢迎来玩 —— [点这里加入 →](https://example.com/group-invite)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"universe": {
|
||||
"items": [
|
||||
{
|
||||
"no": "0000",
|
||||
"name": "零号宇宙",
|
||||
"kind": "主宇宙",
|
||||
"tag": "晶钻超算主宇宙",
|
||||
"desc": "门户主宇宙,也是晶钻超算本体:把平行宇宙压成盘符,逐条演算多世界线。其余编号都是它演算出的分支世界线,零号自身负责总调度与收束。",
|
||||
"tags": [
|
||||
"门户主宇宙",
|
||||
"晶钻超算",
|
||||
"多世界线演算"
|
||||
],
|
||||
"look": {
|
||||
"style": "crystal",
|
||||
"accent": "#FFD36E",
|
||||
"enter": "zoom",
|
||||
"r": 2.6,
|
||||
"orbit": [
|
||||
0.0,
|
||||
0
|
||||
],
|
||||
"why": "晶钻超算:多面体切面像钻石,内部有发光的演算脉络。",
|
||||
"moons": [
|
||||
{
|
||||
"style": "crystal",
|
||||
"r": 0.45,
|
||||
"d": 5.0,
|
||||
"speed": 0.35,
|
||||
"colors": [
|
||||
"#BFF4FF",
|
||||
"#8E7BFF",
|
||||
"#FFE59A",
|
||||
"#FFFFFF"
|
||||
]
|
||||
},
|
||||
{
|
||||
"style": "rock",
|
||||
"r": 0.32,
|
||||
"d": 6.6,
|
||||
"speed": 0.22
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"no": "0001",
|
||||
"name": "火柴人宇宙",
|
||||
"kind": "原创",
|
||||
"tag": "火柴人的冒险",
|
||||
"desc": "金钻小时候在课上天马行空画出来的世界线,《火柴人的冒险》就从这里开始。",
|
||||
"tags": [
|
||||
"金钻原创",
|
||||
"小时候的课堂",
|
||||
"火柴人的冒险"
|
||||
],
|
||||
"look": {
|
||||
"style": "paper",
|
||||
"accent": "#F6F1E4",
|
||||
"enter": "push",
|
||||
"r": 1.25,
|
||||
"orbit": [
|
||||
20.0,
|
||||
0
|
||||
],
|
||||
"why": "小时候课上画出来的:米白纸面、铅笔等高线、暗面排线、几个红笔圈。",
|
||||
"moons": [
|
||||
{
|
||||
"style": "paper",
|
||||
"r": 0.36,
|
||||
"d": 2.6,
|
||||
"speed": 0.6,
|
||||
"colors": [
|
||||
"#FFF8EC",
|
||||
"#2B2E45",
|
||||
"#E5544B",
|
||||
"#F2C14D"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"no": "0002",
|
||||
"name": "极寒世界",
|
||||
"kind": "原创",
|
||||
"tag": "冰河时期",
|
||||
"desc": "2030年代确认北大西洋环流(AMOC)减弱、气候转入长期寒冷;2040年高含水彗星「那迦」撞击北大西洋,水汽化为冰晶云遮蔽日照,冰河期开始。故事发生在2056年,冰河已持续16年,地表约-50℃(极端-90℃)。人类转入五大地下深垒。",
|
||||
"tags": [
|
||||
"金钻原创",
|
||||
"冰河时期",
|
||||
"那迦彗星",
|
||||
"五大深垒",
|
||||
"2056"
|
||||
],
|
||||
"look": {
|
||||
"style": "ice",
|
||||
"accent": "#9FE3FF",
|
||||
"enter": "rise",
|
||||
"r": 1.35,
|
||||
"orbit": [
|
||||
29.0,
|
||||
1
|
||||
],
|
||||
"why": "冰河期地球:纬向冰带、厚极冠、冰裂纹;旁边那颗小卫星是「那迦」彗星残骸。",
|
||||
"moons": [
|
||||
{
|
||||
"style": "rock",
|
||||
"r": 0.3,
|
||||
"d": 2.7,
|
||||
"speed": 0.5,
|
||||
"colors": [
|
||||
"#CFE6FF",
|
||||
"#8FB4E0",
|
||||
"#5C79B8",
|
||||
"#FFFFFF"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"no": "0003",
|
||||
"name": "没落赛博城",
|
||||
"kind": "二创",
|
||||
"tag": "史蒂夫的探险之旅",
|
||||
"desc": "金钻刚接触动画时随手做的二创世界线:史蒂夫穿过没落的赛博城,一路探险。",
|
||||
"tags": [
|
||||
"二创",
|
||||
"史蒂夫的探险之旅",
|
||||
"赛博废墟"
|
||||
],
|
||||
"look": {
|
||||
"style": "neon",
|
||||
"accent": "#C9A6FF",
|
||||
"enter": "warp",
|
||||
"r": 1.4,
|
||||
"orbit": [
|
||||
38.0,
|
||||
2
|
||||
],
|
||||
"why": "没落的赛博城:深紫地表、霓虹街区网格、零星还亮着的窗灯。",
|
||||
"moons": [
|
||||
{
|
||||
"style": "rock",
|
||||
"r": 0.28,
|
||||
"d": 3.0,
|
||||
"speed": 0.42,
|
||||
"colors": [
|
||||
"#3A2F66",
|
||||
"#2A2350",
|
||||
"#1A1535",
|
||||
"#FF5FD2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"style": "neon",
|
||||
"r": 0.22,
|
||||
"d": 3.8,
|
||||
"speed": 0.3
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"no": "0004",
|
||||
"name": "善恶等级",
|
||||
"kind": "原创",
|
||||
"tag": "设定待定",
|
||||
"desc": "这条世界线的设定还在酝酿中,先留好位置,等金钻想清楚再填。",
|
||||
"tags": [
|
||||
"金钻原创",
|
||||
"设定酝酿中"
|
||||
],
|
||||
"look": {
|
||||
"style": "duality",
|
||||
"accent": "#FFD36E",
|
||||
"enter": "orbit",
|
||||
"r": 1.3,
|
||||
"orbit": [
|
||||
46.0,
|
||||
3
|
||||
],
|
||||
"why": "设定还在酝酿,先按名字「善恶」做成两半:一半金色白昼,一半紫色夜空,交界一条发光的波浪线。设定定了再换。",
|
||||
"moons": [
|
||||
{
|
||||
"style": "gas",
|
||||
"r": 0.34,
|
||||
"d": 2.8,
|
||||
"speed": 0.45,
|
||||
"colors": [
|
||||
"#FFF0C8",
|
||||
"#F2B84B",
|
||||
"#2D1E57",
|
||||
"#FFFFFF"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"empty": 6
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,96 @@
|
||||
Fusion Pixel Font
|
||||
https://github.com/TakWolf/fusion-pixel-font
|
||||
|
||||
Copyright (c) 2022, TakWolf (https://takwolf.com).
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
@@ -0,0 +1,64 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>画展 · 金钻客栈</title>
|
||||
<meta name="description" content="金钻的画、渲染图和视频,按时间排。">
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<meta name="theme-color" content="#0D1020" media="(max-width: 760px) and (prefers-color-scheme: dark)">
|
||||
<link rel="icon" href="assets/gem.webp" type="image/webp">
|
||||
<link rel="preload" href="fonts/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="fonts/fusion-pixel-12.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=6">
|
||||
</head>
|
||||
<body data-page="gallery">
|
||||
<div class="jz-boot" id="jzBoot" aria-hidden="true"><div class="jz-boot-in"><canvas class="jz-boot-gem" width="168" height="168"></canvas><b class="jz-boot-name">金钻客栈</b><i class="jz-boot-bar"><i></i></i></div></div>
|
||||
<script>/* 加载动画:同一个标签页里只在第一次打开时放;系统要求「减少动效」就不放 */
|
||||
try{if(sessionStorage.getItem('jz-boot')||matchMedia('(prefers-reduced-motion: reduce)').matches){document.getElementById('jzBoot').remove()}else{document.documentElement.classList.add('booting')}}catch(e){document.getElementById('jzBoot').remove()}</script>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html" aria-current="page">画展</a><a href="tools.html">工具与开源</a><a href="universe.html">金钻宇宙</a><a href="links.html">平台入口</a><a href="about.html">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="/order/"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="admin/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head"><div class="zone num" aria-hidden="true" style="--zc:#F2C14D;--zc2:#E8913A">01</div><div><h1>画展</h1><p>画的图、渲染图和视频,按时间排。</p></div><div class="meta"><b id="gN">0</b> 件<span id="gViews" hidden><br>看过 <b id="gViewsU">0</b> 人</span></div></div>
|
||||
<div class="tools-bar">
|
||||
<div class="seg crystal" role="group" aria-label="按类型筛选" id="gType"><button type="button" data-f="all" aria-pressed="true">全部<em id="cAll"></em></button><button type="button" data-f="image" aria-pressed="false">图片<em id="cImage"></em></button><button type="button" data-f="video" aria-pressed="false">视频<em id="cVideo"></em></button><button type="button" data-f="special" aria-pressed="false">特殊<em id="cSpecial"></em></button></div>
|
||||
<button type="button" class="btn btn-crystal btn-sm" id="gMore" aria-expanded="false" aria-controls="gMorePanel"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5h18"/><path d="M6 12h12"/><path d="M10 19h4"/></svg>更多筛选</button>
|
||||
<button type="button" class="btn btn-crystal btn-sm" id="gSort" aria-pressed="true"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4v16"/><path d="m3 16 4 4 4-4"/><path d="M17 20V4"/><path d="m21 8-4-4-4 4"/></svg><span>最新的在前</span></button>
|
||||
<button type="button" class="btn btn-crystal btn-sm" id="gClear" hidden>清除筛选</button>
|
||||
</div>
|
||||
<div class="g-more crystal" id="gMorePanel" hidden>
|
||||
<div class="g-more-row"><b>谁做的</b><div class="seg" role="group" aria-label="按制作者筛选" id="gOwner"><button type="button" data-o="all" aria-pressed="true">都看</button><button type="button" data-o="own" aria-pressed="false">金钻做的<em id="cOwn"></em></button><button type="button" data-o="gift" aria-pressed="false">别人送的<em id="cGift"></em></button></div></div>
|
||||
<div class="g-more-row"><b>看过的</b><div class="seg" role="group" aria-label="看过的作品怎么排" id="gSeen"><button type="button" data-s="off" aria-pressed="true">不区分</button><button type="button" data-s="first" aria-pressed="false">放前面</button><button type="button" data-s="last" aria-pressed="false">放后面</button><button type="button" data-s="hide" aria-pressed="false">不显示</button></div></div>
|
||||
<div class="g-more-row m-years"><b>年份</b><div class="seg" role="group" aria-label="按年份筛选" id="gYearsM"></div></div>
|
||||
</div>
|
||||
<div class="gal">
|
||||
<nav class="years" aria-label="年份" id="gYears"><b>年份</b></nav>
|
||||
<div><div class="wall" id="gWall"></div><p class="note">点开看大图。全景图可以拖着转一圈,动态壁纸可以拖时间轴。</p></div>
|
||||
</div>
|
||||
</main>
|
||||
<div class="gbox" id="gbox" role="dialog" aria-modal="true" aria-label="看作品" hidden>
|
||||
<div class="gbox-bar"><div class="gbox-t"><b id="gbT"></b><span id="gbD"></span></div><a class="btn btn-crystal btn-sm" id="gbOrig" href="#" target="_blank" rel="noopener" hidden>原图</a><a class="btn btn-crystal btn-sm" id="gbBili" href="#" target="_blank" rel="noopener noreferrer" hidden>去 B 站看</a><button type="button" class="btn btn-crystal btn-sm" id="gbClose"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg>关闭</button></div>
|
||||
<div class="gbox-stage" id="gbStage">
|
||||
<img id="gbImg" alt="" hidden><span class="gbox-load" id="gbLoad" hidden>正在加载高清图…</span>
|
||||
<div class="gbox-vid" id="gbVidWrap" hidden><video id="gbVid" controls playsinline preload="metadata" controlslist="nodownload"></video><span class="v-wm" id="gbWm"></span></div>
|
||||
<iframe id="gbBiliFrame" hidden allow="fullscreen; autoplay" referrerpolicy="no-referrer" loading="lazy" title="B 站视频"></iframe>
|
||||
<canvas id="gbPano" hidden></canvas>
|
||||
<img id="gbWall" alt="" hidden draggable="false">
|
||||
</div>
|
||||
<div class="gbox-foot"><span class="gbox-hint" id="gbHint"></span><div class="gbox-wallbar" id="gbWallBar" hidden><button type="button" class="btn btn-crystal btn-sm" id="gbPlay" aria-label="播放 / 暂停">❚❚</button><input type="range" id="gbRange" min="0" max="0" value="0" aria-label="时间轴"><span id="gbLbl" class="num"></span></div><div class="g-links" id="gbLinks"></div></div>
|
||||
</div>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html" aria-current="page"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="/order/"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a></div></footer>
|
||||
<script src="assets/site-info.js?v=5"></script>
|
||||
<!-- 网站内容:内容后台发布时生成 content/site.js(window.JZ_CONTENT) -->
|
||||
<script src="content/site.js"></script>
|
||||
<script>/* 预览草稿:内容后台点「预览」会带 ?preview=1 打开;只有登录了内容后台的浏览器拿得到草稿(拿不到就还是正式内容) */
|
||||
if(/[?&]preview=1(&|$)/.test(location.search)) document.write('<script src="/order/api/cms/draft.js"><\/script>');</script>
|
||||
<script>window.__hdcEarly=(function(){try{return fetch("hd_cache/manifest.json",{cache:"force-cache"})}catch(e){return Promise.resolve(null)}})();</script>
|
||||
<script src="assets/pages.js?v=5"></script>
|
||||
<script src="assets/gallery.js?v=5"></script>
|
||||
<script src="assets/site.js?v=5"></script>
|
||||
<script src="assets/boot.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
+39
-4766
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>平台入口 · 金钻客栈</title>
|
||||
<meta name="description" content="金钻在各个平台的主页:视频、图文、模型、开源、小店和邮箱。">
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<meta name="theme-color" content="#0D1020" media="(max-width: 760px) and (prefers-color-scheme: dark)">
|
||||
<link rel="icon" href="assets/gem.webp" type="image/webp">
|
||||
<link rel="preload" href="fonts/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="fonts/fusion-pixel-12.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=6">
|
||||
</head>
|
||||
<body data-page="links">
|
||||
<div class="jz-boot" id="jzBoot" aria-hidden="true"><div class="jz-boot-in"><canvas class="jz-boot-gem" width="168" height="168"></canvas><b class="jz-boot-name">金钻客栈</b><i class="jz-boot-bar"><i></i></i></div></div>
|
||||
<script>/* 加载动画:同一个标签页里只在第一次打开时放;系统要求「减少动效」就不放 */
|
||||
try{if(sessionStorage.getItem('jz-boot')||matchMedia('(prefers-reduced-motion: reduce)').matches){document.getElementById('jzBoot').remove()}else{document.documentElement.classList.add('booting')}}catch(e){document.getElementById('jzBoot').remove()}</script>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html">画展</a><a href="tools.html">工具与开源</a><a href="universe.html">金钻宇宙</a><a href="links.html" aria-current="page">平台入口</a><a href="about.html">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="/order/"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="admin/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head"><div class="zone num" aria-hidden="true" style="--zc:#22B573;--zc2:#3C8527">04</div><div><h1>平台入口</h1><p>金钻在这些平台都有号,点一下就打开。</p></div><div class="meta"><b id="lN">0</b> 个</div></div>
|
||||
<div class="board crystal" id="lBoard"></div>
|
||||
</main>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="/order/"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" aria-current="page" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a></div></footer>
|
||||
<script src="assets/site-info.js?v=5"></script>
|
||||
<!-- 网站内容:内容后台发布时生成 content/site.js(window.JZ_CONTENT) -->
|
||||
<script src="content/site.js"></script>
|
||||
<script>/* 预览草稿:内容后台点「预览」会带 ?preview=1 打开;只有登录了内容后台的浏览器拿得到草稿(拿不到就还是正式内容) */
|
||||
if(/[?&]preview=1(&|$)/.test(location.search)) document.write('<script src="/order/api/cms/draft.js"><\/script>');</script>
|
||||
<script src="assets/pages.js?v=5"></script>
|
||||
<script src="assets/site.js?v=5"></script>
|
||||
<script src="assets/boot.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,142 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<meta name="robots" content="noindex">
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<title>金钻客栈 · 维护中</title>
|
||||
<link rel="icon" href="/assets/gem.webp" type="image/webp">
|
||||
<style>
|
||||
/* 金钻客栈 · 维护页(2026-10-06):「钻石在打磨中」
|
||||
一把像素钻石镐抬起 → 敲一下钻石 → 钻石被敲得一扁一弹(Q 弹)→ 迸出几粒光谱色的像素火花 → 一道白光扫过;
|
||||
下面一排 MC 方块进度条,每敲一下多亮一格,满了闪一下光谱色再重来。点一下钻石也会自己敲一下。
|
||||
动画都是 CSS(一轮 2.4 秒);脚本只管进度条跟拍子、点钻石敲一下、读群号;系统要求「减少动效」就全部静止。 */
|
||||
@font-face{font-family:'Fusion Pixel';src:url('/fonts/fusion-pixel-12.woff2') format('woff2');font-display:swap}
|
||||
:root{--ink:#1E2440;--ink-2:#4A5070;--ink-3:#737891;--bg:#FAFBFE;--mc:#3C8527;--mc-hi:#5BAA3C;--mc-lo:#1D4D13;
|
||||
--spec:linear-gradient(90deg,#FF9BB0 0%,#FFCC7A 25%,#94E3B4 50%,#8CC8FF 75%,#B9A2FF 100%);
|
||||
--pixel:'Fusion Pixel','PingFang SC','Microsoft YaHei',sans-serif;--T:2.4s}
|
||||
*{box-sizing:border-box}
|
||||
html,body{height:100%;margin:0}
|
||||
body{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px 16px;overflow:hidden;color:var(--ink);
|
||||
font:15px/1.7 'OPPO Sans',-apple-system,'PingFang SC','Microsoft YaHei',sans-serif;-webkit-font-smoothing:antialiased;background:var(--bg)}
|
||||
/* 背后几团慢慢漂的彩光(白光藏色) */
|
||||
.orbs{position:fixed;inset:-20%;z-index:-1;pointer-events:none}
|
||||
.orbs i{position:absolute;width:60vmax;height:60vmax;border-radius:50%;opacity:.55;animation:drift 18s ease-in-out infinite alternate}
|
||||
.orbs i:nth-child(1){left:-10%;top:-10%;background:radial-gradient(circle,rgba(255,182,204,.8),transparent 65%)}
|
||||
.orbs i:nth-child(2){right:-15%;top:5%;background:radial-gradient(circle,rgba(160,206,255,.8),transparent 65%);animation-duration:22s}
|
||||
.orbs i:nth-child(3){left:20%;bottom:-25%;background:radial-gradient(circle,rgba(170,238,204,.75),transparent 65%);animation-duration:26s}
|
||||
@keyframes drift{to{transform:translate(8vw,6vh) scale(1.1)}}
|
||||
|
||||
.card{position:relative;width:100%;max-width:440px;padding:30px 28px 26px;text-align:center;border-radius:12px;
|
||||
border:2px solid rgba(255,255,255,.95);background:linear-gradient(160deg,rgba(255,255,255,.86),rgba(255,255,255,.62));
|
||||
box-shadow:inset 0 0 0 1px rgba(30,36,64,.05),0 26px 50px -30px rgba(80,100,170,.5);
|
||||
-webkit-backdrop-filter:blur(10px) saturate(1.3);backdrop-filter:blur(10px) saturate(1.3)}
|
||||
|
||||
/* ---------- 打磨台:钻石 + 镐 + 火花 ---------- */
|
||||
.forge{position:relative;width:180px;height:150px;margin:0 auto 6px;cursor:pointer;-webkit-tap-highlight-color:transparent;outline:none}
|
||||
.forge .halo{position:absolute;left:50%;top:58px;width:120px;height:120px;margin:-60px 0 0 -60px;border-radius:50%;
|
||||
background:radial-gradient(circle,rgba(255,255,255,.95) 0%,rgba(166,213,255,.45) 38%,rgba(205,185,255,.18) 58%,transparent 72%);animation:halo var(--T) ease-in-out infinite}
|
||||
.forge .ring{position:absolute;left:50%;top:58px;width:104px;height:104px;margin:-52px 0 0 -52px;border-radius:50%;padding:2px;
|
||||
background:conic-gradient(from 0deg,#FFB3C3,#FFD99A,#A9EBC6,#A6D5FF,#CDB9FF,#FFB3C3);
|
||||
-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);
|
||||
opacity:.55;animation:spin 14s linear infinite}
|
||||
.forge .floor{position:absolute;left:50%;bottom:10px;width:70px;height:10px;margin-left:-35px;border-radius:50%;background:rgba(30,36,64,.14);filter:blur(2px);animation:floor var(--T) ease-in-out infinite}
|
||||
/* 钻石:平时轻轻漂浮;被敲那一下先扁后弹,最后落定 */
|
||||
.gem{position:absolute;left:50%;top:22px;width:72px;height:72px;margin-left:-36px;animation:float var(--T) ease-in-out infinite}
|
||||
.gem img{display:block;width:72px;height:72px;image-rendering:pixelated;transform-origin:50% 90%;animation:squash var(--T) cubic-bezier(.3,0,.3,1) infinite;
|
||||
filter:drop-shadow(-5px 9px 9px rgba(255,110,140,.25)) drop-shadow(5px 9px 9px rgba(70,140,255,.25))}
|
||||
/* 敲完一道白光斜着扫过钻石(只扫钻石的形状:用钻石图当遮罩) */
|
||||
.gem::after{content:"";position:absolute;inset:0;-webkit-mask:url('/assets/gem.webp') center/contain no-repeat;mask:url('/assets/gem.webp') center/contain no-repeat;
|
||||
background:linear-gradient(115deg,transparent 35%,rgba(255,255,255,.95) 50%,transparent 65%) no-repeat;background-size:260% 100%;background-position:120% 0;animation:glint var(--T) ease-out infinite}
|
||||
/* 像素钻石镐:绕握把末端转,抬起 → 猛地敲下 → 回弹 */
|
||||
/* 钻石镐:Minecraft 原版 16×16 物品图(assets/diamond-pickaxe.png),一格像素放大成 3px;
|
||||
平时就是原版图标的样子(0°、整像素对齐),只在挥的时候绕柄尾(左下角那格)转;顺时针转 = 往钻石那边砸 */
|
||||
.pick{position:absolute;left:22px;top:-17px;width:48px;height:48px;transform-origin:8px 43px;animation:swing var(--T) cubic-bezier(.5,0,.2,1) infinite}
|
||||
.pick img{display:block;width:48px;height:48px;image-rendering:pixelated;image-rendering:crisp-edges;filter:drop-shadow(1px 3px 2px rgba(30,36,64,.25))}
|
||||
/* 火花:五粒光谱色像素,敲中时迸出去、划个弧落下 */
|
||||
.spark{position:absolute;left:61px;top:23px;width:6px;height:6px;opacity:0;animation:spark var(--T) cubic-bezier(.2,.7,.4,1) infinite}
|
||||
.spark:nth-of-type(1){background:#FF8FAB;--dx:-30px;--dy:-26px}
|
||||
.spark:nth-of-type(2){background:#FFC24D;--dx:-6px;--dy:-44px;width:5px;height:5px}
|
||||
.spark:nth-of-type(3){background:#6FDB9A;--dx:22px;--dy:-36px}
|
||||
.spark:nth-of-type(4){background:#6FB8FF;--dx:-38px;--dy:-6px;width:4px;height:4px}
|
||||
.spark:nth-of-type(5){background:#B496FF;--dx:34px;--dy:-14px;width:4px;height:4px}
|
||||
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
@keyframes float{0%,100%{transform:translateY(0)}25%{transform:translateY(-6px)}}
|
||||
/* 一轮 2.4s:0% 原版图标的样子 → 28% 往后抡起 → 36–38% 砸下、镐尖碰到钻石顶(敲中)→ 弹开、落回 0° */
|
||||
@keyframes swing{0%{transform:rotate(0)}28%{transform:rotate(-38deg)}36%{transform:rotate(16deg)}38%{transform:rotate(14deg)}47%{transform:rotate(4deg)}56%,100%{transform:rotate(0)}}
|
||||
@keyframes squash{0%,37%{transform:scale(1,1)}40%{transform:scale(1.14,.82)}46%{transform:scale(.92,1.1)}53%{transform:scale(1.04,.97)}60%,100%{transform:scale(1,1)}}
|
||||
@keyframes spark{0%,37%{opacity:0;transform:translate(0,0)}39%{opacity:1;transform:translate(calc(var(--dx)*.25),calc(var(--dy)*.4))}58%{opacity:1;transform:translate(var(--dx),var(--dy))}74%{opacity:0;transform:translate(calc(var(--dx)*1.3),calc(var(--dy)*.2 + 26px))}100%{opacity:0}}
|
||||
@keyframes glint{0%,42%{background-position:120% 0}64%,100%{background-position:-20% 0}}
|
||||
@keyframes halo{0%,37%,100%{transform:scale(1);opacity:.9}42%{transform:scale(1.14);opacity:1}}
|
||||
@keyframes floor{0%,100%{transform:scale(1);opacity:1}25%{transform:scale(.82);opacity:.7}40%{transform:scale(1.12);opacity:1}}
|
||||
|
||||
/* ---------- 字 ---------- */
|
||||
h1{margin:4px 0 2px;font:400 36px/1.2 var(--pixel);letter-spacing:.04em;-webkit-font-smoothing:none}
|
||||
.tag{display:inline-flex;align-items:center;gap:8px;height:28px;padding:0 12px;border-radius:4px;background:rgba(255,255,255,.75);
|
||||
box-shadow:inset 0 0 0 1px rgba(30,36,64,.06);font-size:13px;font-weight:700;color:var(--ink-2);margin-bottom:14px}
|
||||
.dots i{font-style:normal;animation:dot 1.2s steps(1) infinite}
|
||||
.dots i:nth-child(2){animation-delay:.2s}.dots i:nth-child(3){animation-delay:.4s}
|
||||
@keyframes dot{0%,100%{opacity:.15}40%{opacity:1}}
|
||||
p{margin:0 0 4px;color:var(--ink-2)}
|
||||
|
||||
/* ---------- MC 方块进度条:每敲一下亮一格,满了闪一下光谱色再从头来 ---------- */
|
||||
.blocks{display:grid;grid-template-columns:repeat(8,1fr);gap:4px;margin:20px auto 18px;max-width:300px;padding:5px;border-radius:6px;
|
||||
background:rgba(30,36,64,.06);box-shadow:inset 0 2px 0 rgba(30,36,64,.08)}
|
||||
.blocks i{height:18px;border-radius:2px;background:#E9ECF4;box-shadow:inset 0 2px 0 #fff,inset 0 -3px 0 #C9CDD8;transition:background .12s,box-shadow .12s}
|
||||
.blocks i.on{background:var(--mc);box-shadow:inset 0 2px 0 var(--mc-hi),inset 0 -3px 0 var(--mc-lo);animation:pop .3s cubic-bezier(.34,1.56,.64,1)}
|
||||
@keyframes pop{0%{transform:scale(.6)}100%{transform:scale(1)}}
|
||||
.blocks.flash i{animation:rainbow .6s ease}
|
||||
.blocks.flash i:nth-child(8n+1){--c:#FF9BB0}.blocks.flash i:nth-child(8n+2){--c:#FFB98A}.blocks.flash i:nth-child(8n+3){--c:#FFCC7A}.blocks.flash i:nth-child(8n+4){--c:#94E3B4}
|
||||
.blocks.flash i:nth-child(8n+5){--c:#7FD6C8}.blocks.flash i:nth-child(8n+6){--c:#8CC8FF}.blocks.flash i:nth-child(8n+7){--c:#A6A9FF}.blocks.flash i:nth-child(8n+8){--c:#B9A2FF}
|
||||
@keyframes rainbow{0%,60%{background:var(--c);box-shadow:inset 0 2px 0 rgba(255,255,255,.7),inset 0 -3px 0 rgba(30,36,64,.15);transform:translateY(-3px)}100%{transform:none}}
|
||||
|
||||
small{display:block;margin-top:4px;color:var(--ink-3);font-size:12.5px}
|
||||
|
||||
@media (max-width:420px){.card{padding:26px 18px 22px}h1{font-size:30px}}
|
||||
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none !important}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="orbs" aria-hidden="true"><i></i><i></i><i></i></div>
|
||||
<main class="card">
|
||||
<div class="forge" id="forge" role="img" aria-label="金钻正在打磨钻石(点一下也能帮忙敲一下)" tabindex="0">
|
||||
<span class="halo"></span><span class="ring"></span><span class="floor"></span>
|
||||
<div class="gem"><img src="/assets/gem.webp" alt="" width="72" height="72"></div>
|
||||
<i class="spark"></i><i class="spark"></i><i class="spark"></i><i class="spark"></i><i class="spark"></i>
|
||||
<div class="pick" aria-hidden="true"><img src="/assets/diamond-pickaxe.png" alt="" width="48" height="48"></div>
|
||||
</div>
|
||||
<h1>金钻客栈</h1>
|
||||
<div class="tag">正在打磨中<span class="dots" aria-hidden="true"><i>.</i><i>.</i><i>.</i></span></div>
|
||||
<p>网站在升级,稍后就回来。</p>
|
||||
<p>你的订单和作品都不受影响。</p>
|
||||
<div class="blocks" id="blocks" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></div>
|
||||
<small id="qq">如有急事,可通过平时联系我的渠道找到我</small>
|
||||
</main>
|
||||
<script src="/assets/site-info.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
/* 群号从站点信息读(有就写上) */
|
||||
var S = window.JZ_SITE; if (S && S.qq) document.getElementById('qq').textContent = '有急事来 QQ 群找金钻:' + (S.qqName || '') + ' ' + S.qq;
|
||||
/* 进度条:跟着镐的节奏走 —— 镐每转一轮(animationiteration)在敲中那一刻(第 38%)亮一格;第 9 下整排闪一下光谱色、清空重来 */
|
||||
var bl = document.getElementById('blocks'), cells = bl.querySelectorAll('i'), pick = document.querySelector('.pick'), n = 0, T = 2400;
|
||||
function hit() {
|
||||
if (n >= cells.length) { bl.classList.remove('flash'); void bl.offsetWidth; bl.classList.add('flash'); [].forEach.call(cells, function (c) { c.classList.remove('on'); }); n = 0; return; }
|
||||
cells[n++].classList.add('on');
|
||||
}
|
||||
function loop() { setTimeout(hit, T * .38); }
|
||||
loop(); pick.addEventListener('animationiteration', loop);
|
||||
/* 点一下钻石:它自己也被敲一下(重放一次扁 → 弹 + 火花) */
|
||||
var f = document.getElementById('forge'), img = f.querySelector('.gem img'), sp = f.querySelectorAll('.spark');
|
||||
function tap() {
|
||||
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
var a = img.animate([{ transform: 'scale(1,1)' }, { transform: 'scale(1.16,.8)', offset: .2 }, { transform: 'scale(.9,1.12)', offset: .5 }, { transform: 'scale(1.04,.97)', offset: .75 }, { transform: 'scale(1,1)' }], { duration: 480, easing: 'cubic-bezier(.3,0,.3,1)', composite: 'replace' });
|
||||
[].forEach.call(sp, function (s) { var cs = getComputedStyle(s); s.animate([{ opacity: 1, transform: 'translate(0,0)' }, { opacity: 1, transform: 'translate(calc(' + cs.getPropertyValue('--dx') + '),' + cs.getPropertyValue('--dy') + ')', offset: .55 }, { opacity: 0, transform: 'translate(calc(' + cs.getPropertyValue('--dx') + ' * 1.3),30px)' }], { duration: 620, easing: 'cubic-bezier(.2,.7,.4,1)' }); });
|
||||
}
|
||||
f.addEventListener('click', tap);
|
||||
f.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); tap(); } });
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,38 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>工具与开源 · 金钻客栈</title>
|
||||
<meta name="description" content="金钻做的小工具和开源项目。">
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<meta name="theme-color" content="#0D1020" media="(max-width: 760px) and (prefers-color-scheme: dark)">
|
||||
<link rel="icon" href="assets/gem.webp" type="image/webp">
|
||||
<link rel="preload" href="fonts/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="fonts/fusion-pixel-12.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=6">
|
||||
</head>
|
||||
<body data-page="tools">
|
||||
<div class="jz-boot" id="jzBoot" aria-hidden="true"><div class="jz-boot-in"><canvas class="jz-boot-gem" width="168" height="168"></canvas><b class="jz-boot-name">金钻客栈</b><i class="jz-boot-bar"><i></i></i></div></div>
|
||||
<script>/* 加载动画:同一个标签页里只在第一次打开时放;系统要求「减少动效」就不放 */
|
||||
try{if(sessionStorage.getItem('jz-boot')||matchMedia('(prefers-reduced-motion: reduce)').matches){document.getElementById('jzBoot').remove()}else{document.documentElement.classList.add('booting')}}catch(e){document.getElementById('jzBoot').remove()}</script>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html">画展</a><a href="tools.html" aria-current="page">工具与开源</a><a href="universe.html">金钻宇宙</a><a href="links.html">平台入口</a><a href="about.html">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="/order/"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="admin/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head"><div class="zone num" aria-hidden="true" style="--zc:#4F86E8;--zc2:#2E5BD8">02</div><div><h1>工具与开源</h1><p>金钻做的小工具。开源的可以去看代码。</p></div><div class="meta"><b id="tN">0</b> 个</div></div>
|
||||
<div class="tools-bar"><div class="seg crystal" role="group" aria-label="按类型筛选" id="tSeg"></div></div>
|
||||
<div id="tRows"></div>
|
||||
</main>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="/order/"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" aria-current="page" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a></div></footer>
|
||||
<script src="assets/site-info.js?v=5"></script>
|
||||
<!-- 网站内容:内容后台发布时生成 content/site.js(window.JZ_CONTENT) -->
|
||||
<script src="content/site.js"></script>
|
||||
<script>/* 预览草稿:内容后台点「预览」会带 ?preview=1 打开;只有登录了内容后台的浏览器拿得到草稿(拿不到就还是正式内容) */
|
||||
if(/[?&]preview=1(&|$)/.test(location.search)) document.write('<script src="/order/api/cms/draft.js"><\/script>');</script>
|
||||
<script src="assets/pages.js?v=5"></script>
|
||||
<script src="assets/site.js?v=5"></script>
|
||||
<script src="assets/boot.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,79 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>金钻宇宙 · 金钻客栈</title>
|
||||
<meta name="description" content="金钻编的平行世界:每一条世界线是一个星系,点开看设定。">
|
||||
<meta name="theme-color" content="#FAFBFE">
|
||||
<meta name="theme-color" content="#0D1020" media="(max-width: 760px) and (prefers-color-scheme: dark)">
|
||||
<link rel="icon" href="assets/gem.webp" type="image/webp">
|
||||
<link rel="preload" href="fonts/OPPOSans-B.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="fonts/fusion-pixel-12.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="assets/site.css?v=6">
|
||||
<link rel="stylesheet" href="assets/universe/universe-page.css?v=5">
|
||||
<script type="importmap">{"imports":{"three":"./assets/vendor/three.module.min.js"}}</script>
|
||||
</head>
|
||||
<body data-page="universe" class="uni">
|
||||
<div class="jz-boot" id="jzBoot" aria-hidden="true"><div class="jz-boot-in"><canvas class="jz-boot-gem" width="168" height="168"></canvas><b class="jz-boot-name">金钻客栈</b><i class="jz-boot-bar"><i></i></i></div></div>
|
||||
<script>/* 加载动画:同一个标签页里只在第一次打开时放;系统要求「减少动效」就不放 */
|
||||
try{if(sessionStorage.getItem('jz-boot')||matchMedia('(prefers-reduced-motion: reduce)').matches){document.getElementById('jzBoot').remove()}else{document.documentElement.classList.add('booting')}}catch(e){document.getElementById('jzBoot').remove()}</script>
|
||||
<div class="orbs" aria-hidden="true"><i class="o1"></i><i class="o2"></i><i class="o3"></i><i class="o4"></i><i class="o5"></i></div>
|
||||
<header class="top"><div class="wrap top-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a><nav class="nav" aria-label="导航"><a href="index.html">首页</a><a href="gallery.html">画展</a><a href="tools.html">工具与开源</a><a href="universe.html" aria-current="page">金钻宇宙</a><a href="links.html">平台入口</a><a href="about.html">关于</a></nav><div class="desk-btn"><a class="btn-pill" href="/order/"><span class="ic" aria-hidden="true"></span>自助渲染<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg></a></div><a class="cms-ent" href="admin/" aria-label="内容管理" title="内容管理"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg></a></div></header>
|
||||
<main class="wrap">
|
||||
<div class="room-head"><div class="zone num" aria-hidden="true" style="--zc:#9A6BE0;--zc2:#3FC9C4">03</div><div><h1>金钻宇宙</h1><p>金钻编的平行世界,每一条是一个星系。点星系或者下面的卡片,飞过去看设定。</p></div><div class="meta"></div></div>
|
||||
<section class="skywin" id="skywin" aria-label="金钻宇宙星系图"><div class="stage" id="uStage"><canvas id="uGl" tabindex="0" aria-label="星系图:每条世界线是一个星系,点名牌或星球打开档案;下面的卡片可以做同样的事"></canvas><div class="labels" id="uLabels"></div><div class="hud" id="uHud"><span>世界线<b id="uAll">11</b></span><span>已点亮<b id="uLit">5</b></span><span>空槽<b id="uEmpty">6</b></span></div><aside class="panel" id="uPanel" aria-live="polite"></aside><div class="ctl"><button class="btn" id="uBack" type="button">回到星系图</button><button class="btn" id="uFull" type="button" aria-pressed="false">全屏</button></div><p class="tip">点星系看档案 · 拖动转视角 · Ctrl + 滚轮缩放</p><div class="ugate" id="uGate" aria-hidden="true"><div class="ugate-core"><span class="ugate-ring r1"></span><span class="ugate-ring r2"></span><span class="ugate-ring r3"></span><i class="gem-img"></i></div>
|
||||
<div class="ugate-txt"><b>金钻宇宙</b><span id="uGateMsg">正在打开星门…</span></div><div class="ugate-slots" id="uGateSlots"></div></div></div></section>
|
||||
<p class="sky-hint">在星图里拖动是转视角、双指缩放;要翻页,在星图外面滑</p>
|
||||
<h2 class="row-title">世界线档案</h2>
|
||||
<div class="uni-list" id="uniList"></div>
|
||||
<div class="uslots" aria-label="空槽" id="uniSlots"></div>
|
||||
</main>
|
||||
<nav class="tabbar" aria-label="导航"><a href="index.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/><path d="M10 21v-6h4v6"/></svg><span>首页</span></a><a href="gallery.html"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/></svg><span>画展</span></a><a class="mid" href="/order/"><i aria-hidden="true"></i><span>渲染</span></a><a href="universe.html" aria-current="page"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M4.2 15.6c-1.6 2.5 4.2 2.4 9.6-.2s9-6.6 7.5-8.6c-.8-1-2.9-.9-5.4 0"/></svg><span>宇宙</span></a><button type="button" data-sheet="more" aria-expanded="false" aria-controls="more"><i class="ic-a"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg></i><i class="ic-b"><svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg></i><span class="lb-a">更多</span><span class="lb-b">收起</span></button></nav>
|
||||
<div class="sheet" id="more" hidden><div class="panel"><nav class="more-grid" aria-label="更多"><a href="tools.html" style="--zc:#4F86E8;--zc2:#2E5BD8"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg></i><span>工具与开源</span></a><a href="links.html" style="--zc:#22B573;--zc2:#3C8527"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg></i><span>平台入口</span></a><a href="about.html" style="--zc:#E0533D;--zc2:#E8913A"><i><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></i><span>关于</span></a></nav><p class="more-qq">QQ 群:屑钻小窝 123456789</p></div></div>
|
||||
<footer class="foot-site"><div class="wrap foot-in"><a class="brand" href="index.html"><i class="gem-img" aria-hidden="true"></i><b>金钻客栈</b></a></div></footer>
|
||||
<script src="assets/site-info.js?v=5"></script>
|
||||
<!-- 网站内容:内容后台发布时生成 content/site.js(window.JZ_CONTENT) -->
|
||||
<script src="content/site.js"></script>
|
||||
<script>/* 预览草稿:内容后台点「预览」会带 ?preview=1 打开;只有登录了内容后台的浏览器拿得到草稿(拿不到就还是正式内容) */
|
||||
if(/[?&]preview=1(&|$)/.test(location.search)) document.write('<script src="/order/api/cms/draft.js"><\/script>');</script>
|
||||
<script src="assets/universe/config.js?v=5"></script>
|
||||
<script src="assets/pages.js?v=5"></script>
|
||||
<script src="assets/site.js?v=5"></script>
|
||||
<script src="assets/boot.js?v=5"></script>
|
||||
<script src="assets/universe/gate.js?v=5"></script>
|
||||
<script type="module">
|
||||
import { mountGalaxy } from './assets/universe/galaxy.js?v=5';
|
||||
const $ = id => document.getElementById(id), CFG = window.JZ_UNIVERSE;
|
||||
const win = $('skywin'), stage = $('uStage');
|
||||
const mob = () => innerWidth < 760, full = () => win.classList.contains('full');
|
||||
let api, cur = null;
|
||||
// 手机上档案卡也在星图窗里(底部抽屉),星球挪到上半个窗:一眼同时看到星球和档案
|
||||
function mark(no) { document.querySelectorAll('.ucell,.uslots button').forEach(b => b.setAttribute('aria-current', String(b.dataset.no === no))); }
|
||||
try {
|
||||
api = mountGalaxy({ stage, canvas: $('uGl'), labels: $('uLabels'), panel: $('uPanel'), back: $('uBack'), hud: $('uHud'),
|
||||
layout: () => mob() ? { x: 0, y: 0.26 } : { x: 0.17, y: 0 },
|
||||
wheelZoom: () => full(),
|
||||
onReady: () => window.JZGate && window.JZGate.open(), // 第一帧画好:星门打开,镜头接着俯冲进来
|
||||
// start:开始飞(列表马上高亮、旧的档案先收起);arrive:镜头快到了(档案这时才出来,和星球落定同步)
|
||||
onFocus: u => { cur = u; mark(u ? u.no : null); },
|
||||
counts: (a, l, e) => { $('uAll').textContent = a; $('uLit').textContent = l; $('uEmpty').textContent = e; } });
|
||||
} catch (e) { window.JZGate && window.JZGate.fail('这台设备打不开 3D 星图(' + e.message + '),下面的档案照样能看'); }
|
||||
// 深链:universe.html#0001 → 星系图好了就飞过去(旧的单页地址 /#0001 也会跳到这里)
|
||||
const deep = (location.hash || '').replace(/^#/, '');
|
||||
if (api && /^\d{4}$/.test(deep)) setTimeout(() => api.fly(deep), 900);
|
||||
// 点下面的卡片:先把窗户滚到眼前,再飞过去
|
||||
document.querySelectorAll('.ucell,.uslots button').forEach(b => b.addEventListener('click', () => {
|
||||
if (!api) return;
|
||||
win.scrollIntoView({ block: 'center', behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' });
|
||||
setTimeout(() => api.fly(b.dataset.no), 350);
|
||||
}));
|
||||
// 全屏:窗户铺满屏幕(滚轮直接缩放;手机上档案卡变成底部抽屉)
|
||||
const fb = $('uFull');
|
||||
function setFull(on) { win.classList.toggle('full', on); document.body.classList.toggle('sky-full', on); fb.textContent = on ? '退出全屏' : '全屏';
|
||||
fb.setAttribute('aria-pressed', String(on)); api && api.resize(); }
|
||||
fb.addEventListener('click', () => setFull(!full()));
|
||||
addEventListener('keydown', e => { if (e.key === 'Escape' && full() && !cur) setFull(false); });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+123
-16
@@ -19,6 +19,7 @@
|
||||
7. [部署与运维](#7-部署与运维)
|
||||
8. [测试与验证](#8-测试与验证)
|
||||
9. [已知未验证 / 待确认](#9-已知未验证--待确认)
|
||||
10. [内容后台(2026-10-05 晚实现)](#10-内容后台2026-10-05-晚实现)
|
||||
|
||||
---
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
|
||||
| 目录 / 文件 | 是什么 | 细节文档 |
|
||||
|---|---|---|
|
||||
| `portal/` | 门户(整个网站):首页 / 画展 / 工具与开源 / 金钻宇宙 / 平台入口 / 关于,单文件 `index.html` + 资源 | 本文第 5、6 节;`portal/assets/universe/交接说明.md`(星系图) |
|
||||
| `portal/` | 门户(整个网站):`index.html` 首页、`gallery.html` 画展、`tools.html` 工具与开源、`universe.html` 金钻宇宙、`links.html` 平台入口、`about.html` 关于(**2026-10-06 起是多页,样子以设计预览站为准**)+ `assets/` `fonts/` `content/` `admin/` | 本文第 2.7、5、6 节;`portal/assets/universe/交接说明.md`(星系图) |
|
||||
| `order/` | 自助模板渲染(下单页)`index.html` + `skincheck.js` | 本文第 6.2 节 |
|
||||
| `backend/backend-site/` | 网站后端:`server.py`(全部服务端逻辑)、`store.py`(数据库)、`admin.py`(命令行管理)、`pngcheck.py`(PNG 结构核验)、`tests/` | `backend/backend-site/交接说明.md`、`回执-Claude.md` |
|
||||
| `backend/backend-tools/` | 店主电脑上的一整套:渲染机 `ys_worker.py`、开单后台 `ys_admin.py`、本机开单 `ys_local.py` + `local.html`、Blender 出图脚本 `make_order.py`、各种启动脚本 | `backend/backend-tools/交接说明.md`、`回执-Claude.md` |
|
||||
@@ -85,7 +86,7 @@
|
||||
|
||||
`backend-tools/local.html` 换成跟网站 / 后台同一套样子;补上原来没写样式的分辨率选择、没绑事件的「清空」;整页接收拖拽;按勾选顺序标号;预计耗时。`ys_local.py` 没动。
|
||||
|
||||
### 2.5 本次提交 · 金钻宇宙换成星系图 + 推送前审查
|
||||
### 2.5 `09b229d` · 金钻宇宙换成星系图 + 推送前审查
|
||||
|
||||
- 门户「金钻宇宙」板块:**删掉**启动仪式、宇宙首屏晶体、盘符机架、读盘舱;**换成**星系图(three.js,懒加载)+ 窗下世界线卡片。
|
||||
- 世界线数据只剩一份:`portal/assets/universe/config.js`(主脚本也读它)。
|
||||
@@ -93,6 +94,56 @@
|
||||
- 审查修掉的后端问题:`add_call` 写库失败会打断渲染机回传;多进程同时首启会重复导入呼叫记录;撤销「处理过了」没清时间。数据库测试加一条,共 38 条。
|
||||
- 本文档。
|
||||
|
||||
### 2.6 内容后台 + 新世界线自动排位 + 星球预设
|
||||
|
||||
- **内容后台**(第 10 节):网站上所有展示内容在网页后台里改 —— 账号密码登录(首次 `admin/admin` 强制改密)、草稿自动保存、预览、发布、回滚、画展传图。
|
||||
后端 `backend-site/cms.py`(挂在 `server.py` 的 `/api/cms/*`),页面 `portal/admin/`,命令行 `admin.py user …`。
|
||||
- **门户 / 下单页改成读内容文件**:`portal/content/site.js`(`window.JZ_CONTENT`)、`order/content/order.js`(`window.JZ_ORDER`),后台发布时生成;代码里写死的数据降级为兜底。
|
||||
- 门户顶栏最右边加内容后台入口:一个不带字的淡色铅笔图标(无边框,hover 稍亮)。
|
||||
- **星系图排布** `layout.js`:新点亮的世界线自动排到中圈不挤的位置,补给线接到附近更靠里的星(不穿星);空槽按编号固定在外圈;**新加一条,已有的星和线都不动**。
|
||||
- **星球预设**从 7 种加到 18 种:类地(卡通地球)/ 海洋 / 丛林 / 荒漠 / 冻原 / 熔岩 / 毒雾 / 荒芜岩球 / 冰巨星 / 带环巨星(光环只有这个预设才有)。
|
||||
- 星图名牌 / 档案卡的文字一律转义(内容来自后台,不能当 HTML 拼)。
|
||||
- 新增 `tests/内容后台测试.py`(78 条);端到端浏览器流程 36 条(第 8 节)。
|
||||
- 推送后全量细审又修了:部署漏配(没设 `YS_PORTAL_DIR` / 缺 `content/site.json`)时内容后台拒绝工作,不会建空的第一版、一发布清空网站;同时最多 2 个 scrypt 在算(内存上限 256M);登录冷却记录定期清理;发布冲突给「丢掉我的草稿 / 用我的覆盖」二选一(原来会卡死在冲突里);草稿没存上、还有图在上传时不让发布;价格 / 付款文件只在这次真改了才写(不覆盖 `admin.py price` 的改动);排位在世界线很多时分档放宽、40 条也不重叠;删掉门户里旧启动仪式留下的死数据。
|
||||
|
||||
### 2.7 2026-10-06 · 全站按设计预览站重做 + 加载动画 + 宇宙开场星门 + 内容后台接住真实画展
|
||||
|
||||
- **门户从单页(`#/板块` 切换)改成六个独立页面**,标记、样式、交互全部照设计预览站(http://161.33.11.66/):
|
||||
`index / gallery / tools / universe / links / about.html`,共用 `assets/site.css`(预览站原样式 + 末尾一段正式站补充)、`assets/site.js`(预览站原交互:流动背景、视差、卡片倾斜、滚动浮现、翻牌、手机「更多」)。
|
||||
内容照旧全部读 `content/site.js`(内容后台发布的),由 `assets/pages.js` 按预览站的标记填进去;画展的真功能在 `assets/gallery.js`。
|
||||
- **画展**(`gallery.js`):样子是预览站的作品墙 + 年份栏 + 白色毛玻璃大图层;原来的功能一样没少 ——
|
||||
类型 / 谁做的 / 年份→月份筛选、最新 / 最早排序、看过的放前 / 放后 / 不显示、hd_cache 先轻后重的高清、本站 mp4(优先网页版副本)、B 站播放器、全景球面环视、动态壁纸时间轴、观展统计 `/hit` + `view_stats.json`、作品外链。
|
||||
作品墙改成 JS 按「最矮的一列」投放(预览站用 CSS 分栏,330 件时顺序会竖着走)。
|
||||
- **旧地址兼容**:`/#/gallery`、`/#/apps`、`/#/universe`、`/#0001` 等会自动跳到新页面(`universe.html#0001` 打开就飞到那条世界线)。
|
||||
- **加载动画(新)** `assets/boot.js`:像素钻石一块块从底往上垒成形 → 白光扫过 →「金钻客栈」逐字弹出 → 光谱进度条跟真实加载走 → 幕布上收。只在同一个标签页第一次打开时放、最少 1.25 秒、最多等 3 秒、点一下可跳过、「减少动效」时不放。
|
||||
- **金钻宇宙开场(新)** `assets/universe/gate.js`:three.js 下载 / 星系生成期间,星图窗里是一道「星门」(钻石 + 三圈光谱环 + 一排世界线格子按编号点亮);星系第一帧画好就光环外炸、格子散开、淡出,接上星系图自己的镜头俯冲。打不开 3D 时停在说明文字上。
|
||||
- **站点固定信息只放一处**:`portal/assets/site-info.js`(`window.JZ_SITE`:域名 / QQ 群号 / 群名 / 加群链接 / 备案号 / 反馈邮箱)。门户六页、下单页、关于页都读它。
|
||||
**仓库里是占位;正式服务器上只替换这一个文件**(以前要在好几个页面里改,容易漏 —— 10-06 就漏过)。
|
||||
- **下单页**对齐预览站:全站同一个顶栏 / 底栏 / 页脚、宽版面、落地页改成「怎么下单?」两张路卡 + 「下过单了?」条 + 模板样图(用 400px 的 jpg)+ 分辨率;之后的步骤卡片照预览站的晶体面板。**按钮 id、下单逻辑、接口一个没动**(新样式在 `<style id="jz-site">`,放在 jz-2026 块后面)。
|
||||
- **像素字体换成更全的子集** `portal/fonts/fusion-pixel-12.woff2`(114KB:ASCII + 常用 3755 字 + 当前全部内容;下单页也用这一份),删了旧的 `jz-pixel-12.woff2`。
|
||||
- **内容后台能原样接住真实画展**(`cms.py`):文件名带空格、本站 mp4 视频(不填 B 站链接)+ `web` 网页版副本、作品外链 `link` / `links`、离线缩略图索引 `media`、世界线 `tone` / `sector` / `media` —— 以前校验时会报错或悄悄丢掉;`site_payload` 把 `media` 一起写进 `site.js`(以前一发布就丢缩略图,画展会直接拉几百张原图)。测试 +8(86 条)。
|
||||
|
||||
### 2.8 2026-10-06 晚 · 五个修复 + 点击光效回归 + 手机深色模式 + 维护页
|
||||
|
||||
- 下单页模板样图按原图 1:1 显示。
|
||||
- 全景 / 动态壁纸:拖着拖出画框外松手,不会再被当成「点空白处」把大图关掉(按下和松手都在空白处才关)。
|
||||
- 画展长图(宽高比 0.45 那种)在大图里整张放得下(按视口高度限,网格行高 auto 时百分比 max-height 不生效);列表缩略图还没下完时大图先铺缩略图。
|
||||
- 点击光效:门户各页不加点击光效;下单页用它原来那套(按下发光、面板染色、邻按钮照亮)。(10-06 晚加过一版全站「彩虹边缘光段 + Q 弹」`fx.js`,店主看了说不要,已删。)
|
||||
- **手机深色模式**:系统设成深色时,手机宽度(≤760px)整站换夜间版(门户六页、画展大图、宇宙页、加载动画、下单页、流动背景着色器 `uDark`);电脑宽度保持浅色。要让电脑也跟随,把 `site.css` / 下单页 `jz-site` 里那段媒体查询的 `(max-width:760px) and` 去掉,`site.js` 里 `mqDark` 同步改。
|
||||
- **维护页** `portal/maintenance.html`:「钻石在打磨中」—— 钻石镐用 Minecraft 原版 16×16 物品图(`portal/assets/diamond-pickaxe.png`,取自 Minecraft Wiki,版权归 Mojang;本站是非官方粉丝向站点,别拿它做商品图),平时就是原版图标的样子(0°、3px 一格),挥的时候抡起、镐尖敲钻石、钻石一扁一弹、光谱像素火花、白光扫过;MC 方块进度条每敲一下亮一格、满了闪光谱色重来;点钻石也会敲一下。上维护:服务器上 `cp /var/www/jinzuan/index.html /var/backups/jinzuan/index.html.<日期>` 备份,再 `cp /var/www/jinzuan/maintenance.html /var/www/jinzuan/index.html`;撤维护:把备份拷回来。**别把备份留在网站目录里**(见 2.9)。
|
||||
|
||||
### 2.9 2026-10-06 · 安全审计与加固
|
||||
|
||||
- **爱发电回调防投毒**:这个地址谁都能 POST。没经开放接口验证的报文(没付款 / 查不到)**不再写进账本** `pay_orders`,只进 kv `hook_unverified`(最近 50 条、字段截断)供人工核对;回调日志只记关键头 + 正文前 4KB,5MB 轮转。nginx 给两个回调地址单独限流(20 次/分)+ 报文上限 64KB。测试 +2。
|
||||
- **福利券领取令牌**改成定长比较;**本机开单后台** `ys_admin.py` 的转义连引号一起转;星门格子提示文字转义;首页价格改读公开接口 `/order/api/payinfo`。
|
||||
- **nginx**(`/etc/nginx/sites-available/family-todo`,备份 `.bak-20261006-pre-security`):
|
||||
- 安全头:`snippets/jz-sec-base.conf`(HSTS / nosniff / X-Frame-Options / Referrer-Policy / Permissions-Policy,全站含待会儿办、隧道入口)、`snippets/jz-sec-csp.conf`(CSP,只给门户 / 下单页 / 内容后台)。⚠️ nginx 的 `add_header` 不继承:**新加的 location 只要写了 add_header,就要在里面再 `include` 这两个**(隧道 / 待会儿办只 include base)。
|
||||
- 挡掉:`*.bak*` `*.maint*` `*.old*` `*.v3-live-*` 之类备份、`preview-*.html`、隐藏文件(`.well-known` 照常)、内容后台原始文件 `content/site.json` / `order/content/order.json`(含「隐藏」的作品、付款设置;页面读的是 site.js / order.js)。
|
||||
- `server_tokens off`(不再暴露 nginx 版本)。
|
||||
- **网站目录里的 35 个备份 / 旧版 / 预览稿**挪到 `/var/backups/jinzuan/webroot-old-20261006/`(没删)。以后备份一律放 `/var/backups/jinzuan/`。
|
||||
- 复查过没问题的:SQL 全参数化;订单号路由 `[A-Z0-9]+` 且先查库再拼路径;渲染机回传文件名过滤;下单 / 反馈 / 呼叫限频 + 长度上限 + 磁盘水位;内容后台 https-only、Cookie `HttpOnly; SameSite=Strict; Secure`、CSRF + 同源、首次强制改密、服务端校验所有字段;公网只开 22 / 80 / 443(阿里云安全组);SSH 只认密钥 + fail2ban;数据目录 750。
|
||||
- **待定**:内容后台还是初始 `admin/admin`(尽快改);主机防火墙没开(8018 待会儿办、1Panel、docker 等监听 0.0.0.0,只靠安全组挡)。
|
||||
|
||||
---
|
||||
|
||||
## 3. 功能增加 / 删除一览
|
||||
@@ -108,6 +159,9 @@
|
||||
| 后端 · 管理接口 | 呼叫记录列表、标「处理过了」、失败单退回重渲、卡密搜索 |
|
||||
| 开单后台 | 待处理首页(要动手的事集中在一页)、订单搜索、卡密搜索 / 停用 / 启用 / 改张数、订单备注、呼叫·反馈页、失败单「退回重渲」按钮 |
|
||||
| 本机开单 | 分辨率选择样式、清空、整页拖拽、出图顺序标号、预计耗时、复制买家说明 |
|
||||
| **内容后台**(新) | 账号密码登录、首次强制改密、草稿 / 预览 / 发布 / 回滚、发布记录、操作日志、登录设备管理;可改:首页文案与公告、板块说明、画展(含传图)、工具与开源、金钻宇宙(档案 + 外观)、平台入口、关于、下单页模板上下架 / 名字 / 说明、页头与公告、价格档位、付款方式 |
|
||||
| 门户 / 下单页 | 读后台发布的内容;首页公告条(可设起止日期);`?preview=1` 预览草稿(只有登录的人看得到) |
|
||||
| 金钻宇宙 | 新世界线自动排位与连线;星球预设 18 种 |
|
||||
|
||||
### 删除
|
||||
|
||||
@@ -134,6 +188,10 @@
|
||||
| 新增字段 | `/api/claim` 回的订单里多一个 `terms_v`(只增不减) | 渲染机可以不理 |
|
||||
| 开单后台本机接口 | 新增 `/api/codes` `/api/calls` `/api/retry` `/api/note` `/api/code-edit` `/api/call-done`(都要 PIN,原样转服务器) | 只有面板页面自己用 |
|
||||
| 前端 | 门户的 `#rack` / `#bay` DOM 与 `window.__icd.open/close/flip/tray` 调试钩子删了;新增 `window.__jzUniverse.show()/fly(no)` | 只有页面自己和自动化脚本 |
|
||||
| **新增接口** | `/api/cms/*`(登录 / 内容 / 草稿 / 发布 / 回滚 / 传图 / 预览),见 `cms.py` 开头;nginx 要加一节(`deploy/nginx-片段.md` ④) | 只有内容后台页面 |
|
||||
| **数据格式** | 库里新增 `cms_users` / `cms_sessions` / `cms_draft` / `cms_versions` / `cms_audit` 五张表(启动时自动建);新增内容文件 `portal/content/site.{json,js}`、`order/content/order.{json,js}`;画展上传的图在 `portal/uploads/` | 服务器、门户、下单页 |
|
||||
| 文件被谁写 | `prices.json` / `payinfo.json` 现在也由内容后台发布时写(**格式不变**,别的字段原样保留;只有这次发布真改了价格 / 付款才写)。`admin.py price` 还能用,但建议统一在后台改 | 服务器 |
|
||||
| 前端 | 门户读 `window.JZ_CONTENT`、下单页读 `window.JZ_ORDER`(读不到用内置兜底);下单页 `TEMPLATES` 拆成 `TEMPLATES_ALL`(全部,用于显示老订单)和 `TEMPLATES`(上架的) | 页面自己 |
|
||||
|
||||
**没变**:所有买家接口、渲染机接口的路径和字段;本机开单的本机接口。
|
||||
|
||||
@@ -162,13 +220,13 @@
|
||||
|
||||
### 5.3 字体
|
||||
|
||||
- **标题**:`JZ Pixel` = 缝合像素字体 12px(TakWolf,SIL OFL 1.1),**只含页面用到的字**(子集)。门户 `portal/fonts/jz-pixel-12.woff2`,下单页 `order/assets/jz-pixel-12.woff2`,协议原文在同目录。12 的整数倍字号最清楚,`-webkit-font-smoothing:none`。
|
||||
- **标题**:缝合像素字体 12px(TakWolf,SIL OFL 1.1),子集 `portal/fonts/fusion-pixel-12.woff2`(门户和下单页共用;ASCII + GB2312 一级常用 3755 字 + 当前全部内容,114KB),协议原文 `portal/fonts/fusion-pixel-OFL.txt`。12 的整数倍字号最清楚,`-webkit-font-smoothing:none`。
|
||||
- **正文**:OPPO Sans(可免费商用)。
|
||||
- **加了新字(比如新世界线名字)要重做子集**,否则那几个字会掉回系统字体:
|
||||
- 常用字都在子集里,一般不用管;**用到生僻字(不在 3755 常用字里)才要重做子集**,否则那几个字会掉回正文字体:
|
||||
```
|
||||
# 文本 = 旧子集里已有的字 ∪ 页面 + config.js + galaxy.js 里所有字(只加不减)
|
||||
python3 -m fontTools.subset fusion-pixel-12px-proportional-zh_hans.otf.woff2 \
|
||||
--text-file=字表.txt --flavor=woff2 --layout-features='*' --output-file=portal/fonts/jz-pixel-12.woff2
|
||||
--text-file=字表.txt --flavor=woff2 --layout-features='*' --no-hinting --output-file=portal/fonts/fusion-pixel-12.woff2
|
||||
```
|
||||
源字体从 fusion-pixel-font 的 release 取(12px proportional zh_hans)。
|
||||
|
||||
@@ -206,16 +264,16 @@
|
||||
|
||||
金钻客栈 = 一个线上「客栈」:画展、工具与开源、金钻宇宙、各平台入口都在里面;**自助模板渲染只是其中一家店**。
|
||||
|
||||
| 门户板块 | 内容 | 数据在哪 |
|
||||
| 页面 | 内容 | 数据在哪 |
|
||||
|---|---|---|
|
||||
| 首页 | 欢迎首屏 + 五个板块卡 | `BOARDS` |
|
||||
| 画展 | 图片 / 视频 / 全景 / 动态壁纸,按时间排、可筛选(脱敏版只有一张占位) | `GALLERY` + `hd_cache/manifest.json` |
|
||||
| 工具与开源 | 开源一行 / 闭源一行,按类型筛选 | `APPS` |
|
||||
| 金钻宇宙 | 星系图 + 世界线档案(0000 零号主宇宙、0001–0004 已点亮、0005–0010 空槽) | `portal/assets/universe/config.js` |
|
||||
| 平台入口 | 视频 / 图文 / 模型创作 / 开源 / 小店 / 联系,外链新窗口打开 | `LINK_GROUPS` + `LINKS` |
|
||||
| 关于 | 制作者、开源组件鸣谢、名字由来 | 静态 HTML |
|
||||
| `index.html` 首页 | 首屏 +「都有些什么」五间屋(桌面)/ 金刚区 + 最新作品(手机)+ 自助渲染服务台(渲染机状态、价格实时读)+ 常用平台 | `content/site.js`(hero / boards / gallery / apps / universe / links / about) |
|
||||
| `gallery.html` 画展 | 图片 / 视频 / 全景 / 动态壁纸,按时间排、可筛选(脱敏版只有一张占位) | `content/site.js` 的 gallery + media,`hd_cache/manifest.json`,`view_stats.json` |
|
||||
| `tools.html` 工具与开源 | 开源 / 在线使用 / 闭源三行,按类型筛选 | apps |
|
||||
| `universe.html` 金钻宇宙 | 星门开场 → 星系图 + 世界线档案 | universe(兜底 `assets/universe/config.js`) |
|
||||
| `links.html` 平台入口 | 按分组列出,外链新窗口打开 | linkGroups + links |
|
||||
| `about.html` 关于 | 名字由来 + 署名卡片 | about |
|
||||
|
||||
路由:`#/板块`(单页切换,无整页刷新);`#0001` 这种编号直接飞到那条世界线;`#rack` 兼容到宇宙板块。
|
||||
各页之间是普通链接(整页跳转)。旧的单页地址 `/#/板块`、`/#0001` 会被首页自动跳到新页面。页脚、「更多」面板里的群号和备案号读 `assets/site-info.js`。
|
||||
|
||||
**加一条世界线**:`config.js` 里把空槽换成完整档案(`no / name / kind / tag / tags / desc`)+ 在 `LOOKS` 里给它一个外观(`style / r / orbit / accent / moons / enter`);名字里有新字记得重做像素字子集(5.3);改了 JS 要换版本号(7.2)。细节见 `portal/assets/universe/交接说明.md`。
|
||||
|
||||
@@ -296,14 +354,38 @@ inactive(停用:网页单等付款 / 手动停用)
|
||||
|
||||
| 文件 | 放到 | 备注 |
|
||||
|---|---|---|
|
||||
| `portal/**` | 网站根目录 | 星系图要 `assets/universe/` 和 `assets/vendor/` 一起上 |
|
||||
| `portal/**` | 网站根目录 | 星系图要 `assets/universe/` 和 `assets/vendor/` 一起上;**`assets/site-info.js` 换成正式服务器那份(真实群号 / 备案号),别用仓库里的占位覆盖**;`content/` 是线上数据,**别用仓库里的占位覆盖**(内容后台管它) |
|
||||
| `order/**` | 网站 `/order/` | |
|
||||
| `server.py` + **`store.py`** + `admin.py` + `pngcheck.py` | `<APP_DIR>`(同一目录) | `server.py` 直接 `import store`,**少了 `store.py` 服务起不来** |
|
||||
| `backend-tools/*` | 店主电脑 `<WORKER_DIR>` | `deploy.py` 推送;面板新按钮依赖服务器新接口,**先升服务器** |
|
||||
| **`cms.py`** | `<APP_DIR>`(和 `server.py` 同一目录) | `server.py` 直接 `import cms` |
|
||||
| `portal/admin/` | 网站 `/admin/` | 内容后台页面(静态) |
|
||||
| `portal/content/`、`order/content/` | 随页面一起 | 后台发布时**由服务器进程覆盖写**:这两个目录和 `portal/uploads/` 要给服务进程写权限 |
|
||||
|
||||
**环境变量**(systemd 单元里加):`YS_PORTAL_DIR=<门户网站根目录>`、`YS_ORDER_DIR=<下单页目录>`(内容后台写内容文件和上传图用;`YS_ROOT` 照旧)。
|
||||
|
||||
### 7.1b 内容后台首次部署(⚠️ 照顺序做)
|
||||
|
||||
1. nginx 按 `deploy/nginx-片段.md` 第 ④ 节加配置(**必须带 `X-Forwarded-Proto`**,整站 http → https)。**没配好证书之前不要开放**:后端会拒绝所有非 https 请求。
|
||||
2. 放好 `cms.py`、设好两个环境变量、给 `content/` `uploads/` 写权限,重启服务。第一次启动会自动建初始账号 `admin / admin`,日志里有一句提示。
|
||||
3. **马上**打开 `https://<站点>/admin/`,用 `admin / admin` 登录 → 强制改密(至少 8 位、不能是 admin / 常见密码)→ 用新密码重新登录。
|
||||
在改密之前,服务端只放行改密码和退出,其它接口一律 403;但这段空档里谁先登进去谁就能改密 —— 所以越快越好。
|
||||
4. 第一次打开内容页时,后台把网站现有的 `content/` 文件当成第 1 版。
|
||||
5. 账号管理(服务器上):
|
||||
```
|
||||
python3 admin.py user list # 有哪些账号、最近登录
|
||||
python3 admin.py user add <用户名> [--email 邮箱] [--temp] # 建账号(--temp 发一次性临时密码,首次登录必须改)
|
||||
python3 admin.py user passwd <账号> # 设新密码(所有会话作废)
|
||||
python3 admin.py user reset <账号> [--to-admin] # 忘了密码:会话全作废 → 临时密码(只打印在终端)→ 下次登录必须改
|
||||
python3 admin.py user disable|enable <账号>
|
||||
python3 admin.py user sessions <账号> [--revoke-all]
|
||||
```
|
||||
|
||||
### 7.2 缓存与版本号
|
||||
|
||||
- 门户星系图:改了 JS / CSS 要换版本号,**四处一起换**:`portal/index.html` 里 `universe.css?v=`、`config.js?v=`、底部模块脚本里 `galaxy.js?v=`,以及 `galaxy.js` 里 `import './planets.js?v='`。踩过:坏文件被缓存住,修好了打开还是「加载不出来」。
|
||||
- 门户各页引用 `assets/*.js|css?v=1`:改了哪个就把六个页面里它的 `?v=` 一起加 1。HTML 本身要 `no-cache`(nginx 片段里给 `*.html` 加了)。
|
||||
- 门户星系图:改了 JS / CSS 要换版本号,**一起换**:`portal/universe.html` 里 `universe-page.css?v=`、`config.js?v=`、底部模块脚本里 `galaxy.js?v=`,`galaxy.js` 里 `import './planets.js?v='` 和 `'./layout.js?v='`,以及 `portal/admin/index.html` 里 `planets.js?v=`。踩过:坏文件被缓存住,修好了打开还是「加载不出来」。
|
||||
- 内容文件 `content/site.js` / `order.js` 文件名不变、内容会变:nginx 给 `/content/` `/order/content/` 加 `Cache-Control: no-cache`(片段里有)。
|
||||
- 检查 ES 模块语法要拷成 `.mjs` 再 `node --check`(按普通脚本查会漏「重复声明」)。
|
||||
- three.js 只在第一次打开「金钻宇宙」时下载(约 690KB,gzip 后约 170KB)。
|
||||
|
||||
@@ -339,6 +421,8 @@ python3 admin.py sweep # 清过期成品 + 核销(建议每天
|
||||
| 本机开单 | 假本机服务(模拟渲染)+ headless 浏览器走完整流程 | 无报错、无横滚 |
|
||||
| 门户 | headless 浏览器 1366 / 390:六个板块都切一遍;宇宙:星图就绪、点卡片飞过去出档案、`#0002` 深链、全屏开关、手机上拖星图页面不滚;首页不下载 three.js | 全过;除星系图板块外,其余板块和改动前**逐像素一致** |
|
||||
| 下单页 | 打开截图 | 正常(本轮没改) |
|
||||
| **内容后台(后端)** | `python3 backend/backend-site/tests/内容后台测试.py <server.py 所在目录> <仓库根目录>` | 78 / 78:部署漏配时拒绝工作、后台发布不覆盖命令行改过的价格、初始账号与强制改密(改密前 11 个接口全 403)、库里无明文、Cookie 属性、https / CSRF / 跨站来源 / 爆破冷却(按 IP 5 次、按账号合计 20 次)、内容校验、XSS 转义、发布写文件、冲突 409、回滚一致、预览要登录、传图核验与去元数据、会话撤销与过期、命令行、三进程同时首启只建一个账号 |
|
||||
| **内容后台(端到端)** | 迷你反代模拟 nginx + 真服务器 + headless 浏览器 1366 / 390 | 36 / 36:门户入口 → 登录 → 强制改密 → 改文案 / 传图 / 点亮新地球 / 加入口 / 下架模板 / 加档位 → 预览(未登录看不到草稿)→ 发布 → 门户 / 星系图 / 下单页都变了 → 回滚复原 → 退出;无新增报错(只有交付副本本来就缺的 `view_stats.json` 和模板缩略图 404) |
|
||||
|
||||
后端测试数据全是测试脚本现编的,建在系统临时目录。⚠️ 交付副本里三个 URL 格式串被脱敏成 `http<WIN-PATH>`,要起服务器的测试得先在**测试副本**里换成能格式化的占位(这三处分别吃 1 / 2 / 0 个参数);线上原版直接跑。
|
||||
|
||||
@@ -349,5 +433,28 @@ python3 admin.py sweep # 清过期成品 + 核销(建议每天
|
||||
- **星系图帧率没在真机上测过**(只在无头浏览器的软件渲染里验证了画面和交互)。上线前用一台普通手机、一台集显笔记本各打开看一下;卡的话按 `universe/交接说明.md` 第 8 节降粒子数。
|
||||
- **数据库没在真机器上跑过**(1.6G 内存 + systemd 内存上限)。部署后先跑一次 `admin.py db check`。
|
||||
- 渲染机、真实 Blender、爱发电真实回调、手机通知脚本(读 `calls.jsonl` 的那段不在仓库里)都没有端到端测过。
|
||||
- 下单页里的链接是站点根路径(`/#/home`、`/order/`),本地从仓库根目录起服务时「首页」会跳到仓库根,线上没问题。
|
||||
- 下单页里的链接是站点根路径(`/index.html`、`/order/`、`/assets/site-info.js`、`/fonts/…`),本地要从 `portal/` 起服务、再把 `order/` 放到 `/order/` 才完整。
|
||||
- 加载动画 / 宇宙星门只在无头浏览器里看过逐帧截图;真机(尤其低端安卓)上看一眼顺不顺。
|
||||
- 署名按要求没改(「苏达 · 大肥鱼」)。
|
||||
|
||||
---
|
||||
|
||||
## 10. 内容后台(2026-10-05 晚实现)
|
||||
|
||||
网站前端所有展示内容在网页后台里改,不用再改代码。设计和每条安全规则的来由见根目录 **`内容后台设计.md`**;实现在:
|
||||
|
||||
| 部分 | 文件 |
|
||||
|---|---|
|
||||
| 服务端(账号 / 会话 / 草稿 / 发布 / 传图) | `backend/backend-site/cms.py`(`server.py` 把 `/api/cms/*` 交给它) |
|
||||
| 后台页面 | `portal/admin/index.html`(入口:门户顶栏最右边的淡色铅笔) |
|
||||
| 内容文件 | `portal/content/site.{json,js}`、`order/content/order.{json,js}`(发布时生成;`.json` 是正本,`.js` 给页面读) |
|
||||
| 命令行 | `admin.py user …`(见 7.1b) |
|
||||
| 测试 | `tests/内容后台测试.py`(75 条) |
|
||||
|
||||
要点(店主定的安全底线,别放松):
|
||||
- 初始账号 `admin / admin`,**首次登录强制改密**;改密前服务端只放行改密码 / 退出,其它接口一律 403。
|
||||
- 密码 `hashlib.scrypt`(没有就 `pbkdf2_hmac`)加盐存哈希,任何地方都不存明文;至少 8 位。
|
||||
- 会话是服务端令牌(库里只存哈希),「记住我」30 天滑动过期;退出 / 改密 / 命令行重置 / 停用都会当场作废。
|
||||
- Cookie:HttpOnly + SameSite=Strict,https 下 Secure;修改类请求要带 CSRF 头;跨站来源拒绝。
|
||||
- 只走 https(反代没说 https 就拒);登录冷却:同一 IP 错 5 次 / 同一账号合计错 20 次开始冷却(账号那档放宽,免得别人故意输错把店主锁在门外)。
|
||||
- 内容后台碰不到卡密 / 订单。
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
# 内容后台 · 设计说明(2026-10-05 定稿,待实现)
|
||||
|
||||
> 目的:网站前端所有**展示内容**都能在网页后台里改,不用再改代码、再部署。
|
||||
> 状态:**2026-10-05 晚已实现**(四步都做了)。实现:`backend/backend-site/cms.py`、`portal/admin/`、`admin.py user …`;部署步骤见 `交接文档-2026-10.md` 7.1b。
|
||||
> 跟设计有出入的地方见文末「实现对照」。
|
||||
|
||||
---
|
||||
|
||||
## 1. 和现有两个后台的关系
|
||||
|
||||
| | **内容后台(本文)** | 开单后台(`backend-tools/ys_admin.py`) |
|
||||
|---|---|---|
|
||||
| 管什么 | 网站上所有展示内容 | 卡密、订单、福利券、激活:跟钱有关 |
|
||||
| 跑在哪 | 服务器上(和 `server.py` 同一个进程) | 店主家里电脑 |
|
||||
| 谁能打开 | 公网能打开登录页,**登录后才能进** | 只在家里局域网 |
|
||||
| 怎么登录 | 账号(用户名或邮箱)+ 密码 | PIN(不变) |
|
||||
| 入口 | 门户顶栏最右边一个**不带字的铅笔图标** | 家里电脑桌面 |
|
||||
|
||||
**内容账号碰不到卡密和订单**:内容后台的接口只读写「内容」那几张表,跟卡密 / 订单 / 账本是两套接口、两套权限。
|
||||
内容账号就算被盗,最坏也就是网页内容被改,而且能一键回到上一版(第 5 节)。
|
||||
|
||||
---
|
||||
|
||||
## 2. 能改什么
|
||||
|
||||
| 页面 | 能改的 |
|
||||
|---|---|
|
||||
| 门户 · 首页 | 大标题下那句话、按钮文字、公告条(可开关、可设起止日期) |
|
||||
| 门户 · 画展 | 增删改作品:标题、日期、类型(图片 / 视频 / 全景 / 动态壁纸)、归属(金钻 / 他人)、说明、排序、隐藏;**上传图片**(第 7 节);视频填 B 站链接 |
|
||||
| 门户 · 工具与开源 | 增删改条目:名称、英文名、类型、开源 / 闭源、说明、版本、状态、链接、仓库 |
|
||||
| 门户 · 金钻宇宙 | 世界线档案(名字、类型、一句话、简介、标签);外观用**下拉选**(星球风格、主色、入场运镜);空槽数量 |
|
||||
| 门户 · 平台入口 | 分组、名称、说明、链接(只允许 `https://` 和 `mailto:`) |
|
||||
| 门户 · 关于 | 名字的由来、署名卡片、鸣谢 |
|
||||
| 下单页 | 模板的名称 / 说明 / 上下架 / 预览图;页面上的提示与说明文字;价格档位(原 `prices.json`);付款方式(原 `payinfo.json`) |
|
||||
|
||||
**刻意不放进来的**:
|
||||
- **条款版本号**:服务器、下单页、渲染机三处必须同时改,放进后台容易只改一处、静默出错;继续手改,见交接文档。
|
||||
- **`.blend` 模板文件本身**:继续在家里电脑上放。
|
||||
- 模板 key(`stand`、`airship` …):渲染机认这个,后台只能改显示名,不能改 key。
|
||||
|
||||
---
|
||||
|
||||
## 3. 账号与密码
|
||||
|
||||
- 登录:**用户名或邮箱 + 密码**。**不开放注册**,账号只能在服务器上用命令行建。
|
||||
- 存储:`hashlib.scrypt`(每个账号一份随机盐,≥16 字节),参数和盐一起存进 SQLite;
|
||||
机器上的 Python 不带 scrypt 时自动改用 `pbkdf2_hmac`(sha256,≥60 万次迭代)。
|
||||
以后加强参数,老账号在下次登录时自动升级。比对用 `hmac.compare_digest`。**任何地方都不存、不记明文**(含日志)。
|
||||
- 密码规则:**至少 8 位**,不能是 `admin`,拦掉一份常见弱密码表。
|
||||
- 防爆破:同一 IP、同一账号连错几次逐步加长冷却;提示统一说「账号或密码不对」,不透露账号是否存在。
|
||||
|
||||
### 3.1 首次部署:初始账号 `admin / admin` + 强制改密(安全底线)
|
||||
|
||||
1. 服务器第一次启动、库里一个账号都没有时,自动建 `admin`,密码 `admin`(入库的同样是哈希)。
|
||||
2. 这个账号带「必须改密码」标记。用它登录后拿到的是**受限会话**:
|
||||
**服务端在接口统一入口拦截,除了「改密码」和「退出」,其它所有内容后台接口一律 403「请先修改初始密码」**。不靠前端跳转。
|
||||
3. 新密码 ≥8 位、不能是 `admin`。改完:清掉标记 → 作废这个账号所有会话 → 用新密码重新登录。
|
||||
4. 初始密码**不设过期**(店主定)。
|
||||
|
||||
> ⚠️ 部署步骤里写死:**服务一启动就马上登录改密**。
|
||||
> 从部署完到改密之间,公网上谁先用 `admin/admin` 登进去谁就能改掉密码 —— 这段空档越短越好。
|
||||
|
||||
### 3.2 服务器命令行(`backend-site/admin.py`)
|
||||
|
||||
| 命令 | 干什么 |
|
||||
|---|---|
|
||||
| `python3 admin.py user add <用户名> [--email 邮箱]` | 建账号,密码在终端里隐藏输入、输两遍 |
|
||||
| `python3 admin.py user passwd <账号>` | 直接设新密码;**作废这个账号所有会话** |
|
||||
| `python3 admin.py user reset <账号>` | 忘了密码用:**作废所有会话** → 生成**随机临时密码**,只打印在执行命令的终端里(不写日志)→ **下次登录必须改密**。加 `--to-admin` 则退回 `admin` |
|
||||
| `python3 admin.py user disable / enable <账号>` | 停用 / 启用;停用时作废所有会话 |
|
||||
| `python3 admin.py user list` | 账号、邮箱、是否待改密、最近登录时间 / IP |
|
||||
| `python3 admin.py user sessions <账号> [--revoke-all]` | 看这个账号在哪些设备登录着;可一键全部踢掉 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 登录态(会话)
|
||||
|
||||
- 登录成功 → 服务端生成随机令牌(`secrets.token_urlsafe(32)`),**库里只存令牌的哈希**,带过期时间。
|
||||
- Cookie:始终 **HttpOnly + SameSite=Strict**;请求是 https 时加 **Secure**(看反代传来的协议)。
|
||||
- 「记住我」(默认勾上):Cookie 保留 **30 天**,每次使用自动续期;不勾 = 关掉浏览器就失效(服务端同样 30 天兜底)。
|
||||
- **服务端主动撤销** = 删掉那一行,下一次请求立刻失效。触发:退出、「退出所有设备」、命令行 `passwd` / `reset` / `disable`、自己改密码(除当前这台)。
|
||||
- 每个修改请求还要带一个防伪造令牌(CSRF,存在会话里,页面拿到后放请求头)。
|
||||
- 后台「账号」页能看到自己在哪些设备登录着(浏览器、IP、最近使用时间),可以逐个退出。
|
||||
|
||||
---
|
||||
|
||||
## 5. 草稿 → 预览 → 发布 → 回滚
|
||||
|
||||
- 编辑只写**草稿**;草稿随时可丢弃。
|
||||
- 「预览」:用草稿数据渲染一份门户 / 下单页(只给登录的人看)。
|
||||
- 「发布」:弹窗列出这次改了哪些地方(按板块统计增 / 改 / 删),写一句说明(可空)后确认。
|
||||
- 每次发布存一个**完整版本**(谁、什么时候、说明、内容快照),「发布记录」里能看、能对比、能**一键回到某一版**(回滚本身也算一次发布,可以再回滚)。
|
||||
- 两个人同时编辑:发布时发现底稿已被别人发布过,提示先看对方改了什么再合并,不静默覆盖。
|
||||
|
||||
---
|
||||
|
||||
## 6. 数据怎么到页面上
|
||||
|
||||
- 数据库(`ys.db`)加表:`cms_users`、`cms_sessions`、`cms_draft`、`cms_versions`、`cms_audit`。
|
||||
- 发布时把内容写成静态文件 `portal/content/site.json`(下单页 `order/content/order.json`),**原子替换**(先写临时文件再 rename)。
|
||||
页面直接读静态 JSON:快、能被缓存、**后端挂了网站照样能看**。
|
||||
- 页面里保留一份内置兜底数据:JSON 读不到时用它,不白屏。
|
||||
- 价格档位 / 付款方式:发布时同时写回服务器原来那两个文件(`prices.json` / `payinfo.json`),下单逻辑不用改。
|
||||
|
||||
---
|
||||
|
||||
## 7. 画展传图
|
||||
|
||||
1. 后台里拖图上传(PNG / JPEG / WebP,单张 ≤ 20MB)。
|
||||
2. 服务器先做**结构核验**(沿用 `pngcheck.py` 的思路,补 JPEG / WebP):拒尾部夹带、拒不认识的块;剥掉 EXIF 等元数据。
|
||||
3. 用 ffmpeg **一次处理一张**生成缩略图和高清版,自动更新媒体清单(`MEDIA` / `hd_cache`)。
|
||||
单张图片处理是这台服务器允许的(下单预览图现在就这么做);视频不上传,只填 B 站链接。
|
||||
4. 上传的文件进草稿;发布了才出现在网站上。
|
||||
|
||||
---
|
||||
|
||||
## 8. 安全清单
|
||||
|
||||
- **登录页和内容后台接口只走 https**:nginx 把 http 一律 301 到 https 并加 HSTS;后端再兜一层,反代说不是 https 就拒绝,不收密码。
|
||||
**没配好证书之前不能开放这个登录页。** 仅服务器本机 http 调试时例外(此时 Cookie 不带 Secure)。
|
||||
- 所有输入在**服务端**校验:字段类型、长度、链接白名单(`https://`、`mailto:`)、颜色格式、枚举值(星球风格 / 运镜只能选列表里的)。
|
||||
- 所有文字在页面上**转义输出**,不允许 HTML(防 XSS);需要换行的字段只认换行符。
|
||||
- 登录、改密、发布、回滚、上传都记审计日志:谁、什么时候、哪个 IP、改了什么。
|
||||
- 登录接口和上传接口在 nginx 上单独限流。
|
||||
- 内容后台接口和卡密 / 订单接口分开,权限互不相通。
|
||||
|
||||
---
|
||||
|
||||
## 9. 分四步做
|
||||
|
||||
| 步 | 内容 | 估时 |
|
||||
|---|---|---|
|
||||
| 1 | 内容从代码里搬出来:门户 / 下单页改成读 `content/*.json`(带内置兜底) | 1–1.5 天 |
|
||||
| 2 | 账号与会话:建表、哈希、初始账号 + 强制改密、Cookie、撤销、CSRF、防爆破、命令行 | 1.5 天 |
|
||||
| 3 | 内容后台页面:各板块编辑、草稿 / 预览 / 发布 / 回滚、账号页、顶栏铅笔图标 | 2–3 天 |
|
||||
| 4 | 画展传图:核验、ffmpeg 转图、媒体清单 | 1–2 天 |
|
||||
|
||||
每步都配测试,至少覆盖:
|
||||
- 库里查不到明文;
|
||||
- 错密码登不进;
|
||||
- 初始账号改密前调其它接口一律 403;
|
||||
- 改密 / 重置 / 停用后旧会话立即失效;
|
||||
- 令牌过期;
|
||||
- http 请求被拒;
|
||||
- 爆破触发冷却;
|
||||
- CSRF 缺失被拒;
|
||||
- 非法链接 / 超长字段被拒;
|
||||
- 转义正确;
|
||||
- 发布原子写入;
|
||||
- 回滚还原一致。
|
||||
|
||||
---
|
||||
|
||||
## 10. 还没定的
|
||||
|
||||
- 署名(关于页「网站构建」那张卡片):后台放开给店主自己改,还是锁成只读?——没定之前按「可以改」做。
|
||||
|
||||
---
|
||||
|
||||
## 11. 实现对照(和上面设计有出入的地方)
|
||||
|
||||
| 设计里写的 | 实际做的 | 为什么 |
|
||||
|---|---|---|
|
||||
| 「同一 IP、同一账号连错几次逐步加长冷却」 | 同一 IP 错 5 次 / **同一账号合计错 20 次**才冷却(30s 起翻倍,最长 15 分钟) | 只按账号算的话,别人从外面故意输错几次就能把店主锁在门外;IP 那档仍然很紧 |
|
||||
| 发布写 `content/site.json` | 同时写 `site.json`(正本)和 `site.js`(`window.JZ_CONTENT = …`,页面同步读) | 页面用同步脚本读,不用改成异步加载,旧代码几乎不动;读不到就用页面内置兜底 |
|
||||
| 「预览」用草稿渲染一份 | 门户 / 下单页带 `?preview=1` 打开时,额外加载 `/order/api/cms/draft.js`(要登录)覆盖内容;页面底部有「预览草稿」提示条 | 不用另做一套预览页;没登录的人带同样的参数也只看到正式内容 |
|
||||
| 画展传图 ≤ 20MB | ≤ 10MB | server.py 请求体上限 15MB,base64 后 10MB 的图约 13.4MB |
|
||||
| 「关于」不允许 HTML | 只认两种简易写法:`[文字](https://网址)` 链接、`` `代码` ``;空一行分段 | 原来的署名卡片里本来就有链接和代码样式,要能保留 |
|
||||
| 下单页「页面上的提示文字」 | 只做了页头那句话 + 公告条 | 其它提示散在下单页逻辑里,动它风险大;以后要加再逐个接 |
|
||||
| 署名卡片是否锁定(待定) | 没锁,店主可以改 | 没定之前按「可以改」 |
|
||||
| 新点亮的世界线放哪 | 自动排位(`portal/assets/universe/layout.js`):中圈不挤的位置,补给线接附近的星,已有的都不动 | 店主要求「新星球的位置和连线要好看、不打架」 |
|
||||
| 「两个人同时编辑:提示先看对方改了什么再合并」 | 发布时底稿过期 → 409,弹窗二选一:丢掉我的草稿 / 确认后用我的草稿覆盖发布(覆盖前可先看发布记录) | 不做逐字段合并,简单可控 |
|
||||
| (设计没写) | 部署漏配(没设 `YS_PORTAL_DIR` / `YS_ORDER_DIR`,或门户目录里没有 `content/site.json`)时内容后台**拒绝工作**,不建第一版、不写任何文件 | 否则会从空骨架开始,店主一发布就把网站内容清空 |
|
||||
| (设计没写) | 价格档位 / 付款方式只有这次发布真改了才写回 `prices.json` / `payinfo.json` | 不覆盖有人用 `admin.py price` 在命令行改过的价格 |
|
||||
| (设计没写) | 同时最多 2 个密码哈希在算 | 一次 scrypt 要 16MB 内存,服务进程上限 256M |
|
||||
|
||||
Reference in New Issue
Block a user