diff --git a/scripts/check-social-discovery.py b/scripts/check-social-discovery.py new file mode 100644 index 0000000..84d993a --- /dev/null +++ b/scripts/check-social-discovery.py @@ -0,0 +1,120 @@ +"""Focused discovery regression. Run with the portal on localhost:3000. + +Uses mocked discovery data; does not publish profiles or send messages. +""" +import asyncio +import json +import os +from pathlib import Path +from playwright.async_api import async_playwright, expect + +BASE = os.environ.get('SOCIAL_BASE_URL', 'http://localhost:3000') +OUTPUT = Path('artifacts/social-discovery') + + +async def main(): + OUTPUT.mkdir(parents=True, exist_ok=True) + async with async_playwright() as p: + browser = await p.chromium.launch() + context = await browser.new_context(locale='en-US', timezone_id='America/New_York', reduced_motion='reduce') + # The Windows host has Chinese fonts installed. Make font-based audience + # detection deterministic for this international-browser scenario only. + await context.add_init_script(''' + const measure = CanvasRenderingContext2D.prototype.measureText; + CanvasRenderingContext2D.prototype.measureText = function(text) { + if (text === 'mmmmmmmmmmlli中文测试') return { width: 100 }; + return measure.call(this, text); + }; + ''') + await context.route('**/favicon.ico?*', lambda route: route.abort()) + async def mock(route): + if '/roster/discovery' in route.request.url: + await route.fulfill(json={'items': [ + {'guestId': 'test-here', 'name': 'Here Offline', 'city': 'Test City', 'status': 'here', 'online': False, 'tags': ['Testing']}, + {'guestId': 'test-soon', 'name': 'Soon Online', 'city': 'Test City', 'status': 'arriving', 'online': True, 'tags': ['Testing']}, + ]}) + elif '/realtime/' in route.request.url: + await route.fulfill(json={'enabled': False}) + else: + await route.fulfill(json={'items': []}) + await context.route('**/api/social/v1/**', mock) + page = await context.new_page() + errors = [] + page.on('pageerror', lambda error: errors.append(str(error))) + async def go(path): + response = await page.goto(BASE + '/social' + path) + assert response.status == 200 + await expect(page.locator('.people-connection-card').first).to_be_visible() + + await go('/people') + cards = page.locator('.people-connection-card') + await expect(cards.filter(has_text='Here Offline')).to_have_count(1) + card = cards.filter(has_text='Here Offline') + await card.get_by_role('button', name='Follow Here Offline', exact=True).click() + await expect(card.get_by_role('button', name='Unfollow Here Offline')).to_have_attribute('aria-pressed', 'true') + await page.locator('.social-filters button').last.click() + await expect(cards).to_have_count(1) + await page.reload() + await page.locator('.social-filters button').last.click() + await expect(cards).to_have_count(1) + await cards.get_by_role('button', name='Unfollow Here Offline').click() + await expect(cards).to_have_count(0) + await expect(page.get_by_role('button', name='Explore everyone')).to_be_visible() + await page.get_by_role('button', name='Explore everyone').click() + # City and the existing text query can be combined without overwriting one another. + await page.locator('.people-toolbar-top select').select_option('Test City') + await page.get_by_role('searchbox').fill('Offline') + await expect(cards).to_have_count(1) + await page.get_by_role('button', name='Remove Test City').click() + await expect(page.get_by_role('searchbox')).to_have_value('Offline') + await page.get_by_role('button', name='Clear search').click() + await page.get_by_role('button', name='Refine', exact=True).click() + await page.locator('#people-refinements select').last.select_option('here') + await expect(cards).to_have_count(1) + await expect(cards).to_contain_text('Here Offline') + await page.locator('#people-refinements select').last.select_option('soon') + await expect(cards).to_have_count(1) + await expect(cards).to_contain_text('Soon Online') + await page.get_by_role('button', name='Reset filters').click() + await page.get_by_role('button', name='Testing', exact=True).first.click() + await expect(cards).to_have_count(2) + await page.get_by_role('button', name='Remove Testing').click() + await page.locator('.people-results-bar select').select_option('name') + names = await cards.locator('h2').all_text_contents() + assert names.index('Here Offline') < names.index('Soon Online') + layouts = [] + for width in [320, 390, 768, 1440]: + await page.set_viewport_size({'width': width, 'height': 900}) + await page.screenshot(path=str(OUTPUT / f'people-{width}.png'), full_page=True) + overflow = await page.evaluate('document.documentElement.scrollWidth - innerWidth') + assert overflow <= 1, (width, overflow) + layouts.append({'page': 'people', 'width': width, 'overflow': overflow}) + await page.goto(BASE + '/social') + await page.get_by_role('button', name='Coffee & conversation', exact=True).click() + await expect(page.locator('#social-intent-panel > .intent-panel-actions > a').first).to_have_attribute('href', '/social/coffeechat') + await page.locator('.intent-options').get_by_role('button', name='Build together', exact=True).click() + await expect(page.locator('#social-intent-panel > .intent-panel-actions > a').first).to_have_attribute('href', '/social/skills') + for width in [320, 390, 768, 1440]: + await page.set_viewport_size({'width': width, 'height': 900}) + await page.locator('.social-intent-guide').scroll_into_view_if_needed() + await page.screenshot(path=str(OUTPUT / f'home-{width}.png')) + overflow = await page.evaluate('document.documentElement.scrollWidth - innerWidth') + assert overflow <= 1, (width, overflow) + layouts.append({'page': 'home', 'width': width, 'overflow': overflow}) + await context.close() + zh = await browser.new_context(locale='zh-CN', timezone_id='Asia/Shanghai', viewport={'width': 390, 'height': 844}) + await zh.route('**/api/social/v1/**', mock) + page = await zh.new_page() + page.on('pageerror', lambda error: errors.append(str(error))) + await go('/people') + await expect(page.get_by_role('button', name='更多筛选', exact=True)).to_be_visible() + assert '???' not in await page.locator('.people-toolbar').inner_text() + await page.screenshot(path=str(OUTPUT / 'people-zh.png')) + assert not errors, errors + report = {'interactions': 'passed', 'locales': ['en', 'zh'], 'layouts': layouts, 'pageErrors': errors} + (OUTPUT / 'report.json').write_text(json.dumps(report, indent=2), encoding='utf-8') + print(json.dumps(report)) + await browser.close() + + +asyncio.run(main()) diff --git a/scripts/check-social-ui.py b/scripts/check-social-ui.py index 9506dea..39ce0f0 100644 --- a/scripts/check-social-ui.py +++ b/scripts/check-social-ui.py @@ -93,18 +93,18 @@ async def check_interactions(): await go('/people/m01') await page.get_by_role('button', name='关注一下',exact=True).click() await page.get_by_role('link', name='回去看看大家',exact=True).click() - await page.get_by_role('button',name='我关注的',exact=True).click() - await expect(page.locator('.social-discovery-grid > a')).to_have_count(1) - await expect(page.locator('.social-discovery-grid')).to_contain_text('林悦') + await page.locator('.social-filters button').last.click() + await expect(page.locator('.people-connection-card')).to_have_count(1) + await expect(page.locator('.people-card-grid')).to_contain_text('林悦') await check('profile follow appears in discovery filter',follow) async def filters(): await page.get_by_role('button',name='重置筛选',exact=True).click() await page.get_by_role('searchbox').fill('不会匹配的内容') await expect(page.locator('.social-empty')).to_be_visible() - await page.get_by_role('button',name='重新看看',exact=True).click() - await expect(page.locator('.social-discovery-grid > a')).to_have_count(12) - assert await page.locator('.social-discovery-grid .reveal:not(.visible)').count()==0 + await page.get_by_role('button',name='看看全部朋友',exact=True).click() + await expect(page.locator('.people-connection-card')).to_have_count(12) + assert await page.locator('.people-card-grid .reveal:not(.visible)').count()==0 await page.get_by_role('searchbox').fill('清迈') await page.get_by_role('button',name='清空搜索').click() await expect(page.get_by_role('searchbox')).to_be_focused() @@ -191,9 +191,9 @@ async def check_interactions(): await page.get_by_role('button',name='保存介绍',exact=True).click() await expect(page.get_by_role('status').filter(has_text='介绍已保存')).to_have_count(1) await go('/people') - await expect(page.locator('.social-discovery-grid')).to_contain_text('UI smoke profile') + await expect(page.locator('.people-card-grid')).to_contain_text('UI smoke profile') await page.reload() - await expect(page.locator('.social-discovery-grid > a')).to_have_count(13) + await expect(page.locator('.people-connection-card')).to_have_count(13) await go('/date') assert await page.locator('.social-date-card.is-top').inner_text() != 'UI smoke profile' await check('edited profile survives discovery reload without render loop',profile) diff --git a/src/app/social/layout.tsx b/src/app/social/layout.tsx index 1fab395..73946d6 100644 --- a/src/app/social/layout.tsx +++ b/src/app/social/layout.tsx @@ -13,6 +13,7 @@ import "@social/app/depth.css"; import "@social/app/vivid.css"; import "@social/app/h5.css"; import "@social/app/blog.css"; +import "@social/app/discovery.css"; import SocialExperience from "@social/components/SocialExperience"; export const metadata = { diff --git a/src/modules/social/README.md b/src/modules/social/README.md index 2123d9d..5727f11 100644 --- a/src/modules/social/README.md +++ b/src/modules/social/README.md @@ -68,3 +68,12 @@ curl http://127.0.0.1:8080/api/social/v1/health ``` 部署说明见 [`deploy/social/README.md`](../../../deploy/social/README.md)。前端先本地验收,未经允许不上线。 + +## 社区发现体验(2026-11-04) + +- 首页 `HomeActionRail` 按认识朋友、咖啡聊、同城探索、技能共创四种意图展示下一步;不新增搜索。 +- `/social/people` 使用独立城市与现有搜索、动态职业/兴趣/语言选项、可移除条件、排序和卡片直接关注。关注沿用本设备存储,与详情页及滑卡共用。 +- 行程仅依据明确的 `status`:`here` 表示当前在此,`arriving` / `soon` 表示即将到达;不再通过在线状态推测行程。没有该字段的示例不参与行程匹配。 +- 运营文案继续走 `copy.socialPages`:`discovery` 配置首页引导标题;`discovery-people`、`discovery-coffee`、`discovery-city`、`discovery-create` 配置对应说明;`peopleConnections` 配置找人页引导。使用已有 `eyebrow/title/description` 字段;`socialHiddenSections: ["discovery"]` 可隐藏首页引导。缺省使用包内中英文文案。 +- 社区语言首次渲染与服务器保持一致,待受众识别完成后更新,避免英文浏览器水合失败。 +- 验证:启动门户后运行 `python scripts/check-social-discovery.py`;覆盖关注持久化、组合筛选、真实行程语义、首页意图入口、中英文和 320/390/768/1440px 布局。截图与报告位于 `artifacts/social-discovery/`。 diff --git a/src/modules/social/app/discovery.css b/src/modules/social/app/discovery.css new file mode 100644 index 0000000..d7ae86a --- /dev/null +++ b/src/modules/social/app/discovery.css @@ -0,0 +1,87 @@ +/* Intent-led discovery and connection cards. Scoped to the social shell. */ +.social-skin .social-page-head .social-actions { min-width: 0; max-width: 100%; } +.social-skin .social-page-head .social-demo-badge { white-space: normal; overflow-wrap: anywhere; line-height: 1.6; max-width: 100%; } +.social-skin .social-intent-guide { margin-top: 26px; margin-bottom: 40px; } +.social-skin .intent-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; } +.social-skin .people-eyebrow { font-size: 10px; letter-spacing: .14em; font-weight: 700; color: var(--accent-3, #4ecdc4); } +.social-skin .intent-heading h2 { margin: 0; font-size: clamp(19px, 2.4vw, 26px); letter-spacing: -.035em; } +.social-skin .intent-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; } +.social-skin .intent-options button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 10px; border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent); border-radius: 14px; background: var(--bg-glass); color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer; transition: background .2s, border-color .2s; } +.social-skin .intent-options button[aria-pressed="true"] { color: var(--text-primary); border-color: var(--accent-3, #4ecdc4); background: color-mix(in srgb, var(--accent-3, #4ecdc4) 12%, var(--bg-primary)); } +.social-skin .intent-panel { position: relative; display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 24px; padding: 30px; border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 25%, transparent); border-radius: 22px; background: linear-gradient(115deg, color-mix(in srgb, var(--accent-3, #4ecdc4) 8%, transparent), transparent 65%), var(--bg-card); } +.social-skin .intent-art { position: relative; display: grid; place-items: center; width: 100px; height: 100px; border: 1px dashed color-mix(in srgb, var(--accent-3, #4ecdc4) 40%, transparent); border-radius: 50%; color: var(--accent-3, #4ecdc4); } +.social-skin .intent-art span { position: absolute; inset: 12px; border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 20%, transparent); border-radius: 50%; } +.social-skin .intent-art i { position: absolute; width: 9px; height: 9px; right: 7px; top: 13px; border-radius: 50%; background: var(--accent-3, #4ecdc4); box-shadow: 0 0 18px color-mix(in srgb, var(--accent-3, #4ecdc4) 45%, transparent); } +.social-skin .intent-step { margin: 0 0 9px; color: var(--accent-3, #4ecdc4); font-size: 11px; } +.social-skin .intent-panel-copy h3 { margin: 0 0 10px; font-size: clamp(18px, 2vw, 24px); letter-spacing: -.03em; line-height: 1.35; } +.social-skin .intent-panel-copy > p:last-child { margin: 0; max-width: 540px; color: var(--text-secondary); font-size: 13px; line-height: 1.8; } +.social-skin .intent-panel-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; } +.social-skin .intent-panel-actions > a:last-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 12px; min-height: 44px; } +.social-skin .people-discovery-banner { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 20px 0; padding: 28px; border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 25%, transparent); border-radius: 20px; background: linear-gradient(110deg, color-mix(in srgb, var(--accent-3, #4ecdc4) 9%, transparent), transparent), var(--bg-card); } +.social-skin .people-discovery-banner h2 { margin: 8px 0; font-size: clamp(20px, 2.4vw, 28px); line-height: 1.4; letter-spacing: -.035em; } +.social-skin .people-discovery-banner p { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.8; } +.social-skin .people-discovery-banner > a { flex-shrink: 0; } +.social-skin .people-toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding: 20px; border-radius: 18px; } +.social-skin .people-toolbar-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 200px) auto; align-items: end; gap: 12px; } +.social-skin .people-toolbar .social-search { width: 100%; min-width: 0; min-height: 46px; margin: 0; } +.social-skin .people-select { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--text-secondary); font-size: 11px; } +.social-skin .people-select select { width: 100%; min-width: 0; min-height: 44px; padding: 9px 30px 9px 12px; color: var(--text-primary); border: 1px solid color-mix(in srgb, var(--text-primary) 14%, transparent); border-radius: 10px; background: var(--bg-secondary); font: inherit; font-size: 12px; text-overflow: ellipsis; } +.social-skin .people-refine { min-height: 46px; justify-content: center; } +.social-skin .people-refinements { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent); } +.social-skin .people-refinements[hidden] { display: none; } +.social-skin .people-refinements > p { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--text-secondary); line-height: 1.6; } +.social-skin .people-filter-chips { display: flex; gap: 8px; flex-wrap: wrap; } +.social-skin .people-filter-chips button { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px; color: var(--accent-3, #4ecdc4); background: color-mix(in srgb, var(--accent-3, #4ecdc4) 9%, transparent); border: 1px solid color-mix(in srgb, var(--accent-3, #4ecdc4) 25%, transparent); border-radius: 8px; font: inherit; font-size: 12px; cursor: pointer; } +.social-skin .people-results-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px 0; } +.social-skin .people-results-bar .social-result-summary { margin: 0; flex: 1; } +.social-skin .people-live-notice { color: var(--accent-3, #4ecdc4); font-size: 12px; } +.social-skin .people-live-notice:empty { margin: 0; } +.social-skin .people-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-bottom: 24px; } +.social-skin .people-connection-card { display: flex; flex-direction: column; min-width: 0; padding: 22px; border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent); border-radius: 20px; background: var(--bg-card); transition: transform .2s, border-color .2s; } +@media (hover: hover) { .social-skin .people-connection-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent-3, #4ecdc4) 50%, transparent); } } +.social-skin .people-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; } +.social-skin .people-card-heading img { border-radius: 18px; object-fit: cover; flex-shrink: 0; } +.social-skin .people-presence { font-size: 10px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; } +.social-skin .people-presence.is-online { color: var(--accent-3, #4ecdc4); } +.social-skin .people-presence.is-online::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; } +.social-skin .people-profile-link { color: inherit; text-decoration: none; } +.social-skin .people-profile-link h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 21px; margin: 0 0 6px; overflow-wrap: anywhere; } +.social-skin .people-profile-link h2 svg { color: var(--text-secondary); flex-shrink: 0; } +.social-skin .people-card-role { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; } +.social-skin .people-card-city { display: flex; align-items: center; gap: 5px; margin: 0 0 16px; font-size: 11px; color: var(--text-secondary); } +.social-skin .people-card-tags { display: flex; flex-wrap: wrap; gap: 6px; } +.social-skin .people-card-tags button { min-height: 36px; max-width: 100%; padding: 6px 9px; border-radius: 8px; border: 1px solid transparent; background: var(--bg-glass); color: var(--text-secondary); font: inherit; font-size: 11px; cursor: pointer; overflow-wrap: anywhere; } +.social-skin .people-card-tags button[aria-pressed="true"] { border-color: var(--accent-3, #4ecdc4); color: var(--accent-3, #4ecdc4); } +.social-skin .people-card-looking { flex: 1; margin: 16px 0 20px; font-size: 13px; line-height: 1.8; color: var(--text-primary); overflow-wrap: anywhere; } +.social-skin .people-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent); padding-top: 14px; } +.social-skin .people-card-footer > a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--text-secondary); font-size: 11px; } +.social-skin .people-follow { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--text-primary) 16%, transparent); background: transparent; color: var(--text-primary); font: inherit; font-size: 12px; border-radius: 10px; cursor: pointer; } +.social-skin .people-follow.is-following { color: var(--accent-1, #ff6b6b); border-color: color-mix(in srgb, var(--accent-1, #ff6b6b) 40%, transparent); background: color-mix(in srgb, var(--accent-1, #ff6b6b) 8%, transparent); } +.social-skin :is(.intent-options, .intent-panel-actions, .people-toolbar, .people-card-grid, .people-results-bar) :is(a, button, select, input):focus-visible { outline: 2px solid var(--accent-3, #4ecdc4); outline-offset: 4px; } +@media (max-width: 1050px) { + .social-skin .people-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .social-skin .intent-panel { grid-template-columns: 80px minmax(0, 1fr); gap: 20px; } + .social-skin .intent-art { width: 76px; height: 76px; } + .social-skin .intent-panel-actions { grid-column: 2; flex-direction: row; justify-content: flex-start; flex-wrap: wrap; } +} +@media (max-width: 600px) { + .social-skin .intent-heading { display: block; } + .social-skin .intent-heading h2 { margin-top: 9px; } + .social-skin .intent-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .social-skin .intent-options button { min-height: 48px; font-size: 12px; } + .social-skin .intent-panel { grid-template-columns: 1fr; padding: 22px; gap: 14px; } + .social-skin .intent-art { display: none; } + .social-skin .intent-panel-actions { grid-column: 1; align-items: flex-start; gap: 8px 16px; } + .social-skin .people-discovery-banner { align-items: flex-start; flex-direction: column; padding: 22px; gap: 16px; } + .social-skin .people-toolbar { padding: 16px; } + .social-skin .people-toolbar-top { grid-template-columns: minmax(0, 1fr) auto; } + .social-skin .people-toolbar-top .social-search { grid-column: 1 / -1; } + .social-skin .people-refinements { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .social-skin .people-card-grid { grid-template-columns: 1fr; gap: 12px; } + .social-skin .people-connection-card { padding: 20px; } + .social-skin .people-filter-chips button, .social-skin .people-card-tags button { min-height: 44px; } + .social-skin .people-results-bar { flex-wrap: wrap; } +} +@media (prefers-reduced-motion: reduce) { + .social-skin :is(.people-connection-card, .intent-options button) { transition: none; transform: none; } +} diff --git a/src/modules/social/components/HomeActionRail.tsx b/src/modules/social/components/HomeActionRail.tsx index 25e4aa1..7a22d52 100644 --- a/src/modules/social/components/HomeActionRail.tsx +++ b/src/modules/social/components/HomeActionRail.tsx @@ -1,104 +1,52 @@ "use client"; +import { useState } from "react"; import Link from "next/link"; -import { - ArrowLeftRight, - Coffee, - Heart, - Map, - Users, -} from "lucide-react"; +import { ArrowUpRight, Coffee, Compass, Heart, Users } from "lucide-react"; import { socialPath } from "@social/lib/socialPath"; -import { socialTx } from "@social/lib/socialTx"; -import { useHomeLivenessGate } from "./HomeStatusStrip"; - -type Action = { - id: string; - href: string; - gated?: boolean; - icon: typeof Users; - title: string; - sub: string; - className: string; -}; +import { useSocialI18n } from "@social/lib/useSocialI18n"; +import { useSocialConfig } from "./SocialExperience"; export default function HomeActionRail() { - const { liveOk, verifyHref } = useHomeLivenessGate(); - - const actions: Action[] = [ - { - id: "people", - href: "#people", - icon: Users, - title: socialTx("想见的人"), - sub: socialTx("先逛逛同频"), - className: "mint", - }, - { - id: "date", - href: socialPath("/date"), - gated: true, - icon: Heart, - title: socialTx("左右滑"), - sub: socialTx("一张一张认识"), - className: "coral", - }, - { - id: "coffee", - href: socialPath("/coffeechat"), - gated: true, - icon: Coffee, - title: socialTx("咖啡聊"), - sub: socialTx("约一杯见面"), - className: "amber", - }, - { - id: "skills", - href: socialPath("/skills"), - icon: ArrowLeftRight, - title: socialTx("技能板"), - sub: socialTx("互换互助"), - className: "mint", - }, - { - id: "map", - href: socialPath("/map"), - gated: true, - icon: Map, - title: socialTx("地图"), - sub: socialTx("同城足迹"), - className: "yellow", - }, + const { tx } = useSocialI18n(); + const config = useSocialConfig(); + const [intent, setIntent] = useState("people"); + const copy = config.copy.socialPages?.discovery; + if (config.copy.socialHiddenSections?.includes("discovery")) return null; + const journeys = [ + { id: "people", icon: Users, label: tx("认识朋友", "Meet people"), + title: tx("先找到同频,再聊得投机。", "Find your people. Let conversation follow."), + description: tx("从兴趣、城市和一段自我介绍开始,慢慢认识值得连接的人。", "Start with shared interests, a city, and a little introduction. Connect at your own pace."), + href: "/people", cta: tx("看看大家", "Meet the community"), secondary: "/date", secondaryLabel: tx("一张一张认识", "Discover one at a time"), step: tx("发现 → 关注 → 了解彼此", "Discover → Follow → Get to know each other") }, + { id: "coffee", icon: Coffee, label: tx("约杯咖啡", "Coffee & conversation"), + title: tx("留一点时间,认真聊一聊。", "Make time for a real conversation."), + description: tx("浏览咖啡聊主理人的介绍与可预约时间,找到适合自己的话题。", "Explore hosts and available times. Find a conversation that feels right for you."), + href: "/coffeechat", cta: tx("探索咖啡聊", "Explore coffee chats"), secondary: "/meetup", secondaryLabel: tx("先参加群聊", "Explore group meetups"), step: tx("选话题 → 看时间 → 预约见面", "Find a topic → Pick a time → Book a chat") }, + { id: "city", icon: Compass, label: tx("探索同城", "Explore a city"), + title: tx("陌生的城市,也有熟悉的同频。", "A new city. A familiar sense of connection."), + description: tx("挑一座城市,了解当地生活,再找适合工作、见面的咖啡馆。", "Choose a city, discover local life, and find a cafe for work or a friendly hello."), + href: "/places", cta: tx("逛逛城市", "Explore cities"), secondary: "/places?tab=cafes", secondaryLabel: tx("找一家咖啡馆", "Find a cafe"), step: tx("选城市 → 看地点 → 安排见面", "Choose a city → Find a place → Make a plan") }, + { id: "create", icon: Heart, label: tx("一起创造", "Build together"), + title: tx("把共同兴趣,变成一起做的事。", "Turn shared interests into something real."), + description: tx("从技能互助到远程协作,找到可以一起行动的人和机会。", "From skill exchanges to remote collaboration, discover people and opportunities to build with."), + href: "/skills", cta: tx("探索技能互助", "Explore skill exchanges"), secondary: "/team", secondaryLabel: tx("看看共创机会", "Find collaborators"), step: tx("发现技能 → 交流想法 → 一起行动", "Discover skills → Exchange ideas → Build together") }, ]; - + const selected = journeys.find(journey => journey.id === intent) || journeys[0]; + const selectedCopy = config.copy.socialPages?.[`discovery-${selected.id}`]; + const Icon = selected.icon; return ( - +
+
{copy?.eyebrow || tx("你的社区,你的节奏", "YOUR COMMUNITY. YOUR PACE.")} +

{copy?.title || tx("今天,想从哪里开始?", "Where would you like to start?")}

+
+
+ {journeys.map(journey => { const Mark = journey.icon; return ; })} +
+
+ +

{selectedCopy?.eyebrow || selected.step}

{selectedCopy?.title || selected.title}

{selectedCopy?.description || selected.description}

+
{selected.cta}{selected.secondaryLabel}
+
+
); } diff --git a/src/modules/social/components/PeopleClient.tsx b/src/modules/social/components/PeopleClient.tsx index b1e6616..70b7db7 100644 --- a/src/modules/social/components/PeopleClient.tsx +++ b/src/modules/social/components/PeopleClient.tsx @@ -3,278 +3,151 @@ import { useMemo, useState } from "react"; import Link from "next/link"; import { useSearchParams } from "next/navigation"; -import { Sparkles } from "lucide-react"; +import { ArrowUpRight, Heart, MapPin, SlidersHorizontal, Sparkles, X } from "lucide-react"; import SiteShell from "./SiteShell"; import SocialAvatar from "./SocialAvatar"; -import { - DemoBadge, - EmptyState, - PageIntro, - SearchField, - ResultSummary, -} from "./SocialUI"; +import { DemoBadge, EmptyState, PageIntro, SearchField, ResultSummary } from "./SocialUI"; import { SELF_MEMBER_ID, useDiscoveryRoster } from "@social/lib/discoveryRoster"; -import { SOCIAL_CITIES } from "@social/lib/cities"; import { socialPath } from "@social/lib/socialPath"; -import { useRosterLikes } from "@social/lib/useRosterLikes"; -import { socialTx } from "@social/lib/socialTx"; - -const PROFESSION_HINTS = ["设计", "开发", "内容", "产品", "摄影", "全栈"]; -const INTEREST_HINTS = ["咖啡局", "冲浪", "瑜伽", "夜跑", "出海", "开源"]; -const LANG_HINTS = ["中文", "English", "日本語", "Português"]; +import { setRosterLike, useRosterLikes } from "@social/lib/useRosterLikes"; +import { useSocialI18n } from "@social/lib/useSocialI18n"; +import { useSocialConfig } from "./SocialExperience"; export default function PeopleClient() { const params = useSearchParams(); - const initialQuery = params.get("city") || ""; - const initialHere = params.get("here") === "1"; - const initialSoon = params.get("soon") === "1"; - return ( - - ); + return ; } -function PeopleDirectory({ - initialQuery, - initialHere, - initialSoon, -}: { - initialQuery: string; - initialHere: boolean; - initialSoon: boolean; +function PeopleDirectory({ initialCity, initialFilter, initialPresence }: { + initialCity: string; initialFilter: string; initialPresence: string; }) { const roster = useDiscoveryRoster(); - const [query, setQuery] = useState(initialQuery); - const [filter, setFilter] = useState("all"); + const { tx } = useSocialI18n(); + const copy = useSocialConfig().copy.socialPages?.peopleConnections; + const likes = useRosterLikes(); + const [query, setQuery] = useState(""); + const [city, setCity] = useState(initialCity); + const [filter, setFilter] = useState(initialFilter); const [profession, setProfession] = useState(""); const [interest, setInterest] = useState(""); const [language, setLanguage] = useState(""); - const [currentlyHere, setCurrentlyHere] = useState(initialHere); - const [arrivingSoon, setArrivingSoon] = useState(initialSoon); - const likes = useRosterLikes(); - - const list = useMemo( - () => - roster.filter((person) => { - const haystack = - `${person.name} ${person.city} ${person.title} ${person.tags.join(" ")} ${person.lookingFor} ${(person.languages || []).join(" ")}`.toLowerCase(); - const q = query.toLowerCase().trim(); - if (q && !haystack.includes(q)) return false; - if (filter === "saved" && !likes[person.id]) return false; - if (filter === "online" && !person.online) return false; - if (profession && !person.title.toLowerCase().includes(profession.toLowerCase())) - return false; - if ( - interest && - !`${person.tags.join(" ")} ${person.lookingFor}`.toLowerCase().includes(interest.toLowerCase()) - ) - return false; - if ( - language && - !(person.languages || []).some((l) => - l.toLowerCase().includes(language.toLowerCase()), - ) - ) - return false; - // Seed roster has no live trip status — treat online as "here" proxy for demo - if (currentlyHere && !person.online) return false; - if (arrivingSoon && person.online) return false; - return true; - }), - [ - query, - filter, - likes, - roster, - profession, - interest, - language, - currentlyHere, - arrivingSoon, - ], - ); - - const reset = () => { - setQuery(""); - setFilter("all"); - setProfession(""); - setInterest(""); - setLanguage(""); - setCurrentlyHere(false); - setArrivingSoon(false); - }; - - const filtered = - Boolean(query) || - filter !== "all" || - profession || - interest || - language || - currentlyHere || - arrivingSoon; - + const [presence, setPresence] = useState(initialPresence); + const [sort, setSort] = useState("recommended"); + const [expanded, setExpanded] = useState(false); + const [notice, setNotice] = useState(""); + const options = useMemo(() => ({ + cities: [...new Set(roster.map(p => p.city.split("·")[0].trim()))].sort(), + professions: [...new Set(roster.map(p => p.title).filter(Boolean))].sort(), + interests: [...new Set(roster.flatMap(p => p.tags))].sort(), + languages: [...new Set(roster.flatMap(p => p.languages || []))].sort(), + }), [roster]); + const list = useMemo(() => { + const result = roster.filter(person => { + const haystack = `${person.name} ${person.city} ${person.title} ${person.tags.join(" ")} ${person.lookingFor} ${(person.languages || []).join(" ")}`.toLowerCase(); + if (query.trim() && !haystack.includes(query.trim().toLowerCase())) return false; + if (city && person.city.split("·")[0].trim() !== city) return false; + if (filter === "saved" && !likes[person.id]) return false; + if (filter === "online" && !person.online) return false; + if (profession && person.title !== profession) return false; + if (interest && !person.tags.includes(interest)) return false; + if (language && !(person.languages || []).includes(language)) return false; + // Presence is explicit profile data; online is never a proxy for location or travel. + if (presence === "here" && person.status !== "here") return false; + if (presence === "soon" && !["arriving", "soon"].includes(person.status || "")) return false; + return true; + }); + if (sort === "name") result.sort((a, b) => a.name.localeCompare(b.name)); + if (sort === "online") result.sort((a, b) => Number(b.online) - Number(a.online)); + return result; + }, [roster, query, city, filter, profession, interest, language, presence, likes, sort]); + const reset = () => { setQuery(""); setCity(""); setFilter("all"); setProfession(""); setInterest(""); setLanguage(""); setPresence("all"); setSort("recommended"); }; + const chips = [ + { value: city, clear: () => setCity("") }, + { value: profession, clear: () => setProfession("") }, + { value: interest, clear: () => setInterest("") }, + { value: language, clear: () => setLanguage("") }, + { value: presence === "here" ? tx("当前在此", "Currently here") : presence === "soon" ? tx("即将到达", "Arriving soon") : "", clear: () => setPresence("all") }, + ].filter(chip => chip.value); + const filtered = Boolean(query || chips.length || filter !== "all"); return ( - - + +
- {list.length} 位 · 示例介绍,方便先逛逛 - - 地图 - + {tx("包含示例介绍 · 关注保存在此设备", "Includes sample profiles · follows stay on this device")} + {tx("地图", "Map")}
-
- -
+
+
{copy?.eyebrow || tx("从一句你好开始", "A HELLO GOES A LONG WAY")} +

{copy?.title || tx("下一位同频朋友,也许就在这里。", "Your next connection could be right here.")}

+

{copy?.description || tx("先关注感兴趣的人,再看介绍、找话题,按自己的节奏认识。", "Save someone interesting, explore their story, and connect at your own pace.")}

+ {tx("写我的介绍", "Create my profile")} +
+
+
+ + + +
+
+ {[{ id: "all", title: tx("全部", "Everyone") }, { id: "online", title: tx("在线状态", "Online status") }, { id: "saved", title: tx("我关注的", "Following") }].map(f => ( + ))} +
+ -
- - - - - - + { label: tx("职业", "Profession"), value: profession, set: setProfession, options: options.professions }, + { label: tx("兴趣", "Interest"), value: interest, set: setInterest, options: options.interests }, + { label: tx("语言", "Language"), value: language, set: setLanguage, options: options.languages }, + ].map(field => )} + +

{tx("行程仅按本人填写的信息筛选;在线不代表正在当地。", "Travel filters use declared profile status. Online does not mean currently in a city.")}

+ {chips.length > 0 &&
{chips.map(chip => )}
}
- -
- {list.map((person, index) => ( - - - - {person.online ? : null} - - - {person.name} - {person.id === SELF_MEMBER_ID ? " · 我" : ""} - - - {person.title} - {person.vibe ? ` · ${person.vibe.split("·")[0].trim()}` : ""} - - - {person.city.split("·")[0].trim()} - {person.tags[0] ? ` · ${person.tags[0]}` : ""} - - - {person.lookingFor} - +
+
+

{notice}

+
+ {list.map(person =>
+
+ {person.online ? tx("在线状态", "Online status") : tx("探索同频", "Open to connection")} +
+ +

{person.name}{person.id === SELF_MEMBER_ID ? tx(" · 我", " · You") : ""}

+

{tx(person.title)}

+

{tx(person.city)}

- ))} - {!list.length && ( - - - - )} -
-
- - - 写我的介绍 - +
{person.tags.slice(0, 3).map(tag => )}
+

{tx(person.lookingFor)}

+
{tx("看看介绍", "View profile")} + {person.id !== SELF_MEMBER_ID && }
+ )}
+ {!list.length && + + } ); } diff --git a/src/modules/social/lib/discoveryRoster.ts b/src/modules/social/lib/discoveryRoster.ts index 818cc2b..52af79f 100644 --- a/src/modules/social/lib/discoveryRoster.ts +++ b/src/modules/social/lib/discoveryRoster.ts @@ -84,6 +84,7 @@ export function profileToMember( bio: profile.bio.trim() || "刚写好介绍,想认识同频的人。", vibe: status === "here" ? "同城想出来" : online ? "在线" : "刚出现", online, + status, lookingFor: (profile.lookingFor || "").trim() || (profile.intents || "").replace(/,/g, " · ") || diff --git a/src/modules/social/lib/rankDiscovery.ts b/src/modules/social/lib/rankDiscovery.ts index 8807d01..94376bf 100644 --- a/src/modules/social/lib/rankDiscovery.ts +++ b/src/modules/social/lib/rankDiscovery.ts @@ -89,6 +89,7 @@ export function discoveryItemToMember(item: { bio: item.bio || "", vibe: item.status === "here" ? "同城想出来" : item.online ? "在线" : "刚出现", online: Boolean(item.online), + status: item.status, lookingFor: item.lookingFor || "想认识同频游民", gender: (item.gender as SocialRosterMember["gender"]) || "f", availability: item.availability || "", diff --git a/src/modules/social/lib/rosterMock.ts b/src/modules/social/lib/rosterMock.ts index 40ccafa..91f5231 100644 --- a/src/modules/social/lib/rosterMock.ts +++ b/src/modules/social/lib/rosterMock.ts @@ -10,6 +10,8 @@ export type SocialRosterMember = { bio: string; vibe: string; online: boolean; + /** Explicit declared travel status; independent of online presence. */ + status?: string; lookingFor: string; gender: "f" | "m"; languages?: string[]; diff --git a/src/modules/social/lib/useSocialI18n.ts b/src/modules/social/lib/useSocialI18n.ts index 88b27aa..9fdf760 100644 --- a/src/modules/social/lib/useSocialI18n.ts +++ b/src/modules/social/lib/useSocialI18n.ts @@ -26,7 +26,9 @@ export function useSocialI18n(): { setLocale: (locale: SocialLocale) => void; } { const { locale: portalLocale, setLocale: setPortalLocale, ready } = useLocale(); - const locale = toSocialLocale(portalLocale); + // Match the portal's server fallback until audience detection is ready. + // Browser language/font signals can differ from the server on first render. + const locale: SocialLocale = ready ? toSocialLocale(portalLocale) : "zh"; const dict = useMemo(() => getSocialDictionary(locale), [locale]); // Keep module-level translator in sync for nested non-hook call sites.