Add isolated 游民社区 (/social) with social_svc and document test5.
Ship portal module + /api/social/v1 SQLite backend separate from /community; update README for MiroTalk CSP and test5 as the next development branch. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
932f912087
commit
6e15868e04
28
README.md
28
README.md
@ -7,10 +7,10 @@
|
||||
```
|
||||
src/ Next.js 门户(app 路由壳 + modules 业务)
|
||||
apps/miniprogram/ Taro:h5 SoT · weapp · tt · xhs
|
||||
apps/api/ 统一 FastAPI(ebook + community + pay)
|
||||
apps/api/ 统一 FastAPI(ebook + community + pay + social)
|
||||
apps/admin/ admin.nomadro.cn 管理 SPA(Vite)
|
||||
packages/ @nomadro/pay · pb · sdk
|
||||
data/ 远程配置等运行时数据
|
||||
data/ 远程配置等运行时数据(含 social.db 独立库)
|
||||
scripts/ 本地开发 / 清理(dev-api · clean-artifacts)
|
||||
```
|
||||
|
||||
@ -18,7 +18,8 @@ scripts/ 本地开发 / 清理(dev-api · clean-artifacts)
|
||||
|------|----------|------|
|
||||
| 导航 | `/nav` | `src/modules/nav` · 远程 `navContent`(后台 `/wechat/nav` 可 CRUD) |
|
||||
| 小册 | `/book` | `src/modules/ebook` + `src/modules/ebook-content` |
|
||||
| 社群 | `/community` | `src/modules/community` |
|
||||
| 旅居社群 | `/community` | `src/modules/community`(Lounge / Ergo / MiroTalk;**勿改名**) |
|
||||
| 游民社区 | `/social` | `src/modules/social` · API `/api/social/v1` · SQLite `data/social/`(可拆独立域) |
|
||||
| VIP | `/vip` | `src/modules/vip`(微信小程序原生页,见下) |
|
||||
| 后台 | admin.nomadro.cn | `apps/admin` |
|
||||
| API | api.nomadro.cn | `apps/api` |
|
||||
@ -115,8 +116,13 @@ pnpm dev:api
|
||||
- **远程配置 + 离线兜底**:`/api/config` · `data/remote-config.json` · `/admin/config`
|
||||
- **禁止**再引入已删垂直树(见 `AGENTS.md`)
|
||||
- **发布流**:本地调试 → 当前开发分支 commit/push → 部署脚本上线 → 冒烟;配置与发版均以 git 为准
|
||||
- 审核冻结分支:`pre4`(**当前微信版本已提交上线审核,勿在本分支继续功能迭代**)
|
||||
- 下一轮开发分支:`pre5`(从 `pre4` 拉出);发版前与 README / 远程对齐
|
||||
- 审核冻结分支:`pre4`(**微信审核包,勿在本分支继续功能迭代**)
|
||||
- `pre5`:承接 pre4 之后的功能(含游民社区 `/social`)
|
||||
- **当前开发分支:`test5`**(从 `pre5` 拉出);发版前与 README / 远程对齐
|
||||
|
||||
### 游民社区(`/social`)
|
||||
|
||||
与旅居社群 `/community` **完全独立**:门户 `src/modules/social` + `src/app/social`;后端 `apps/api/services/social_svc`(前缀 `/api/social/v1`,库文件 `data/social/social.db`);`SOCIAL_ENABLED=false` 或挂载失败不影响 ebook / community / pay。门户首页主入口为「游民社区」;旅居社群仍保留。增量部署见 [`deploy/social/README.md`](deploy/social/README.md)。MiroTalk 站内嵌 CSP 在公网机 `107.173.30.245` 的 Caddy(须含 `nomadro.cn` 与本地 `:3000`)。
|
||||
|
||||
## pre4 摘要(审核包)
|
||||
|
||||
@ -136,9 +142,17 @@ pnpm dev:api
|
||||
- VIP/加群开关联动;加群点击强制拉最新 `/api/config`
|
||||
- **P0/P1 加固**(`017008d`):VIP library 鉴权、Mine 登录、game stub、WAL/限流、CORS
|
||||
|
||||
## pre5(下一轮)
|
||||
## pre5 摘要
|
||||
|
||||
从 `pre4` 切出;**勿改动审核包行为**,仅做下一版本功能。建议方向:课时资料后台可视化编辑、桥接 UX 打磨、DevTools Timeout 排查(真机网络/域名)。
|
||||
从 `pre4` 切出;**勿改动审核包行为**。本轮落地:
|
||||
|
||||
- **游民社区**:`/social` 全站能力(加入 / 文字厅 / 活动直播嵌 MiroTalk / coffeechat / 约会 / 花名册 / UGC / 接单 / 反馈 / VIP 入口)
|
||||
- 隔离 API + SQLite;远程配置 `modules.social`;门户 hero 主入口切换为游民社区
|
||||
- 社区 Settings `extra="ignore"`,避免统一 `.env` 拖垮 community 启动
|
||||
|
||||
## test5(当前开发)
|
||||
|
||||
从 `pre5` 切出。建议方向:social 线上增量部署与冒烟、课时资料后台可视化、桥接 UX、真机网络/域名排查。
|
||||
|
||||
## pre3 摘要(已合入)
|
||||
|
||||
|
||||
@ -67,6 +67,19 @@ from pay_svc.routers import ( # noqa: E402
|
||||
)
|
||||
from pay_svc.routers.salon_meetup import router as salon_meetup_router # noqa: E402
|
||||
|
||||
# 游民社区:可选挂载;失败绝不拖垮现网 ebook/community/pay
|
||||
_social_router = None
|
||||
try:
|
||||
from social_svc.config import SOCIAL_ENABLED # noqa: E402
|
||||
from social_svc.routers import router as _social_router_mod # noqa: E402
|
||||
from social_svc.store import init_db as _social_init_db # noqa: E402
|
||||
|
||||
if SOCIAL_ENABLED:
|
||||
_social_router = _social_router_mod
|
||||
except Exception as _social_err: # pragma: no cover
|
||||
print(f"[social_svc] skip mount: {_social_err}")
|
||||
_social_router = None
|
||||
|
||||
try:
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
|
||||
@ -87,6 +100,12 @@ async def lifespan(_: FastAPI):
|
||||
get_pb_client()
|
||||
except Exception:
|
||||
pass
|
||||
# social isolated sqlite (own file only)
|
||||
if _social_router is not None:
|
||||
try:
|
||||
_social_init_db()
|
||||
except Exception as e:
|
||||
print(f"[social_svc] init_db failed (non-fatal): {e}")
|
||||
yield
|
||||
if scheduler is not None:
|
||||
scheduler.shutdown(wait=False)
|
||||
@ -152,11 +171,18 @@ app.include_router(salon_meetup_router)
|
||||
app.include_router(chatbot_router)
|
||||
app.include_router(hackrobot_router)
|
||||
|
||||
# —— 游民社区(独立前缀 /api/social/v1,独立 SQLite)——
|
||||
if _social_router is not None:
|
||||
app.include_router(_social_router, prefix="/api/social/v1")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
@app.get("/api/ebook/health")
|
||||
async def health():
|
||||
return {"ok": True, "service": "nomadro-api", "modules": ["ebook", "community", "pay"]}
|
||||
modules = ["ebook", "community", "pay"]
|
||||
if _social_router is not None:
|
||||
modules.append("social")
|
||||
return {"ok": True, "service": "nomadro-api", "modules": modules}
|
||||
|
||||
|
||||
@app.get("/")
|
||||
@ -166,4 +192,5 @@ async def root():
|
||||
"docs": "/docs",
|
||||
"health": "/health",
|
||||
"community_health": "/api/v1/health",
|
||||
"social_health": "/api/social/v1/health",
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
# 忽略 .env 中其它模块键,避免本地/统一 env 拖垮启动(不改业务字段)
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||||
|
||||
pocketbase_url: str = "http://127.0.0.1:8090"
|
||||
pocketbase_admin_email: str = "admin@nomadro.com"
|
||||
pocketbase_admin_password: str = "Xiao4669805"
|
||||
@ -40,8 +43,5 @@ class Settings(BaseSettings):
|
||||
def cors_origin_list(self) -> list[str]:
|
||||
return [o.strip() for o in self.cors_origins.split(",") if o.strip()]
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
1
apps/api/services/social_svc/__init__.py
Normal file
1
apps/api/services/social_svc/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""游民社区独立后端 — 与 community/ebook/pay 数据完全隔离。"""
|
||||
11
apps/api/services/social_svc/config.py
Normal file
11
apps/api/services/social_svc/config.py
Normal file
@ -0,0 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# 默认写在仓库 data/social,与 PocketBase / community 目录分离
|
||||
_ROOT = Path(__file__).resolve().parents[4] # nomadro/
|
||||
_DEFAULT_DB = _ROOT / "data" / "social" / "social.db"
|
||||
|
||||
SOCIAL_DB_PATH = Path(os.getenv("SOCIAL_DB_PATH", str(_DEFAULT_DB))).resolve()
|
||||
SOCIAL_ENABLED = os.getenv("SOCIAL_ENABLED", "true").lower() in {"1", "true", "yes", "on"}
|
||||
3
apps/api/services/social_svc/routers/__init__.py
Normal file
3
apps/api/services/social_svc/routers/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .api import router
|
||||
|
||||
__all__ = ["router"]
|
||||
139
apps/api/services/social_svc/routers/api.py
Normal file
139
apps/api/services/social_svc/routers/api.py
Normal file
@ -0,0 +1,139 @@
|
||||
"""游民社区 API — 前缀 /api/social/v1,与 /api/v1 社群隔离。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Header, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from social_svc import store
|
||||
from social_svc.config import SOCIAL_ENABLED
|
||||
|
||||
router = APIRouter(tags=["social"])
|
||||
|
||||
|
||||
def _guest(x_social_guest_id: str | None) -> str:
|
||||
gid = (x_social_guest_id or "").strip()
|
||||
if not gid or len(gid) > 80:
|
||||
raise HTTPException(status_code=400, detail="missing X-Social-Guest-Id")
|
||||
return gid
|
||||
|
||||
|
||||
class MessageIn(BaseModel):
|
||||
author: str = Field(default="游民", max_length=48)
|
||||
text: str = Field(min_length=1, max_length=2000)
|
||||
|
||||
|
||||
class ReviewIn(BaseModel):
|
||||
author: str = Field(default="游民", max_length=48)
|
||||
score: int = Field(default=5, ge=1, le=5)
|
||||
text: str = Field(min_length=1, max_length=2000)
|
||||
photoNote: str = Field(default="", max_length=200)
|
||||
|
||||
|
||||
class RosterIn(BaseModel):
|
||||
name: str = Field(default="", max_length=64)
|
||||
title: str = Field(default="", max_length=80)
|
||||
city: str = Field(default="", max_length=64)
|
||||
phone: str = Field(default="", max_length=32)
|
||||
linktree: str = Field(default="", max_length=240)
|
||||
skills: str = Field(default="", max_length=200)
|
||||
bio: str = Field(default="", max_length=2000)
|
||||
|
||||
|
||||
class FeedbackIn(BaseModel):
|
||||
kind: str = Field(default="建议", max_length=8)
|
||||
text: str = Field(min_length=1, max_length=4000)
|
||||
contact: str = Field(default="", max_length=120)
|
||||
|
||||
|
||||
class GigAppIn(BaseModel):
|
||||
name: str = Field(min_length=1, max_length=64)
|
||||
contact: str = Field(min_length=1, max_length=120)
|
||||
note: str = Field(default="", max_length=2000)
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def social_health():
|
||||
if not SOCIAL_ENABLED:
|
||||
return {"ok": False, "module": "social", "enabled": False}
|
||||
return store.health()
|
||||
|
||||
|
||||
@router.get("/channels/{channel_id}/messages")
|
||||
async def get_messages(channel_id: str, limit: int = 100):
|
||||
store.init_db()
|
||||
return {"items": store.list_messages(channel_id, limit)}
|
||||
|
||||
|
||||
@router.post("/channels/{channel_id}/messages")
|
||||
async def post_message(
|
||||
channel_id: str,
|
||||
body: MessageIn,
|
||||
x_social_guest_id: str | None = Header(default=None),
|
||||
):
|
||||
guest = _guest(x_social_guest_id)
|
||||
store.init_db()
|
||||
if not body.text.strip():
|
||||
raise HTTPException(status_code=400, detail="empty text")
|
||||
return store.add_message(channel_id, body.author, body.text, guest)
|
||||
|
||||
|
||||
@router.get("/cafes/{cafe_id}/reviews")
|
||||
async def get_reviews(cafe_id: str, limit: int = 50):
|
||||
store.init_db()
|
||||
return {"items": store.list_reviews(cafe_id, limit)}
|
||||
|
||||
|
||||
@router.post("/cafes/{cafe_id}/reviews")
|
||||
async def post_review(
|
||||
cafe_id: str,
|
||||
body: ReviewIn,
|
||||
x_social_guest_id: str | None = Header(default=None),
|
||||
):
|
||||
guest = _guest(x_social_guest_id)
|
||||
store.init_db()
|
||||
return store.add_review(
|
||||
cafe_id,
|
||||
body.author,
|
||||
body.score,
|
||||
body.text,
|
||||
body.photoNote,
|
||||
guest,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/roster/me")
|
||||
async def get_my_roster(x_social_guest_id: str | None = Header(default=None)):
|
||||
guest = _guest(x_social_guest_id)
|
||||
store.init_db()
|
||||
return {"item": store.get_roster(guest)}
|
||||
|
||||
|
||||
@router.put("/roster/me")
|
||||
async def put_my_roster(
|
||||
body: RosterIn,
|
||||
x_social_guest_id: str | None = Header(default=None),
|
||||
):
|
||||
guest = _guest(x_social_guest_id)
|
||||
store.init_db()
|
||||
return store.upsert_roster(guest, body.model_dump())
|
||||
|
||||
|
||||
@router.post("/feedback")
|
||||
async def post_feedback(
|
||||
body: FeedbackIn,
|
||||
x_social_guest_id: str | None = Header(default=None),
|
||||
):
|
||||
guest = _guest(x_social_guest_id)
|
||||
store.init_db()
|
||||
return store.add_feedback(body.kind, body.text, body.contact, guest)
|
||||
|
||||
|
||||
@router.post("/gigs/{gig_id}/apply")
|
||||
async def post_gig_apply(
|
||||
gig_id: str,
|
||||
body: GigAppIn,
|
||||
x_social_guest_id: str | None = Header(default=None),
|
||||
):
|
||||
guest = _guest(x_social_guest_id)
|
||||
store.init_db()
|
||||
return store.add_gig_app(gig_id, body.name, body.contact, body.note, guest)
|
||||
330
apps/api/services/social_svc/store.py
Normal file
330
apps/api/services/social_svc/store.py
Normal file
@ -0,0 +1,330 @@
|
||||
"""Isolated SQLite store for 游民社区 — never touches community/PB tables."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sqlite3
|
||||
import time
|
||||
import uuid
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterator
|
||||
|
||||
from .config import SOCIAL_DB_PATH
|
||||
|
||||
try:
|
||||
from ebook_svc.core.sqlite_util import connect as _connect
|
||||
except Exception: # pragma: no cover
|
||||
def _connect(path: str | Path, *, timeout: float = 30.0) -> sqlite3.Connection:
|
||||
p = Path(path)
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
c = sqlite3.connect(str(p), timeout=timeout)
|
||||
c.row_factory = sqlite3.Row
|
||||
c.execute("PRAGMA journal_mode=WAL")
|
||||
return c
|
||||
|
||||
|
||||
def _uid(prefix: str) -> str:
|
||||
return f"{prefix}_{uuid.uuid4().hex[:12]}"
|
||||
|
||||
|
||||
def _now() -> str:
|
||||
return time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
|
||||
|
||||
|
||||
@contextmanager
|
||||
def db() -> Iterator[sqlite3.Connection]:
|
||||
SOCIAL_DB_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
conn = _connect(SOCIAL_DB_PATH)
|
||||
try:
|
||||
yield conn
|
||||
conn.commit()
|
||||
except Exception:
|
||||
conn.rollback()
|
||||
raise
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
with db() as conn:
|
||||
conn.executescript(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
id TEXT PRIMARY KEY,
|
||||
channel_id TEXT NOT NULL,
|
||||
author TEXT NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
guest_id TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_channel ON messages(channel_id, created_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cafe_reviews (
|
||||
id TEXT PRIMARY KEY,
|
||||
cafe_id TEXT NOT NULL,
|
||||
author TEXT NOT NULL,
|
||||
score INTEGER NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
photo_note TEXT,
|
||||
guest_id TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_reviews_cafe ON cafe_reviews(cafe_id, created_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roster (
|
||||
guest_id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
title TEXT,
|
||||
city TEXT,
|
||||
phone TEXT,
|
||||
linktree TEXT,
|
||||
skills TEXT,
|
||||
bio TEXT,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS feedback (
|
||||
id TEXT PRIMARY KEY,
|
||||
kind TEXT NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
contact TEXT,
|
||||
guest_id TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS gig_apps (
|
||||
id TEXT PRIMARY KEY,
|
||||
gig_id TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
contact TEXT NOT NULL,
|
||||
note TEXT,
|
||||
guest_id TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def list_messages(channel_id: str, limit: int = 100) -> list[dict[str, Any]]:
|
||||
with db() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT id, channel_id, author, text, guest_id, created_at
|
||||
FROM messages
|
||||
WHERE channel_id = ?
|
||||
ORDER BY created_at ASC
|
||||
LIMIT ?
|
||||
""",
|
||||
(channel_id, max(1, min(limit, 500))),
|
||||
).fetchall()
|
||||
return [
|
||||
{
|
||||
"id": r["id"],
|
||||
"channelId": r["channel_id"],
|
||||
"author": r["author"],
|
||||
"text": r["text"],
|
||||
"guestId": r["guest_id"],
|
||||
"at": r["created_at"],
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
|
||||
|
||||
def add_message(channel_id: str, author: str, text: str, guest_id: str) -> dict[str, Any]:
|
||||
item = {
|
||||
"id": _uid("msg"),
|
||||
"channelId": channel_id,
|
||||
"author": (author or "游民").strip()[:48] or "游民",
|
||||
"text": text.strip()[:2000],
|
||||
"guestId": guest_id,
|
||||
"at": _now(),
|
||||
}
|
||||
with db() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO messages(id, channel_id, author, text, guest_id, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(item["id"], item["channelId"], item["author"], item["text"], guest_id, item["at"]),
|
||||
)
|
||||
return item
|
||||
|
||||
|
||||
def list_reviews(cafe_id: str, limit: int = 50) -> list[dict[str, Any]]:
|
||||
with db() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT id, cafe_id, author, score, text, photo_note, guest_id, created_at
|
||||
FROM cafe_reviews
|
||||
WHERE cafe_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT ?
|
||||
""",
|
||||
(cafe_id, max(1, min(limit, 200))),
|
||||
).fetchall()
|
||||
return [
|
||||
{
|
||||
"id": r["id"],
|
||||
"cafeId": r["cafe_id"],
|
||||
"author": r["author"],
|
||||
"score": r["score"],
|
||||
"text": r["text"],
|
||||
"photoNote": r["photo_note"] or "",
|
||||
"guestId": r["guest_id"],
|
||||
"at": r["created_at"],
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
|
||||
|
||||
def add_review(
|
||||
cafe_id: str,
|
||||
author: str,
|
||||
score: int,
|
||||
text: str,
|
||||
photo_note: str,
|
||||
guest_id: str,
|
||||
) -> dict[str, Any]:
|
||||
item = {
|
||||
"id": _uid("rv"),
|
||||
"cafeId": cafe_id,
|
||||
"author": (author or "游民").strip()[:48] or "游民",
|
||||
"score": max(1, min(int(score or 5), 5)),
|
||||
"text": text.strip()[:2000],
|
||||
"photoNote": (photo_note or "").strip()[:200],
|
||||
"guestId": guest_id,
|
||||
"at": _now(),
|
||||
}
|
||||
with db() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO cafe_reviews(id, cafe_id, author, score, text, photo_note, guest_id, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
item["id"],
|
||||
item["cafeId"],
|
||||
item["author"],
|
||||
item["score"],
|
||||
item["text"],
|
||||
item["photoNote"],
|
||||
guest_id,
|
||||
item["at"],
|
||||
),
|
||||
)
|
||||
return item
|
||||
|
||||
|
||||
def get_roster(guest_id: str) -> dict[str, Any] | None:
|
||||
with db() as conn:
|
||||
r = conn.execute("SELECT * FROM roster WHERE guest_id = ?", (guest_id,)).fetchone()
|
||||
if not r:
|
||||
return None
|
||||
return {
|
||||
"guestId": r["guest_id"],
|
||||
"name": r["name"],
|
||||
"title": r["title"] or "",
|
||||
"city": r["city"] or "",
|
||||
"phone": r["phone"] or "",
|
||||
"linktree": r["linktree"] or "",
|
||||
"skills": r["skills"] or "",
|
||||
"bio": r["bio"] or "",
|
||||
"updatedAt": r["updated_at"],
|
||||
}
|
||||
|
||||
|
||||
def upsert_roster(guest_id: str, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
updated = _now()
|
||||
row = {
|
||||
"guestId": guest_id,
|
||||
"name": str(payload.get("name") or "").strip()[:64] or "游民",
|
||||
"title": str(payload.get("title") or "").strip()[:80],
|
||||
"city": str(payload.get("city") or "").strip()[:64],
|
||||
"phone": str(payload.get("phone") or "").strip()[:32],
|
||||
"linktree": str(payload.get("linktree") or "").strip()[:240],
|
||||
"skills": str(payload.get("skills") or "").strip()[:200],
|
||||
"bio": str(payload.get("bio") or "").strip()[:2000],
|
||||
"updatedAt": updated,
|
||||
}
|
||||
with db() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO roster(guest_id, name, title, city, phone, linktree, skills, bio, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(guest_id) DO UPDATE SET
|
||||
name=excluded.name,
|
||||
title=excluded.title,
|
||||
city=excluded.city,
|
||||
phone=excluded.phone,
|
||||
linktree=excluded.linktree,
|
||||
skills=excluded.skills,
|
||||
bio=excluded.bio,
|
||||
updated_at=excluded.updated_at
|
||||
""",
|
||||
(
|
||||
guest_id,
|
||||
row["name"],
|
||||
row["title"],
|
||||
row["city"],
|
||||
row["phone"],
|
||||
row["linktree"],
|
||||
row["skills"],
|
||||
row["bio"],
|
||||
updated,
|
||||
),
|
||||
)
|
||||
return row
|
||||
|
||||
|
||||
def add_feedback(kind: str, text: str, contact: str, guest_id: str) -> dict[str, Any]:
|
||||
item = {
|
||||
"id": _uid("fb"),
|
||||
"kind": kind if kind in {"反馈", "建议"} else "建议",
|
||||
"text": text.strip()[:4000],
|
||||
"contact": (contact or "").strip()[:120],
|
||||
"guestId": guest_id,
|
||||
"at": _now(),
|
||||
}
|
||||
with db() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO feedback(id, kind, text, contact, guest_id, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(item["id"], item["kind"], item["text"], item["contact"], guest_id, item["at"]),
|
||||
)
|
||||
return item
|
||||
|
||||
|
||||
def add_gig_app(gig_id: str, name: str, contact: str, note: str, guest_id: str) -> dict[str, Any]:
|
||||
item = {
|
||||
"id": _uid("app"),
|
||||
"gigId": gig_id,
|
||||
"name": name.strip()[:64],
|
||||
"contact": contact.strip()[:120],
|
||||
"note": (note or "").strip()[:2000],
|
||||
"guestId": guest_id,
|
||||
"at": _now(),
|
||||
}
|
||||
with db() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO gig_apps(id, gig_id, name, contact, note, guest_id, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(item["id"], item["gigId"], item["name"], item["contact"], item["note"], guest_id, item["at"]),
|
||||
)
|
||||
return item
|
||||
|
||||
|
||||
def health() -> dict[str, Any]:
|
||||
init_db()
|
||||
exists = SOCIAL_DB_PATH.exists()
|
||||
size = SOCIAL_DB_PATH.stat().st_size if exists else 0
|
||||
return {
|
||||
"ok": True,
|
||||
"module": "social",
|
||||
"db": str(SOCIAL_DB_PATH),
|
||||
"dbBytes": size,
|
||||
"isolated": True,
|
||||
}
|
||||
@ -22,6 +22,12 @@
|
||||
"title": "旅居社群",
|
||||
"tabLabel": "社群"
|
||||
},
|
||||
"social": {
|
||||
"enabled": true,
|
||||
"title": "游民社区",
|
||||
"tabLabel": "社区",
|
||||
"note": "门户 /social · 可拆独立域"
|
||||
},
|
||||
"destinations": {
|
||||
"enabled": true,
|
||||
"title": "目的地"
|
||||
|
||||
0
data/social/.gitkeep
Normal file
0
data/social/.gitkeep
Normal file
53
deploy/social/README.md
Normal file
53
deploy/social/README.md
Normal file
@ -0,0 +1,53 @@
|
||||
# 游民社区(social)增量部署
|
||||
|
||||
独立于旅居社群 `/community`、电子书、支付。
|
||||
|
||||
## 隔离保证
|
||||
|
||||
| 项 | 约定 |
|
||||
|---|---|
|
||||
| API 前缀 | `/api/social/v1/*`(不占用 `/api/v1`) |
|
||||
| 存储 | `data/social/social.db`(可用 `SOCIAL_DB_PATH` 改路径) |
|
||||
| 挂载 | `apps/api/app/main.py` 内 try/except;social 挂载失败不影响现网 |
|
||||
| 开关 | `SOCIAL_ENABLED=false` 可整模块关闭 |
|
||||
| 前端 | `/social` + `modules.social` 远程开关 |
|
||||
|
||||
**禁止**改 PocketBase 现有 collection、禁止写 community/ebook/pay 表。
|
||||
|
||||
## 本地
|
||||
|
||||
```bash
|
||||
# 终端 1
|
||||
pnpm dev:api
|
||||
|
||||
# 终端 2(若已在跑可跳过)
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
检查:`http://localhost:8080/api/social/v1/health`(端口以现网 API_URL 为准)
|
||||
|
||||
## 线上增量(可重启 API)
|
||||
|
||||
1. 拉代码(含 `apps/api/services/social_svc`、门户 `/social`)
|
||||
2. 确认环境变量(可选):
|
||||
- `SOCIAL_ENABLED=true`
|
||||
- `SOCIAL_DB_PATH=/var/www/nomadro-data/social/social.db`(独立目录,勿放进 PB data)
|
||||
3. 重启 **统一 API** 进程(systemd/pm2)——只加载新路由 + 新 sqlite 文件
|
||||
4. 构建/重启门户 Next(含 `/social` 与 rewrite `/api/social/*`)
|
||||
5. 冒烟:
|
||||
- `GET /api/social/v1/health` → `ok` + `isolated: true`
|
||||
- `GET /api/v1/health` 与 `/health` 仍正常(现网未坏)
|
||||
- 打开 `https://nomadro.cn/social` 发一条聊天
|
||||
|
||||
回滚:设 `SOCIAL_ENABLED=false` 或去掉 social 代码后重启 API;**不要删**现网 PB/其它库。social.db 可单独备份/删除,不影响其它业务。
|
||||
|
||||
## MiroTalk 站内嵌(CSP)
|
||||
|
||||
公网 `mirotalk.nomadro.com` 解析在 **`107.173.30.245`**(Caddy 反代 `mirotalk.nomadro.cn`),`frame-ancestors` 写在:
|
||||
|
||||
- `/etc/caddy/sites/mirotalk.nomadro.com.caddy`
|
||||
- `/etc/caddy/sites/lounge.nomadro.com.caddy`(文字厅同源策略)
|
||||
|
||||
须包含:`https://nomadro.cn` `https://www.nomadro.cn` `http://localhost:3000` `http://127.0.0.1:3000`(及可选 `:3001`)。改完后 `systemctl reload caddy`。
|
||||
|
||||
本地 `pnpm dev`(:3000)活动页应可 iframe;若仍被拒,`MeetupLiveClient` 会本页 `location.assign` 进入(不新开标签)。
|
||||
@ -10,6 +10,7 @@ const API_URL = (process.env.API_URL || "http://127.0.0.1:8080").replace(
|
||||
const aliases = {
|
||||
"@ebook": path.resolve(__dirname, "src/modules/ebook"),
|
||||
"@community": path.resolve(__dirname, "src/modules/community"),
|
||||
"@social": path.resolve(__dirname, "src/modules/social"),
|
||||
"@navmini": path.resolve(__dirname, "src/modules/nav"),
|
||||
"@vip": path.resolve(__dirname, "src/modules/vip"),
|
||||
"@nomadro/pay": path.resolve(__dirname, "packages/pay/src/index.ts"),
|
||||
@ -42,6 +43,7 @@ const nextConfig: NextConfig = {
|
||||
resolveAlias: {
|
||||
"@ebook": "./src/modules/ebook",
|
||||
"@community": "./src/modules/community",
|
||||
"@social": "./src/modules/social",
|
||||
"@navmini": "./src/modules/nav",
|
||||
"@vip": "./src/modules/vip",
|
||||
"@nomadro/pay": "./packages/pay/src/index.ts",
|
||||
@ -74,6 +76,10 @@ const nextConfig: NextConfig = {
|
||||
source: "/api/v1/:path*",
|
||||
destination: `${API_URL}/api/v1/:path*`,
|
||||
},
|
||||
{
|
||||
source: "/api/social/:path*",
|
||||
destination: `${API_URL}/api/social/:path*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
async headers() {
|
||||
|
||||
@ -21,6 +21,12 @@ const VERTICALS = [
|
||||
route: "/community",
|
||||
notes: ["门户 Next", "API apps/api"],
|
||||
},
|
||||
{
|
||||
name: "游民社区",
|
||||
code: "modules/social",
|
||||
route: "/social",
|
||||
notes: ["门户 Next", "可拆独立域 social.nomadro.cn"],
|
||||
},
|
||||
{
|
||||
name: "私域会员",
|
||||
code: "modules/vip",
|
||||
|
||||
@ -317,12 +317,19 @@ html.light .hub-navbar.scrolled,
|
||||
grid-area: portals;
|
||||
align-self: start;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
max-width: 520px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.hub-portal-grid {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
max-width: 720px;
|
||||
}
|
||||
}
|
||||
|
||||
.hub-gradient-text {
|
||||
background: var(--hub-gradient-text);
|
||||
-webkit-background-clip: text;
|
||||
|
||||
@ -26,7 +26,7 @@ export const viewport: Viewport = {
|
||||
export const metadata: Metadata = {
|
||||
metadataBase: new URL("https://nomadro.cn"),
|
||||
title: "nomadro",
|
||||
description: "数字游民入口 · 出海导航 · 数字游民小册 · 旅居社群",
|
||||
description: "数字游民入口 · 出海导航 · 数字游民小册 · 游民社区",
|
||||
applicationName: "nomadro",
|
||||
keywords: [
|
||||
"数字游民",
|
||||
|
||||
8
src/app/social/chat/[id]/page.tsx
Normal file
8
src/app/social/chat/[id]/page.tsx
Normal file
@ -0,0 +1,8 @@
|
||||
import ChatRoomClient from "@social/components/ChatRoomClient";
|
||||
import { SEED_CHANNELS } from "@social/lib/seed";
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const channelId = SEED_CHANNELS.some((c) => c.id === id) ? id : SEED_CHANNELS[0].id;
|
||||
return <ChatRoomClient channelId={channelId} />;
|
||||
}
|
||||
5
src/app/social/chat/page.tsx
Normal file
5
src/app/social/chat/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import ChatListClient from "@social/components/ChatListClient";
|
||||
|
||||
export default function Page() {
|
||||
return <ChatListClient />;
|
||||
}
|
||||
5
src/app/social/coffeechat/page.tsx
Normal file
5
src/app/social/coffeechat/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import CoffeechatClient from "@social/components/CoffeechatClient";
|
||||
|
||||
export default function Page() {
|
||||
return <CoffeechatClient />;
|
||||
}
|
||||
5
src/app/social/date/page.tsx
Normal file
5
src/app/social/date/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import DateClient from "@social/components/DateClient";
|
||||
|
||||
export default function Page() {
|
||||
return <DateClient />;
|
||||
}
|
||||
5
src/app/social/ebook/page.tsx
Normal file
5
src/app/social/ebook/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import EbookClient from "@social/components/EbookClient";
|
||||
|
||||
export default function Page() {
|
||||
return <EbookClient />;
|
||||
}
|
||||
5
src/app/social/feedback/page.tsx
Normal file
5
src/app/social/feedback/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import FeedbackClient from "@social/components/FeedbackClient";
|
||||
|
||||
export default function Page() {
|
||||
return <FeedbackClient />;
|
||||
}
|
||||
5
src/app/social/gigs/page.tsx
Normal file
5
src/app/social/gigs/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import GigsClient from "@social/components/GigsClient";
|
||||
|
||||
export default function Page() {
|
||||
return <GigsClient />;
|
||||
}
|
||||
5
src/app/social/join/page.tsx
Normal file
5
src/app/social/join/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import JoinClient from "@social/components/JoinClient";
|
||||
|
||||
export default function Page() {
|
||||
return <JoinClient />;
|
||||
}
|
||||
21
src/app/social/layout.tsx
Normal file
21
src/app/social/layout.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { ModuleBoundary } from "~/components/module-boundary";
|
||||
/* 视觉 SoT:对齐旅居社群;业务样式在 social globals */
|
||||
import "@community/app/globals.css";
|
||||
import "@social/app/globals.css";
|
||||
|
||||
export const metadata = {
|
||||
title: "游民社区 · nomadro",
|
||||
description: "数字游民社交:线上聊天 · Meetup · Coffeechat · 职业花名册 · UGC",
|
||||
};
|
||||
|
||||
export default function SocialLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<ModuleBoundary moduleKey="social">
|
||||
<div className="community-root social-skin">{children}</div>
|
||||
</ModuleBoundary>
|
||||
);
|
||||
}
|
||||
8
src/app/social/meetup/[id]/page.tsx
Normal file
8
src/app/social/meetup/[id]/page.tsx
Normal file
@ -0,0 +1,8 @@
|
||||
import MeetupLiveClient from "@social/components/MeetupLiveClient";
|
||||
import { SEED_MEETUPS } from "@social/lib/seed";
|
||||
|
||||
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const meetupId = SEED_MEETUPS.some((m) => m.id === id) ? id : SEED_MEETUPS[0].id;
|
||||
return <MeetupLiveClient meetupId={meetupId} />;
|
||||
}
|
||||
5
src/app/social/meetup/page.tsx
Normal file
5
src/app/social/meetup/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import MeetupClient from "@social/components/MeetupClient";
|
||||
|
||||
export default function Page() {
|
||||
return <MeetupClient />;
|
||||
}
|
||||
5
src/app/social/page.tsx
Normal file
5
src/app/social/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import HomeClient from "@social/components/HomeClient";
|
||||
|
||||
export default function SocialHomePage() {
|
||||
return <HomeClient />;
|
||||
}
|
||||
5
src/app/social/roster/page.tsx
Normal file
5
src/app/social/roster/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import RosterClient from "@social/components/RosterClient";
|
||||
|
||||
export default function Page() {
|
||||
return <RosterClient />;
|
||||
}
|
||||
5
src/app/social/videos/page.tsx
Normal file
5
src/app/social/videos/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import VideosClient from "@social/components/VideosClient";
|
||||
|
||||
export default function Page() {
|
||||
return <VideosClient />;
|
||||
}
|
||||
5
src/app/social/vip/page.tsx
Normal file
5
src/app/social/vip/page.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import VipClient from "@social/components/VipClient";
|
||||
|
||||
export default function Page() {
|
||||
return <VipClient />;
|
||||
}
|
||||
@ -15,6 +15,7 @@ const EXTERNAL_PORTALS = {
|
||||
nav: "https://nav.hackrobot.cn/",
|
||||
book: "https://nomadweb.nomadro.com/book",
|
||||
community: "https://nomadweb.nomadro.com",
|
||||
social: "https://social.nomadro.cn",
|
||||
vip: "https://vip.hackrobot.cn/",
|
||||
} as const;
|
||||
|
||||
@ -22,6 +23,7 @@ const INTERNAL_PORTALS = {
|
||||
nav: "/nav",
|
||||
book: "/book",
|
||||
community: "/community",
|
||||
social: "/social",
|
||||
vip: "/vip",
|
||||
} as const;
|
||||
|
||||
@ -46,6 +48,13 @@ const PORTALS = [
|
||||
moduleKey: "community" as const,
|
||||
emoji: "🌏",
|
||||
name: "旅居社群",
|
||||
main: false,
|
||||
},
|
||||
{
|
||||
id: "social" as const,
|
||||
moduleKey: "social" as const,
|
||||
emoji: "💬",
|
||||
name: "游民社区",
|
||||
main: true,
|
||||
},
|
||||
];
|
||||
|
||||
@ -92,6 +92,8 @@ export type NomadroRemoteConfig = {
|
||||
nav: ModuleToggle;
|
||||
book: ModuleToggle;
|
||||
community: ModuleToggle;
|
||||
/** 游民社区(社交垂直;可拆独立域) */
|
||||
social: ModuleToggle;
|
||||
vip: ModuleToggle;
|
||||
meetups: ModuleToggle;
|
||||
destinations: ModuleToggle;
|
||||
@ -300,6 +302,12 @@ export const DEFAULT_REMOTE_CONFIG: NomadroRemoteConfig = {
|
||||
tabLabel: "社群",
|
||||
note: "nomadweb",
|
||||
},
|
||||
social: {
|
||||
enabled: true,
|
||||
title: "游民社区",
|
||||
tabLabel: "社区",
|
||||
note: "门户 /social · 可拆独立域",
|
||||
},
|
||||
destinations: { enabled: true, title: "目的地" },
|
||||
meetups: { enabled: true, title: "活动" },
|
||||
vip: { enabled: false, title: "会员中心", note: "deep link only" },
|
||||
|
||||
21
src/modules/social/README.md
Normal file
21
src/modules/social/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# 游民社区(social)
|
||||
|
||||
门户:`/social` · SoT:`src/modules/social` · API:`/api/social/v1`
|
||||
**与旅居社群 `/community` 完全独立。**
|
||||
|
||||
## 隔离
|
||||
|
||||
- 后端:`apps/api/services/social_svc` → 独立 SQLite `data/social/social.db`
|
||||
- 前缀:`/api/social/v1`(不占用 `/api/v1`)
|
||||
- 挂载失败 / `SOCIAL_ENABLED=false` → 不影响 ebook / community / pay
|
||||
- 前端失败自动降级 localStorage
|
||||
|
||||
## 本地
|
||||
|
||||
```bash
|
||||
pnpm dev:api
|
||||
pnpm dev
|
||||
curl http://127.0.0.1:8080/api/social/v1/health
|
||||
```
|
||||
|
||||
部署说明见 [`deploy/social/README.md`](../../../deploy/social/README.md)。
|
||||
915
src/modules/social/app/globals.css
Normal file
915
src/modules/social/app/globals.css
Normal file
@ -0,0 +1,915 @@
|
||||
/* 游民社区首页 / 壳层 — 对齐旅居社群视觉语言 */
|
||||
.social-flow {
|
||||
position: relative;
|
||||
min-height: 100dvh;
|
||||
background: var(--bg-primary, #0a0e17);
|
||||
color: var(--text-primary, #f1f5f9);
|
||||
}
|
||||
|
||||
.social-hub-block {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.social-hub-block-head {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.social-hub-block-head h3 {
|
||||
margin: 0 0 4px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.25rem;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.social-hub-block-head p {
|
||||
margin: 0;
|
||||
color: var(--text-secondary, #94a3b8);
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.social-hub-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.social-hub-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 168px;
|
||||
padding: 20px 18px;
|
||||
border-radius: var(--radius-xl, 24px);
|
||||
border: var(--border-glass);
|
||||
background: var(--bg-card);
|
||||
backdrop-filter: blur(14px);
|
||||
transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.social-hub-card:hover {
|
||||
transform: translateY(-3px);
|
||||
border-color: rgba(78, 205, 196, 0.35);
|
||||
box-shadow: var(--shadow-glow);
|
||||
}
|
||||
|
||||
.social-hub-card-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.social-hub-emoji {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 14px;
|
||||
background: var(--bg-glass);
|
||||
border: var(--border-glass);
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.social-pill {
|
||||
font-size: 0.72rem;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
border: var(--border-glass);
|
||||
color: var(--text-muted, #64748b);
|
||||
}
|
||||
|
||||
.social-pill.live {
|
||||
color: #4ecdc4;
|
||||
border-color: rgba(78, 205, 196, 0.35);
|
||||
}
|
||||
|
||||
.social-hub-card h4 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.social-hub-card p {
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
color: var(--text-secondary, #94a3b8);
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.social-hub-go {
|
||||
color: var(--accent-3, #4ecdc4);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.social-next-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.social-next-card {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto;
|
||||
gap: 14px;
|
||||
align-items: center;
|
||||
padding: 18px 16px;
|
||||
border-radius: var(--radius-xl, 24px);
|
||||
border: var(--border-glass);
|
||||
background: var(--bg-card);
|
||||
transition: transform 0.2s, border-color 0.2s;
|
||||
}
|
||||
|
||||
.social-next-card:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: rgba(255, 230, 109, 0.35);
|
||||
}
|
||||
|
||||
.social-next-card span {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.social-next-card strong {
|
||||
display: block;
|
||||
font-family: var(--font-display);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.social-next-card p {
|
||||
margin: 0;
|
||||
color: var(--text-secondary, #94a3b8);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.social-next-card em {
|
||||
font-style: normal;
|
||||
color: var(--accent-2, #ffe66d);
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.social-flow .footer-inner {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 2fr;
|
||||
gap: 32px;
|
||||
padding: 48px 0 24px;
|
||||
}
|
||||
|
||||
.social-flow .footer-cols {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.social-flow .footer-cols h4 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.social-flow .footer-cols a {
|
||||
display: block;
|
||||
color: var(--text-secondary, #94a3b8);
|
||||
font-size: 0.88rem;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.social-flow .footer-cols a:hover {
|
||||
color: var(--text-primary, #f1f5f9);
|
||||
}
|
||||
|
||||
.social-flow .footer-brand p {
|
||||
margin-top: 12px;
|
||||
color: var(--text-secondary, #94a3b8);
|
||||
max-width: 28rem;
|
||||
}
|
||||
|
||||
.social-flow .footer-bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 16px 0 40px;
|
||||
border-top: var(--border-glass);
|
||||
color: var(--text-muted, #64748b);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
/* 子页:社区壳 + 内容区顶距 */
|
||||
.social-root {
|
||||
/* keep legacy tokens for chat/forms pages */
|
||||
}
|
||||
|
||||
.social-page-pad {
|
||||
padding-top: calc(var(--nav-height, 72px) + 24px);
|
||||
padding-bottom: 64px;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.social-hub-grid,
|
||||
.social-next-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.social-flow .footer-inner {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.social-hub-grid,
|
||||
.social-next-grid,
|
||||
.social-flow .footer-cols {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.social-flow .nav-links {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.social-root {
|
||||
--sc-bg: #0a0e17;
|
||||
--sc-bg-card: rgba(17, 24, 39, 0.72);
|
||||
--sc-bg-glass: rgba(255, 255, 255, 0.05);
|
||||
--sc-text: #f1f5f9;
|
||||
--sc-muted: #94a3b8;
|
||||
--sc-accent-1: #ff6b6b;
|
||||
--sc-accent-2: #ffe66d;
|
||||
--sc-accent-3: #4ecdc4;
|
||||
--sc-gradient: linear-gradient(135deg, #ff6b6b 0%, #ffe66d 50%, #4ecdc4 100%);
|
||||
--sc-border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
--sc-radius: 16px;
|
||||
--sc-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
--sc-font-display: var(--font-outfit), var(--font-noto-sc), sans-serif;
|
||||
--sc-font-body: var(--font-noto-sc), var(--font-outfit), sans-serif;
|
||||
--sc-nav-h: 64px;
|
||||
--sc-ease: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
min-height: 100dvh;
|
||||
font-family: var(--sc-font-body);
|
||||
background:
|
||||
radial-gradient(ellipse 70% 45% at 50% -10%, rgba(78, 205, 196, 0.14), transparent),
|
||||
radial-gradient(ellipse 50% 35% at 90% 20%, rgba(255, 107, 107, 0.1), transparent),
|
||||
var(--sc-bg);
|
||||
color: var(--sc-text);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
html.light .social-root,
|
||||
[data-theme="light"] .social-root {
|
||||
--sc-bg: #f8fafc;
|
||||
--sc-bg-card: rgba(255, 255, 255, 0.88);
|
||||
--sc-bg-glass: rgba(15, 23, 42, 0.04);
|
||||
--sc-text: #0f172a;
|
||||
--sc-muted: #64748b;
|
||||
--sc-accent-1: #e11d48;
|
||||
--sc-accent-2: #d97706;
|
||||
--sc-accent-3: #0d9488;
|
||||
--sc-gradient: linear-gradient(135deg, #e11d48 0%, #d97706 50%, #0d9488 100%);
|
||||
--sc-border: 1px solid rgba(15, 23, 42, 0.08);
|
||||
--sc-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
|
||||
background:
|
||||
radial-gradient(ellipse 70% 45% at 50% -10%, rgba(13, 148, 136, 0.1), transparent),
|
||||
radial-gradient(ellipse 50% 35% at 90% 20%, rgba(225, 29, 72, 0.06), transparent),
|
||||
var(--sc-bg);
|
||||
}
|
||||
|
||||
.social-root a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.social-nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 40;
|
||||
height: var(--sc-nav-h);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 20px;
|
||||
border-bottom: var(--sc-border);
|
||||
background: color-mix(in srgb, var(--sc-bg) 82%, transparent);
|
||||
backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.social-brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-family: var(--sc-font-display);
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.social-brand-mark {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 12px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--sc-bg-glass);
|
||||
border: var(--sc-border);
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.social-nav-back {
|
||||
min-height: 44px;
|
||||
padding: 0 14px;
|
||||
border-radius: 999px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.9rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.social-nav-back:hover {
|
||||
color: var(--sc-text);
|
||||
border-color: rgba(78, 205, 196, 0.35);
|
||||
}
|
||||
|
||||
.social-main {
|
||||
width: min(1080px, calc(100% - 32px));
|
||||
margin: 0 auto;
|
||||
padding: 40px 0 80px;
|
||||
}
|
||||
|
||||
.social-hero {
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.social-hero-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 12px;
|
||||
border-radius: 999px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.82rem;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.social-hero h1 {
|
||||
margin: 0 0 12px;
|
||||
font-family: var(--sc-font-display);
|
||||
font-size: clamp(2rem, 5vw, 3.2rem);
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.social-hero h1 span {
|
||||
background: var(--sc-gradient);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.social-hero p {
|
||||
margin: 0;
|
||||
max-width: 36rem;
|
||||
color: var(--sc-muted);
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.social-section {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.social-section-head {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.social-section-head h2 {
|
||||
margin: 0 0 4px;
|
||||
font-family: var(--sc-font-display);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.social-section-head p {
|
||||
margin: 0;
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.social-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.social-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 140px;
|
||||
padding: 18px 16px;
|
||||
border-radius: var(--sc-radius);
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-card);
|
||||
box-shadow: var(--sc-shadow);
|
||||
backdrop-filter: blur(14px);
|
||||
transition: transform var(--sc-ease), border-color var(--sc-ease), box-shadow var(--sc-ease);
|
||||
}
|
||||
|
||||
.social-card:hover {
|
||||
transform: translateY(-3px);
|
||||
border-color: rgba(78, 205, 196, 0.35);
|
||||
box-shadow: 0 0 28px rgba(78, 205, 196, 0.12), var(--sc-shadow);
|
||||
}
|
||||
|
||||
.social-card-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.social-card-ico {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 12px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--sc-bg-glass);
|
||||
border: var(--sc-border);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.social-badge {
|
||||
font-size: 0.72rem;
|
||||
padding: 4px 8px;
|
||||
border-radius: 999px;
|
||||
border: var(--sc-border);
|
||||
color: var(--sc-muted);
|
||||
}
|
||||
|
||||
.social-badge.live {
|
||||
color: #4ecdc4;
|
||||
border-color: rgba(78, 205, 196, 0.35);
|
||||
}
|
||||
|
||||
.social-card strong {
|
||||
font-family: var(--sc-font-display);
|
||||
font-size: 1.02rem;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.social-card p {
|
||||
margin: 0;
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
.social-footer {
|
||||
margin-top: 56px;
|
||||
padding-top: 20px;
|
||||
border-top: var(--sc-border);
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.85rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.social-nav-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.social-nav-link {
|
||||
min-height: 44px;
|
||||
padding: 0 10px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.88rem;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.social-nav-link:hover {
|
||||
color: var(--sc-text);
|
||||
background: var(--sc-bg-glass);
|
||||
}
|
||||
|
||||
.social-muted {
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.social-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.social-list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border-radius: var(--sc-radius);
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-card);
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.social-list-item strong {
|
||||
display: block;
|
||||
font-family: var(--sc-font-display);
|
||||
}
|
||||
|
||||
.social-list-item p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
.social-list-item em {
|
||||
font-style: normal;
|
||||
color: var(--sc-accent-3);
|
||||
font-size: 0.85rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.social-list-stack {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.social-card-btn {
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.social-card.active,
|
||||
.social-list-item.active {
|
||||
border-color: rgba(78, 205, 196, 0.45);
|
||||
box-shadow: 0 0 0 1px rgba(78, 205, 196, 0.2);
|
||||
}
|
||||
|
||||
.social-panel {
|
||||
margin-top: 28px;
|
||||
padding: 20px;
|
||||
border-radius: var(--sc-radius);
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-card);
|
||||
}
|
||||
|
||||
.social-panel h2 {
|
||||
margin: 0 0 8px;
|
||||
font-family: var(--sc-font-display);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.social-form {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.social-form label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
font-size: 0.9rem;
|
||||
color: var(--sc-muted);
|
||||
}
|
||||
|
||||
.social-form input,
|
||||
.social-form textarea,
|
||||
.social-form select {
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
color: var(--sc-text);
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.social-form textarea {
|
||||
min-height: 96px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.social-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.social-btn {
|
||||
min-height: 44px;
|
||||
padding: 0 16px;
|
||||
border-radius: 999px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
color: var(--sc-text);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.social-btn.primary {
|
||||
border: none;
|
||||
color: #0a0e17;
|
||||
background: var(--sc-gradient);
|
||||
}
|
||||
|
||||
.social-chat-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.social-chat-nick {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.social-chat-nick label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.social-chat-nick input {
|
||||
min-height: 40px;
|
||||
padding: 0 12px;
|
||||
border-radius: 10px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
color: var(--sc-text);
|
||||
}
|
||||
|
||||
.social-chat-thread {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
max-height: min(55vh, 520px);
|
||||
overflow: auto;
|
||||
padding: 12px;
|
||||
border-radius: var(--sc-radius);
|
||||
border: var(--sc-border);
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.social-bubble {
|
||||
max-width: min(92%, 520px);
|
||||
padding: 10px 12px;
|
||||
border-radius: 14px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-card);
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.social-bubble.mine {
|
||||
align-self: flex-end;
|
||||
background: linear-gradient(160deg, rgba(255, 107, 107, 0.16), rgba(78, 205, 196, 0.1));
|
||||
}
|
||||
|
||||
.social-bubble header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
font-size: 0.78rem;
|
||||
color: var(--sc-muted);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.social-bubble p {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.social-compose {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.social-compose input {
|
||||
min-height: 48px;
|
||||
padding: 0 14px;
|
||||
border-radius: 14px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-card);
|
||||
color: var(--sc-text);
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.social-compose button {
|
||||
min-height: 48px;
|
||||
min-width: 88px;
|
||||
border: none;
|
||||
border-radius: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
color: #0a0e17;
|
||||
background: var(--sc-gradient);
|
||||
}
|
||||
|
||||
/* Immersive Meetup live room — stay in-app, no new tab */
|
||||
.social-live-root {
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.social-live-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: var(--sc-border);
|
||||
background: color-mix(in srgb, var(--sc-bg) 88%, transparent);
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.social-live-bar-main {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.social-live-bar-main p {
|
||||
margin: 2px 0 0;
|
||||
}
|
||||
|
||||
.social-live-tabs {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
padding: 4px;
|
||||
border-radius: 999px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
}
|
||||
|
||||
.social-live-tab {
|
||||
min-height: 40px;
|
||||
padding: 0 14px;
|
||||
border: none;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: var(--sc-muted);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.social-live-tab.active {
|
||||
color: #0a0e17;
|
||||
background: var(--sc-gradient);
|
||||
}
|
||||
|
||||
.social-live-stage {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.social-live-stage.layout-split {
|
||||
grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
|
||||
}
|
||||
|
||||
.social-live-stage.layout-video,
|
||||
.social-live-stage.layout-chat {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.social-live-video,
|
||||
.social-live-chat {
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-left: var(--sc-border);
|
||||
}
|
||||
|
||||
.social-live-video {
|
||||
border-left: none;
|
||||
background: #05070c;
|
||||
}
|
||||
|
||||
.social-live-iframe {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-height: min(70vh, 720px);
|
||||
border: 0;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.social-live-gate {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
place-content: center;
|
||||
gap: 12px;
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.social-live-gate h2 {
|
||||
margin: 0;
|
||||
font-family: var(--sc-font-display);
|
||||
}
|
||||
|
||||
.social-live-gate p {
|
||||
margin: 0;
|
||||
color: var(--sc-muted);
|
||||
}
|
||||
|
||||
.social-live-gate label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
justify-items: center;
|
||||
color: var(--sc-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.social-live-gate input {
|
||||
min-height: 44px;
|
||||
width: min(280px, 100%);
|
||||
padding: 0 12px;
|
||||
border-radius: 12px;
|
||||
border: var(--sc-border);
|
||||
background: var(--sc-bg-glass);
|
||||
color: var(--sc-text);
|
||||
}
|
||||
|
||||
.social-live-chat {
|
||||
padding: 12px;
|
||||
background: var(--sc-bg);
|
||||
}
|
||||
|
||||
.social-live-chat-head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.social-live-thread {
|
||||
flex: 1;
|
||||
max-height: none;
|
||||
min-height: 220px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.social-live-stage.layout-split {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: minmax(42vh, 1fr) minmax(38vh, 1fr);
|
||||
}
|
||||
|
||||
.social-live-chat {
|
||||
border-left: none;
|
||||
border-top: var(--sc-border);
|
||||
}
|
||||
|
||||
.social-live-iframe {
|
||||
min-height: 42vh;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.social-main {
|
||||
width: min(100%, calc(100% - 24px));
|
||||
padding-top: 28px;
|
||||
}
|
||||
|
||||
.social-hero {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.social-nav-link {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.social-nav-link:nth-child(-n + 2),
|
||||
.social-nav-back {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
33
src/modules/social/components/ChatListClient.tsx
Normal file
33
src/modules/social/components/ChatListClient.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { SEED_CHANNELS } from "@social/lib/seed";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
export default function ChatListClient() {
|
||||
return (
|
||||
<SiteShell title="聊天室">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">实时文字</div>
|
||||
<h1>
|
||||
聊天室
|
||||
<br />
|
||||
<span>自研频道 · 可扩展小程序</span>
|
||||
</h1>
|
||||
<p>消息保存在本机(localStorage),不依赖 Lounge / web-view。后续可接 FastAPI + WS。</p>
|
||||
</section>
|
||||
<div className="social-list">
|
||||
{SEED_CHANNELS.map((c) => (
|
||||
<Link key={c.id} href={socialPath(`/chat/${c.id}`)} className="social-list-item">
|
||||
<div>
|
||||
<strong>{c.name}</strong>
|
||||
<p>{c.topic}</p>
|
||||
</div>
|
||||
<em>{c.members} 人</em>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
153
src/modules/social/components/ChatRoomClient.tsx
Normal file
153
src/modules/social/components/ChatRoomClient.tsx
Normal file
@ -0,0 +1,153 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialApi } from "@social/lib/api";
|
||||
import { SEED_CHANNELS, SEED_MESSAGES } from "@social/lib/seed";
|
||||
import { loadJson, saveJson } from "@social/lib/storage";
|
||||
import type { SocialChatMessage } from "@social/lib/types";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
export default function ChatRoomClient({ channelId }: { channelId: string }) {
|
||||
const channel = SEED_CHANNELS.find((c) => c.id === channelId) || SEED_CHANNELS[0];
|
||||
const storageKey = `chat:${channel.id}`;
|
||||
const [messages, setMessages] = useState<SocialChatMessage[]>([]);
|
||||
const [text, setText] = useState("");
|
||||
const [nick, setNick] = useState("游民");
|
||||
const [online, setOnline] = useState(true);
|
||||
const [sending, setSending] = useState(false);
|
||||
const bottomRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const seedForRoom = useMemo(
|
||||
() => SEED_MESSAGES.filter((m) => m.channelId === channel.id),
|
||||
[channel.id],
|
||||
);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
const res = await socialApi.listMessages(channel.id);
|
||||
const items = (res.items || []).map((m) => ({
|
||||
id: m.id,
|
||||
channelId: m.channelId,
|
||||
author: m.author,
|
||||
text: m.text,
|
||||
at: m.at,
|
||||
}));
|
||||
if (items.length) {
|
||||
setMessages(items);
|
||||
saveJson(storageKey, items);
|
||||
} else {
|
||||
const local = loadJson<SocialChatMessage[]>(storageKey, seedForRoom);
|
||||
setMessages(local);
|
||||
}
|
||||
setOnline(true);
|
||||
} catch {
|
||||
setOnline(false);
|
||||
setMessages(loadJson<SocialChatMessage[]>(storageKey, seedForRoom));
|
||||
}
|
||||
}, [channel.id, seedForRoom, storageKey]);
|
||||
|
||||
useEffect(() => {
|
||||
setNick(loadJson("nick", "游民"));
|
||||
void refresh();
|
||||
const id = window.setInterval(() => void refresh(), 4000);
|
||||
return () => clearInterval(id);
|
||||
}, [refresh]);
|
||||
|
||||
useEffect(() => {
|
||||
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [messages]);
|
||||
|
||||
const send = async () => {
|
||||
const body = text.trim();
|
||||
if (!body || sending) return;
|
||||
setSending(true);
|
||||
const author = nick.trim() || "游民";
|
||||
try {
|
||||
const saved = await socialApi.sendMessage(channel.id, author, body);
|
||||
setText("");
|
||||
saveJson("nick", author);
|
||||
await refresh();
|
||||
if (!saved?.id) {
|
||||
/* refresh already applied */
|
||||
}
|
||||
setOnline(true);
|
||||
} catch {
|
||||
setOnline(false);
|
||||
const next: SocialChatMessage = {
|
||||
id: `local_${Date.now()}`,
|
||||
channelId: channel.id,
|
||||
author,
|
||||
text: body,
|
||||
at: new Date().toISOString(),
|
||||
mine: true,
|
||||
};
|
||||
const merged = [...messages, next];
|
||||
setMessages(merged);
|
||||
saveJson(storageKey, merged);
|
||||
saveJson("nick", author);
|
||||
setText("");
|
||||
} finally {
|
||||
setSending(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SiteShell title={channel.name}>
|
||||
<div className="social-chat-head">
|
||||
<Link href={socialPath("/chat")} className="social-nav-back">
|
||||
← 频道列表
|
||||
</Link>
|
||||
<div>
|
||||
<strong>{channel.name}</strong>
|
||||
<p className="social-muted">
|
||||
{channel.topic}
|
||||
{" · "}
|
||||
{online ? "已同步服务器" : "离线本地模式"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="social-chat-nick">
|
||||
<label>
|
||||
昵称
|
||||
<input
|
||||
value={nick}
|
||||
onChange={(e) => setNick(e.target.value)}
|
||||
maxLength={24}
|
||||
aria-label="聊天昵称"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="social-chat-thread">
|
||||
{messages.map((m) => (
|
||||
<div key={m.id} className={`social-bubble${m.mine ? " mine" : ""}`}>
|
||||
<header>
|
||||
{m.author}
|
||||
<time>{new Date(m.at).toLocaleString()}</time>
|
||||
</header>
|
||||
<p>{m.text}</p>
|
||||
</div>
|
||||
))}
|
||||
<div ref={bottomRef} />
|
||||
</div>
|
||||
|
||||
<div className="social-compose">
|
||||
<input
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") void send();
|
||||
}}
|
||||
placeholder="说点什么…"
|
||||
aria-label="消息内容"
|
||||
/>
|
||||
<button type="button" onClick={() => void send()} disabled={sending}>
|
||||
{sending ? "…" : "发送"}
|
||||
</button>
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
190
src/modules/social/components/CoffeechatClient.tsx
Normal file
190
src/modules/social/components/CoffeechatClient.tsx
Normal file
@ -0,0 +1,190 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialApi } from "@social/lib/api";
|
||||
import { SEED_CAFES } from "@social/lib/seed";
|
||||
import { loadJson, saveJson } from "@social/lib/storage";
|
||||
import type { SocialCafeReview } from "@social/lib/types";
|
||||
|
||||
export default function CoffeechatClient() {
|
||||
const [cafeId, setCafeId] = useState(SEED_CAFES[0]?.id || "");
|
||||
const [reviews, setReviews] = useState<SocialCafeReview[]>([]);
|
||||
const [author, setAuthor] = useState("游民");
|
||||
const [score, setScore] = useState(5);
|
||||
const [text, setText] = useState("");
|
||||
const [photoNote, setPhotoNote] = useState("");
|
||||
const [online, setOnline] = useState(true);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const cafe = SEED_CAFES.find((c) => c.id === cafeId) || SEED_CAFES[0];
|
||||
const cacheKey = `cafe-reviews:${cafeId}`;
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
if (!cafeId) return;
|
||||
try {
|
||||
const res = await socialApi.listReviews(cafeId);
|
||||
const items = (res.items || []).map((r) => ({
|
||||
id: r.id,
|
||||
cafeId: r.cafeId,
|
||||
author: r.author,
|
||||
score: r.score,
|
||||
text: r.text,
|
||||
photoNote: r.photoNote,
|
||||
at: r.at,
|
||||
}));
|
||||
setReviews(items);
|
||||
saveJson(cacheKey, items);
|
||||
setOnline(true);
|
||||
} catch {
|
||||
setOnline(false);
|
||||
setReviews(loadJson<SocialCafeReview[]>(cacheKey, []));
|
||||
}
|
||||
}, [cafeId, cacheKey]);
|
||||
|
||||
useEffect(() => {
|
||||
setAuthor(loadJson("nick", "游民"));
|
||||
void refresh();
|
||||
}, [refresh]);
|
||||
|
||||
const submit = async () => {
|
||||
if (!cafe || !text.trim() || busy) return;
|
||||
setBusy(true);
|
||||
const payload = {
|
||||
author: author.trim() || "游民",
|
||||
score,
|
||||
text: text.trim(),
|
||||
photoNote: photoNote.trim(),
|
||||
};
|
||||
try {
|
||||
await socialApi.postReview(cafe.id, payload);
|
||||
saveJson("nick", payload.author);
|
||||
setText("");
|
||||
setPhotoNote("");
|
||||
setOnline(true);
|
||||
await refresh();
|
||||
} catch {
|
||||
setOnline(false);
|
||||
const item: SocialCafeReview = {
|
||||
id: `local_${Date.now()}`,
|
||||
cafeId: cafe.id,
|
||||
...payload,
|
||||
at: new Date().toISOString(),
|
||||
};
|
||||
const next = [item, ...reviews];
|
||||
setReviews(next);
|
||||
saveJson(cacheKey, next);
|
||||
saveJson("nick", payload.author);
|
||||
setText("");
|
||||
setPhotoNote("");
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SiteShell title="Coffeechat">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">线下 · 咖啡馆</div>
|
||||
<h1>
|
||||
Coffeechat
|
||||
<br />
|
||||
<span>合作店 · 评价 · 合照备注</span>
|
||||
</h1>
|
||||
<p>
|
||||
评价写入独立 social 库(与旅居社群数据隔离)。
|
||||
{online ? " 当前已连后端。" : " 后端不可用时先存本机。"}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div className="social-grid">
|
||||
{SEED_CAFES.map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
type="button"
|
||||
className={`social-card social-card-btn${c.id === cafeId ? " active" : ""}`}
|
||||
onClick={() => setCafeId(c.id)}
|
||||
>
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">☕</span>
|
||||
{c.partners ? (
|
||||
<span className="social-badge live">合作</span>
|
||||
) : (
|
||||
<span className="social-badge">收录</span>
|
||||
)}
|
||||
</div>
|
||||
<strong>{c.name}</strong>
|
||||
<p>
|
||||
{c.city} · WiFi ~{c.wifiMbps}Mbps · ★{c.rating}
|
||||
</p>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{cafe ? (
|
||||
<section className="social-panel">
|
||||
<h2>{cafe.name}</h2>
|
||||
<p className="social-muted">
|
||||
{cafe.vibe} · 电源:{cafe.power} · 评价 {reviews.length} 条
|
||||
</p>
|
||||
|
||||
<div className="social-form">
|
||||
<label>
|
||||
你的名字
|
||||
<input value={author} onChange={(e) => setAuthor(e.target.value)} />
|
||||
</label>
|
||||
<label>
|
||||
评分 {score}
|
||||
<input
|
||||
type="range"
|
||||
min={1}
|
||||
max={5}
|
||||
value={score}
|
||||
onChange={(e) => setScore(Number(e.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
评价
|
||||
<textarea
|
||||
rows={3}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder="网络、插座、适不适合深聊…"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
合照备注
|
||||
<input
|
||||
value={photoNote}
|
||||
onChange={(e) => setPhotoNote(e.target.value)}
|
||||
placeholder="例如:门口合照 / 工位视角 jpg"
|
||||
/>
|
||||
</label>
|
||||
<button type="button" className="social-btn primary" onClick={() => void submit()} disabled={busy}>
|
||||
{busy ? "提交中…" : "提交评价"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="social-list" style={{ marginTop: 20 }}>
|
||||
{reviews.length === 0 ? (
|
||||
<p className="social-muted">还没有评价,来写第一条吧。</p>
|
||||
) : (
|
||||
reviews.map((r) => (
|
||||
<article key={r.id} className="social-list-item social-list-stack">
|
||||
<div>
|
||||
<strong>
|
||||
{r.author} · {"★".repeat(r.score)}
|
||||
</strong>
|
||||
<p>{r.text}</p>
|
||||
{r.photoNote ? <p className="social-muted">合照:{r.photoNote}</p> : null}
|
||||
</div>
|
||||
<time className="social-muted">{new Date(r.at).toLocaleString()}</time>
|
||||
</article>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
39
src/modules/social/components/DateClient.tsx
Normal file
39
src/modules/social/components/DateClient.tsx
Normal file
@ -0,0 +1,39 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { SEED_VIDEOS } from "@social/lib/seed";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
export default function DateClient() {
|
||||
return (
|
||||
<SiteShell title="Date">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">线下访谈</div>
|
||||
<h1>
|
||||
Date / 访谈视频
|
||||
<br />
|
||||
<span>把偶遇做成故事</span>
|
||||
</h1>
|
||||
<p>线下 Coffeechat / 访谈成片沉淀在这里;完整播放器可接 PeerTube / 对象存储。</p>
|
||||
</section>
|
||||
<div className="social-grid">
|
||||
{SEED_VIDEOS.map((v) => (
|
||||
<article key={v.id} className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">{v.coverEmoji}</span>
|
||||
<span className="social-badge">{v.minutes} 分</span>
|
||||
</div>
|
||||
<strong>{v.title}</strong>
|
||||
<p>
|
||||
{v.city} · {v.summary}
|
||||
</p>
|
||||
<Link className="social-btn" href={socialPath(`/videos#${v.id}`)}>
|
||||
在视频库查看
|
||||
</Link>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
38
src/modules/social/components/EbookClient.tsx
Normal file
38
src/modules/social/components/EbookClient.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { SEED_EBOOKS } from "@social/lib/seed";
|
||||
|
||||
export default function EbookClient() {
|
||||
return (
|
||||
<SiteShell title="电子书">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">UGC · ebook</div>
|
||||
<h1>
|
||||
社区小册
|
||||
<br />
|
||||
<span>玩法沉淀成可读内容</span>
|
||||
</h1>
|
||||
<p>社区向小册在此聚合;完整阅读器复用门户数字游民小册能力。</p>
|
||||
</section>
|
||||
<div className="social-grid">
|
||||
{SEED_EBOOKS.map((b) => (
|
||||
<article key={b.id} className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">📖</span>
|
||||
<span className="social-badge">
|
||||
{b.chapters} 章 · {b.minutes} 分
|
||||
</span>
|
||||
</div>
|
||||
<strong>{b.title}</strong>
|
||||
<p>{b.blurb}</p>
|
||||
<Link className="social-btn" href="/book">
|
||||
打开小册阅读器
|
||||
</Link>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
85
src/modules/social/components/FeedbackClient.tsx
Normal file
85
src/modules/social/components/FeedbackClient.tsx
Normal file
@ -0,0 +1,85 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialApi } from "@social/lib/api";
|
||||
import { loadJson, saveJson, uid } from "@social/lib/storage";
|
||||
|
||||
type FeedbackItem = {
|
||||
id: string;
|
||||
kind: "反馈" | "建议";
|
||||
text: string;
|
||||
contact: string;
|
||||
at: string;
|
||||
};
|
||||
|
||||
export default function FeedbackClient() {
|
||||
const [kind, setKind] = useState<"反馈" | "建议">("建议");
|
||||
const [text, setText] = useState("");
|
||||
const [contact, setContact] = useState("");
|
||||
const [ok, setOk] = useState("");
|
||||
|
||||
const submit = async () => {
|
||||
if (!text.trim()) return;
|
||||
const payload = { kind, text: text.trim(), contact: contact.trim() };
|
||||
try {
|
||||
await socialApi.postFeedback(payload);
|
||||
setOk("已同步到游民社区独立库,感谢反馈。");
|
||||
} catch {
|
||||
const list = loadJson<FeedbackItem[]>("feedback", []);
|
||||
const item: FeedbackItem = {
|
||||
id: uid("fb"),
|
||||
kind,
|
||||
text: payload.text,
|
||||
contact: payload.contact,
|
||||
at: new Date().toISOString(),
|
||||
};
|
||||
saveJson("feedback", [item, ...list]);
|
||||
setOk("后端暂不可用,已先存本机。");
|
||||
}
|
||||
setText("");
|
||||
};
|
||||
|
||||
return (
|
||||
<SiteShell title="反馈">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">远程团队</div>
|
||||
<h1>
|
||||
反馈 / 建议
|
||||
<br />
|
||||
<span>把槽点变成迭代清单</span>
|
||||
</h1>
|
||||
<p>写入独立 social 库,不影响现网其它业务表。</p>
|
||||
</section>
|
||||
|
||||
<section className="social-panel">
|
||||
<div className="social-form">
|
||||
<label>
|
||||
类型
|
||||
<select value={kind} onChange={(e) => setKind(e.target.value as "反馈" | "建议")}>
|
||||
<option value="建议">建议</option>
|
||||
<option value="反馈">反馈</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
内容
|
||||
<textarea
|
||||
rows={5}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder="例如:希望 Coffeechat 支持按城市筛选…"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
联系方式(可选)
|
||||
<input value={contact} onChange={(e) => setContact(e.target.value)} />
|
||||
</label>
|
||||
<button type="button" className="social-btn primary" onClick={() => void submit()}>
|
||||
提交
|
||||
</button>
|
||||
{ok ? <p className="social-muted">{ok}</p> : null}
|
||||
</div>
|
||||
</section>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
107
src/modules/social/components/GigsClient.tsx
Normal file
107
src/modules/social/components/GigsClient.tsx
Normal file
@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialApi } from "@social/lib/api";
|
||||
import { SEED_GIGS } from "@social/lib/seed";
|
||||
import { loadJson, saveJson, uid } from "@social/lib/storage";
|
||||
|
||||
type Application = {
|
||||
id: string;
|
||||
gigId: string;
|
||||
name: string;
|
||||
contact: string;
|
||||
note: string;
|
||||
at: string;
|
||||
};
|
||||
|
||||
export default function GigsClient() {
|
||||
const [gigId, setGigId] = useState(SEED_GIGS[0]?.id || "");
|
||||
const [name, setName] = useState("");
|
||||
const [contact, setContact] = useState("");
|
||||
const [note, setNote] = useState("");
|
||||
const [ok, setOk] = useState("");
|
||||
|
||||
const apply = async () => {
|
||||
if (!gigId || !name.trim() || !contact.trim()) return;
|
||||
const payload = {
|
||||
name: name.trim(),
|
||||
contact: contact.trim(),
|
||||
note: note.trim(),
|
||||
};
|
||||
try {
|
||||
await socialApi.applyGig(gigId, payload);
|
||||
setOk("已同步到游民社区独立库。");
|
||||
} catch {
|
||||
const list = loadJson<Application[]>("gig-apps", []);
|
||||
const item: Application = {
|
||||
id: uid("app"),
|
||||
gigId,
|
||||
...payload,
|
||||
at: new Date().toISOString(),
|
||||
};
|
||||
saveJson("gig-apps", [item, ...list]);
|
||||
setOk("后端暂不可用,申请已先存本机。");
|
||||
}
|
||||
setNote("");
|
||||
};
|
||||
|
||||
return (
|
||||
<SiteShell title="兼职">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">远程团队</div>
|
||||
<h1>
|
||||
招募兼职
|
||||
<br />
|
||||
<span>运营 / 拍摄助理 · 大学生</span>
|
||||
</h1>
|
||||
<p>投递写入独立 social 库,与现网招聘 / 社群表隔离。</p>
|
||||
</section>
|
||||
|
||||
<div className="social-list">
|
||||
{SEED_GIGS.map((g) => (
|
||||
<button
|
||||
key={g.id}
|
||||
type="button"
|
||||
className={`social-list-item social-card-btn${g.id === gigId ? " active" : ""}`}
|
||||
onClick={() => setGigId(g.id)}
|
||||
>
|
||||
<div>
|
||||
<strong>{g.title}</strong>
|
||||
<p>
|
||||
{g.role} · {g.pay} · {g.remote ? "远程" : "驻场"}
|
||||
</p>
|
||||
<p className="social-muted">{g.tags.join(" · ")}</p>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<section className="social-panel" style={{ marginTop: 20 }}>
|
||||
<h2>投递申请</h2>
|
||||
<div className="social-form">
|
||||
<label>
|
||||
姓名
|
||||
<input value={name} onChange={(e) => setName(e.target.value)} />
|
||||
</label>
|
||||
<label>
|
||||
联系方式
|
||||
<input
|
||||
value={contact}
|
||||
onChange={(e) => setContact(e.target.value)}
|
||||
placeholder="微信 / 手机 / 邮箱"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
自我介绍
|
||||
<textarea rows={3} value={note} onChange={(e) => setNote(e.target.value)} />
|
||||
</label>
|
||||
<button type="button" className="social-btn primary" onClick={() => void apply()}>
|
||||
提交
|
||||
</button>
|
||||
{ok ? <p className="social-muted">{ok}</p> : null}
|
||||
</div>
|
||||
</section>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
361
src/modules/social/components/HomeClient.tsx
Normal file
361
src/modules/social/components/HomeClient.tsx
Normal file
@ -0,0 +1,361 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import Link from "next/link";
|
||||
import ParticleCanvas from "./ParticleCanvas";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { SOCIAL_SECTIONS } from "@social/lib/catalog";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
const PHRASES = [
|
||||
"不是逃离生活,而是在流动中找到同类。",
|
||||
"加群报到,聊天室续聊,Meetup 见一面。",
|
||||
"Coffeechat 约咖啡馆,花名册让同城看见你。",
|
||||
"线上文字房 + 站内视频房,不新开标签页。",
|
||||
];
|
||||
|
||||
const PATH_STEPS = [
|
||||
{
|
||||
n: "01",
|
||||
emoji: "🚩",
|
||||
title: "先加群报到",
|
||||
desc: "公众号 / 抖音群进门,再回站内聊天室。",
|
||||
href: "/join",
|
||||
cta: "去加群",
|
||||
},
|
||||
{
|
||||
n: "02",
|
||||
emoji: "💬",
|
||||
title: "遇见同行",
|
||||
desc: "文字频道与 Meetup 分屏,像原生 App 一样留在站内。",
|
||||
href: "/chat",
|
||||
cta: "进聊天室",
|
||||
},
|
||||
{
|
||||
n: "03",
|
||||
emoji: "☕",
|
||||
title: "线下连结",
|
||||
desc: "Coffeechat、访谈与职业花名册,把线上聊到的变成见面。",
|
||||
href: "/coffeechat",
|
||||
cta: "看咖啡馆",
|
||||
},
|
||||
];
|
||||
|
||||
export default function HomeClient() {
|
||||
useEffect(() => {
|
||||
const el = document.getElementById("social-typewriter");
|
||||
if (!el) return;
|
||||
let phraseIdx = 0;
|
||||
let charIdx = 0;
|
||||
let deleting = false;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
|
||||
const type = () => {
|
||||
const current = PHRASES[phraseIdx];
|
||||
if (!deleting) {
|
||||
el.textContent = current.substring(0, charIdx + 1);
|
||||
charIdx++;
|
||||
if (charIdx === current.length) {
|
||||
deleting = true;
|
||||
timer = setTimeout(type, 2400);
|
||||
return;
|
||||
}
|
||||
timer = setTimeout(type, 56);
|
||||
} else {
|
||||
el.textContent = current.substring(0, charIdx - 1);
|
||||
charIdx--;
|
||||
if (charIdx === 0) {
|
||||
deleting = false;
|
||||
phraseIdx = (phraseIdx + 1) % PHRASES.length;
|
||||
}
|
||||
timer = setTimeout(type, 28);
|
||||
}
|
||||
};
|
||||
timer = setTimeout(type, 350);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) =>
|
||||
entries.forEach((e) => {
|
||||
if (e.isIntersecting) {
|
||||
e.target.classList.add("visible");
|
||||
observer.unobserve(e.target);
|
||||
}
|
||||
}),
|
||||
{ threshold: 0.08, rootMargin: "0px 0px -40px 0px" },
|
||||
);
|
||||
document.querySelectorAll(".reveal").forEach((el) => observer.observe(el));
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="home-flow social-flow">
|
||||
<ParticleCanvas />
|
||||
<SiteShell home>
|
||||
<section className="hero" id="hero">
|
||||
<div className="hero-bg-shapes" aria-hidden>
|
||||
<div className="shape shape-1" />
|
||||
<div className="shape shape-2" />
|
||||
<div className="shape shape-3" />
|
||||
</div>
|
||||
|
||||
<div className="hero-inner">
|
||||
<div className="hero-top">
|
||||
<div className="hero-content">
|
||||
<div className="hero-badge reveal">
|
||||
<span className="badge-dot" />
|
||||
nomadro · 游民社区
|
||||
</div>
|
||||
<h1 className="hero-title reveal">
|
||||
线上线下
|
||||
<br />
|
||||
<span className="gradient-text">找到同类</span> 💬
|
||||
</h1>
|
||||
<p className="hero-subtitle reveal">
|
||||
<span id="social-typewriter" />
|
||||
<span className="typewriter-cursor">|</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="hero-visual reveal">
|
||||
<div className="globe-container">
|
||||
<svg className="globe-svg" viewBox="0 0 400 400" aria-hidden>
|
||||
<defs>
|
||||
<radialGradient id="socialGlobeGlow" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0%" stopColor="#4ECDC4" stopOpacity="0.3" />
|
||||
<stop offset="100%" stopColor="#4ECDC4" stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<linearGradient id="socialOrbitGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stopColor="#FF6B6B" />
|
||||
<stop offset="100%" stopColor="#4ECDC4" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle cx="200" cy="200" r="160" fill="url(#socialGlobeGlow)" />
|
||||
<circle
|
||||
cx="200"
|
||||
cy="200"
|
||||
r="120"
|
||||
fill="none"
|
||||
stroke="rgba(78,205,196,0.2)"
|
||||
strokeWidth="1"
|
||||
/>
|
||||
<ellipse
|
||||
cx="200"
|
||||
cy="200"
|
||||
rx="120"
|
||||
ry="40"
|
||||
fill="none"
|
||||
stroke="rgba(78,205,196,0.3)"
|
||||
strokeWidth="1.5"
|
||||
className="orbit-ring"
|
||||
/>
|
||||
<ellipse
|
||||
cx="200"
|
||||
cy="200"
|
||||
rx="40"
|
||||
ry="120"
|
||||
fill="none"
|
||||
stroke="rgba(255,107,107,0.3)"
|
||||
strokeWidth="1.5"
|
||||
className="orbit-ring orbit-ring-2"
|
||||
/>
|
||||
<g className="nomad-dots">
|
||||
<circle cx="180" cy="155" r="5" fill="#FF6B6B" className="pulse-dot" />
|
||||
<circle cx="260" cy="215" r="5" fill="#FFE66D" className="pulse-dot" />
|
||||
<circle cx="145" cy="225" r="5" fill="#4ECDC4" className="pulse-dot" />
|
||||
<circle cx="220" cy="175" r="5" fill="#A78BFA" className="pulse-dot" />
|
||||
</g>
|
||||
<path
|
||||
d="M180 155 Q220 140 260 215"
|
||||
fill="none"
|
||||
stroke="url(#socialOrbitGrad)"
|
||||
strokeWidth="2"
|
||||
strokeDasharray="6 4"
|
||||
className="flight-path"
|
||||
/>
|
||||
</svg>
|
||||
<div className="floating-cards">
|
||||
<div className="float-card fc-1">
|
||||
💬 Chat
|
||||
<br />
|
||||
<small>实时文字房</small>
|
||||
</div>
|
||||
<div className="float-card fc-2">
|
||||
📹 Meetup
|
||||
<br />
|
||||
<small>站内视频</small>
|
||||
</div>
|
||||
<div className="float-card fc-3">
|
||||
☕ Coffee
|
||||
<br />
|
||||
<small>同城约见</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="hero-bottom reveal">
|
||||
<div className="hero-actions">
|
||||
<Link href={socialPath("/chat")} className="btn btn-primary">
|
||||
<span>进入聊天室</span>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M5 12h14M12 5l7 7-7 7" />
|
||||
</svg>
|
||||
</Link>
|
||||
<Link href={socialPath("/join")} className="btn btn-ghost">
|
||||
先加群
|
||||
</Link>
|
||||
<a href="#path" className="btn btn-ghost">
|
||||
看看路径
|
||||
</a>
|
||||
</div>
|
||||
<div className="scroll-hint">
|
||||
<span>向下滚动</span>
|
||||
<div className="scroll-arrow" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="journey-strip section-compact" id="path" aria-label="游民社区路径">
|
||||
<div className="container">
|
||||
<div className="section-header journey-head reveal">
|
||||
<span className="section-tag">PATH</span>
|
||||
<h2>一条路径,三步相扣</h2>
|
||||
<p>先报到,再聊天 / Meetup,最后线下见面——按需进入,不必一次看完。</p>
|
||||
</div>
|
||||
<ol className="journey-rail journey-rail-3 reveal">
|
||||
{PATH_STEPS.map((s, i) => (
|
||||
<li key={s.n} className="journey-step">
|
||||
{i > 0 && <span className="journey-connector" aria-hidden />}
|
||||
<div className="journey-card">
|
||||
<div className="journey-card-top">
|
||||
<span className="journey-n">{s.n}</span>
|
||||
<span className="journey-emoji">{s.emoji}</span>
|
||||
</div>
|
||||
<h3>{s.title}</h3>
|
||||
<p>{s.desc}</p>
|
||||
<div className="journey-actions">
|
||||
<Link href={socialPath(s.href)} className="btn btn-primary btn-sm">
|
||||
{s.cta}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section-compact" id="modules">
|
||||
<div className="container">
|
||||
<div className="section-header reveal">
|
||||
<span className="section-tag">HUB</span>
|
||||
<h2>核心能力</h2>
|
||||
<p>线上社交、线下连接、VIP 花名册与 UGC——全部站内原生体验。</p>
|
||||
</div>
|
||||
|
||||
{SOCIAL_SECTIONS.map((section) => (
|
||||
<div key={section.id} className="social-hub-block reveal" id={section.id}>
|
||||
<div className="social-hub-block-head">
|
||||
<h3>{section.title}</h3>
|
||||
<p>{section.subtitle}</p>
|
||||
</div>
|
||||
<div className="social-hub-grid">
|
||||
{section.features.map((f) => (
|
||||
<Link key={f.id} href={socialPath(f.href)} className="social-hub-card">
|
||||
<div className="social-hub-card-top">
|
||||
<span className="social-hub-emoji">{f.emoji}</span>
|
||||
<span className={`social-pill${f.status === "live" ? " live" : ""}`}>
|
||||
{f.status === "live" ? "开放" : "即将"}
|
||||
</span>
|
||||
</div>
|
||||
<h4>{f.title}</h4>
|
||||
<p>{f.desc}</p>
|
||||
<span className="social-hub-go">进入 →</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="section-compact" id="next">
|
||||
<div className="container">
|
||||
<div className="section-header reveal">
|
||||
<span className="section-tag">NEXT</span>
|
||||
<h2>接下来你可以</h2>
|
||||
</div>
|
||||
<div className="social-next-grid reveal">
|
||||
<Link href={socialPath("/meetup")} className="social-next-card">
|
||||
<span>📹</span>
|
||||
<div>
|
||||
<strong>站内 Meetup</strong>
|
||||
<p>视频与文字同页分屏,不跳外链标签页。</p>
|
||||
</div>
|
||||
<em>→</em>
|
||||
</Link>
|
||||
<Link href={socialPath("/roster")} className="social-next-card">
|
||||
<span>📇</span>
|
||||
<div>
|
||||
<strong>完善花名册</strong>
|
||||
<p>职业资料、Linktree、手机号,让同城找到你。</p>
|
||||
</div>
|
||||
<em>→</em>
|
||||
</Link>
|
||||
<Link href={socialPath("/vip")} className="social-next-card">
|
||||
<span>✨</span>
|
||||
<div>
|
||||
<strong>开通会员</strong>
|
||||
<p>花名册公开、活动席位与 Coffeechat 优先。</p>
|
||||
</div>
|
||||
<em>→</em>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer className="footer">
|
||||
<div className="container footer-inner">
|
||||
<div className="footer-brand">
|
||||
<div className="nav-logo">
|
||||
<span className="logo-icon">💬</span>
|
||||
<span className="logo-text">游民社区</span>
|
||||
</div>
|
||||
<p>让数字游民在流动中相遇——线上聊天、Meetup、线下 Coffeechat。</p>
|
||||
</div>
|
||||
<div className="footer-cols">
|
||||
<div>
|
||||
<h4>连接</h4>
|
||||
<Link href={socialPath("/join")}>加群</Link>
|
||||
<Link href={socialPath("/chat")}>聊天室</Link>
|
||||
<Link href={socialPath("/meetup")}>Meetup</Link>
|
||||
<Link href={socialPath("/coffeechat")}>Coffeechat</Link>
|
||||
</div>
|
||||
<div>
|
||||
<h4>成长</h4>
|
||||
<Link href={socialPath("/roster")}>花名册</Link>
|
||||
<Link href={socialPath("/vip")}>VIP</Link>
|
||||
<Link href={socialPath("/gigs")}>兼职</Link>
|
||||
<Link href={socialPath("/feedback")}>反馈</Link>
|
||||
</div>
|
||||
<div>
|
||||
<h4>更多</h4>
|
||||
<Link href="/">门户首页</Link>
|
||||
<Link href="/community">旅居社群</Link>
|
||||
<Link href="/book">数字游民小册</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="container footer-bottom">
|
||||
<span>© {new Date().getFullYear()} nomadro · 游民社区</span>
|
||||
</div>
|
||||
</footer>
|
||||
</SiteShell>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
54
src/modules/social/components/JoinClient.tsx
Normal file
54
src/modules/social/components/JoinClient.tsx
Normal file
@ -0,0 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { WechatOaModal } from "~/components/social-follow";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
export default function JoinClient() {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<SiteShell title="加群">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">线上社区</div>
|
||||
<h1>
|
||||
加入游民社区
|
||||
<br />
|
||||
<span>找到同频旅伴</span>
|
||||
</h1>
|
||||
<p>个人主体小程序不能嵌 web-view;Web 端用公众号 / 抖音群引导进群,再回聊天室继续聊。</p>
|
||||
</section>
|
||||
|
||||
<div className="social-grid">
|
||||
<button type="button" className="social-card social-card-btn" onClick={() => setOpen(true)}>
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">🚩</span>
|
||||
<span className="social-badge live">开放</span>
|
||||
</div>
|
||||
<strong>打开加群引导</strong>
|
||||
<p>按后台开关展示公众号或抖音群二维码</p>
|
||||
</button>
|
||||
<Link href={socialPath("/chat")} className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">💬</span>
|
||||
<span className="social-badge live">下一步</span>
|
||||
</div>
|
||||
<strong>进入实时聊天室</strong>
|
||||
<p>加群后也可先在站内频道报到</p>
|
||||
</Link>
|
||||
<Link href={socialPath("/roster")} className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">📇</span>
|
||||
<span className="social-badge">推荐</span>
|
||||
</div>
|
||||
<strong>完善职业花名册</strong>
|
||||
<p>填写资料,方便同城 / 同业匹配</p>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<WechatOaModal open={open} onClose={() => setOpen(false)} />
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
43
src/modules/social/components/MeetupClient.tsx
Normal file
43
src/modules/social/components/MeetupClient.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { SEED_MEETUPS } from "@social/lib/seed";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
export default function MeetupClient() {
|
||||
return (
|
||||
<SiteShell title="Meetup">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">线上 WebRTC</div>
|
||||
<h1>
|
||||
Meetup
|
||||
<br />
|
||||
<span>站内视频房 · 同页文字频道</span>
|
||||
</h1>
|
||||
<p>全程留在游民社区内体验,不新开标签页。视频与文字可分屏切换。</p>
|
||||
</section>
|
||||
|
||||
<div className="social-list">
|
||||
{SEED_MEETUPS.map((m) => (
|
||||
<article key={m.id} className="social-list-item social-list-stack">
|
||||
<div>
|
||||
<strong>{m.title}</strong>
|
||||
<p>
|
||||
{m.date} {m.time} · {m.city} · {m.mode}
|
||||
</p>
|
||||
</div>
|
||||
<div className="social-actions">
|
||||
<Link className="social-btn primary" href={socialPath(`/meetup/${m.id}`)}>
|
||||
进入活动
|
||||
</Link>
|
||||
<Link className="social-btn" href={socialPath(`/chat/${m.channelId}`)}>
|
||||
仅文字频道
|
||||
</Link>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
236
src/modules/social/components/MeetupLiveClient.tsx
Normal file
236
src/modules/social/components/MeetupLiveClient.tsx
Normal file
@ -0,0 +1,236 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { socialApi } from "@social/lib/api";
|
||||
import { MIROTALK_URL, SEED_CHANNELS, SEED_MEETUPS, SEED_MESSAGES } from "@social/lib/seed";
|
||||
import { loadJson, saveJson } from "@social/lib/storage";
|
||||
import type { SocialChatMessage } from "@social/lib/types";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
type Layout = "split" | "video" | "chat";
|
||||
|
||||
/** Origins currently listed in mirotalk.nomadro.com Caddy frame-ancestors. */
|
||||
const EMBED_OK = new Set([
|
||||
"https://nomadro.cn",
|
||||
"https://www.nomadro.cn",
|
||||
"https://nomadweb.nomadro.com",
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://localhost:3001",
|
||||
"http://127.0.0.1:3001",
|
||||
]);
|
||||
|
||||
function joinUrl(room: string, name: string) {
|
||||
const q = new URLSearchParams({ room, name });
|
||||
return `${MIROTALK_URL.replace(/\/$/, "")}/join?${q.toString()}`;
|
||||
}
|
||||
|
||||
function canEmbedHere() {
|
||||
if (typeof window === "undefined") return true;
|
||||
return EMBED_OK.has(window.location.origin);
|
||||
}
|
||||
|
||||
export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
|
||||
const meetup = SEED_MEETUPS.find((m) => m.id === meetupId) || SEED_MEETUPS[0];
|
||||
const channel =
|
||||
SEED_CHANNELS.find((c) => c.id === meetup.channelId) || SEED_CHANNELS[0];
|
||||
const storageKey = `chat:${channel.id}`;
|
||||
const seedForRoom = useMemo(
|
||||
() => SEED_MESSAGES.filter((m) => m.channelId === channel.id),
|
||||
[channel.id],
|
||||
);
|
||||
|
||||
const [layout, setLayout] = useState<Layout>("split");
|
||||
const [nick, setNick] = useState("游民");
|
||||
const [text, setText] = useState("");
|
||||
const [messages, setMessages] = useState<SocialChatMessage[]>([]);
|
||||
const [videoReady, setVideoReady] = useState(false);
|
||||
const [embedBlocked, setEmbedBlocked] = useState(false);
|
||||
const bottomRef = useRef<HTMLDivElement>(null);
|
||||
const videoSrc = joinUrl(meetup.mirotalkRoom, nick.trim() || "nomadro");
|
||||
const preferEmbed = canEmbedHere() && !embedBlocked;
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
const res = await socialApi.listMessages(channel.id);
|
||||
const items = (res.items || []).map((m) => ({
|
||||
id: m.id,
|
||||
channelId: m.channelId,
|
||||
author: m.author,
|
||||
text: m.text,
|
||||
at: m.at,
|
||||
}));
|
||||
setMessages(items.length ? items : loadJson(storageKey, seedForRoom));
|
||||
if (items.length) saveJson(storageKey, items);
|
||||
} catch {
|
||||
setMessages(loadJson(storageKey, seedForRoom));
|
||||
}
|
||||
}, [channel.id, seedForRoom, storageKey]);
|
||||
|
||||
useEffect(() => {
|
||||
setNick(loadJson("nick", "游民"));
|
||||
void refresh();
|
||||
const id = window.setInterval(() => void refresh(), 4000);
|
||||
return () => clearInterval(id);
|
||||
}, [refresh]);
|
||||
|
||||
useEffect(() => {
|
||||
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [messages]);
|
||||
|
||||
const send = async () => {
|
||||
const body = text.trim();
|
||||
if (!body) return;
|
||||
const author = nick.trim() || "游民";
|
||||
try {
|
||||
await socialApi.sendMessage(channel.id, author, body);
|
||||
saveJson("nick", author);
|
||||
setText("");
|
||||
await refresh();
|
||||
} catch {
|
||||
const next: SocialChatMessage = {
|
||||
id: `local_${Date.now()}`,
|
||||
channelId: channel.id,
|
||||
author,
|
||||
text: body,
|
||||
at: new Date().toISOString(),
|
||||
mine: true,
|
||||
};
|
||||
const merged = [...messages, next];
|
||||
setMessages(merged);
|
||||
saveJson(storageKey, merged);
|
||||
saveJson("nick", author);
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="social-root social-live-root">
|
||||
<header className="social-live-bar">
|
||||
<div className="social-live-bar-main">
|
||||
<Link href={socialPath("/meetup")} className="social-nav-back">
|
||||
← 活动列表
|
||||
</Link>
|
||||
<div>
|
||||
<strong>{meetup.title}</strong>
|
||||
<p className="social-muted">
|
||||
{meetup.date} {meetup.time} · {channel.name}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="social-live-tabs" role="tablist" aria-label="布局">
|
||||
{(["split", "video", "chat"] as const).map((m) => (
|
||||
<button
|
||||
key={m}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={layout === m}
|
||||
className={`social-live-tab${layout === m ? " active" : ""}`}
|
||||
onClick={() => setLayout(m)}
|
||||
>
|
||||
{m === "split" ? "分屏" : m === "video" ? "视频" : "文字"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className={`social-live-stage layout-${layout}`}>
|
||||
{(layout === "split" || layout === "video") && (
|
||||
<section className="social-live-video" aria-label="视频房间">
|
||||
{!videoReady ? (
|
||||
<div className="social-live-gate">
|
||||
<h2>进入视频房间</h2>
|
||||
<p>
|
||||
{preferEmbed
|
||||
? "在站内嵌打开,不新开标签页。请允许摄像头 / 麦克风。"
|
||||
: "当前域名未在视频 CSP 白名单,将在本页跳转进入(不新开标签)。浏览器返回即可回到社区。"}
|
||||
</p>
|
||||
<label>
|
||||
显示名
|
||||
<input
|
||||
value={nick}
|
||||
onChange={(e) => setNick(e.target.value)}
|
||||
maxLength={24}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className="social-btn primary"
|
||||
onClick={() => {
|
||||
const name = nick.trim() || "游民";
|
||||
saveJson("nick", name);
|
||||
const url = joinUrl(meetup.mirotalkRoom, name);
|
||||
if (preferEmbed) {
|
||||
setVideoReady(true);
|
||||
} else {
|
||||
window.location.assign(url);
|
||||
}
|
||||
}}
|
||||
>
|
||||
开始视频
|
||||
</button>
|
||||
</div>
|
||||
) : preferEmbed ? (
|
||||
<iframe
|
||||
title={`${meetup.title} video`}
|
||||
src={videoSrc}
|
||||
className="social-live-iframe"
|
||||
allow="camera; microphone; display-capture; autoplay; fullscreen; clipboard-write"
|
||||
referrerPolicy="no-referrer-when-downgrade"
|
||||
onError={() => setEmbedBlocked(true)}
|
||||
/>
|
||||
) : (
|
||||
<div className="social-live-gate">
|
||||
<h2>无法站内嵌</h2>
|
||||
<p>将在本页打开视频房;用浏览器返回键回到游民社区。</p>
|
||||
<button
|
||||
type="button"
|
||||
className="social-btn primary"
|
||||
onClick={() => window.location.assign(videoSrc)}
|
||||
>
|
||||
继续进入
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
{(layout === "split" || layout === "chat") && (
|
||||
<section className="social-live-chat" aria-label="文字频道">
|
||||
<div className="social-live-chat-head">
|
||||
<strong>{channel.name}</strong>
|
||||
<span className="social-muted">{channel.topic}</span>
|
||||
</div>
|
||||
<div className="social-chat-thread social-live-thread">
|
||||
{messages.map((m) => (
|
||||
<div key={m.id} className={`social-bubble${m.mine ? " mine" : ""}`}>
|
||||
<header>
|
||||
{m.author}
|
||||
<time>{new Date(m.at).toLocaleTimeString()}</time>
|
||||
</header>
|
||||
<p>{m.text}</p>
|
||||
</div>
|
||||
))}
|
||||
<div ref={bottomRef} />
|
||||
</div>
|
||||
<div className="social-compose">
|
||||
<input
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") void send();
|
||||
}}
|
||||
placeholder="发到活动文字频道…"
|
||||
aria-label="消息内容"
|
||||
/>
|
||||
<button type="button" onClick={() => void send()}>
|
||||
发送
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
121
src/modules/social/components/ParticleCanvas.tsx
Normal file
121
src/modules/social/components/ParticleCanvas.tsx
Normal file
@ -0,0 +1,121 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
/** Ambient particle field — same feel as 旅居社群 homepage. */
|
||||
export default function ParticleCanvas() {
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas) return;
|
||||
const ctx = canvas.getContext("2d", { alpha: true });
|
||||
if (!ctx) return;
|
||||
|
||||
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
||||
canvas.style.display = "none";
|
||||
return;
|
||||
}
|
||||
|
||||
let animId = 0;
|
||||
let running = false;
|
||||
let started = false;
|
||||
let resizeTimer = 0;
|
||||
let particles: {
|
||||
x: number;
|
||||
y: number;
|
||||
size: number;
|
||||
speedX: number;
|
||||
speedY: number;
|
||||
opacity: number;
|
||||
hue: number;
|
||||
}[] = [];
|
||||
|
||||
const resize = () => {
|
||||
const dpr = Math.min(window.devicePixelRatio || 1, 1.5);
|
||||
const w = window.innerWidth;
|
||||
const h = window.innerHeight;
|
||||
canvas.width = Math.floor(w * dpr);
|
||||
canvas.height = Math.floor(h * dpr);
|
||||
canvas.style.width = `${w}px`;
|
||||
canvas.style.height = `${h}px`;
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
};
|
||||
|
||||
const create = () => {
|
||||
const w = window.innerWidth;
|
||||
const count = Math.min(Math.floor(w / 40), 28);
|
||||
particles = Array.from({ length: count }, () => ({
|
||||
x: Math.random() * w,
|
||||
y: Math.random() * window.innerHeight,
|
||||
size: Math.random() * 2 + 0.5,
|
||||
speedX: (Math.random() - 0.5) * 0.22,
|
||||
speedY: (Math.random() - 0.5) * 0.22,
|
||||
opacity: Math.random() * 0.35 + 0.08,
|
||||
hue: [0, 45, 170, 280][Math.floor(Math.random() * 4)],
|
||||
}));
|
||||
};
|
||||
|
||||
const draw = () => {
|
||||
if (!running) return;
|
||||
const w = window.innerWidth;
|
||||
const h = window.innerHeight;
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
for (const p of particles) {
|
||||
p.x += p.speedX;
|
||||
p.y += p.speedY;
|
||||
if (p.x < 0) p.x = w;
|
||||
if (p.x > w) p.x = 0;
|
||||
if (p.y < 0) p.y = h;
|
||||
if (p.y > h) p.y = 0;
|
||||
ctx.beginPath();
|
||||
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
||||
ctx.fillStyle = `hsla(${p.hue}, 70%, 60%, ${p.opacity})`;
|
||||
ctx.fill();
|
||||
}
|
||||
animId = requestAnimationFrame(draw);
|
||||
};
|
||||
|
||||
const start = () => {
|
||||
if (started) return;
|
||||
started = true;
|
||||
resize();
|
||||
create();
|
||||
running = document.visibilityState === "visible";
|
||||
if (running) draw();
|
||||
};
|
||||
|
||||
const onResize = () => {
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = window.setTimeout(() => {
|
||||
resize();
|
||||
create();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
const onVis = () => {
|
||||
running = document.visibilityState === "visible" && started;
|
||||
if (running) draw();
|
||||
else cancelAnimationFrame(animId);
|
||||
};
|
||||
|
||||
const ric = window.requestIdleCallback
|
||||
? window.requestIdleCallback(() => start(), { timeout: 1800 })
|
||||
: 0;
|
||||
const fallback = window.setTimeout(start, 400);
|
||||
|
||||
window.addEventListener("resize", onResize, { passive: true });
|
||||
document.addEventListener("visibilitychange", onVis);
|
||||
return () => {
|
||||
running = false;
|
||||
cancelAnimationFrame(animId);
|
||||
clearTimeout(fallback);
|
||||
clearTimeout(resizeTimer);
|
||||
if (ric && window.cancelIdleCallback) window.cancelIdleCallback(ric);
|
||||
window.removeEventListener("resize", onResize);
|
||||
document.removeEventListener("visibilitychange", onVis);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <canvas id="particle-canvas" ref={canvasRef} aria-hidden="true" />;
|
||||
}
|
||||
150
src/modules/social/components/RosterClient.tsx
Normal file
150
src/modules/social/components/RosterClient.tsx
Normal file
@ -0,0 +1,150 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState, type FormEvent } from "react";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialApi } from "@social/lib/api";
|
||||
import { loadJson, saveJson } from "@social/lib/storage";
|
||||
import type { SocialRosterProfile } from "@social/lib/types";
|
||||
|
||||
const EMPTY: SocialRosterProfile = {
|
||||
name: "",
|
||||
title: "",
|
||||
city: "",
|
||||
phone: "",
|
||||
linktree: "",
|
||||
skills: "",
|
||||
bio: "",
|
||||
};
|
||||
|
||||
export default function RosterClient() {
|
||||
const [form, setForm] = useState<SocialRosterProfile>(EMPTY);
|
||||
const [saved, setSaved] = useState("");
|
||||
const [online, setOnline] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
const local = loadJson<SocialRosterProfile>("roster", EMPTY);
|
||||
if (!cancelled) setForm(local);
|
||||
try {
|
||||
const res = await socialApi.getRoster();
|
||||
if (cancelled) return;
|
||||
if (res.item) {
|
||||
const mapped: SocialRosterProfile = {
|
||||
name: res.item.name || "",
|
||||
title: res.item.title || "",
|
||||
city: res.item.city || "",
|
||||
phone: res.item.phone || "",
|
||||
linktree: res.item.linktree || "",
|
||||
skills: res.item.skills || "",
|
||||
bio: res.item.bio || "",
|
||||
updatedAt: res.item.updatedAt,
|
||||
};
|
||||
setForm(mapped);
|
||||
saveJson("roster", mapped);
|
||||
}
|
||||
setOnline(true);
|
||||
} catch {
|
||||
if (!cancelled) setOnline(false);
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const set = (key: keyof SocialRosterProfile, value: string) =>
|
||||
setForm((prev) => ({ ...prev, [key]: value }));
|
||||
|
||||
const submit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
const next = { ...form, updatedAt: new Date().toISOString() };
|
||||
saveJson("roster", next);
|
||||
if (next.name) saveJson("nick", next.name);
|
||||
setForm(next);
|
||||
try {
|
||||
await socialApi.saveRoster({
|
||||
name: next.name,
|
||||
title: next.title,
|
||||
city: next.city,
|
||||
phone: next.phone,
|
||||
linktree: next.linktree,
|
||||
skills: next.skills,
|
||||
bio: next.bio,
|
||||
});
|
||||
setOnline(true);
|
||||
setSaved("已同步到游民社区独立库");
|
||||
} catch {
|
||||
setOnline(false);
|
||||
setSaved("后端暂不可用,已先保存到本机");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SiteShell title="花名册">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">VIP · 职业花名册</div>
|
||||
<h1>
|
||||
完善个人资料
|
||||
<br />
|
||||
<span>表单 · Linktree · 手机号</span>
|
||||
</h1>
|
||||
<p>
|
||||
数据写入独立 social SQLite,不进旅居社群 / VIP 表。
|
||||
{online ? "" : " (当前离线本地)"}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<form className="social-form social-panel" onSubmit={(e) => void submit(e)}>
|
||||
<label>
|
||||
昵称 / 姓名
|
||||
<input required value={form.name} onChange={(e) => set("name", e.target.value)} />
|
||||
</label>
|
||||
<label>
|
||||
职业头衔
|
||||
<input
|
||||
value={form.title}
|
||||
onChange={(e) => set("title", e.target.value)}
|
||||
placeholder="独立开发 / 设计师 / 运营"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
当前城市
|
||||
<input value={form.city} onChange={(e) => set("city", e.target.value)} placeholder="清迈" />
|
||||
</label>
|
||||
<label>
|
||||
手机号
|
||||
<input
|
||||
value={form.phone}
|
||||
onChange={(e) => set("phone", e.target.value)}
|
||||
placeholder="仅用于同城约见"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
社交媒体 Linktree
|
||||
<input
|
||||
value={form.linktree}
|
||||
onChange={(e) => set("linktree", e.target.value)}
|
||||
placeholder="https://linktr.ee/..."
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
技能标签
|
||||
<input
|
||||
value={form.skills}
|
||||
onChange={(e) => set("skills", e.target.value)}
|
||||
placeholder="React, 短视频, 英语"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
简介
|
||||
<textarea rows={4} value={form.bio} onChange={(e) => set("bio", e.target.value)} />
|
||||
</label>
|
||||
<button type="submit" className="social-btn primary">
|
||||
保存资料
|
||||
</button>
|
||||
{saved ? <p className="social-muted">{saved}</p> : null}
|
||||
</form>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
153
src/modules/social/components/SiteShell.tsx
Normal file
153
src/modules/social/components/SiteShell.tsx
Normal file
@ -0,0 +1,153 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
|
||||
const GROUPS = [
|
||||
{
|
||||
id: "online",
|
||||
label: "线上",
|
||||
items: [
|
||||
{ href: "/join", label: "加群" },
|
||||
{ href: "/chat", label: "聊天室" },
|
||||
{ href: "/meetup", label: "Meetup" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "offline",
|
||||
label: "线下",
|
||||
items: [
|
||||
{ href: "/coffeechat", label: "Coffeechat" },
|
||||
{ href: "/date", label: "访谈" },
|
||||
{ href: "/roster", label: "花名册" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "grow",
|
||||
label: "成长",
|
||||
items: [
|
||||
{ href: "/vip", label: "VIP" },
|
||||
{ href: "/ebook", label: "小册" },
|
||||
{ href: "/videos", label: "视频" },
|
||||
{ href: "/gigs", label: "兼职" },
|
||||
{ href: "/feedback", label: "反馈" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export default function SiteShell({
|
||||
children,
|
||||
title,
|
||||
home = false,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
title?: string;
|
||||
/** 首页自带 hero 顶距,不再套 social-main */
|
||||
home?: boolean;
|
||||
}) {
|
||||
const [theme, setTheme] = useState<"dark" | "light">("dark");
|
||||
const [openGroup, setOpenGroup] = useState<string | null>(null);
|
||||
const [scrolled, setScrolled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const saved =
|
||||
localStorage.getItem("nomadro-theme") || localStorage.getItem("nomad-theme");
|
||||
const next = saved === "light" ? "light" : "dark";
|
||||
setTheme(next);
|
||||
document.documentElement.setAttribute("data-theme", next);
|
||||
document.documentElement.classList.toggle("light", next === "light");
|
||||
document.documentElement.classList.toggle("dark", next === "dark");
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const onScroll = () => setScrolled(window.scrollY > 24);
|
||||
onScroll();
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
return () => window.removeEventListener("scroll", onScroll);
|
||||
}, []);
|
||||
|
||||
const toggleTheme = () => {
|
||||
const next = theme === "dark" ? "light" : "dark";
|
||||
setTheme(next);
|
||||
localStorage.setItem("nomadro-theme", next);
|
||||
document.documentElement.setAttribute("data-theme", next);
|
||||
document.documentElement.classList.toggle("light", next === "light");
|
||||
document.documentElement.classList.toggle("dark", next === "dark");
|
||||
};
|
||||
|
||||
const nav = (
|
||||
<nav className={`navbar${scrolled ? " scrolled" : ""}`} aria-label="游民社区">
|
||||
<div className="nav-container">
|
||||
<Link href={socialPath("/")} className="nav-logo">
|
||||
<span className="logo-icon">💬</span>
|
||||
<span className="logo-text">{title || "游民社区"}</span>
|
||||
</Link>
|
||||
|
||||
<div className="nav-links">
|
||||
{GROUPS.map((g) => (
|
||||
<div
|
||||
key={g.id}
|
||||
className={`nav-group${openGroup === g.id ? " open" : ""}`}
|
||||
onMouseEnter={() => setOpenGroup(g.id)}
|
||||
onMouseLeave={() => setOpenGroup(null)}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="nav-group-btn"
|
||||
aria-expanded={openGroup === g.id}
|
||||
onClick={() => setOpenGroup(openGroup === g.id ? null : g.id)}
|
||||
>
|
||||
{g.label}
|
||||
<span aria-hidden>▾</span>
|
||||
</button>
|
||||
<div className="nav-dropdown">
|
||||
{g.items.map((item) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={socialPath(item.href)}
|
||||
className="nav-dropdown-link"
|
||||
onClick={() => setOpenGroup(null)}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="nav-actions">
|
||||
<button type="button" className="nav-icon-btn" onClick={toggleTheme} aria-label="切换主题">
|
||||
{theme === "dark" ? "🌙" : "☀️"}
|
||||
</button>
|
||||
<Link href={socialPath("/chat")} className="nav-icon-btn" aria-label="聊天室">
|
||||
✉️
|
||||
</Link>
|
||||
<Link href={socialPath("/join")} className="btn btn-primary btn-sm">
|
||||
加群
|
||||
</Link>
|
||||
<Link href="/" className="btn btn-ghost btn-sm">
|
||||
门户
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
|
||||
if (home) {
|
||||
return (
|
||||
<>
|
||||
{nav}
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="social-flow social-root">
|
||||
{nav}
|
||||
<div className="social-main social-page-pad">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
44
src/modules/social/components/VideosClient.tsx
Normal file
44
src/modules/social/components/VideosClient.tsx
Normal file
@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import SiteShell from "./SiteShell";
|
||||
import { SEED_VIDEOS } from "@social/lib/seed";
|
||||
|
||||
export default function VideosClient() {
|
||||
return (
|
||||
<SiteShell title="视频">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">UGC · 视频</div>
|
||||
<h1>
|
||||
视频库
|
||||
<br />
|
||||
<span>访谈 · 旅居切片 · Date 成片</span>
|
||||
</h1>
|
||||
<p>当前为可浏览目录;片源可接 PeerTube / SeaweedFS。点击条目可锚定分享。</p>
|
||||
</section>
|
||||
<div className="social-grid">
|
||||
{SEED_VIDEOS.map((v) => (
|
||||
<article key={v.id} id={v.id} className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">{v.coverEmoji}</span>
|
||||
<span className="social-badge">{v.minutes} 分</span>
|
||||
</div>
|
||||
<strong>{v.title}</strong>
|
||||
<p>
|
||||
{v.city} · {v.summary}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
className="social-btn"
|
||||
onClick={() => {
|
||||
const url = `${window.location.pathname}#${v.id}`;
|
||||
void navigator.clipboard?.writeText(window.location.origin + url);
|
||||
}}
|
||||
>
|
||||
复制分享链接
|
||||
</button>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
65
src/modules/social/components/VipClient.tsx
Normal file
65
src/modules/social/components/VipClient.tsx
Normal file
@ -0,0 +1,65 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import SiteShell from "./SiteShell";
|
||||
import { socialPath } from "@social/lib/socialPath";
|
||||
import { useRemoteConfig } from "~/lib/use-remote-config";
|
||||
|
||||
export default function VipClient() {
|
||||
const { config } = useRemoteConfig();
|
||||
const fen = config.copy?.vipPriceFen || 29800;
|
||||
const price = (fen / 100).toFixed(0);
|
||||
const cta = config.copy?.vipCta || `立即加入 · ¥${price}`;
|
||||
|
||||
return (
|
||||
<SiteShell title="会员">
|
||||
<section className="social-hero">
|
||||
<div className="social-hero-tag">虚拟支付</div>
|
||||
<h1>
|
||||
游民社区 VIP
|
||||
<br />
|
||||
<span>花名册广场 · 优先约见 · 活动席位</span>
|
||||
</h1>
|
||||
<p>
|
||||
国内虚拟支付走门户统一网关(zpay / xpay);海外可接 Creem。价格由远程配置下发:¥{price}。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div className="social-grid">
|
||||
<article className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">📇</span>
|
||||
<span className="social-badge live">权益</span>
|
||||
</div>
|
||||
<strong>职业花名册公开</strong>
|
||||
<p>资料进入可检索花名册,同城 / 同业可见</p>
|
||||
</article>
|
||||
<article className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">☕</span>
|
||||
<span className="social-badge live">权益</span>
|
||||
</div>
|
||||
<strong>Coffeechat 优先</strong>
|
||||
<p>合作咖啡馆预约与线下活动席位优先</p>
|
||||
</article>
|
||||
<article className="social-card">
|
||||
<div className="social-card-top">
|
||||
<span className="social-card-ico">📹</span>
|
||||
<span className="social-badge live">权益</span>
|
||||
</div>
|
||||
<strong>Meetup 席位</strong>
|
||||
<p>线上 WebRTC 房间与 AMA 优先入场</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div className="social-actions" style={{ marginTop: 24 }}>
|
||||
<Link className="social-btn primary" href="/vip">
|
||||
{cta}
|
||||
</Link>
|
||||
<Link className="social-btn" href={socialPath("/roster")}>
|
||||
先完善花名册
|
||||
</Link>
|
||||
</div>
|
||||
</SiteShell>
|
||||
);
|
||||
}
|
||||
85
src/modules/social/lib/api.ts
Normal file
85
src/modules/social/lib/api.ts
Normal file
@ -0,0 +1,85 @@
|
||||
"use client";
|
||||
|
||||
import { loadJson, saveJson, uid } from "./storage";
|
||||
|
||||
const BASE = "/api/social/v1";
|
||||
const GUEST_KEY = "guest-id";
|
||||
|
||||
export function getGuestId(): string {
|
||||
let id = loadJson<string>(GUEST_KEY, "");
|
||||
if (!id) {
|
||||
id = uid("guest");
|
||||
saveJson(GUEST_KEY, id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
async function req<T>(
|
||||
path: string,
|
||||
init?: RequestInit & { json?: unknown },
|
||||
): Promise<T> {
|
||||
const headers: Record<string, string> = {
|
||||
"X-Social-Guest-Id": getGuestId(),
|
||||
...(init?.headers as Record<string, string> | undefined),
|
||||
};
|
||||
let body = init?.body;
|
||||
if (init?.json !== undefined) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
body = JSON.stringify(init.json);
|
||||
}
|
||||
const res = await fetch(`${BASE}${path}`, {
|
||||
...init,
|
||||
headers,
|
||||
body,
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = await res.text().catch(() => "");
|
||||
throw new Error(err || `HTTP ${res.status}`);
|
||||
}
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
export const socialApi = {
|
||||
health: () => req<{ ok: boolean; isolated?: boolean }>("/health"),
|
||||
|
||||
listMessages: (channelId: string) =>
|
||||
req<{ items: Array<{ id: string; channelId: string; author: string; text: string; at: string; guestId?: string }> }>(
|
||||
`/channels/${encodeURIComponent(channelId)}/messages`,
|
||||
),
|
||||
|
||||
sendMessage: (channelId: string, author: string, text: string) =>
|
||||
req<{ id: string; channelId: string; author: string; text: string; at: string }>(
|
||||
`/channels/${encodeURIComponent(channelId)}/messages`,
|
||||
{ method: "POST", json: { author, text } },
|
||||
),
|
||||
|
||||
listReviews: (cafeId: string) =>
|
||||
req<{ items: Array<{ id: string; cafeId: string; author: string; score: number; text: string; photoNote?: string; at: string }> }>(
|
||||
`/cafes/${encodeURIComponent(cafeId)}/reviews`,
|
||||
),
|
||||
|
||||
postReview: (
|
||||
cafeId: string,
|
||||
payload: { author: string; score: number; text: string; photoNote?: string },
|
||||
) =>
|
||||
req(`/cafes/${encodeURIComponent(cafeId)}/reviews`, {
|
||||
method: "POST",
|
||||
json: payload,
|
||||
}),
|
||||
|
||||
getRoster: () =>
|
||||
req<{ item: Record<string, string> | null }>("/roster/me"),
|
||||
|
||||
saveRoster: (payload: Record<string, string>) =>
|
||||
req("/roster/me", { method: "PUT", json: payload }),
|
||||
|
||||
postFeedback: (payload: { kind: string; text: string; contact?: string }) =>
|
||||
req("/feedback", { method: "POST", json: payload }),
|
||||
|
||||
applyGig: (gigId: string, payload: { name: string; contact: string; note?: string }) =>
|
||||
req(`/gigs/${encodeURIComponent(gigId)}/apply`, {
|
||||
method: "POST",
|
||||
json: payload,
|
||||
}),
|
||||
};
|
||||
143
src/modules/social/lib/catalog.ts
Normal file
143
src/modules/social/lib/catalog.ts
Normal file
@ -0,0 +1,143 @@
|
||||
/** Hub IA for 游民社区 — all core routes live. */
|
||||
|
||||
export type SocialFeature = {
|
||||
id: string;
|
||||
emoji: string;
|
||||
title: string;
|
||||
desc: string;
|
||||
href: string;
|
||||
status: "live" | "soon";
|
||||
};
|
||||
|
||||
export type SocialSection = {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
features: SocialFeature[];
|
||||
};
|
||||
|
||||
export const SOCIAL_SECTIONS: SocialSection[] = [
|
||||
{
|
||||
id: "online",
|
||||
title: "线上社交",
|
||||
subtitle: "加群 · 实时聊天 · Meetup",
|
||||
features: [
|
||||
{
|
||||
id: "join",
|
||||
emoji: "🚩",
|
||||
title: "加群",
|
||||
desc: "线上社区入口,找到同频游民",
|
||||
href: "/join",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "chat",
|
||||
emoji: "💬",
|
||||
title: "实时聊天室",
|
||||
desc: "自研文字频道,本地可发消息",
|
||||
href: "/chat",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "meetup",
|
||||
emoji: "📹",
|
||||
title: "线上 Meetup",
|
||||
desc: "站内分屏视频房 · 同页文字频道",
|
||||
href: "/meetup",
|
||||
status: "live",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "offline",
|
||||
title: "线下连接",
|
||||
subtitle: "Coffeechat · Date",
|
||||
features: [
|
||||
{
|
||||
id: "coffeechat",
|
||||
emoji: "☕",
|
||||
title: "Coffeechat",
|
||||
desc: "咖啡馆合作 · 评价 · 合照备注",
|
||||
href: "/coffeechat",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "date",
|
||||
emoji: "🎙",
|
||||
title: "Date / 访谈",
|
||||
desc: "线下访谈视频与故事",
|
||||
href: "/date",
|
||||
status: "live",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "vip",
|
||||
title: "VIP",
|
||||
subtitle: "职业花名册 · 虚拟支付",
|
||||
features: [
|
||||
{
|
||||
id: "roster",
|
||||
emoji: "📇",
|
||||
title: "职业花名册",
|
||||
desc: "资料表单 · Linktree · 手机号",
|
||||
href: "/roster",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "pay",
|
||||
emoji: "💳",
|
||||
title: "会员开通",
|
||||
desc: "虚拟支付 · 对接门户 VIP",
|
||||
href: "/vip",
|
||||
status: "live",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "ugc",
|
||||
title: "UGC",
|
||||
subtitle: "小册 · 视频",
|
||||
features: [
|
||||
{
|
||||
id: "ebook",
|
||||
emoji: "📖",
|
||||
title: "电子书",
|
||||
desc: "游民内容共创与阅读",
|
||||
href: "/ebook",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "video",
|
||||
emoji: "🎬",
|
||||
title: "视频",
|
||||
desc: "UGC 视频与访谈合集",
|
||||
href: "/videos",
|
||||
status: "live",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "ops",
|
||||
title: "远程团队",
|
||||
subtitle: "招募 · 反馈",
|
||||
features: [
|
||||
{
|
||||
id: "gigs",
|
||||
emoji: "🧑💻",
|
||||
title: "招募兼职",
|
||||
desc: "运营 / 拍摄助理 · 大学生兼职",
|
||||
href: "/gigs",
|
||||
status: "live",
|
||||
},
|
||||
{
|
||||
id: "feedback",
|
||||
emoji: "💡",
|
||||
title: "反馈建议",
|
||||
desc: "产品反馈与改进建议",
|
||||
href: "/feedback",
|
||||
status: "live",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
183
src/modules/social/lib/seed.ts
Normal file
183
src/modules/social/lib/seed.ts
Normal file
@ -0,0 +1,183 @@
|
||||
import type {
|
||||
SocialCafe,
|
||||
SocialChannel,
|
||||
SocialChatMessage,
|
||||
SocialEbook,
|
||||
SocialGig,
|
||||
SocialMeetup,
|
||||
SocialVideo,
|
||||
} from "./types";
|
||||
|
||||
export const SEED_CHANNELS: SocialChannel[] = [
|
||||
{ id: "general", name: "#general", topic: "游民闲聊 · 报到打卡", members: 128 },
|
||||
{ id: "chiangmai", name: "#chiangmai", topic: "清迈同城 · cowork / visa", members: 64 },
|
||||
{ id: "meetup-live", name: "#meetup-live", topic: "线上活动文字房", members: 42 },
|
||||
{ id: "coffee", name: "#coffeechat", topic: "咖啡馆约见协调", members: 31 },
|
||||
];
|
||||
|
||||
export const SEED_MESSAGES: SocialChatMessage[] = [
|
||||
{
|
||||
id: "m1",
|
||||
channelId: "general",
|
||||
author: "林远",
|
||||
text: "欢迎来到游民社区实时聊天室 👋 先报个到:你在哪座城?",
|
||||
at: "2026-10-28T09:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "m2",
|
||||
channelId: "general",
|
||||
author: "Mika",
|
||||
text: "清迈第三周,Nimman 找 cowork,有人一起吗?",
|
||||
at: "2026-10-28T09:12:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "m3",
|
||||
channelId: "chiangmai",
|
||||
author: "Ken",
|
||||
text: "Graph Table 二楼靠窗位 WiFi 稳,插座够。",
|
||||
at: "2026-10-29T02:20:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "m4",
|
||||
channelId: "meetup-live",
|
||||
author: "Host",
|
||||
text: "今晚 20:00 Meetup,视频走 MiroTalk,文字留在本频道。",
|
||||
at: "2026-10-30T08:00:00.000Z",
|
||||
},
|
||||
];
|
||||
|
||||
export const SEED_CAFES: SocialCafe[] = [
|
||||
{
|
||||
id: "graph-table",
|
||||
name: "Graph Table",
|
||||
city: "清迈",
|
||||
wifiMbps: 80,
|
||||
power: "座位大多有插座",
|
||||
vibe: "安静 · 设计感",
|
||||
partners: true,
|
||||
rating: 4.7,
|
||||
reviews: 18,
|
||||
},
|
||||
{
|
||||
id: "camp",
|
||||
name: "Camp",
|
||||
city: "清迈",
|
||||
wifiMbps: 100,
|
||||
power: "全覆盖",
|
||||
vibe: "社区感 · 活动多",
|
||||
partners: true,
|
||||
rating: 4.6,
|
||||
reviews: 24,
|
||||
},
|
||||
{
|
||||
id: "blink",
|
||||
name: "Blink Cowork",
|
||||
city: "槟城",
|
||||
wifiMbps: 120,
|
||||
power: "全覆盖",
|
||||
vibe: "海风 · 开放工位",
|
||||
partners: false,
|
||||
rating: 4.4,
|
||||
reviews: 9,
|
||||
},
|
||||
{
|
||||
id: "forest",
|
||||
name: "Forest Coffee",
|
||||
city: "大理",
|
||||
wifiMbps: 40,
|
||||
power: "靠窗有限",
|
||||
vibe: "慢节奏 · 适合深谈",
|
||||
partners: true,
|
||||
rating: 4.5,
|
||||
reviews: 11,
|
||||
},
|
||||
];
|
||||
|
||||
export const SEED_MEETUPS: SocialMeetup[] = [
|
||||
{
|
||||
id: "wk-nomad-office",
|
||||
title: "周三线上办公室",
|
||||
city: "Online",
|
||||
date: "2026-11-05",
|
||||
time: "20:00",
|
||||
mode: "online",
|
||||
mirotalkRoom: "nomadro-social-office",
|
||||
channelId: "meetup-live",
|
||||
},
|
||||
{
|
||||
id: "visa-ama",
|
||||
title: "签证 AMA · 东南亚",
|
||||
city: "Online",
|
||||
date: "2026-11-08",
|
||||
time: "21:00",
|
||||
mode: "hybrid",
|
||||
mirotalkRoom: "nomadro-visa-ama",
|
||||
channelId: "meetup-live",
|
||||
},
|
||||
];
|
||||
|
||||
export const SEED_VIDEOS: SocialVideo[] = [
|
||||
{
|
||||
id: "cm-morning",
|
||||
title: "清迈的周二早晨",
|
||||
city: "清迈",
|
||||
minutes: 12,
|
||||
coverEmoji: "🛵",
|
||||
summary: "咖啡馆办公、时区套利、同城聚餐。",
|
||||
},
|
||||
{
|
||||
id: "penang-walk",
|
||||
title: "槟城街头访谈",
|
||||
city: "槟城",
|
||||
minutes: 8,
|
||||
coverEmoji: "🎙",
|
||||
summary: "两位远程设计师聊租金与 cowork。",
|
||||
},
|
||||
{
|
||||
id: "dali-date",
|
||||
title: "大理 Coffeechat 实录",
|
||||
city: "大理",
|
||||
minutes: 15,
|
||||
coverEmoji: "☕",
|
||||
summary: "线下约见流程:场地、合照、评价。",
|
||||
},
|
||||
];
|
||||
|
||||
export const SEED_EBOOKS: SocialEbook[] = [
|
||||
{
|
||||
id: "social-playbook",
|
||||
title: "游民社区玩法手册",
|
||||
chapters: 6,
|
||||
minutes: 35,
|
||||
blurb: "加群、聊天室、Meetup、Coffeechat 怎么玩。",
|
||||
},
|
||||
{
|
||||
id: "roster-guide",
|
||||
title: "职业花名册指南",
|
||||
chapters: 4,
|
||||
minutes: 20,
|
||||
blurb: "如何写资料、挂 Linktree、被同城找到。",
|
||||
},
|
||||
];
|
||||
|
||||
export const SEED_GIGS: SocialGig[] = [
|
||||
{
|
||||
id: "ops-assistant",
|
||||
title: "运营 / 拍摄助理",
|
||||
role: "L 大学生兼职",
|
||||
pay: "按场次结算",
|
||||
remote: true,
|
||||
tags: ["拍摄", "剪辑素材", "活动跟场"],
|
||||
},
|
||||
{
|
||||
id: "community-mod",
|
||||
title: "社群值班主持人",
|
||||
role: "远程兼职",
|
||||
pay: "月度津贴",
|
||||
remote: true,
|
||||
tags: ["聊天室", "Meetup 控场"],
|
||||
},
|
||||
];
|
||||
|
||||
export const MIROTALK_URL =
|
||||
process.env.NEXT_PUBLIC_MIROTALK_URL || "https://mirotalk.nomadro.com";
|
||||
21
src/modules/social/lib/socialPath.ts
Normal file
21
src/modules/social/lib/socialPath.ts
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Portal mounts 游民社区 under `/social`.
|
||||
* Standalone deploy: set SOCIAL_BASE="" (or "/") so paths stay root-relative.
|
||||
*/
|
||||
|
||||
export const SOCIAL_BASE = "/social";
|
||||
|
||||
export function socialPath(path = "/"): string {
|
||||
if (!path || path === "/") return SOCIAL_BASE;
|
||||
if (
|
||||
path.startsWith("http://") ||
|
||||
path.startsWith("https://") ||
|
||||
path.startsWith("mailto:") ||
|
||||
path.startsWith("tel:")
|
||||
) {
|
||||
return path;
|
||||
}
|
||||
if (path === SOCIAL_BASE || path.startsWith(`${SOCIAL_BASE}/`)) return path;
|
||||
if (path.startsWith("/")) return `${SOCIAL_BASE}${path}`;
|
||||
return `${SOCIAL_BASE}/${path}`;
|
||||
}
|
||||
27
src/modules/social/lib/storage.ts
Normal file
27
src/modules/social/lib/storage.ts
Normal file
@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
const PREFIX = "nomadro-social:";
|
||||
|
||||
export function loadJson<T>(key: string, fallback: T): T {
|
||||
if (typeof window === "undefined") return fallback;
|
||||
try {
|
||||
const raw = window.localStorage.getItem(PREFIX + key);
|
||||
if (!raw) return fallback;
|
||||
return JSON.parse(raw) as T;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
export function saveJson<T>(key: string, value: T): void {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
window.localStorage.setItem(PREFIX + key, JSON.stringify(value));
|
||||
} catch {
|
||||
/* quota / private mode */
|
||||
}
|
||||
}
|
||||
|
||||
export function uid(prefix = "id"): string {
|
||||
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
||||
}
|
||||
85
src/modules/social/lib/types.ts
Normal file
85
src/modules/social/lib/types.ts
Normal file
@ -0,0 +1,85 @@
|
||||
export type SocialChannel = {
|
||||
id: string;
|
||||
name: string;
|
||||
topic: string;
|
||||
members: number;
|
||||
};
|
||||
|
||||
export type SocialChatMessage = {
|
||||
id: string;
|
||||
channelId: string;
|
||||
author: string;
|
||||
text: string;
|
||||
at: string;
|
||||
mine?: boolean;
|
||||
};
|
||||
|
||||
export type SocialCafe = {
|
||||
id: string;
|
||||
name: string;
|
||||
city: string;
|
||||
wifiMbps: number;
|
||||
power: string;
|
||||
vibe: string;
|
||||
partners: boolean;
|
||||
rating: number;
|
||||
reviews: number;
|
||||
};
|
||||
|
||||
export type SocialCafeReview = {
|
||||
id: string;
|
||||
cafeId: string;
|
||||
author: string;
|
||||
score: number;
|
||||
text: string;
|
||||
photoNote?: string;
|
||||
at: string;
|
||||
};
|
||||
|
||||
export type SocialMeetup = {
|
||||
id: string;
|
||||
title: string;
|
||||
city: string;
|
||||
date: string;
|
||||
time: string;
|
||||
mode: "online" | "hybrid";
|
||||
mirotalkRoom: string;
|
||||
channelId: string;
|
||||
};
|
||||
|
||||
export type SocialVideo = {
|
||||
id: string;
|
||||
title: string;
|
||||
city: string;
|
||||
minutes: number;
|
||||
coverEmoji: string;
|
||||
summary: string;
|
||||
};
|
||||
|
||||
export type SocialEbook = {
|
||||
id: string;
|
||||
title: string;
|
||||
chapters: number;
|
||||
minutes: number;
|
||||
blurb: string;
|
||||
};
|
||||
|
||||
export type SocialGig = {
|
||||
id: string;
|
||||
title: string;
|
||||
role: string;
|
||||
pay: string;
|
||||
remote: boolean;
|
||||
tags: string[];
|
||||
};
|
||||
|
||||
export type SocialRosterProfile = {
|
||||
name: string;
|
||||
title: string;
|
||||
city: string;
|
||||
phone: string;
|
||||
linktree: string;
|
||||
skills: string;
|
||||
bio: string;
|
||||
updatedAt?: string;
|
||||
};
|
||||
@ -20,6 +20,7 @@
|
||||
"~/*": ["./src/*"],
|
||||
"@ebook/*": ["./src/modules/ebook/*"],
|
||||
"@community/*": ["./src/modules/community/*"],
|
||||
"@social/*": ["./src/modules/social/*"],
|
||||
"@navmini/*": ["./src/modules/nav/*"],
|
||||
"@vip/*": ["./src/modules/vip/*"],
|
||||
"@nomadro/pay": ["./packages/pay/src/index.ts"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user