diff --git a/README.md b/README.md index 82d9d04..669a239 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ UI 组件:`apps/admin/src/pages/wechat.css` · `apps/admin/src/components/wxUi | VIP 落地 | `pages/vip/index` | 模块锚点真滚动、虚拟支付 / 免费方案 | | 专题课 | `pages/vip-course/index?id=` | `cloudphone` / `livestream` / `indie` / `aiagent` | | 课时 | `pages/vip-lesson/index` | 原生 Video + 配套 markdown | -| 电子书 | `pages/vip-ebook/index?id=` | `nomad`(免费)/ `cloudphone`(VIP),目录抽屉 | +| 电子书 | `pages/vip-ebook/index?id=` | `nomad`(免费)/ `cloudphone`(VIP);**Youtube运营笔记**走 `pages/reader?id=default`(后台 books/default) | | **知识社群** | `pages/vip-memo` · `vip-memo-detail` | 知识星球风格:精华/收藏/Markdown/图/#话题;缓存秒开 | | **设备商城** | `pages/vip-store*` | 虚拟卡 + 实物发货;微信 `chooseAddress` | @@ -120,8 +120,13 @@ pnpm dev:api ## pre4 摘要 - 微信启动页 **`pages/home/index`**(话题/体验码同路径);`pages/index` 兼容 `reLaunch` → home -- 本轮标记:**`20261011b`**(视觉对齐 `20261011`) -- **P0/P1 加固** +- 本轮标记:**`20261011-2`**(审核候选;承接 `20261011b` 路径 + `20261011` 视觉) +- **审核前修复(`20261011-2`)** + - VIP「Youtube运营笔记」→ `reader?id=default`(后台「内容→VIP→电子书→youtube运营笔记」),禁止误进数字游民 `vip-ebook?id=nomad` + - `vipContent.ebooks` 默认含 youtube-notes;服务端 `_ensure_youtube_notes_ebook` 校正 href + - 提审开关只影响数字游民,不劫持 `book_id=default` + - 「VIP 中心」开关与加群联动:开→跳会员页,关→公众号弹窗;加群点击强制拉最新 `/api/config` +- **P0/P1 加固**(已在 `017008d`) - 统一 API 挂载 VIP library / weapp switches;VIP 正文需鉴权(目录可匿名) - Mine 统一 ebook 登录(`ensureLogin` / `clearLogin`) - weapp game:`index.weapp.tsx` stub + `IgnorePlugin(three)`,无 Three.js 包体 @@ -140,4 +145,6 @@ pnpm dev:api 构建微信包:`pnpm build:weapp` / `pnpm dev:weapp` → 开发者工具打开 `apps/miniprogram/weapp`(读 `dist/`)。图片域名需放行 `nomadro.cn`。 -微信启动首页为 **`pages/home/index`**(官方话题/体验码同路径;视觉对齐 **`20261011`**,路径发版 tag **`20261011b`**)。`pages/index/index` 仅作兼容:`reLaunch` → home(勿与 home 共用组件入口,否则页面 wxss 缺失)。详见 `apps/miniprogram/weapp/README.md`。 +微信启动首页为 **`pages/home/index`**(官方话题/体验码同路径;视觉对齐 **`20261011`**;路径 **`20261011b`**;**审核包 tag `20261011-2`**)。`pages/index/index` 仅作兼容:`reLaunch` → home(勿与 home 共用组件入口,否则页面 wxss 缺失)。详见 `apps/miniprogram/weapp/README.md`。 + +提审上传:本地 `pnpm build:weapp` → 开发者工具打开 `apps/miniprogram/weapp`(读 `dist/`)→ 上传体验版;后台「数字游民」提审开关按需开启。 diff --git a/apps/admin/deploy/_fix_vip_youtube_ebook.py b/apps/admin/deploy/_fix_vip_youtube_ebook.py new file mode 100644 index 0000000..947de36 --- /dev/null +++ b/apps/admin/deploy/_fix_vip_youtube_ebook.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +"""Deploy vip_content.py + patch remote-config: Youtube运营笔记 → books/default.""" +from __future__ import annotations + +import json +import time +from pathlib import Path + +import paramiko + +REPO = Path(__file__).resolve().parents[3] +HOST, USER, PASS = "82.157.112.245", "ubuntu", "Xiao4669805" +SRC = REPO / "apps/api/services/ebook_svc/services/vip_content.py" + +YT = { + "id": "youtube-notes", + "title": "Youtube运营笔记", + "desc": "试读可进,单买或 VIP 解锁全文", + "ebookId": "default", + "href": "/pages/reader/index?id=default", + "free": False, + "enabled": True, + "sort": 1, +} + + +def to_app_pkg(src: Path) -> bytes: + return src.read_text(encoding="utf-8").replace("ebook_svc.", "app.").encode("utf-8") + + +def main() -> int: + data = to_app_pkg(SRC) + c = paramiko.SSHClient() + c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + c.connect(HOST, username=USER, password=PASS, timeout=60, allow_agent=False, look_for_keys=False) + sftp = c.open_sftp() + with sftp.file("/tmp/vip_content_yt.py", "wb") as rf: + rf.write(data) + print("up vip_content", len(data), flush=True) + sftp.close() + + patch_json = json.dumps(YT, ensure_ascii=False) + cmd = r""" +set -e +B=/opt/nomadmini/backend/app +sudo cp /tmp/vip_content_yt.py "$B/services/vip_content.py" + +# patch remote-config ebooks +python3 <<'PY' +import json +from pathlib import Path +paths = [ + Path("/var/www/nomadro.cn/data/remote-config.json"), + Path("/opt/nomadmini/backend/data/remote-config.json"), +] +yt = { + "id": "youtube-notes", + "title": "Youtube运营笔记", + "desc": "试读可进,单买或 VIP 解锁全文", + "ebookId": "default", + "href": "/pages/reader/index?id=default", + "free": False, + "enabled": True, + "sort": 1, +} +for p in paths: + if not p.is_file(): + print("skip missing", p) + continue + raw = json.loads(p.read_text(encoding="utf-8")) + platforms = raw.setdefault("platforms", {}) + weapp = platforms.setdefault("weapp", {}) + vc = weapp.setdefault("vipContent", {}) + ebooks = list(vc.get("ebooks") or []) + hit = -1 + for i, e in enumerate(ebooks): + if not isinstance(e, dict): + continue + t = str(e.get("title") or "") + if ( + e.get("id") == "youtube-notes" + or e.get("ebookId") == "default" + or "youtube" in t.lower() + or "运营笔记" in t + ): + hit = i + break + if hit >= 0: + prev = ebooks[hit] + ebooks[hit] = {**yt, "title": prev.get("title") or yt["title"], "desc": prev.get("desc") or yt["desc"], "enabled": prev.get("enabled") is not False, "sort": prev.get("sort", 1)} + else: + idx = next((i for i, e in enumerate(ebooks) if isinstance(e, dict) and (e.get("id") == "1" or e.get("title") == "数字游民")), -1) + if idx >= 0: + ebooks.insert(idx + 1, dict(yt)) + else: + ebooks.append(dict(yt)) + # fix cloudphone sort if needed + for e in ebooks: + if isinstance(e, dict) and e.get("id") == "2" and e.get("sort") in (None, 1): + e["sort"] = 2 + vc["ebooks"] = ebooks + stats = dict(vc.get("stats") or {}) + stats["ebooks"] = "3" + vc["stats"] = stats + weapp["vipContent"] = vc + platforms["weapp"] = weapp + raw["platforms"] = platforms + raw["updatedAt"] = raw.get("updatedAt") or "" + bak = p.with_suffix(p.suffix + ".bak-yt") + bak.write_text(p.read_text(encoding="utf-8"), encoding="utf-8") + p.write_text(json.dumps(raw, ensure_ascii=False, indent=2), encoding="utf-8") + print("patched", p, "ebooks=", [e.get("id") for e in ebooks if isinstance(e, dict)]) +PY + +cd /opt/nomadmini/backend +.venv/bin/python -c 'from app.services import vip_content as v; d=v.default_vip_content(); ids=[e["id"] for e in d["ebooks"]]; assert "youtube-notes" in ids; print("default_ok", ids)' +sudo systemctl restart nomadmini-api +sleep 3 +systemctl is-active nomadmini-api +curl -sk https://api.nomadro.cn/api/config | python3 -c 'import sys,json; d=json.load(sys.stdin); e=((d.get("config") or {}).get("platforms") or {}).get("weapp",{}).get("vipContent",{}).get("ebooks") or []); print("live_ebooks", [(x.get("id"), x.get("ebookId"), x.get("href")) for x in e])' +rm -f /tmp/vip_content_yt.py +""" + _, stdout, _ = c.exec_command(cmd, timeout=180, get_pty=True) + while not stdout.channel.exit_status_ready(): + if stdout.channel.recv_ready(): + print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True) + time.sleep(0.05) + while stdout.channel.recv_ready(): + print(stdout.channel.recv(65536).decode("utf-8", "replace"), end="", flush=True) + code = stdout.channel.recv_exit_status() + print(f"[exit {code}]", flush=True) + c.close() + return code + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/apps/admin/src/pages/Switches.tsx b/apps/admin/src/pages/Switches.tsx index 46f7493..0539f22 100644 --- a/apps/admin/src/pages/Switches.tsx +++ b/apps/admin/src/pages/Switches.tsx @@ -58,7 +58,7 @@ const PAGE_MODS: Array<{ key: string; label: string; ico: string; desc: string } { key: 'nav', label: '出海导航', ico: '🧭', desc: '导航页 / Tab' }, { key: 'book', label: '数字游民小册', ico: '📕', desc: '小册 Tab → 正式读 nomad' }, { key: 'community', label: '旅居社群', ico: '🏕️', desc: '社群入口' }, - { key: 'vip', label: 'VIP 中心', ico: '👑', desc: '会员落地页' }, + { key: 'vip', label: 'VIP 中心', ico: '👑', desc: '会员落地页;关闭后「加群」改弹公众号' }, { key: 'destinations', label: '目的地', ico: '📍', desc: '目的地列表' }, { key: 'meetups', label: '活动', ico: '📅', desc: '活动入口' }, ] @@ -232,12 +232,25 @@ export default function Switches() { checked={on} disabled={busy} label={m.label} - onChange={(v) => + onChange={(v) => { + // VIP 中心 ↔ 加群行为联动:开=跳会员页,关=公众号弹窗(实时) + if (m.key === 'vip') { + void patch( + { + modules: { vip: { enabled: v } }, + flags: { joinGroupAction: v ? 'vip' : 'popup' }, + }, + v + ? 'VIP 中心已开启 · 加群跳转会员页' + : 'VIP 中心已关闭 · 加群改为公众号弹窗', + ) + return + } void patch( { modules: { [m.key]: { enabled: v } } }, `${m.label}已${v ? '开启' : '关闭'}`, ) - } + }} />

{m.label}

@@ -299,7 +312,7 @@ export default function Switches() {
加群行为 - 点击加群:弹窗或跳转 VIP + 弹窗=关注公众号;跳 VIP 需「VIP 中心」开启,否则仍弹窗