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 <cursoragent@cursor.com>
This commit is contained in:
parent
9ef0729eeb
commit
893526942c
@ -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
|
||||
|
||||
231
apps/api/services/ebook_svc/services/social_experience.py
Normal file
231
apps/api/services/ebook_svc/services/social_experience.py
Normal file
@ -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()
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
Ntfy,
|
||||
Orders,
|
||||
SocialDetail,
|
||||
SocialExperience,
|
||||
SocialLocaleGeo,
|
||||
Switches,
|
||||
Users,
|
||||
@ -106,6 +107,7 @@ export default function App() {
|
||||
<Route path="social/joins" element={<Social />} />
|
||||
<Route path="social/catalog" element={<Social />} />
|
||||
<Route path="social/locale-geo" element={<SocialLocaleGeo />} />
|
||||
<Route path="social/experience" element={<SocialExperience />} />
|
||||
<Route path="social/roster/:id" element={<SocialDetail />} />
|
||||
<Route path="social/messages/:id" element={<SocialDetail />} />
|
||||
<Route path="social/reviews/:id" element={<SocialDetail />} />
|
||||
|
||||
@ -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: '语' },
|
||||
],
|
||||
},
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -23,6 +23,9 @@ export default function Docs() {
|
||||
<li>
|
||||
<code>…/social</code> — 游民社区 UGC(聊天 / 花名册 / 评价 / 接单 / 反馈)
|
||||
</li>
|
||||
<li>
|
||||
<code>…/social/experience</code> — 视觉主题 1/2/3/4 · 首页编排 · 文案(remote-config)
|
||||
</li>
|
||||
<li>
|
||||
<code>…/social/locale-geo</code> — 语言开关 / 国家目录 / 优先城市(remote-config)
|
||||
</li>
|
||||
|
||||
135
apps/com/admin/src/pages/ImageLightbox.tsx
Normal file
135
apps/com/admin/src/pages/ImageLightbox.tsx
Normal file
@ -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 (
|
||||
<div
|
||||
className="com-lightbox"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="图片预览"
|
||||
onClick={onClose}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="com-lightbox-close"
|
||||
aria-label="关闭"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
{total > 1 ? (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="com-lightbox-nav com-lightbox-prev"
|
||||
aria-label="上一张"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
prev()
|
||||
}}
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="com-lightbox-nav com-lightbox-next"
|
||||
aria-label="下一张"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
next()
|
||||
}}
|
||||
>
|
||||
›
|
||||
</button>
|
||||
</>
|
||||
) : null}
|
||||
<figure
|
||||
className="com-lightbox-stage"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<img src={src} alt="" />
|
||||
<figcaption>
|
||||
{safeIndex + 1} / {total}
|
||||
<a href={src} target="_blank" rel="noreferrer">
|
||||
原图
|
||||
</a>
|
||||
</figcaption>
|
||||
</figure>
|
||||
{total > 1 ? (
|
||||
<div
|
||||
className="com-lightbox-thumbs"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{urls.map((u, i) => (
|
||||
<button
|
||||
key={`${u}-${i}`}
|
||||
type="button"
|
||||
className={
|
||||
i === safeIndex
|
||||
? 'com-lightbox-thumb is-active'
|
||||
: 'com-lightbox-thumb'
|
||||
}
|
||||
onClick={() => onIndex(i)}
|
||||
>
|
||||
<img src={resolveMediaUrl(u)} alt="" />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function feedbackImageUrls(row: Record<string, unknown>): 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))
|
||||
}
|
||||
@ -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: '支付与发货' },
|
||||
|
||||
@ -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<string, unknown>,
|
||||
@ -229,8 +239,56 @@ export default function Social() {
|
||||
const [msg, setMsg] = useState('')
|
||||
const [catalogJson, setCatalogJson] = useState('')
|
||||
const [editRoster, setEditRoster] = useState<Record<string, unknown> | null>(null)
|
||||
const [lightbox, setLightbox] = useState<{ urls: string[]; index: number } | null>(
|
||||
null,
|
||||
)
|
||||
const presence = useSharedSocialPresence()
|
||||
|
||||
const openFeedbackImages = (
|
||||
row: Record<string, unknown>,
|
||||
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<string, unknown>) => {
|
||||
const urls = feedbackImageUrls(row)
|
||||
if (!urls.length) {
|
||||
return <span className="com-muted">—</span>
|
||||
}
|
||||
return (
|
||||
<div
|
||||
className="com-feedback-thumbs"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{urls.slice(0, 4).map((url, i) => (
|
||||
<button
|
||||
key={`${url}-${i}`}
|
||||
type="button"
|
||||
className="com-feedback-thumb"
|
||||
title="点击放大"
|
||||
onClick={(e) => openFeedbackImages(row, i, e)}
|
||||
>
|
||||
<img src={url} alt="" loading="lazy" />
|
||||
</button>
|
||||
))}
|
||||
{urls.length > 4 ? (
|
||||
<button
|
||||
type="button"
|
||||
className="com-feedback-thumb-more"
|
||||
onClick={(e) => openFeedbackImages(row, 0, e)}
|
||||
>
|
||||
+{urls.length - 4}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const loadOverview = useCallback(async () => {
|
||||
const data = await api<Overview>('/api/admin/social/ugc/overview')
|
||||
setOverview(data)
|
||||
@ -877,7 +935,8 @@ export default function Social() {
|
||||
<tr>
|
||||
<th>{personKey ? '#' : '类型'}</th>
|
||||
<th>{personKey ? '类型' : '内容'}</th>
|
||||
<th>{personKey ? '内容 / 截图' : '联系'}</th>
|
||||
<th>图片</th>
|
||||
<th>{personKey ? '内容' : '联系'}</th>
|
||||
<th>{personKey ? '联系' : '访客'}</th>
|
||||
<th>时间</th>
|
||||
<th>操作</th>
|
||||
@ -1085,6 +1144,7 @@ export default function Social() {
|
||||
) : null}
|
||||
</td>
|
||||
<td>{short(row.text, 56)}</td>
|
||||
<td>{renderFeedbackImageCell(row)}</td>
|
||||
<td>{short(row.contact, 24) || '—'}</td>
|
||||
<td
|
||||
onClick={(e) => {
|
||||
@ -1121,38 +1181,8 @@ export default function Social() {
|
||||
<td>
|
||||
<span className="com-badge tone-info">{String(row.kind || '—')}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div>{short(row.text, 72)}</div>
|
||||
{Array.isArray(row.images) && row.images.length ? (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
gap: 6,
|
||||
marginTop: 6,
|
||||
flexWrap: 'wrap',
|
||||
}}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{(row.images as unknown[])
|
||||
.filter((u): u is string => typeof u === 'string')
|
||||
.slice(0, 4)
|
||||
.map((url) => (
|
||||
<a key={url} href={url} target="_blank" rel="noreferrer">
|
||||
<img
|
||||
src={url}
|
||||
alt=""
|
||||
style={{
|
||||
width: 44,
|
||||
height: 44,
|
||||
objectFit: 'cover',
|
||||
borderRadius: 8,
|
||||
}}
|
||||
/>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td>{renderFeedbackImageCell(row)}</td>
|
||||
<td>{short(row.text, 72)}</td>
|
||||
<td>{short(row.contact, 24) || '—'}</td>
|
||||
<td>{fmtTime(row.created_at || row.createdAt || row.at)}</td>
|
||||
</>
|
||||
@ -1481,6 +1511,15 @@ export default function Social() {
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{lightbox ? (
|
||||
<ImageLightbox
|
||||
urls={lightbox.urls}
|
||||
index={lightbox.index}
|
||||
onClose={() => setLightbox(null)}
|
||||
onIndex={(i) => setLightbox((cur) => (cur ? { ...cur, index: i } : cur))}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{editRoster ? (
|
||||
<div className="com-modal-mask" onClick={() => setEditRoster(null)}>
|
||||
<div className="com-modal" onClick={(e) => e.stopPropagation()}>
|
||||
|
||||
@ -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<string, boolean>
|
||||
sections?: Record<string, boolean>
|
||||
pages?: Record<string, Record<string, PageCopy>>
|
||||
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<string, PageCopy> = {
|
||||
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<Response | null>(null)
|
||||
const [draft, setDraft] = useState<Experience>({})
|
||||
const [baseline, setBaseline] = useState('{}')
|
||||
const [skins, setSkins] = useState<SkinMeta[]>(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<Response>('/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<Response>('/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 <div className="com-page com-experience">
|
||||
<UnsavedChanges dirty={dirty} />
|
||||
<header className="com-page-head com-page-head-row"><div><p className="com-kicker">SOCIAL / EXPERIENCE STUDIO</p><h1>社区体验设计台</h1><p>首页、导航与中英文文案 · 美国 .com 门户</p></div><a className="com-btn" href="https://nomadro.com/" target="_blank" rel="noreferrer">预览线上首页 ↗</a></header>
|
||||
<header className="com-page-head com-page-head-row"><div><p className="com-kicker">SOCIAL / EXPERIENCE STUDIO</p><h1>社区体验设计台</h1><p>视觉主题 · 首页 · 导航 · 中英文文案 · 美国 .com 门户</p></div><a className="com-btn" href="https://nomadro.com/" target="_blank" rel="noreferrer">预览线上首页 ↗</a></header>
|
||||
{error && <div className="com-toast com-toast-err" role="alert">{error}</div>}
|
||||
{message && <div className="com-toast" role="status">{message}</div>}
|
||||
{stale && <div className="com-toast com-toast-err" role="alert">配置已有新版本。先复制需要保留的文案,再加载最新配置后编辑。<button className="com-btn" onClick={() => void load()}>加载最新配置</button></div>}
|
||||
{!remote ? <div className="com-empty" role="status">{loading ? '正在加载社区配置…' : <button className="com-btn" onClick={() => void load()}>重试加载</button>}</div> : <fieldset className="com-experience-fields" disabled={saving}>
|
||||
<section className="com-panel">
|
||||
<div className="com-panel-head">
|
||||
<div>
|
||||
<h2>视觉主题切换</h2>
|
||||
<p className="com-muted">主题1 已保存为当前线上样式。切换后点「发布社区体验」,门户 `/social` 会按远程配置换肤。</p>
|
||||
</div>
|
||||
<span className="com-chip com-chip-ok">当前草稿 · 主题{activeSkin}</span>
|
||||
</div>
|
||||
<div className="com-experience-nav-grid" role="radiogroup" aria-label="社区视觉主题">
|
||||
{skins.map(skin => (
|
||||
<label className="com-experience-toggle" key={skin.id} data-active={activeSkin === skin.id ? 'true' : 'false'}>
|
||||
<span>
|
||||
{skin.label}
|
||||
<small>{skin.note}</small>
|
||||
</span>
|
||||
<input
|
||||
type="radio"
|
||||
name="social-skin"
|
||||
value={skin.id}
|
||||
checked={activeSkin === skin.id}
|
||||
onChange={() => setDraft(current => ({ ...current, skin: skin.id }))}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<section className="com-panel"><div className="com-panel-head"><div><h2>三个连接方向,一套清晰导航</h2><p className="com-muted">控制主导航和功能搜索的入口。隐藏入口不删除页面,也不改变业务权限。</p></div></div>
|
||||
<div className="com-experience-nav-grid">{GROUPS.map(group => <div key={group.title}><h3>{group.title}</h3>{group.items.map(([key, label]) => <label className="com-experience-toggle" key={key}><span>{label}<small>/social/{key}</small></span><input type="checkbox" checked={draft.navigation?.[key] !== false} onChange={event => setDraft(current => ({ ...current, navigation: { ...current.navigation, [key]: event.target.checked } }))} /></label>)}</div>)}</div>
|
||||
</section>
|
||||
@ -78,7 +124,7 @@ export default function SocialExperience() {
|
||||
<div className="com-experience-copy-grid">{(['eyebrow', 'title', 'accent', 'description'] as const).map(key => <label className="com-field" key={key}>{({ eyebrow: '引导短句', title: '主标题', accent: '强调文案', description: '介绍文案' })[key]}{key === 'description' ? <textarea rows={4} maxLength={2000} value={copy[key] || ''} placeholder={page === 'home' ? DEFAULT_HOME[locale][key] : '留空使用默认内容'} onChange={event => pageField(key, event.target.value)} /> : <input maxLength={key === 'eyebrow' ? 200 : 300} value={copy[key] || ''} placeholder={page === 'home' ? DEFAULT_HOME[locale][key] : '留空使用默认内容'} onChange={event => pageField(key, event.target.value)} />}</label>)}</div>
|
||||
<div className="com-experience-preview" lang={locale === 'zh' ? 'zh-CN' : 'en'}><small>{copy.eyebrow || (page === 'home' ? DEFAULT_HOME[locale].eyebrow : 'NOMADRO / COMMUNITY')}</small><h2>{copy.title || (page === 'home' ? DEFAULT_HOME[locale].title : '页面默认标题')} <span>{copy.accent || (page === 'home' ? DEFAULT_HOME[locale].accent : '')}</span></h2><p>{copy.description || (page === 'home' ? DEFAULT_HOME[locale].description : '页面会在此显示介绍文案。')}</p></div>
|
||||
</section>
|
||||
<div className="com-experience-save"><span>配置版本 v{remote.version} · {dirty ? '有待发布修改' : '已与线上同步'}</span><button className="com-btn" disabled={!dirty || saving || Boolean(stale)} onClick={() => void save()}>{saving ? '正在发布…' : '发布社区体验'}</button></div>
|
||||
<div className="com-experience-save"><span>配置版本 v{remote.version} · 主题{activeSkin} · {dirty ? '有待发布修改' : '已与线上同步'}</span><button className="com-btn" disabled={!dirty || saving || Boolean(stale)} onClick={() => void save()}>{saving ? '正在发布…' : '发布社区体验'}</button></div>
|
||||
</fieldset>}
|
||||
</div>
|
||||
}
|
||||
|
||||
@ -1802,6 +1802,140 @@ button.com-chip.is-on,
|
||||
gap: 12px;
|
||||
margin: 8px 0 4px;
|
||||
}
|
||||
|
||||
/* Feedback list thumbs + fullscreen slideshow */
|
||||
.com-feedback-thumbs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
max-width: 220px;
|
||||
}
|
||||
.com-feedback-thumb {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #09090b;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
.com-feedback-thumb img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.com-feedback-thumb-more {
|
||||
min-width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 8px;
|
||||
border: 1px dashed var(--line);
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.com-lightbox {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1200;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 24px 16px 20px;
|
||||
background: rgba(0, 0, 0, 0.88);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.com-lightbox-close {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: 16px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
font-size: 28px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.com-lightbox-nav {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
font-size: 32px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.com-lightbox-prev { left: 16px; }
|
||||
.com-lightbox-next { right: 16px; }
|
||||
.com-lightbox-stage {
|
||||
margin: 0;
|
||||
max-width: min(960px, 92vw);
|
||||
max-height: calc(100dvh - 140px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.com-lightbox-stage img {
|
||||
max-width: 100%;
|
||||
max-height: calc(100dvh - 180px);
|
||||
object-fit: contain;
|
||||
border-radius: 12px;
|
||||
background: #09090b;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
.com-lightbox-stage figcaption {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
color: #d4d4d8;
|
||||
font-size: 13px;
|
||||
}
|
||||
.com-lightbox-stage figcaption a {
|
||||
color: #f59e0b;
|
||||
}
|
||||
.com-lightbox-thumbs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
max-width: min(960px, 92vw);
|
||||
overflow-x: auto;
|
||||
padding: 4px 2px;
|
||||
}
|
||||
.com-lightbox-thumb {
|
||||
flex: 0 0 auto;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
padding: 0;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #111;
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.com-lightbox-thumb.is-active {
|
||||
border-color: #f59e0b;
|
||||
opacity: 1;
|
||||
}
|
||||
.com-lightbox-thumb img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.com-media {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
|
||||
@ -135,7 +135,7 @@ export function ConnectionHero({
|
||||
</H5El>
|
||||
<H5El>
|
||||
<H5El as='strong'>同频的人,正在这里相遇</H5El>
|
||||
<H5El as='span'>自由职业 · 远程工作 · 出来见一面</H5El>
|
||||
<H5El as='span'>自由职业 · 远程协作 · 出来见一面</H5El>
|
||||
</H5El>
|
||||
</H5El>
|
||||
</H5El>
|
||||
|
||||
@ -183,21 +183,66 @@ export async function POST(req: NextRequest) {
|
||||
store.items = store.items.slice(0, 2000);
|
||||
await writeStore(store);
|
||||
|
||||
// Best-effort forward to social_svc (PB) — failure does not fail the request
|
||||
const payload = JSON.stringify({ kind, text, contact, images, meta });
|
||||
// Forward to social_svc → PocketBase (admin 读 PB,不是 Next 本机 JSON)。
|
||||
// 对齐 join-leads:await 同源 rewrite + SOCIAL_API_URL,禁止只写 local。
|
||||
const payload = JSON.stringify({
|
||||
kind,
|
||||
text,
|
||||
contact,
|
||||
images,
|
||||
meta,
|
||||
guestId,
|
||||
});
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Social-Guest-Id": guestId || "portal",
|
||||
};
|
||||
const upstreams: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
const pushUp = (base: string) => {
|
||||
const b = (base || "").replace(/\/$/, "");
|
||||
if (!b || seen.has(b)) return;
|
||||
seen.add(b);
|
||||
upstreams.push(b);
|
||||
};
|
||||
try {
|
||||
const proto =
|
||||
req.headers.get("x-forwarded-proto") ||
|
||||
req.nextUrl.protocol.replace(":", "") ||
|
||||
"https";
|
||||
const host =
|
||||
req.headers.get("x-forwarded-host") ||
|
||||
req.headers.get("host") ||
|
||||
req.nextUrl.host;
|
||||
if (host) pushUp(`${proto}://${host}`);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
for (const raw of [process.env.SOCIAL_API_URL, process.env.API_URL]) {
|
||||
const base = (raw || "").replace(/\/$/, "");
|
||||
if (!base || /127\.0\.0\.1|localhost/i.test(base)) continue;
|
||||
void fetch(`${base}/api/social/v1/feedback`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
signal: AbortSignal.timeout(4000),
|
||||
}).catch(() => undefined);
|
||||
pushUp(raw || "");
|
||||
}
|
||||
// Production Next often has empty SOCIAL_API_URL; hard-fallback to online .com.
|
||||
pushUp("https://nomadro.com");
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
pushUp("http://127.0.0.1:8020");
|
||||
}
|
||||
|
||||
let forwarded = false;
|
||||
for (const upstream of upstreams) {
|
||||
try {
|
||||
const res = await fetch(`${upstream}/api/social/v1/feedback`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
signal: AbortSignal.timeout(8000),
|
||||
});
|
||||
if (res.ok) {
|
||||
forwarded = true;
|
||||
break;
|
||||
}
|
||||
} catch {
|
||||
/* try next upstream */
|
||||
}
|
||||
}
|
||||
|
||||
return withCors(
|
||||
@ -211,7 +256,8 @@ export async function POST(req: NextRequest) {
|
||||
userKey: item.userKey,
|
||||
guestId: item.guestId,
|
||||
at: item.at,
|
||||
stored: "local",
|
||||
stored: forwarded ? "pb" : "local",
|
||||
forwarded,
|
||||
remaining: Math.max(0, FEEDBACK_MAX_PER_USER - used - 1),
|
||||
max: FEEDBACK_MAX_PER_USER,
|
||||
}),
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { ModuleBoundary } from "~/components/module-boundary";
|
||||
/* 主题1:旅居社群对齐;主题2:琥珀信号(theme2.css,可切换) */
|
||||
/* 主题1=旅居社群(默认)· 主题2=琥珀信号 · 主题3/4=预留;后台 remote skin 可切换 */
|
||||
import "@community/app/globals.css";
|
||||
import "@social/app/globals.css";
|
||||
import "@social/app/fx.css";
|
||||
import "@social/app/theme2.css";
|
||||
import "@social/app/theme3.css";
|
||||
import "@social/app/theme4.css";
|
||||
import "@social/app/home.css";
|
||||
import "@social/app/experience.css";
|
||||
import "@social/app/interaction.css";
|
||||
@ -31,10 +33,10 @@ export default function SocialLayout({
|
||||
return (
|
||||
<ModuleBoundary moduleKey="social">
|
||||
<div className="community-root social-skin">
|
||||
{/* 首屏防闪:默认主题1;切换器已隐藏,皮肤代码保留可再开 */}
|
||||
{/* 首屏防闪:优先缓存主题,否则主题1;远程配置拉取后由 SiteShell 覆盖 */}
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `(function(){try{localStorage.setItem('nomadro-social-skin','1');}catch(e){}document.documentElement.setAttribute('data-social-skin','1');})();`,
|
||||
__html: `(function(){var k='nomadro-social-skin',s='1';try{var v=localStorage.getItem(k);if(v==='1'||v==='2'||v==='3'||v==='4')s=v;}catch(e){}document.documentElement.setAttribute('data-social-skin',s);})();`,
|
||||
}}
|
||||
/>
|
||||
<SocialExperience>{children}</SocialExperience>
|
||||
|
||||
@ -333,6 +333,36 @@ export type NomadroRemoteConfig = {
|
||||
enabledCountries?: string[];
|
||||
featuredCityIds?: string[];
|
||||
};
|
||||
/**
|
||||
* /social 视觉主题:1=旅居社群(默认)· 2=琥珀信号 · 3/4=预留。
|
||||
* 管理后台「社区体验」可切换;离线默认主题1。
|
||||
*/
|
||||
socialSkin?: "1" | "2" | "3" | "4";
|
||||
/** 社区体验设计台完整配置(导航/区块/文案/主题) */
|
||||
socialExperience?: {
|
||||
skin?: "1" | "2" | "3" | "4";
|
||||
navigation?: Record<string, boolean>;
|
||||
sections?: Record<string, boolean>;
|
||||
pages?: Record<
|
||||
string,
|
||||
Record<
|
||||
string,
|
||||
{
|
||||
eyebrow?: string;
|
||||
title?: string;
|
||||
accent?: string;
|
||||
description?: string;
|
||||
}
|
||||
>
|
||||
>;
|
||||
announcement?: {
|
||||
enabled?: boolean;
|
||||
zh?: string;
|
||||
en?: string;
|
||||
href?: string;
|
||||
};
|
||||
featuredCityIds?: string[];
|
||||
};
|
||||
/** AdSense 文案位兜底(优先 flags) */
|
||||
adsenseClientId?: string;
|
||||
adsensePublisherId?: string;
|
||||
@ -631,6 +661,10 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
enabledCountries: [],
|
||||
featuredCityIds: ["chiangmai", "bali", "dali", "lisbon", "chengdu"],
|
||||
},
|
||||
socialSkin: "1",
|
||||
socialExperience: {
|
||||
skin: "1",
|
||||
},
|
||||
socialWayGroup: "聊天群",
|
||||
socialWayChat: "语音厅",
|
||||
socialWayDate: "约会",
|
||||
|
||||
8
src/modules/social/app/theme3.css
Normal file
8
src/modules/social/app/theme3.css
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* 游民社区 · 主题 3「预留」
|
||||
* html[data-social-skin="3"] 启用。当前继承主题1变量,后续可独立换肤。
|
||||
*/
|
||||
|
||||
html[data-social-skin="3"] .social-skin {
|
||||
/* 预留钩子:后续覆盖 --sc-* 即可 */
|
||||
}
|
||||
8
src/modules/social/app/theme4.css
Normal file
8
src/modules/social/app/theme4.css
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* 游民社区 · 主题 4「预留」
|
||||
* html[data-social-skin="4"] 启用。当前继承主题1变量,后续可独立换肤。
|
||||
*/
|
||||
|
||||
html[data-social-skin="4"] .social-skin {
|
||||
/* 预留钩子:后续覆盖 --sc-* 即可 */
|
||||
}
|
||||
@ -409,11 +409,11 @@ export function ConnectionWays({ copy }: { copy: SocialLandingCopy }) {
|
||||
},
|
||||
{
|
||||
id: "05",
|
||||
href: "/team",
|
||||
href: "/ebook",
|
||||
icon: Users,
|
||||
title: copy.socialWayTeam,
|
||||
sub: copy.socialTeamTitle,
|
||||
cta: "看看机会",
|
||||
cta: "逛共创",
|
||||
className: "mint",
|
||||
},
|
||||
];
|
||||
|
||||
@ -28,8 +28,8 @@ export default function HomeActionRail() {
|
||||
href: "/places", cta: tx("逛逛城市", "Explore cities"), secondary: "/places?tab=cafes", secondaryLabel: tx("找一家咖啡馆", "Find a cafe"), step: tx("选城市 → 看地点 → 安排见面", "Choose a city → Find a place → Make a plan") },
|
||||
{ id: "create", icon: Heart, label: tx("一起创造", "Build together"),
|
||||
title: tx("把共同兴趣,变成一起做的事。", "Turn shared interests into something real."),
|
||||
description: tx("从招聘机会到远程协作,找到可以一起行动的人和事。", "From hiring posts to remote collaboration, discover people and opportunities to build with."),
|
||||
href: "/team", cta: tx("看看招聘", "Browse hiring"), secondary: "/ebook", secondaryLabel: tx("看看共创机会", "Find co-create projects"), step: tx("看机会 → 表达兴趣 → 一起行动", "Browse roles → Express interest → Build together") },
|
||||
description: tx("从小册、视频共创到远程协作,找到可以一起行动的人和事。", "From co-creating guides and videos to remote collaboration, discover people and projects to build with."),
|
||||
href: "/ebook", cta: tx("逛共创", "Browse co-create"), secondary: "/work", secondaryLabel: tx("远程协作", "Remote collaboration"), step: tx("逛共创 → 表达兴趣 → 一起行动", "Browse co-create → Express interest → Build together") },
|
||||
];
|
||||
const selected = journeys.find(journey => journey.id === intent) || journeys[0];
|
||||
const selectedCopy = config.copy.socialPages?.[`discovery-${selected.id}`];
|
||||
|
||||
@ -480,6 +480,31 @@ export default function HomeClient() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{!loggedIn ? (
|
||||
<section
|
||||
className="connection-invite container"
|
||||
aria-label={t.joinCommunity}
|
||||
>
|
||||
<div className="connection-invite-orbit" aria-hidden="true">
|
||||
<span />
|
||||
<span />
|
||||
<Sparkles size={52} strokeWidth={1} />
|
||||
</div>
|
||||
<div>
|
||||
<span className="connection-eyebrow">{t.joinCommunity}</span>
|
||||
<h2>{landingCopy.socialInviteTitle}</h2>
|
||||
<p>{landingCopy.socialInviteLead}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn connection-join"
|
||||
onClick={openJoin}
|
||||
>
|
||||
{socialTx("加入游民社区")} <ArrowUpRight size={19} />
|
||||
</button>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
<FxBelt />
|
||||
|
||||
<section
|
||||
@ -491,7 +516,6 @@ export default function HomeClient() {
|
||||
<div className="section-header reveal">
|
||||
<SectionSpark label="team" />
|
||||
<span className="section-tag">
|
||||
<span>{socialTx("招聘")}</span>
|
||||
<span>{socialTx("共创")}</span>
|
||||
</span>
|
||||
<h2>
|
||||
@ -502,57 +526,11 @@ export default function HomeClient() {
|
||||
</h2>
|
||||
<p>
|
||||
{socialTx(
|
||||
"有人在找帮手;也有人一起写小册、拍视频做共创。点卡片看看详情,合适再表达兴趣。",
|
||||
"一起写小册、拍视频做共创。点卡片看看详情,合适再表达兴趣。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="social-together-tabs reveal" role="tablist">
|
||||
<Link
|
||||
href={socialPath("/team")}
|
||||
className="is-on"
|
||||
role="tab"
|
||||
aria-selected="true"
|
||||
>
|
||||
{socialTx("招聘")}
|
||||
</Link>
|
||||
<Link href={socialPath("/ebook")} role="tab" aria-selected="false">
|
||||
{socialTx("共创")}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="social-panel-grid social-panel-grid-3">
|
||||
{gigs.slice(0, 3).map((g, i) => (
|
||||
<Link
|
||||
key={g.id}
|
||||
href={socialPath(`/team#${g.id}`)}
|
||||
className="social-panel social-panel-fx connection-team reveal is-clickable"
|
||||
style={{ ["--stagger" as string]: `${i * 60}ms` }}
|
||||
>
|
||||
<div className="social-panel-ico" aria-hidden>
|
||||
{ROLE_EMOJI[g.kind || "parttime"] || "📝"}
|
||||
</div>
|
||||
<div className="social-panel-meta">
|
||||
<span>
|
||||
{socialTx(TEAM_KIND_LABEL[g.kind || "parttime"])}
|
||||
</span>
|
||||
<span>
|
||||
{g.remote
|
||||
? socialTx("线上也能做")
|
||||
: socialTx("可以见面做")}
|
||||
</span>
|
||||
</div>
|
||||
<h3>{socialTx(g.title)}</h3>
|
||||
<p>{socialTx(g.pay)}</p>
|
||||
<div className="social-panel-foot">
|
||||
{(g.tags || []).slice(0, 3).map((t) => (
|
||||
<span key={t}>{socialTx(t)}</span>
|
||||
))}
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="social-ugc-row reveal">
|
||||
{SEED_EBOOKS.slice(0, 2).map((book) => (
|
||||
<Link
|
||||
@ -593,9 +571,6 @@ export default function HomeClient() {
|
||||
</div>
|
||||
|
||||
<div className="social-section-actions reveal">
|
||||
<Link href={socialPath("/team")} className="btn btn-ghost">
|
||||
{socialTx("更多机会")}
|
||||
</Link>
|
||||
<Link href={socialPath("/ebook")} className="btn btn-ghost">
|
||||
{socialTx("逛共创")}
|
||||
</Link>
|
||||
@ -610,30 +585,71 @@ export default function HomeClient() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{!loggedIn ? (
|
||||
<section
|
||||
className="connection-invite container"
|
||||
aria-label={t.joinCommunity}
|
||||
>
|
||||
<div className="connection-invite-orbit" aria-hidden="true">
|
||||
<span />
|
||||
<span />
|
||||
<Sparkles size={52} strokeWidth={1} />
|
||||
<FxBelt />
|
||||
|
||||
<section
|
||||
className="section section-compact"
|
||||
id="hire"
|
||||
aria-label={socialTx("招聘")}
|
||||
>
|
||||
<div className="container">
|
||||
<div className="section-header reveal">
|
||||
<SectionSpark label="hire" />
|
||||
<span className="section-tag">
|
||||
<span>{socialTx("招聘")}</span>
|
||||
</span>
|
||||
<h2>
|
||||
<span className="social-title-emoji" aria-hidden>
|
||||
💼
|
||||
</span>
|
||||
{socialTx("招聘")}
|
||||
</h2>
|
||||
<p>
|
||||
{socialTx(
|
||||
"有人在找帮手。点卡片看看详情,合适再表达兴趣。",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="connection-eyebrow">{t.joinCommunity}</span>
|
||||
<h2>{landingCopy.socialInviteTitle}</h2>
|
||||
<p>{landingCopy.socialInviteLead}</p>
|
||||
|
||||
<div className="social-panel-grid social-panel-grid-3">
|
||||
{gigs.slice(0, 3).map((g, i) => (
|
||||
<Link
|
||||
key={g.id}
|
||||
href={socialPath(`/team#${g.id}`)}
|
||||
className="social-panel social-panel-fx connection-team reveal is-clickable"
|
||||
style={{ ["--stagger" as string]: `${i * 60}ms` }}
|
||||
>
|
||||
<div className="social-panel-ico" aria-hidden>
|
||||
{ROLE_EMOJI[g.kind || "parttime"] || "📝"}
|
||||
</div>
|
||||
<div className="social-panel-meta">
|
||||
<span>
|
||||
{socialTx(TEAM_KIND_LABEL[g.kind || "parttime"])}
|
||||
</span>
|
||||
<span>
|
||||
{g.remote
|
||||
? socialTx("线上也能做")
|
||||
: socialTx("可以见面做")}
|
||||
</span>
|
||||
</div>
|
||||
<h3>{socialTx(g.title)}</h3>
|
||||
<p>{socialTx(g.pay)}</p>
|
||||
<div className="social-panel-foot">
|
||||
{(g.tags || []).slice(0, 3).map((t) => (
|
||||
<span key={t}>{socialTx(t)}</span>
|
||||
))}
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn connection-join"
|
||||
onClick={openJoin}
|
||||
>
|
||||
{socialTx("加入游民社区")} <ArrowUpRight size={19} />
|
||||
</button>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
<div className="social-section-actions reveal">
|
||||
<Link href={socialPath("/team")} className="btn btn-ghost">
|
||||
{socialTx("更多机会")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer className="footer social-home-footer">
|
||||
@ -660,8 +676,8 @@ export default function HomeClient() {
|
||||
<h4>{socialTx("见面 · 做事")}</h4>
|
||||
<Link href={socialPath("/places")}>{socialTx("城市")}</Link>
|
||||
<Link href={socialPath("/people")}>{socialTx("找搭子")}</Link>
|
||||
<Link href={socialPath("/team")}>{socialTx("招聘")}</Link>
|
||||
<Link href={socialPath("/ebook")}>{socialTx("共创")}</Link>
|
||||
<Link href={socialPath("/team")}>{socialTx("招聘")}</Link>
|
||||
</div>
|
||||
<div className="footer-links footer-links-more">
|
||||
<h4>{socialTx("更多")}</h4>
|
||||
|
||||
@ -13,7 +13,12 @@ import {
|
||||
} from "react";
|
||||
import NotifyBell from "@notify/components/NotifyBell";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
import { applySocialSkin, SOCIAL_SKIN_DEFAULT } from "@social/lib/skin";
|
||||
import {
|
||||
applySocialSkin,
|
||||
parseSocialSkin,
|
||||
readSocialSkinDebugLock,
|
||||
SOCIAL_SKIN_DEFAULT,
|
||||
} from "@social/lib/skin";
|
||||
import {
|
||||
getSocialSession,
|
||||
logoutSocialSession,
|
||||
@ -23,6 +28,7 @@ import { useRevealMotion } from "@social/lib/useRevealMotion";
|
||||
import { useSocialI18n } from "@social/lib/useSocialI18n";
|
||||
import { socialTx } from "@social/lib/socialTx";
|
||||
import { LanguageSwitcher } from "~/components/language-switcher";
|
||||
import { useRemoteConfig } from "~/lib/use-remote-config";
|
||||
import { SocialMobileDock } from "./SocialNavigation";
|
||||
import SocialQuickRail from "./SocialQuickRail";
|
||||
import SocialBrandLogo from "./SocialBrandLogo";
|
||||
@ -57,6 +63,7 @@ export default function SiteShell({
|
||||
onJoin?: () => void;
|
||||
}) {
|
||||
const { t } = useSocialI18n();
|
||||
const { config } = useRemoteConfig();
|
||||
const [openGroup, setOpenGroup] = useState<string | null>(null);
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
const [scrolled, setScrolled] = useState(false);
|
||||
@ -75,9 +82,22 @@ export default function SiteShell({
|
||||
const session = JSON.parse(sessionSnap) as ReturnType<
|
||||
typeof getSocialSession
|
||||
>;
|
||||
const remoteSkin = parseSocialSkin(
|
||||
config.copy.socialSkin ||
|
||||
config.copy.socialExperience?.skin ||
|
||||
SOCIAL_SKIN_DEFAULT,
|
||||
);
|
||||
useEffect(() => {
|
||||
applySocialSkin(SOCIAL_SKIN_DEFAULT);
|
||||
}, []);
|
||||
const sync = () => {
|
||||
// 本地调试小球锁定后,不让远程配置把主题打回去
|
||||
if (readSocialSkinDebugLock()) return;
|
||||
applySocialSkin(remoteSkin);
|
||||
};
|
||||
sync();
|
||||
window.addEventListener("nomadro-social-skin-change", sync);
|
||||
return () =>
|
||||
window.removeEventListener("nomadro-social-skin-change", sync);
|
||||
}, [remoteSkin]);
|
||||
|
||||
const openJoin = () => {
|
||||
setLoginOpen(true);
|
||||
|
||||
@ -15,6 +15,7 @@ import { localizeSocialConfig } from "@social/lib/localizeConfig";
|
||||
import { useSocialI18n } from "@social/lib/useSocialI18n";
|
||||
import { warmTranslationCache } from "@social/lib/translateBus";
|
||||
import { SOCIAL_PHRASES_EN } from "@social/lib/phrases";
|
||||
import SocialSkinDebugBall from "./SocialSkinDebugBall";
|
||||
|
||||
const SocialConfigContext = createContext(DEFAULT_REMOTE_CONFIG);
|
||||
export const useSocialConfig = () => useContext(SocialConfigContext);
|
||||
@ -188,6 +189,7 @@ export default function SocialExperience({
|
||||
<Constellation active={immersive} />
|
||||
<div className="social-pointer-glow" aria-hidden="true" />
|
||||
<SocialConfigContext value={localized}>{children}</SocialConfigContext>
|
||||
<SocialSkinDebugBall />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
166
src/modules/social/components/SocialSkinDebugBall.css
Normal file
166
src/modules/social/components/SocialSkinDebugBall.css
Normal file
@ -0,0 +1,166 @@
|
||||
.ssd-root {
|
||||
position: fixed;
|
||||
left: max(14px, env(safe-area-inset-left, 0px));
|
||||
bottom: max(18px, env(safe-area-inset-bottom, 0px));
|
||||
z-index: 9300;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ssd-root > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.ssd-orb {
|
||||
position: relative;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid color-mix(in srgb, #4ecdc4 45%, rgba(255, 255, 255, 0.12));
|
||||
background:
|
||||
radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.34), transparent 42%),
|
||||
linear-gradient(145deg, #132028 0%, #0b1016 55%, #12181f 100%);
|
||||
box-shadow:
|
||||
0 12px 28px rgba(0, 0, 0, 0.4),
|
||||
0 0 0 1px rgba(78, 205, 196, 0.14),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.12);
|
||||
color: #e8fffb;
|
||||
cursor: pointer;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.04em;
|
||||
animation: ssd-bob 3.2s ease-in-out infinite;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.ssd-orb i {
|
||||
position: absolute;
|
||||
inset: 7px;
|
||||
border-radius: 50%;
|
||||
border: 1px dashed color-mix(in srgb, #4ecdc4 40%, transparent);
|
||||
opacity: 0.7;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ssd-orb:hover,
|
||||
.ssd-orb:focus-visible {
|
||||
transform: translateY(-2px) scale(1.05);
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 16px 34px rgba(0, 0, 0, 0.46),
|
||||
0 0 0 1px rgba(78, 205, 196, 0.32),
|
||||
0 0 22px rgba(78, 205, 196, 0.22);
|
||||
}
|
||||
|
||||
.ssd-panel {
|
||||
width: min(280px, calc(100vw - 28px));
|
||||
padding: 12px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid color-mix(in srgb, #4ecdc4 28%, rgba(255, 255, 255, 0.1));
|
||||
background: color-mix(in srgb, #0b1016 88%, #4ecdc4 6%);
|
||||
backdrop-filter: blur(16px) saturate(1.15);
|
||||
box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
|
||||
color: #e8eef5;
|
||||
}
|
||||
|
||||
.ssd-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.ssd-head strong {
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.ssd-head span {
|
||||
font-size: 11px;
|
||||
color: #8fa3b5;
|
||||
}
|
||||
|
||||
.ssd-skins {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ssd-skin {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
min-height: 52px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid color-mix(in srgb, #fff 12%, transparent);
|
||||
background: color-mix(in srgb, #101820 80%, transparent);
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: border-color 0.18s ease, background 0.18s ease;
|
||||
}
|
||||
|
||||
.ssd-skin b {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.ssd-skin small {
|
||||
font-size: 11px;
|
||||
color: #8fa3b5;
|
||||
}
|
||||
|
||||
.ssd-skin[aria-pressed="true"] {
|
||||
border-color: color-mix(in srgb, #4ecdc4 55%, transparent);
|
||||
background: color-mix(in srgb, #4ecdc4 16%, #101820);
|
||||
}
|
||||
|
||||
.ssd-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.ssd-btn {
|
||||
flex: 1;
|
||||
min-height: 40px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid color-mix(in srgb, #4ecdc4 35%, transparent);
|
||||
background: color-mix(in srgb, #4ecdc4 18%, transparent);
|
||||
color: #d7fff8;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ssd-btn.ghost {
|
||||
border-color: color-mix(in srgb, #fff 14%, transparent);
|
||||
background: transparent;
|
||||
color: #9eb0c0;
|
||||
}
|
||||
|
||||
@keyframes ssd-bob {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ssd-orb {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
121
src/modules/social/components/SocialSkinDebugBall.tsx
Normal file
121
src/modules/social/components/SocialSkinDebugBall.tsx
Normal file
@ -0,0 +1,121 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useId, useState } from "react";
|
||||
import {
|
||||
applySocialSkinDebug,
|
||||
clearSocialSkinDebug,
|
||||
isSocialSkinDevHost,
|
||||
parseSocialSkin,
|
||||
readSocialSkin,
|
||||
readSocialSkinDebugLock,
|
||||
SOCIAL_SKIN_OPTIONS,
|
||||
type SocialSkin,
|
||||
} from "@social/lib/skin";
|
||||
import "./SocialSkinDebugBall.css";
|
||||
|
||||
const SKIN_EVENT = "nomadro-social-skin-change";
|
||||
|
||||
function emitSkinChange(skin: SocialSkin) {
|
||||
if (typeof window === "undefined") return;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(SKIN_EVENT, { detail: { skin } }),
|
||||
);
|
||||
}
|
||||
|
||||
export default function SocialSkinDebugBall() {
|
||||
const panelId = useId();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [skin, setSkin] = useState<SocialSkin>("1");
|
||||
const [locked, setLocked] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSocialSkinDevHost()) return;
|
||||
setVisible(true);
|
||||
setSkin(readSocialSkin());
|
||||
setLocked(readSocialSkinDebugLock());
|
||||
const onChange = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ skin?: string }>).detail;
|
||||
if (detail?.skin) setSkin(parseSocialSkin(detail.skin));
|
||||
else setSkin(readSocialSkin());
|
||||
setLocked(readSocialSkinDebugLock());
|
||||
};
|
||||
window.addEventListener(SKIN_EVENT, onChange);
|
||||
window.addEventListener("storage", onChange);
|
||||
return () => {
|
||||
window.removeEventListener(SKIN_EVENT, onChange);
|
||||
window.removeEventListener("storage", onChange);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
const pick = (next: SocialSkin) => {
|
||||
applySocialSkinDebug(next);
|
||||
setSkin(next);
|
||||
setLocked(true);
|
||||
emitSkinChange(next);
|
||||
};
|
||||
|
||||
const followRemote = () => {
|
||||
clearSocialSkinDebug();
|
||||
setLocked(false);
|
||||
// SiteShell 收到事件后会按远程 socialSkin 重新应用
|
||||
emitSkinChange(skin);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="ssd-root" data-open={open ? "true" : "false"}>
|
||||
{open ? (
|
||||
<div
|
||||
className="ssd-panel"
|
||||
id={panelId}
|
||||
role="dialog"
|
||||
aria-label="本地主题调试"
|
||||
>
|
||||
<header className="ssd-head">
|
||||
<strong>本地调试</strong>
|
||||
<span>{locked ? "已锁定本地主题" : "跟随远程配置"}</span>
|
||||
</header>
|
||||
<div className="ssd-skins" role="group" aria-label="视觉主题">
|
||||
{SOCIAL_SKIN_OPTIONS.map((option) => (
|
||||
<button
|
||||
key={option.id}
|
||||
type="button"
|
||||
className="ssd-skin"
|
||||
aria-pressed={skin === option.id}
|
||||
onClick={() => pick(option.id)}
|
||||
>
|
||||
<b>T{option.id}</b>
|
||||
<small>{option.label.replace(/^主题\d+\s*·\s*/, "")}</small>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="ssd-actions">
|
||||
<button type="button" className="ssd-btn" onClick={followRemote}>
|
||||
解除锁定 · 跟远程
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="ssd-btn ghost"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
收起
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
className="ssd-orb"
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? panelId : undefined}
|
||||
aria-label={`主题调试 · 当前 T${skin}`}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<i aria-hidden="true" />
|
||||
<span>T{skin}</span>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -553,12 +553,23 @@ export const socialApi = {
|
||||
};
|
||||
const email = socialEmail();
|
||||
if (email) headers["X-Social-Email"] = email;
|
||||
// Prefer portal (local seed + server forward to PB). If portal only stored
|
||||
// locally (forward failed), fall through to social so admin can see it.
|
||||
const urls = [
|
||||
"/api/portal/feedback",
|
||||
"https://nomadro.com/api/portal/feedback",
|
||||
`${BASE}/feedback`,
|
||||
"https://nomadro.com/api/social/v1/feedback",
|
||||
];
|
||||
let lastErr = "";
|
||||
let localOnly: {
|
||||
ok?: boolean;
|
||||
id?: string;
|
||||
stored?: string;
|
||||
forwarded?: boolean;
|
||||
remaining?: number;
|
||||
max?: number;
|
||||
} | null = null;
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
@ -566,7 +577,7 @@ export const socialApi = {
|
||||
headers,
|
||||
body: JSON.stringify(body),
|
||||
cache: "no-store",
|
||||
signal: AbortSignal.timeout(url.startsWith("http") ? 12000 : 4000),
|
||||
signal: AbortSignal.timeout(url.startsWith("http") ? 12000 : 8000),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const raw = await res.text().catch(() => `HTTP ${res.status}`);
|
||||
@ -586,13 +597,22 @@ export const socialApi = {
|
||||
lastErr = detail.slice(0, 200);
|
||||
continue;
|
||||
}
|
||||
return (await res.json()) as {
|
||||
const data = (await res.json()) as {
|
||||
ok?: boolean;
|
||||
id?: string;
|
||||
stored?: string;
|
||||
forwarded?: boolean;
|
||||
remaining?: number;
|
||||
max?: number;
|
||||
};
|
||||
const synced =
|
||||
data.forwarded === true ||
|
||||
data.stored === "pb" ||
|
||||
data.stored === "pocketbase" ||
|
||||
url.includes("/api/social/");
|
||||
if (synced) return data;
|
||||
// Portal wrote local JSON only — keep trying upstreams for admin visibility.
|
||||
localOnly = data;
|
||||
} catch (e) {
|
||||
if (e instanceof Error && /最多提交/.test(e.message)) throw e;
|
||||
const raw = e instanceof Error ? e.message : String(e);
|
||||
@ -601,6 +621,7 @@ export const socialApi = {
|
||||
: raw;
|
||||
}
|
||||
}
|
||||
if (localOnly) return localOnly;
|
||||
throw new Error(lastErr || "反馈提交失败");
|
||||
},
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ export const SOCIAL_SECTIONS: SocialSection[] = [
|
||||
{
|
||||
id: "grow",
|
||||
title: "一起做事",
|
||||
subtitle: "找搭子 · 招聘 · 共创 · 远程工作",
|
||||
subtitle: "找搭子 · 共创 · 远程协作",
|
||||
features: [
|
||||
{
|
||||
id: "people",
|
||||
@ -108,14 +108,6 @@ export const SOCIAL_SECTIONS: SocialSection[] = [
|
||||
href: "/people",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "team",
|
||||
emoji: "🧑💻",
|
||||
title: "招聘",
|
||||
desc: "帮忙、兼职、一起做点事",
|
||||
href: "/team",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "cocreate",
|
||||
emoji: "✨",
|
||||
@ -127,7 +119,7 @@ export const SOCIAL_SECTIONS: SocialSection[] = [
|
||||
{
|
||||
id: "work",
|
||||
emoji: "🗂️",
|
||||
title: "远程工作",
|
||||
title: "远程协作",
|
||||
desc: "看板协作 · 实时文档 · 团队二次开发底座",
|
||||
href: "/work",
|
||||
status: "live",
|
||||
|
||||
@ -72,7 +72,7 @@ const zh: SocialDictionary = {
|
||||
footerTagline: "游民社区 · 认识同频的人",
|
||||
watchStory: "看看社区故事",
|
||||
proofTitle: "同频的人,正在这里相遇",
|
||||
proofLead: "自由职业 · 远程工作 · 出来见一面",
|
||||
proofLead: "自由职业 · 远程协作 · 出来见一面",
|
||||
navGroups: [
|
||||
{
|
||||
id: "online",
|
||||
@ -97,9 +97,8 @@ const zh: SocialDictionary = {
|
||||
label: "一起做事",
|
||||
items: [
|
||||
{ href: "/people", label: "找搭子" },
|
||||
{ href: "/team", label: "招聘" },
|
||||
{ href: "/ebook", label: "共创" },
|
||||
{ href: "/work", label: "远程工作" },
|
||||
{ href: "/work", label: "远程协作" },
|
||||
],
|
||||
},
|
||||
],
|
||||
@ -117,9 +116,9 @@ const zh: SocialDictionary = {
|
||||
{ href: "/date", label: "约会", emoji: "💕" },
|
||||
{ href: "/meetup", label: "语音厅", emoji: "📡" },
|
||||
{ href: "/chat", label: "聊天群", emoji: "💬" },
|
||||
{ href: "/team", label: "招聘", emoji: "🚀" },
|
||||
{ href: "/work", label: "远程工作", emoji: "🗂️" },
|
||||
{ href: "/work", label: "远程协作", emoji: "🗂️" },
|
||||
{ href: "/ebook", label: "共创", emoji: "🎨" },
|
||||
{ href: "/team", label: "招聘", emoji: "💼" },
|
||||
{ href: "/wrapped", label: "年度回顾", emoji: "✨" },
|
||||
{ href: "/join", label: "加入社区", emoji: "✨" },
|
||||
],
|
||||
@ -129,8 +128,8 @@ const zh: SocialDictionary = {
|
||||
{ href: "/coffeechat", label: "线下咖啡", emoji: "☕", external: true },
|
||||
{ href: "#cities", label: "城市", emoji: "📍" },
|
||||
{ href: "/map", label: "地图", emoji: "🗺️", external: true },
|
||||
{ href: "/team", label: "招聘", emoji: "🚀", external: true },
|
||||
{ href: "#team", label: "一起做事", emoji: "🚀" },
|
||||
{ href: "#hire", label: "招聘", emoji: "💼" },
|
||||
{ href: "/wrapped", label: "年度回顾", emoji: "✨", external: true },
|
||||
],
|
||||
landing: {
|
||||
@ -150,7 +149,7 @@ const zh: SocialDictionary = {
|
||||
socialWayChat: "语音厅",
|
||||
socialWayDate: "约会",
|
||||
socialWayCafe: "找个地方见面",
|
||||
socialWayTeam: "招聘 · 共创",
|
||||
socialWayTeam: "共创",
|
||||
socialPayJoinLabel: "加入社区",
|
||||
socialOaJoinLabel: "先看看公众号",
|
||||
},
|
||||
@ -173,7 +172,7 @@ const en: SocialDictionary = {
|
||||
footerTagline: "Nomad Social · Meet people on your wavelength",
|
||||
watchStory: "Watch community story",
|
||||
proofTitle: "People on your wavelength are meeting here",
|
||||
proofLead: "Freelance · remote work · meet in person",
|
||||
proofLead: "Freelance · remote collaboration · meet in person",
|
||||
navGroups: [
|
||||
{
|
||||
id: "online",
|
||||
@ -198,9 +197,8 @@ const en: SocialDictionary = {
|
||||
label: "Build together",
|
||||
items: [
|
||||
{ href: "/people", label: "Find buddies" },
|
||||
{ href: "/team", label: "Hiring" },
|
||||
{ href: "/ebook", label: "Co-create" },
|
||||
{ href: "/work", label: "Remote work" },
|
||||
{ href: "/work", label: "Remote collaboration" },
|
||||
],
|
||||
},
|
||||
],
|
||||
@ -218,9 +216,9 @@ const en: SocialDictionary = {
|
||||
{ href: "/date", label: "Dating", emoji: "💕" },
|
||||
{ href: "/meetup", label: "Voice lounge", emoji: "📡" },
|
||||
{ href: "/chat", label: "Chat rooms", emoji: "💬" },
|
||||
{ href: "/team", label: "Hiring", emoji: "🚀" },
|
||||
{ href: "/work", label: "Remote work", emoji: "🗂️" },
|
||||
{ href: "/work", label: "Remote collaboration", emoji: "🗂️" },
|
||||
{ href: "/ebook", label: "Co-create", emoji: "🎨" },
|
||||
{ href: "/team", label: "Hiring", emoji: "💼" },
|
||||
{ href: "/wrapped", label: "Year wrapped", emoji: "✨" },
|
||||
{ href: "/join", label: "Join", emoji: "✨" },
|
||||
],
|
||||
@ -230,8 +228,8 @@ const en: SocialDictionary = {
|
||||
{ href: "/coffeechat", label: "Coffee chat", emoji: "☕", external: true },
|
||||
{ href: "#cities", label: "Cities", emoji: "📍" },
|
||||
{ href: "/map", label: "Map", emoji: "🗺️", external: true },
|
||||
{ href: "/team", label: "Hiring", emoji: "🚀", external: true },
|
||||
{ href: "#team", label: "Collaborate", emoji: "🚀" },
|
||||
{ href: "#hire", label: "Hiring", emoji: "💼" },
|
||||
{ href: "/wrapped", label: "Year wrapped", emoji: "✨", external: true },
|
||||
],
|
||||
landing: {
|
||||
@ -251,7 +249,7 @@ const en: SocialDictionary = {
|
||||
socialWayChat: "Voice lounge",
|
||||
socialWayDate: "Dating",
|
||||
socialWayCafe: "Find a place to meet",
|
||||
socialWayTeam: "Hiring · co-create",
|
||||
socialWayTeam: "Co-create",
|
||||
socialPayJoinLabel: "Join community",
|
||||
socialOaJoinLabel: "Follow our WeChat OA",
|
||||
},
|
||||
|
||||
@ -229,12 +229,12 @@ const JOIN_GATE_COPY: Record<
|
||||
avatarHint: "补全头像等资料后即可继续约会",
|
||||
},
|
||||
work: {
|
||||
guestTitle: "登录后使用远程工作",
|
||||
guestTitle: "登录后使用远程协作",
|
||||
guestHint: "看板与实时文档需先登录 / 注册加入社区",
|
||||
profileHint: "你已登录,请先完善资料再使用远程工作",
|
||||
profileHint: "你已登录,请先完善资料再使用远程协作",
|
||||
liveHint: "完成自拍确认后即可使用看板与文档",
|
||||
payHint: "你已登录邮箱,请继续完成加入后再使用远程工作",
|
||||
avatarHint: "补全头像等资料后即可使用远程工作",
|
||||
payHint: "你已登录邮箱,请继续完成加入后再使用远程协作",
|
||||
avatarHint: "补全头像等资料后即可使用远程协作",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ export function clearLivenessState(): void {
|
||||
/**
|
||||
* Locked until live selfie passes:
|
||||
* 群聊 / 语音视频 / 约会 / 咖啡聊 / 地图 / 「一起做事」下拉相关。
|
||||
* 含远程工作:未注册无权限,提示登录 / 注册 / 补充资料。
|
||||
* 含远程协作:未注册无权限,提示登录 / 注册 / 补充资料。
|
||||
*/
|
||||
export const LIVENESS_GATED_PATHS = [
|
||||
"/social/chat",
|
||||
|
||||
@ -395,6 +395,8 @@ export const SOCIAL_PHRASES_EN: Record<string, string> = {
|
||||
"先进聊天群组热热身,再开语音或视频见面。「想参加」会先记在你这边。": "Warm up in chat, then hop on voice or video. “Interested” is saved on this device first.",
|
||||
"认识了、聊过之后,出来见一面会更自然。先挑一座城市,再找适合见面的咖啡馆。": "After chatting, meeting in person feels more natural. Pick a city, then a café that works for meeting.",
|
||||
"有人在找帮手;也有人一起写小册、拍视频做共创。点卡片看看详情,合适再表达兴趣。": "Some look for helpers; others co-create guides and videos. Open a card for details, then express interest if it fits.",
|
||||
"一起写小册、拍视频做共创。点卡片看看详情,合适再表达兴趣。": "Co-create guides and videos together. Open a card for details, then express interest if it fits.",
|
||||
"有人在找帮手。点卡片看看详情,合适再表达兴趣。": "Someone is looking for help. Open a card for details, then express interest if it fits.",
|
||||
"群里打个招呼 → 开麦 / 开视频 → 认识新朋友": "Say hi in chat → unmute / video → meet people",
|
||||
"每场标注活动时区,并换算你的本地时间 · 「想参加」先记在你这边,还不等于已经约好": "Each event shows its timezone and yours · “Interested” is local only — not a booking",
|
||||
"「想参加」还不等于已经约好 · 随时可以离开回去看别的场": "“Interested” is not a booking · leave anytime and try another room",
|
||||
@ -484,18 +486,20 @@ export const SOCIAL_PHRASES_EN: Record<string, string> = {
|
||||
"想接着逛?先加入社区": "Want to keep exploring? Join first",
|
||||
"想用更多功能,先加入社区": "Join to unlock more",
|
||||
"登录": "Log in",
|
||||
"登录后使用远程工作": "Sign in to use remote work",
|
||||
"登录后使用远程协作": "Sign in to use remote collaboration",
|
||||
"看板与实时文档需先登录 / 注册加入社区":
|
||||
"Boards and live pads require sign-in / joining the community",
|
||||
"你已登录,请先完善资料再使用远程工作":
|
||||
"You're signed in — complete your profile to use remote work",
|
||||
"你已登录,请先完善资料再使用远程协作":
|
||||
"You're signed in — complete your profile to use remote collaboration",
|
||||
"完成自拍确认后即可使用看板与文档":
|
||||
"Finish selfie verification to use boards and pads",
|
||||
"你已登录邮箱,请继续完成加入后再使用远程工作":
|
||||
"You're signed in — finish joining to use remote work",
|
||||
"补全头像等资料后即可使用远程工作":
|
||||
"Add your photo and profile to use remote work",
|
||||
"加入后使用远程工作": "Join to use remote work",
|
||||
"你已登录邮箱,请继续完成加入后再使用远程协作":
|
||||
"You're signed in — finish joining to use remote collaboration",
|
||||
"补全头像等资料后即可使用远程协作":
|
||||
"Add your photo and profile to use remote collaboration",
|
||||
"加入后使用远程协作": "Join to use remote collaboration",
|
||||
"远程协作": "Remote collaboration",
|
||||
"远程工作": "Remote collaboration",
|
||||
"看板与实时文档需登录并完成资料后使用":
|
||||
"Boards and pads require sign-in and a completed profile",
|
||||
"登录 / 注册": "Log in / Sign up",
|
||||
|
||||
@ -1,15 +1,59 @@
|
||||
/** 游民社区视觉主题:1=现网社区对齐,2=独立自定义 */
|
||||
/** 游民社区视觉主题:1=旅居社群(当前默认)· 2=琥珀信号 · 3/4=预留 */
|
||||
|
||||
export type SocialSkin = "1" | "2";
|
||||
export type SocialSkin = "1" | "2" | "3" | "4";
|
||||
|
||||
export const SOCIAL_SKIN_KEY = "nomadro-social-skin";
|
||||
/** 本地调试锁定:有值时门户不跟远程 socialSkin 覆盖 */
|
||||
export const SOCIAL_SKIN_DEBUG_LOCK_KEY = "nomadro-social-skin-debug-lock";
|
||||
export const SOCIAL_SKIN_DEFAULT: SocialSkin = "1";
|
||||
|
||||
export const SOCIAL_SKIN_OPTIONS: ReadonlyArray<{
|
||||
id: SocialSkin;
|
||||
label: string;
|
||||
note: string;
|
||||
}> = [
|
||||
{ id: "1", label: "主题1 · 旅居社群", note: "当前线上默认样式" },
|
||||
{ id: "2", label: "主题2 · 琥珀信号", note: "琥珀强调 + 科技线" },
|
||||
{ id: "3", label: "主题3 · 预留", note: "可后续扩展 CSS" },
|
||||
{ id: "4", label: "主题4 · 预留", note: "可后续扩展 CSS" },
|
||||
];
|
||||
|
||||
export function parseSocialSkin(value: unknown): SocialSkin {
|
||||
const v = String(value ?? "").trim();
|
||||
if (v === "1" || v === "2" || v === "3" || v === "4") return v;
|
||||
return SOCIAL_SKIN_DEFAULT;
|
||||
}
|
||||
|
||||
export function isSocialSkinDevHost(): boolean {
|
||||
if (typeof window === "undefined") return false;
|
||||
if (process.env.NODE_ENV === "development") return true;
|
||||
const host = window.location.hostname;
|
||||
return host === "localhost" || host === "127.0.0.1" || host === "[::1]";
|
||||
}
|
||||
|
||||
export function readSocialSkinDebugLock(): boolean {
|
||||
if (typeof window === "undefined") return false;
|
||||
try {
|
||||
return localStorage.getItem(SOCIAL_SKIN_DEBUG_LOCK_KEY) === "1";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeSocialSkinDebugLock(locked: boolean) {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
if (locked) localStorage.setItem(SOCIAL_SKIN_DEBUG_LOCK_KEY, "1");
|
||||
else localStorage.removeItem(SOCIAL_SKIN_DEBUG_LOCK_KEY);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function readSocialSkin(): SocialSkin {
|
||||
if (typeof window === "undefined") return SOCIAL_SKIN_DEFAULT;
|
||||
try {
|
||||
const v = localStorage.getItem(SOCIAL_SKIN_KEY);
|
||||
if (v === "1" || v === "2") return v;
|
||||
return parseSocialSkin(localStorage.getItem(SOCIAL_SKIN_KEY));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
@ -17,16 +61,28 @@ export function readSocialSkin(): SocialSkin {
|
||||
}
|
||||
|
||||
export function writeSocialSkin(skin: SocialSkin) {
|
||||
const next = parseSocialSkin(skin);
|
||||
try {
|
||||
localStorage.setItem(SOCIAL_SKIN_KEY, skin);
|
||||
localStorage.setItem(SOCIAL_SKIN_KEY, next);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
if (typeof document !== "undefined") {
|
||||
document.documentElement.setAttribute("data-social-skin", skin);
|
||||
document.documentElement.setAttribute("data-social-skin", next);
|
||||
}
|
||||
}
|
||||
|
||||
export function applySocialSkin(skin: SocialSkin) {
|
||||
writeSocialSkin(skin);
|
||||
writeSocialSkin(parseSocialSkin(skin));
|
||||
}
|
||||
|
||||
/** 本地调试:切主题并锁定,避免被远程配置打回 */
|
||||
export function applySocialSkinDebug(skin: SocialSkin) {
|
||||
writeSocialSkinDebugLock(true);
|
||||
applySocialSkin(skin);
|
||||
}
|
||||
|
||||
export function clearSocialSkinDebug(fallback?: SocialSkin) {
|
||||
writeSocialSkinDebugLock(false);
|
||||
if (fallback) applySocialSkin(fallback);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* 远程工作门禁:未注册 / 未完成加入 → 提示登录、注册或补充资料。
|
||||
* 远程协作门禁:未注册 / 未完成加入 → 提示登录、注册或补充资料。
|
||||
*/
|
||||
import Link from "next/link";
|
||||
import { useEffect, useSyncExternalStore, type ReactNode } from "react";
|
||||
@ -64,7 +64,7 @@ export default function WorkAccessGate({ children }: { children: ReactNode }) {
|
||||
gate.kind === "continue" || gate.kind === "join-modal"
|
||||
? socialTx(gate.title)
|
||||
: zh
|
||||
? "加入后使用远程工作"
|
||||
? "加入后使用远程协作"
|
||||
: "Join to use remote work";
|
||||
const hint =
|
||||
gate.kind === "continue" || gate.kind === "join-modal"
|
||||
@ -74,7 +74,7 @@ export default function WorkAccessGate({ children }: { children: ReactNode }) {
|
||||
: "Boards and pads require sign-in and a completed profile";
|
||||
|
||||
return (
|
||||
<SiteShell title={socialTx("远程工作")} tools>
|
||||
<SiteShell title={socialTx("远程协作")} tools>
|
||||
<div className="work-landing work-gate">
|
||||
<section className="work-gate-card" role="status">
|
||||
<p className="work-landing-brand">
|
||||
|
||||
@ -34,7 +34,7 @@ export default function WorkClient() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<SiteShell title={socialTx("远程工作")} tools>
|
||||
<SiteShell title={socialTx("远程协作")} tools>
|
||||
<div className="work-landing">
|
||||
<section className="work-landing-hero" aria-labelledby="work-brand">
|
||||
<div className="work-landing-orb work-landing-orb-a" aria-hidden />
|
||||
|
||||
@ -105,7 +105,7 @@ export default function MicroAppHost({ appId }: Props) {
|
||||
<header className="work-mf-bar">
|
||||
<div className="work-mf-bar-left">
|
||||
<Link href={socialPath("/work")} className="work-mf-back">
|
||||
← {zh ? "远程工作" : "Remote work"}
|
||||
← {zh ? "远程协作" : "Remote collaboration"}
|
||||
</Link>
|
||||
<span className="work-mf-sep" aria-hidden>
|
||||
/
|
||||
|
||||
@ -84,7 +84,7 @@ export default function PlankaNextRoot() {
|
||||
return (
|
||||
<div className="planka-next-shell">
|
||||
<header className="planka-next-bar">
|
||||
<Link href={socialPath("/work")}>← 远程工作</Link>
|
||||
<Link href={socialPath("/work")}>← 远程协作</Link>
|
||||
<strong>看板协作</strong>
|
||||
<span className={`dot ${bundle ? "on" : ""}`} />
|
||||
</header>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user