Wire Taro social pages to social_svc (Centrifugo + live RTMP), drop multi-channel chat chrome, and add weapp WXSS sanitize/deploy helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
377 lines
13 KiB
TypeScript
377 lines
13 KiB
TypeScript
import { useState, type CSSProperties } from 'react'
|
||
import { Video } from '@tarojs/components'
|
||
import Taro from '@tarojs/taro'
|
||
import { MOCK_ROSTER, SOCIAL_COPY, type SocialLandingCopy } from '@/data/socialSeed'
|
||
import { goPage } from '@/utils/nav'
|
||
import { SocialAvatar } from './SocialAvatar'
|
||
import { FloatingEmojiField } from './SocialExperience'
|
||
import { H5El } from './H5El'
|
||
|
||
const NODES = [
|
||
{ member: 0, x: 22, y: 22, rotate: -8 },
|
||
{ member: 1, x: 79, y: 26, rotate: 7 },
|
||
{ member: 4, x: 85, y: 65, rotate: -6 },
|
||
{ member: 3, x: 18, y: 69, rotate: 6 },
|
||
]
|
||
|
||
const ORBIT_SVG = `<svg class="connection-orbits" viewBox="0 0 560 480" fill="none" aria-hidden="true">
|
||
<defs>
|
||
<radialGradient id="connection-globe"><stop stop-color="#4ecdc4" stop-opacity=".15"/><stop offset="1" stop-color="#4ecdc4" stop-opacity="0"/></radialGradient>
|
||
<linearGradient id="connection-line" x1="100" y1="100" x2="450" y2="400" gradientUnits="userSpaceOnUse">
|
||
<stop stop-color="#4ecdc4"/><stop offset=".5" stop-color="#ffe66d"/><stop offset="1" stop-color="#ff6b6b"/>
|
||
</linearGradient>
|
||
</defs>
|
||
<circle cx="280" cy="240" r="185" fill="url(#connection-globe)"/>
|
||
<g class="connection-globe-lines" stroke="currentColor" stroke-width=".7">
|
||
<circle cx="280" cy="240" r="121"/><ellipse cx="280" cy="240" rx="121" ry="45"/><ellipse cx="280" cy="240" rx="121" ry="88"/>
|
||
<ellipse cx="280" cy="240" rx="45" ry="121"/><ellipse cx="280" cy="240" rx="88" ry="121"/><path d="M159 240h242M280 119v242"/>
|
||
</g>
|
||
<g stroke="url(#connection-line)" stroke-width="1">
|
||
<ellipse cx="280" cy="240" rx="221" ry="148" transform="rotate(-28 280 240)" opacity=".35"/>
|
||
<ellipse cx="280" cy="240" rx="230" ry="186" transform="rotate(24 280 240)" stroke-dasharray="3 9" opacity=".3"/>
|
||
<circle cx="280" cy="240" r="170" opacity=".12"/>
|
||
</g>
|
||
<g class="connection-orbit-traveler"><circle cx="280" cy="70" r="4" fill="#4ecdc4"/><circle cx="280" cy="70" r="9" stroke="#4ecdc4" stroke-opacity=".25"/></g>
|
||
<g class="connection-orbit-traveler connection-orbit-traveler-second"><circle cx="280" cy="410" r="3" fill="#ff6b6b"/></g>
|
||
<path class="connection-flight-path" d="M126 106Q280 40 442 125M100 330Q270 440 470 310" stroke="url(#connection-line)" stroke-width="1.5" stroke-dasharray="5 8" opacity=".55"/>
|
||
</svg>`
|
||
|
||
const isH5 = process.env.TARO_ENV === 'h5'
|
||
|
||
export function ConnectionHero({
|
||
onJoin,
|
||
promoUrl,
|
||
copy = SOCIAL_COPY,
|
||
}: {
|
||
onJoin: () => void
|
||
promoUrl: string
|
||
copy?: SocialLandingCopy
|
||
}) {
|
||
const [videoOpen, setVideoOpen] = useState(false)
|
||
|
||
return (
|
||
<H5El as='section' className='connection-hero' id='hero' aria-labelledby='connection-title'>
|
||
<H5El className='connection-hero-grid' aria-hidden />
|
||
<FloatingEmojiField />
|
||
<H5El className='container connection-hero-layout'>
|
||
<H5El className='connection-copy'>
|
||
<H5El className='connection-eyebrow'>
|
||
<H5El as='span' className='connection-status-dot' /> 游民社区{' '}
|
||
<H5El as='span' className='connection-eyebrow-divider' /> {copy.socialEyebrow}
|
||
</H5El>
|
||
<H5El as='h1' id='connection-title'>
|
||
<H5El as='span' className='connection-title-line'>
|
||
{copy.socialHeroLine1}
|
||
</H5El>
|
||
<H5El as='span' className='connection-title-line'>
|
||
还好
|
||
<H5El as='span' className='connection-title-accent'>
|
||
{copy.socialHeroAccent}
|
||
</H5El>
|
||
不远
|
||
<H5El as='span' className='connection-title-period'>
|
||
。
|
||
</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
<H5El as='p' className='connection-description'>
|
||
{copy.socialHeroLead}
|
||
</H5El>
|
||
<H5El className='connection-actions'>
|
||
<H5El
|
||
as='button'
|
||
className='btn connection-join'
|
||
onClick={onJoin}
|
||
trackLabel='social_join'
|
||
>
|
||
{copy.socialJoinCta} <H5El as='span'>↗</H5El>
|
||
</H5El>
|
||
<H5El
|
||
as='a'
|
||
className='connection-film'
|
||
href='#chat'
|
||
onClick={() => goPage('/pages/social/chat/index')}
|
||
trackLabel='social_film_chat'
|
||
>
|
||
<H5El as='span'>💬</H5El>
|
||
群组聊天
|
||
</H5El>
|
||
<H5El
|
||
as='a'
|
||
className='connection-film'
|
||
href='#date'
|
||
onClick={() => goPage('/pages/social/date/index')}
|
||
trackLabel='social_film_date'
|
||
>
|
||
<H5El as='span'>💕</H5El>
|
||
认识一下
|
||
</H5El>
|
||
<H5El
|
||
as='button'
|
||
className='connection-film connection-film-story'
|
||
onClick={() => setVideoOpen(true)}
|
||
trackLabel='social_film_story'
|
||
>
|
||
<H5El as='span'>▶</H5El>
|
||
社区故事
|
||
</H5El>
|
||
</H5El>
|
||
<H5El className='connection-proof'>
|
||
<H5El className='connection-avatar-stack' aria-hidden>
|
||
{MOCK_ROSTER.slice(0, 5).map((m) => (
|
||
<SocialAvatar key={m.id} src={m.avatar} size={36} />
|
||
))}
|
||
</H5El>
|
||
<H5El>
|
||
<H5El as='strong'>同频的人,正在这里相遇</H5El>
|
||
<H5El as='span'>自由职业 · 远程工作 · 出来见一面</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
|
||
<H5El className='connection-universe'>
|
||
<H5El className='connection-universe-label'>
|
||
<H5El as='span'>🌐</H5El>
|
||
<H5El as='span'>不止在线,更在身边</H5El>
|
||
<H5El as='span' className='connection-signal' aria-hidden>
|
||
<H5El as='i' />
|
||
<H5El as='i' />
|
||
<H5El as='i' />
|
||
<H5El as='i' />
|
||
</H5El>
|
||
</H5El>
|
||
<H5El className='connection-orbit-scene'>
|
||
{isH5 ? (
|
||
<H5El
|
||
className='connection-orbits-host'
|
||
// eslint-disable-next-line react/no-danger
|
||
dangerouslySetInnerHTML={{ __html: ORBIT_SVG }}
|
||
/>
|
||
) : null}
|
||
<H5El className='connection-center'>
|
||
<H5El className='connection-center-icon'>
|
||
<H5El as='span'>✨</H5El>
|
||
</H5El>
|
||
<H5El as='strong'>同频,自有引力</H5El>
|
||
<H5El as='span'>想见的人</H5El>
|
||
</H5El>
|
||
{NODES.map(({ member, x, y, rotate }, i) => {
|
||
const m = MOCK_ROSTER[member]!
|
||
const style = {
|
||
['--node-x' as string]: `${x}%`,
|
||
['--node-y' as string]: `${y}%`,
|
||
['--node-rotate' as string]: `${rotate}deg`,
|
||
['--node-delay' as string]: `${i * -1.4}s`,
|
||
} as CSSProperties
|
||
return (
|
||
<H5El
|
||
as='a'
|
||
key={m.id}
|
||
href='#people'
|
||
className={`connection-person connection-person-${i}`}
|
||
style={style}
|
||
onClick={() => goPage('/pages/social/people/index')}
|
||
aria-label={`认识${m.name},${m.title}`}
|
||
>
|
||
<H5El as='span' className='connection-person-avatar'>
|
||
<SocialAvatar src={m.avatar} size={44} />
|
||
<H5El as='i' />
|
||
</H5El>
|
||
<H5El as='span'>
|
||
<H5El as='strong'>
|
||
{m.name}
|
||
<H5El as='span'>↗</H5El>
|
||
</H5El>
|
||
<H5El as='small'>{m.title}</H5El>
|
||
<H5El as='em'>{m.city.split('·')[0]?.trim()}</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
)
|
||
})}
|
||
<H5El as='span' className='connection-coordinate connection-coordinate-one'>
|
||
18.79° N · 清迈
|
||
</H5El>
|
||
<H5El as='span' className='connection-coordinate connection-coordinate-two'>
|
||
25.60° N · 大理
|
||
</H5El>
|
||
<H5El className='connection-wave'>
|
||
<H5El as='span'>☕</H5El>
|
||
<H5El as='span'>下一杯咖啡,和新朋友。</H5El>
|
||
<H5El as='span'>↗</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
<H5El className='connection-universe-footer'>
|
||
<H5El as='span'>
|
||
<H5El as='span' className='connection-status-dot' /> 连接没有边界
|
||
</H5El>
|
||
<H5El as='span'>先用示例看看感觉</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
</H5El>
|
||
|
||
<H5El className='container connection-hero-bottom'>
|
||
<H5El
|
||
as='a'
|
||
href='#people'
|
||
onClick={() => {
|
||
if (process.env.TARO_ENV === 'h5' && typeof document !== 'undefined') {
|
||
document.getElementById('people')?.scrollIntoView({ behavior: 'smooth' })
|
||
} else {
|
||
const query = Taro.createSelectorQuery()
|
||
query.select('#people').boundingClientRect()
|
||
query.selectViewport().scrollOffset()
|
||
query.exec((res) => {
|
||
const rect = res?.[0] as { top?: number } | undefined
|
||
const offset = res?.[1] as { scrollTop?: number } | undefined
|
||
if (!rect || typeof rect.top !== 'number') return
|
||
Taro.pageScrollTo({
|
||
scrollTop: Math.max(0, (offset?.scrollTop || 0) + rect.top - 72),
|
||
duration: 300,
|
||
})
|
||
})
|
||
}
|
||
}}
|
||
>
|
||
↓ 继续往下看
|
||
</H5El>
|
||
<H5El as='span'>认识人 · 开视频 · 见一面</H5El>
|
||
</H5El>
|
||
|
||
{videoOpen ? (
|
||
<H5El
|
||
className='connection-video-dialog is-open'
|
||
role='dialog'
|
||
aria-label='社区故事'
|
||
style={{
|
||
position: 'fixed',
|
||
inset: 0,
|
||
zIndex: 2000,
|
||
display: 'flex',
|
||
alignItems: 'center',
|
||
justifyContent: 'center',
|
||
background: 'rgba(0,0,0,0.72)',
|
||
padding: 16,
|
||
}}
|
||
onClick={() => setVideoOpen(false)}
|
||
>
|
||
<H5El
|
||
className='connection-video-content'
|
||
style={{
|
||
width: 'min(920px, 100%)',
|
||
background: '#0c0c0f',
|
||
borderRadius: 16,
|
||
overflow: 'hidden',
|
||
border: '1px solid rgba(255,255,255,0.1)',
|
||
}}
|
||
onClick={() => undefined}
|
||
>
|
||
<H5El
|
||
as='header'
|
||
style={{
|
||
display: 'flex',
|
||
justifyContent: 'space-between',
|
||
alignItems: 'center',
|
||
padding: '12px 16px',
|
||
}}
|
||
>
|
||
<H5El as='h2'>游民社区 · 社区故事</H5El>
|
||
<H5El as='button' onClick={() => setVideoOpen(false)} aria-label='关闭'>
|
||
✕
|
||
</H5El>
|
||
</H5El>
|
||
<Video
|
||
src={promoUrl}
|
||
controls
|
||
autoplay
|
||
style={{ width: '100%', height: 360, display: 'block' }}
|
||
/>
|
||
</H5El>
|
||
</H5El>
|
||
) : null}
|
||
</H5El>
|
||
)
|
||
}
|
||
|
||
export function ConnectionWays({ copy = SOCIAL_COPY }: { copy?: SocialLandingCopy }) {
|
||
const ways = [
|
||
{
|
||
id: '01',
|
||
path: '/pages/social/chat/index',
|
||
emoji: '💬',
|
||
title: copy.socialWayGroup,
|
||
sub: '大家一起聊 · 先打个招呼',
|
||
cta: '进群聊',
|
||
className: 'mint',
|
||
},
|
||
{
|
||
id: '02',
|
||
path: '/pages/social/date/index',
|
||
emoji: '💕',
|
||
title: copy.socialWayDate,
|
||
sub: '左右滑,慢慢认识',
|
||
cta: '开始看看',
|
||
className: 'coral',
|
||
},
|
||
{
|
||
id: '03',
|
||
path: '/pages/social/meetup/index',
|
||
emoji: '📡',
|
||
title: copy.socialWayChat,
|
||
sub: '聊天群组 · 语音视频',
|
||
cta: '去聊聊',
|
||
className: 'mint',
|
||
},
|
||
{
|
||
id: '04',
|
||
path: '/pages/social/people/index?mode=cafe',
|
||
emoji: '☕',
|
||
title: copy.socialWayCafe,
|
||
sub: copy.socialOfflineTitle,
|
||
cta: '选城市',
|
||
className: 'yellow',
|
||
},
|
||
{
|
||
id: '05',
|
||
path: '/pages/social/team/index',
|
||
emoji: '🚀',
|
||
title: copy.socialWayTeam,
|
||
sub: copy.socialTeamTitle,
|
||
cta: '看看机会',
|
||
className: 'mint',
|
||
},
|
||
]
|
||
|
||
return (
|
||
<H5El className='container connection-ways is-alive' aria-label='选择连接方式'>
|
||
{ways.map((way, index) => (
|
||
<H5El
|
||
as='a'
|
||
key={way.id}
|
||
href={way.path}
|
||
className={`connection-way ${way.className}`}
|
||
style={{ ['--stagger' as string]: `${index * 70}ms` }}
|
||
onClick={() => goPage(way.path)}
|
||
trackLabel={`social_way_${way.id}`}
|
||
>
|
||
<H5El as='span' className='connection-way-index'>
|
||
{way.id}
|
||
</H5El>
|
||
<H5El as='span' className='connection-way-icon'>
|
||
<H5El as='span' style={{ fontSize: 23 }}>
|
||
{way.emoji}
|
||
</H5El>
|
||
</H5El>
|
||
<H5El as='span' className='connection-way-copy'>
|
||
<H5El as='strong'>{way.title}</H5El>
|
||
<H5El as='small'>{way.sub}</H5El>
|
||
<H5El as='em'>{way.cta}</H5El>
|
||
</H5El>
|
||
<H5El as='span' className='connection-way-arrow'>
|
||
↗
|
||
</H5El>
|
||
</H5El>
|
||
))}
|
||
</H5El>
|
||
)
|
||
}
|