From 893526942cb6a9d7cefbdb42f827ca42b9c17953 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 10 Nov 2026 13:02:04 +0800 Subject: [PATCH] Ship social theme switching, feedback image ops, and local skin debug ball. Save current look as theme 1, add admin experience skin controls for themes 1-4, fix feedback image sync/lightbox, move hiring to the home bottom, and expose a localhost-only debug orb for instant skin preview. Co-authored-by: Cursor --- .../ebook_svc/routers/social_ugc_admin.py | 21 ++ .../ebook_svc/services/social_experience.py | 231 ++++++++++++++++++ apps/api/services/social_svc/pb_data.py | 37 ++- apps/api/tests/test_social_experience.py | 17 ++ apps/com/admin/src/App.tsx | 2 + apps/com/admin/src/components/WebLayout.tsx | 1 + apps/com/admin/src/lib/pageModules.ts | 3 + apps/com/admin/src/pages/Docs.tsx | 3 + apps/com/admin/src/pages/ImageLightbox.tsx | 135 ++++++++++ apps/com/admin/src/pages/LaneHub.tsx | 1 + apps/com/admin/src/pages/Social.tsx | 107 +++++--- apps/com/admin/src/pages/SocialExperience.tsx | 56 ++++- apps/com/admin/src/styles.css | 134 ++++++++++ .../social/_components/ConnectionHero.tsx | 2 +- src/app/api/portal/feedback/route.ts | 68 +++++- src/app/social/layout.tsx | 8 +- src/lib/remote-config.ts | 34 +++ src/modules/social/app/theme3.css | 8 + src/modules/social/app/theme4.css | 8 + .../social/components/ConnectionHero.tsx | 4 +- .../social/components/HomeActionRail.tsx | 4 +- src/modules/social/components/HomeClient.tsx | 164 +++++++------ src/modules/social/components/SiteShell.tsx | 26 +- .../social/components/SocialExperience.tsx | 2 + .../social/components/SocialSkinDebugBall.css | 166 +++++++++++++ .../social/components/SocialSkinDebugBall.tsx | 121 +++++++++ src/modules/social/lib/api.ts | 25 +- src/modules/social/lib/catalog.ts | 12 +- src/modules/social/lib/i18n.ts | 26 +- src/modules/social/lib/joinFlow.ts | 8 +- src/modules/social/lib/livenessGate.ts | 2 +- src/modules/social/lib/phrases.ts | 20 +- src/modules/social/lib/skin.ts | 70 +++++- .../work/components/WorkAccessGate.tsx | 6 +- src/modules/work/components/WorkClient.tsx | 2 +- src/modules/work/micro/MicroAppHost.tsx | 2 +- .../work/planka/bridge/PlankaNextRoot.tsx | 2 +- 37 files changed, 1345 insertions(+), 193 deletions(-) create mode 100644 apps/api/services/ebook_svc/services/social_experience.py create mode 100644 apps/com/admin/src/pages/ImageLightbox.tsx create mode 100644 src/modules/social/app/theme3.css create mode 100644 src/modules/social/app/theme4.css create mode 100644 src/modules/social/components/SocialSkinDebugBall.css create mode 100644 src/modules/social/components/SocialSkinDebugBall.tsx diff --git a/apps/api/services/ebook_svc/routers/social_ugc_admin.py b/apps/api/services/ebook_svc/routers/social_ugc_admin.py index 94c3755..03ee9eb 100644 --- a/apps/api/services/ebook_svc/routers/social_ugc_admin.py +++ b/apps/api/services/ebook_svc/routers/social_ugc_admin.py @@ -386,6 +386,27 @@ class CatalogBody(BaseModel): videos: list[dict[str, Any]] | None = None +class ExperienceBody(BaseModel): + expectedVersion: int | None = Field(default=None, ge=0) + experience: dict[str, Any] = Field(default_factory=dict) + + +@router.get("/experience") +async def get_experience(_: str = Depends(require_admin)) -> dict[str, Any]: + from ebook_svc.services import social_experience as experience + + return experience.read_experience() + + +@router.put("/experience") +async def put_experience( + body: ExperienceBody, _: str = Depends(require_admin) +) -> dict[str, Any]: + from ebook_svc.services import social_experience as experience + + return experience.write_experience(body.expectedVersion, body.experience) + + @router.get("/catalog") async def get_catalog(_: str = Depends(require_admin)) -> dict[str, Any]: from ebook_svc.services.social_ops import _read_raw diff --git a/apps/api/services/ebook_svc/services/social_experience.py b/apps/api/services/ebook_svc/services/social_experience.py new file mode 100644 index 0000000..de38e1e --- /dev/null +++ b/apps/api/services/ebook_svc/services/social_experience.py @@ -0,0 +1,231 @@ +"""社区体验设计台 — 导航 / 区块 / 文案 / 视觉主题。 + +只读写 copy.socialExperience,并同步 skin → copy.socialSkin、 +sections → socialHiddenSections、中文 pages → socialPages。 +不碰 orders、PocketBase、platforms.tt、socialCatalogs 内容数组。 +""" +from __future__ import annotations + +import re +from typing import Any + +from fastapi import HTTPException + +from ebook_svc.services.social_ops import _read_raw, _write_raw, resolve_config_file + +SKIN_IDS = ("1", "2", "3", "4") +SKIN_DEFAULT = "1" +SKIN_META = ( + {"id": "1", "label": "主题1 · 旅居社群", "note": "当前线上默认样式(已保存)"}, + {"id": "2", "label": "主题2 · 琥珀信号", "note": "theme2.css"}, + {"id": "3", "label": "主题3 · 预留", "note": "可后续扩展 CSS"}, + {"id": "4", "label": "主题4 · 预留", "note": "可后续扩展 CSS"}, +) + +NAV_KEYS = ( + "chat", + "people", + "date", + "meetup", + "coffeechat", + "map", + "places", + "team", + "skills", + "ebook", + "videos", + "work", + "feedback", +) + +SECTION_KEYS = ( + "discover", + "people", + "cities", + "meetup", + "collaborate", + "faq", +) + +PAGE_KEYS = ( + "home", + "discovery", + "chat", + "people", + "date", + "meetup", + "coffeechat", + "map", + "places", + "team", + "skills", + "ebook", + "videos", + "work", + "feedback", + "roster", +) + +LOCALE_KEYS = ("zh", "en") +COPY_FIELDS = ("eyebrow", "title", "accent", "description") +_SAFE_HREF = re.compile(r"^(/social(/[\w.-]+)*)?/?$") + + +def _clip(value: Any, limit: int) -> str: + text = str(value or "").strip() + return text[:limit] if text else "" + + +def _norm_bool_map(raw: Any, keys: tuple[str, ...], default: bool = True) -> dict[str, bool]: + src = raw if isinstance(raw, dict) else {} + out: dict[str, bool] = {} + for key in keys: + if key in src: + out[key] = bool(src[key]) + else: + out[key] = default + return out + + +def _norm_skin(raw: Any) -> str: + skin = str(raw or "").strip() + return skin if skin in SKIN_IDS else SKIN_DEFAULT + + +def _norm_page_copy(raw: Any) -> dict[str, str]: + src = raw if isinstance(raw, dict) else {} + out: dict[str, str] = {} + limits = {"eyebrow": 200, "title": 300, "accent": 300, "description": 2000} + for field in COPY_FIELDS: + text = _clip(src.get(field), limits[field]) + if text: + out[field] = text + return out + + +def _norm_pages(raw: Any) -> dict[str, dict[str, dict[str, str]]]: + src = raw if isinstance(raw, dict) else {} + out: dict[str, dict[str, dict[str, str]]] = {} + for locale, pages in src.items(): + loc = str(locale or "").strip() + if loc not in LOCALE_KEYS: + raise HTTPException(422, f"unsupported locale: {loc}") + if not isinstance(pages, dict): + continue + locale_pages: dict[str, dict[str, str]] = {} + for page_key, copy in pages.items(): + key = str(page_key or "").strip() + if key not in PAGE_KEYS: + continue + cleaned = _norm_page_copy(copy) + if cleaned: + locale_pages[key] = cleaned + if locale_pages: + out[loc] = locale_pages + return out + + +def _norm_announcement(raw: Any) -> dict[str, Any]: + src = raw if isinstance(raw, dict) else {} + href = _clip(src.get("href"), 500) + if href and not _SAFE_HREF.match(href): + raise HTTPException(422, "announcement.href must be an in-app /social path") + return { + "enabled": bool(src.get("enabled")), + "zh": _clip(src.get("zh"), 400), + "en": _clip(src.get("en"), 400), + "href": href, + } + + +def _norm_featured(raw: Any) -> list[str]: + if not isinstance(raw, list): + return [] + out: list[str] = [] + for item in raw: + cid = str(item or "").strip() + if cid and cid not in out: + out.append(cid[:64]) + return out[:40] + + +def normalize_experience(raw: Any) -> dict[str, Any]: + src = raw if isinstance(raw, dict) else {} + return { + "skin": _norm_skin(src.get("skin")), + "navigation": _norm_bool_map(src.get("navigation"), NAV_KEYS, True), + "sections": _norm_bool_map(src.get("sections"), SECTION_KEYS, True), + "pages": _norm_pages(src.get("pages")), + "announcement": _norm_announcement(src.get("announcement")), + "featuredCityIds": _norm_featured(src.get("featuredCityIds")), + } + + +def _sync_portal_fields(copy: dict[str, Any], experience: dict[str, Any]) -> None: + copy["socialSkin"] = experience["skin"] + copy["socialExperience"] = experience + hidden = [key for key, on in experience["sections"].items() if not on] + copy["socialHiddenSections"] = hidden + zh_pages = experience.get("pages", {}).get("zh") + if isinstance(zh_pages, dict) and zh_pages: + pages = dict(copy.get("socialPages") or {}) if isinstance(copy.get("socialPages"), dict) else {} + for key, value in zh_pages.items(): + if key == "home": + if value.get("eyebrow"): + copy["socialEyebrow"] = value["eyebrow"] + if value.get("title"): + copy["socialHeroLine1"] = value["title"] + if value.get("accent"): + copy["socialHeroAccent"] = value["accent"] + if value.get("description"): + copy["socialHeroLead"] = value["description"] + continue + pages[key] = {**(pages.get(key) if isinstance(pages.get(key), dict) else {}), **value} + copy["socialPages"] = pages + + +def read_experience() -> dict[str, Any]: + raw = _read_raw() + copy = raw.get("copy") if isinstance(raw.get("copy"), dict) else {} + stored = copy.get("socialExperience") + if not isinstance(stored, dict): + stored = { + "skin": copy.get("socialSkin") or SKIN_DEFAULT, + "navigation": {}, + "sections": {}, + "pages": {}, + "announcement": {}, + "featuredCityIds": [], + } + # seed sections from legacy socialHiddenSections + hidden = copy.get("socialHiddenSections") + if isinstance(hidden, list): + sections = {k: True for k in SECTION_KEYS} + for item in hidden: + key = str(item or "").strip() + if key in sections: + sections[key] = False + stored["sections"] = sections + experience = normalize_experience(stored) + return { + "ok": True, + "version": int(raw.get("version") or 1), + "updatedAt": raw.get("updatedAt"), + "experience": experience, + "skins": list(SKIN_META), + "configPath": str(resolve_config_file()), + } + + +def write_experience(expected_version: int | None, experience_raw: Any) -> dict[str, Any]: + raw = _read_raw() + current_version = int(raw.get("version") or 1) + if expected_version is not None and int(expected_version) != current_version: + raise HTTPException(409, "配置已更新,请加载最新配置后重试;当前草稿尚未保存") + experience = normalize_experience(experience_raw) + out = dict(raw) if raw else {"version": 1, "modules": {}, "flags": {}, "copy": {}} + copy = dict(out.get("copy") or {}) + _sync_portal_fields(copy, experience) + out["copy"] = copy + _write_raw(out) + return read_experience() diff --git a/apps/api/services/social_svc/pb_data.py b/apps/api/services/social_svc/pb_data.py index 29e003a..730fa72 100644 --- a/apps/api/services/social_svc/pb_data.py +++ b/apps/api/services/social_svc/pb_data.py @@ -1,6 +1,7 @@ """Social data access via online PocketBase (no SQLite).""" from __future__ import annotations +import os import time import uuid import hashlib @@ -2115,6 +2116,13 @@ def admin_list_feedback( def _row(r: dict[str, Any]) -> dict[str, Any]: meta = r.get("meta") if isinstance(r.get("meta"), dict) else {} + if isinstance(r.get("meta"), str): + try: + parsed_meta = json.loads(r.get("meta") or "") + if isinstance(parsed_meta, dict): + meta = parsed_meta + except Exception: + meta = {} guest = r.get("guestId") or r.get("guest_id") or "" contact = r.get("contact") or "" user_key = str(r.get("userKey") or r.get("user_key") or "") or feedback_user_key( @@ -2122,12 +2130,25 @@ def admin_list_feedback( contact=str(contact), meta=meta, ) + images = r.get("images") + if isinstance(images, str): + try: + images = json.loads(images) + except Exception: + images = [] + if not isinstance(images, list): + images = [] + images = [ + str(u).strip() + for u in images + if isinstance(u, str) and str(u).strip().startswith(("http://", "https://")) + ] return { "id": r.get("id"), "kind": r.get("kind"), "text": r.get("text"), "contact": contact, - "images": r.get("images") if isinstance(r.get("images"), list) else [], + "images": images, "meta": meta, "userKey": user_key, "guestId": guest, @@ -2155,12 +2176,16 @@ def admin_list_feedback( for r in src: if isinstance(r, dict): _append(r) - # Also portal data/feedback.json + # Also portal data/feedback.json (monorepo + production absolute paths) try: - portal_fb = Path.cwd() / "data" / "feedback.json" - root_fb = Path(__file__).resolve().parents[4] / "data" / "feedback.json" - for p in (portal_fb, root_fb): - if not p.is_file(): + candidates = [ + Path.cwd() / "data" / "feedback.json", + Path(__file__).resolve().parents[4] / "data" / "feedback.json", + Path("/var/www/nomadro.cn/data/feedback.json"), + Path(os.environ.get("PORTAL_FEEDBACK_JSON", "")), + ] + for p in candidates: + if not p or not str(p) or not p.is_file(): continue raw = json.loads(p.read_text(encoding="utf-8")) rows = raw.get("items") if isinstance(raw, dict) else raw diff --git a/apps/api/tests/test_social_experience.py b/apps/api/tests/test_social_experience.py index 9df47b3..04f64b7 100644 --- a/apps/api/tests/test_social_experience.py +++ b/apps/api/tests/test_social_experience.py @@ -57,4 +57,21 @@ class ExperienceTests(unittest.TestCase): self.assertEqual(json.loads(self.path.read_text()),self.original) self.assertEqual(self.client.put('/api/admin/social/ugc/experience',json={'expectedVersion':7,'experience':{'announcement':{'href':''}}}).status_code,200) + def test_skin_switch_persists_theme_one_default(self): + self.login() + url='/api/admin/social/ugc/experience' + got=self.client.get(url).json() + self.assertEqual(got['experience']['skin'],'1') + body={'expectedVersion':7,'experience':{'skin':'2'}} + response=self.client.put(url,json=body) + self.assertEqual(response.status_code,200,response.text) + payload=response.json() + self.assertEqual(payload['experience']['skin'],'2') + raw=json.loads(self.path.read_text(encoding='utf-8')) + self.assertEqual(raw['copy']['socialSkin'],'2') + self.assertEqual(raw['copy']['socialExperience']['skin'],'2') + bad=self.client.put(url,json={'expectedVersion':8,'experience':{'skin':'9'}}) + self.assertEqual(bad.status_code,200) + self.assertEqual(bad.json()['experience']['skin'],'1') + if __name__=='__main__': unittest.main() diff --git a/apps/com/admin/src/App.tsx b/apps/com/admin/src/App.tsx index dfb740d..0d02de8 100644 --- a/apps/com/admin/src/App.tsx +++ b/apps/com/admin/src/App.tsx @@ -8,6 +8,7 @@ import { Ntfy, Orders, SocialDetail, + SocialExperience, SocialLocaleGeo, Switches, Users, @@ -106,6 +107,7 @@ export default function App() { } /> } /> } /> + } /> } /> } /> } /> diff --git a/apps/com/admin/src/components/WebLayout.tsx b/apps/com/admin/src/components/WebLayout.tsx index 02d7307..7f661df 100644 --- a/apps/com/admin/src/components/WebLayout.tsx +++ b/apps/com/admin/src/components/WebLayout.tsx @@ -67,6 +67,7 @@ function buildNav(lane: LaneKey): NavGroup[] { { to: `${p}/switches`, label: '页面开关', ico: '开' }, { to: `${p}/audience`, label: '受众设置', ico: '众' }, { to: `${s}/catalog`, label: '目录配置', ico: '录' }, + { to: `${s}/experience`, label: '体验主题', ico: '肤' }, { to: `${s}/locale-geo`, label: '语言国家', ico: '语' }, ], }, diff --git a/apps/com/admin/src/lib/pageModules.ts b/apps/com/admin/src/lib/pageModules.ts index 212eeae..52e8889 100644 --- a/apps/com/admin/src/lib/pageModules.ts +++ b/apps/com/admin/src/lib/pageModules.ts @@ -24,6 +24,7 @@ export const Users = lz(() => import('../pages/Users')) export const Ntfy = lz(() => import('../pages/Ntfy')) export const SocialDetail = lz(() => import('../pages/SocialDetail')) export const SocialLocaleGeo = lz(() => import('../pages/SocialLocaleGeo')) +export const SocialExperience = lz(() => import('../pages/SocialExperience')) export const Blog = lz(() => import('../pages/Blog')) /** Warm likely next chunks after shell mounts / on idle. */ @@ -32,6 +33,7 @@ export function warmSecondaryChunks() { void Blog.preload() void Switches.preload() void Events.preload() + void SocialExperience.preload() } if (typeof requestIdleCallback === 'function') { requestIdleCallback(run, { timeout: 2500 }) @@ -42,6 +44,7 @@ export function warmSecondaryChunks() { /** Preload chunk for a nav target before click. */ export function preloadForPath(to: string) { + if (to.includes('/social/experience')) return void SocialExperience.preload() if (to.includes('/social/locale-geo')) return void SocialLocaleGeo.preload() if (/\/social\/[^/]+\/[^/]+/.test(to)) return void SocialDetail.preload() if (to.includes('/blog')) return void Blog.preload() diff --git a/apps/com/admin/src/pages/Docs.tsx b/apps/com/admin/src/pages/Docs.tsx index 8ffaaba..b082c97 100644 --- a/apps/com/admin/src/pages/Docs.tsx +++ b/apps/com/admin/src/pages/Docs.tsx @@ -23,6 +23,9 @@ export default function Docs() {
  • …/social — 游民社区 UGC(聊天 / 花名册 / 评价 / 接单 / 反馈)
  • +
  • + …/social/experience — 视觉主题 1/2/3/4 · 首页编排 · 文案(remote-config) +
  • …/social/locale-geo — 语言开关 / 国家目录 / 优先城市(remote-config)
  • diff --git a/apps/com/admin/src/pages/ImageLightbox.tsx b/apps/com/admin/src/pages/ImageLightbox.tsx new file mode 100644 index 0000000..e01ab8b --- /dev/null +++ b/apps/com/admin/src/pages/ImageLightbox.tsx @@ -0,0 +1,135 @@ +/** + * Fullscreen image slideshow for admin feedback / media lists. + */ +import { useEffect, useCallback } from 'react' +import { resolveMediaUrl } from './MediaValue' + +type Props = { + urls: string[] + index: number + onClose: () => void + onIndex: (i: number) => void +} + +export function ImageLightbox({ urls, index, onClose, onIndex }: Props) { + const total = urls.length + const safeIndex = total ? ((index % total) + total) % total : 0 + const src = total ? resolveMediaUrl(urls[safeIndex]) : '' + + const prev = useCallback(() => { + if (!total) return + onIndex((safeIndex - 1 + total) % total) + }, [onIndex, safeIndex, total]) + + const next = useCallback(() => { + if (!total) return + onIndex((safeIndex + 1) % total) + }, [onIndex, safeIndex, total]) + + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if (e.key === 'Escape') onClose() + if (e.key === 'ArrowLeft') prev() + if (e.key === 'ArrowRight') next() + } + window.addEventListener('keydown', onKey) + const prevOverflow = document.body.style.overflow + document.body.style.overflow = 'hidden' + return () => { + window.removeEventListener('keydown', onKey) + document.body.style.overflow = prevOverflow + } + }, [onClose, prev, next]) + + if (!total) return null + + return ( +
    + + {total > 1 ? ( + <> + + + + ) : null} +
    e.stopPropagation()} + > + +
    + {safeIndex + 1} / {total} + + 原图 + +
    +
    + {total > 1 ? ( +
    e.stopPropagation()} + > + {urls.map((u, i) => ( + + ))} +
    + ) : null} +
    + ) +} + +export function feedbackImageUrls(row: Record): string[] { + const raw = row.images + if (!Array.isArray(raw)) return [] + return raw + .filter((u): u is string => typeof u === 'string') + .map((u) => u.trim()) + .filter((u) => /^https?:\/\//i.test(u)) +} diff --git a/apps/com/admin/src/pages/LaneHub.tsx b/apps/com/admin/src/pages/LaneHub.tsx index 3f22c5a..35a6c6d 100644 --- a/apps/com/admin/src/pages/LaneHub.tsx +++ b/apps/com/admin/src/pages/LaneHub.tsx @@ -156,6 +156,7 @@ export default function LaneHub({ lane }: { lane: LaneKey }) { { to: `/${lane}/social/overview`, ico: '◈', title: '指挥台', desc: '加入 / 自拍 / 举报优先' }, { to: `/${lane}/pricing`, ico: '¥', title: '动态价格', desc: '免费 / 付费一键切换 · 体验次数' }, { to: `/${lane}/switches`, ico: '开', title: '页面开关', desc: '模块显隐 · VIP 入口 · 文案' }, + { to: `/${lane}/social/experience`, ico: '肤', title: '体验主题', desc: '主题1/2/3/4 · 首页编排 · 文案' }, { to: `/${lane}/social/locale-geo`, ico: '语', title: '语言国家', desc: '多语言开关 · 国家目录 · 优先城市' }, { to: `/${lane}/blog`, ico: '✎', title: 'Nomad Blog', desc: '文章显隐 / 置顶' }, { to: `/${lane}/orders`, ico: '订', title: '订单', desc: '支付与发货' }, diff --git a/apps/com/admin/src/pages/Social.tsx b/apps/com/admin/src/pages/Social.tsx index 9735f6e..7ddb579 100644 --- a/apps/com/admin/src/pages/Social.tsx +++ b/apps/com/admin/src/pages/Social.tsx @@ -2,7 +2,13 @@ * 游民社区 · 列表页(无页内 Tab;侧栏二级菜单切入) * 整行可进详情;分页;软删除进存档。 */ -import { useCallback, useEffect, useMemo, useState } from 'react' +import { + useCallback, + useEffect, + useMemo, + useState, + type MouseEvent as ReactMouseEvent, +} from 'react' import { Link, Navigate, @@ -34,6 +40,10 @@ import { short, } from './socialMeta' import { looksLikeUrl, MediaValue } from './MediaValue' +import { + ImageLightbox, + feedbackImageUrls, +} from './ImageLightbox' function rowLivePeer( row: Record, @@ -229,8 +239,56 @@ export default function Social() { const [msg, setMsg] = useState('') const [catalogJson, setCatalogJson] = useState('') const [editRoster, setEditRoster] = useState | null>(null) + const [lightbox, setLightbox] = useState<{ urls: string[]; index: number } | null>( + null, + ) const presence = useSharedSocialPresence() + const openFeedbackImages = ( + row: Record, + index = 0, + e?: ReactMouseEvent, + ) => { + e?.stopPropagation() + const urls = feedbackImageUrls(row) + if (!urls.length) return + setLightbox({ urls, index: Math.max(0, Math.min(index, urls.length - 1)) }) + } + + const renderFeedbackImageCell = (row: Record) => { + const urls = feedbackImageUrls(row) + if (!urls.length) { + return — + } + return ( +
    e.stopPropagation()} + > + {urls.slice(0, 4).map((url, i) => ( + + ))} + {urls.length > 4 ? ( + + ) : null} +
    + ) + } + const loadOverview = useCallback(async () => { const data = await api('/api/admin/social/ugc/overview') setOverview(data) @@ -877,7 +935,8 @@ export default function Social() { {personKey ? '#' : '类型'} {personKey ? '类型' : '内容'} - {personKey ? '内容 / 截图' : '联系'} + 图片 + {personKey ? '内容' : '联系'} {personKey ? '联系' : '访客'} 时间 操作 @@ -1085,6 +1144,7 @@ export default function Social() { ) : null} {short(row.text, 56)} + {renderFeedbackImageCell(row)} {short(row.contact, 24) || '—'} { @@ -1121,38 +1181,8 @@ export default function Social() { {String(row.kind || '—')} - -
    {short(row.text, 72)}
    - {Array.isArray(row.images) && row.images.length ? ( -
    e.stopPropagation()} - > - {(row.images as unknown[]) - .filter((u): u is string => typeof u === 'string') - .slice(0, 4) - .map((url) => ( - - - - ))} -
    - ) : null} - + {renderFeedbackImageCell(row)} + {short(row.text, 72)} {short(row.contact, 24) || '—'} {fmtTime(row.created_at || row.createdAt || row.at)} @@ -1481,6 +1511,15 @@ export default function Social() { ) : null} + {lightbox ? ( + setLightbox(null)} + onIndex={(i) => setLightbox((cur) => (cur ? { ...cur, index: i } : cur))} + /> + ) : null} + {editRoster ? (
    setEditRoster(null)}>
    e.stopPropagation()}> diff --git a/apps/com/admin/src/pages/SocialExperience.tsx b/apps/com/admin/src/pages/SocialExperience.tsx index d887a14..e9bb74d 100644 --- a/apps/com/admin/src/pages/SocialExperience.tsx +++ b/apps/com/admin/src/pages/SocialExperience.tsx @@ -6,13 +6,16 @@ import { useConfigLive } from '../lib/useConfigLive' type PageCopy = { eyebrow?: string; title?: string; accent?: string; description?: string } type Experience = { + skin?: string navigation?: Record sections?: Record pages?: Record> announcement?: { enabled?: boolean; zh?: string; en?: string; href?: string } featuredCityIds?: string[] } -type Response = { version: number; experience: Experience } +type SkinMeta = { id: string; label: string; note: string } +type Response = { version: number; experience: Experience; skins?: SkinMeta[] } + const GROUPS = [ { title: '认识人', items: [['chat', '聊天群'], ['people', '想见的人'], ['date', '约会'], ['meetup', '语音厅']] }, { title: '见一面', items: [['coffeechat', '线下咖啡聊'], ['map', '地图'], ['places', '城市']] }, @@ -20,6 +23,12 @@ const GROUPS = [ ] const SECTIONS = [['discover', '探索方向'], ['people', '发现朋友'], ['cities', '城市与咖啡'], ['meetup', '聊天与语音厅'], ['collaborate', '一起做事'], ['faq', '常见问题']] const PAGES = [['home', '首页首屏'], ['discovery', '探索方向标题'], ...GROUPS.flatMap(group => group.items), ['roster', '我的介绍']] +const DEFAULT_SKINS: SkinMeta[] = [ + { id: '1', label: '主题1 · 旅居社群', note: '当前线上默认样式(已保存)' }, + { id: '2', label: '主题2 · 琥珀信号', note: 'theme2.css' }, + { id: '3', label: '主题3 · 预留', note: '可后续扩展 CSS' }, + { id: '4', label: '主题4 · 预留', note: '可后续扩展 CSS' }, +] const DEFAULT_HOME: Record = { zh: { eyebrow: '自由生活,同频相遇', title: '世界很大,', accent: '同频的人不远。', description: '换一座城市,不必重新孤独。从一句你好、一杯咖啡开始,找到一起探索、一起创造的人。' }, en: { eyebrow: 'FREE LIVING. SAME WAVELENGTH.', title: 'A big world.', accent: 'Your kind of people.', description: 'A new city doesn’t have to mean starting over alone. Find your people through a hello, a coffee, or something you build together.' }, @@ -30,6 +39,7 @@ export default function SocialExperience() { const [remote, setRemote] = useState(null) const [draft, setDraft] = useState({}) const [baseline, setBaseline] = useState('{}') + const [skins, setSkins] = useState(DEFAULT_SKINS) const [locale, setLocale] = useState('zh') const [page, setPage] = useState('home') const [loading, setLoading] = useState(false) @@ -42,7 +52,11 @@ export default function SocialExperience() { setLoading(true); setError('') try { const result = await api('/api/admin/social/ugc/experience') - setRemote(result); setDraft(result.experience || {}); setBaseline(JSON.stringify(result.experience || {})) + const experience = { skin: '1', ...(result.experience || {}) } + setRemote(result) + setDraft(experience) + setBaseline(JSON.stringify(experience)) + if (Array.isArray(result.skins) && result.skins.length) setSkins(result.skins) } catch (e) { setError(e instanceof Error ? e.message : '加载失败') } finally { setLoading(false) } }, []) @@ -53,19 +67,51 @@ export default function SocialExperience() { setSaving(true); setMessage(''); setError('') try { const result = await api('/api/admin/social/ugc/experience', { method: 'PUT', body: JSON.stringify({ expectedVersion: remote.version, experience: draft }) }) - setRemote(result); setDraft(result.experience); setBaseline(JSON.stringify(result.experience)); setMessage('社区体验配置已发布,门户将自动更新。') + const experience = { skin: '1', ...(result.experience || {}) } + setRemote(result) + setDraft(experience) + setBaseline(JSON.stringify(experience)) + if (Array.isArray(result.skins) && result.skins.length) setSkins(result.skins) + setMessage(`社区体验已发布(主题${experience.skin || '1'}),门户将自动更新。`) } catch (e) { setError(e instanceof Error ? e.message : '发布失败;草稿已保留') } finally { setSaving(false) } } const copy = draft.pages?.[locale]?.[page] || {} const pageField = (key: keyof PageCopy, value: string) => setDraft(current => ({ ...current, pages: { ...current.pages, [locale]: { ...current.pages?.[locale], [page]: { ...current.pages?.[locale]?.[page], [key]: value } } } })) + const activeSkin = draft.skin || '1' return
    -

    SOCIAL / EXPERIENCE STUDIO

    社区体验设计台

    首页、导航与中英文文案 · 美国 .com 门户

    预览线上首页 ↗
    +

    SOCIAL / EXPERIENCE STUDIO

    社区体验设计台

    视觉主题 · 首页 · 导航 · 中英文文案 · 美国 .com 门户

    预览线上首页 ↗
    {error &&
    {error}
    } {message &&
    {message}
    } {stale &&
    配置已有新版本。先复制需要保留的文案,再加载最新配置后编辑。
    } {!remote ?
    {loading ? '正在加载社区配置…' : }
    :
    +
    +
    +
    +

    视觉主题切换

    +

    主题1 已保存为当前线上样式。切换后点「发布社区体验」,门户 `/social` 会按远程配置换肤。

    +
    + 当前草稿 · 主题{activeSkin} +
    +
    + {skins.map(skin => ( + + ))} +
    +

    三个连接方向,一套清晰导航

    控制主导航和功能搜索的入口。隐藏入口不删除页面,也不改变业务权限。

    {GROUPS.map(group =>

    {group.title}

    {group.items.map(([key, label]) => )}
    )}
    @@ -78,7 +124,7 @@ export default function SocialExperience() {
    {(['eyebrow', 'title', 'accent', 'description'] as const).map(key =>