/** * 社区首页收敛:仅顶栏 + Hero;「加群」按 flags.joinGroupAction 弹窗或跳 VIP。 * Hero 视觉:社交星座网(区别于门户首页地球)。对齐 Next `/community`。 */ import { View, Button } from '@tarojs/components' import Taro from '@tarojs/taro' import { useEffect, useMemo, useState } from 'react' import { CommunityNavbar } from '../../components/Chrome' import { H5Box, H5Txt } from '../../components/H5Box' import { WechatOaModal } from '../../components/WechatOaModal' import { TYPEWRITER_LINES, TYPEWRITER_LINES_EN } from '../../data/homeStatic' import { MiniModuleGate } from '@/components/MiniModuleGate' import { useNomadroTheme } from '@/utils/h5Theme' import { usePageShare, markPageShare } from '@/utils/pageShare' import { getSafeAreaMetrics } from '@/utils/safeArea' import { getCachedRemoteConfig, loadRemoteConfig } from '@/services/remoteConfig' import { usePageTrack } from '@/hooks/usePageTrack' import { trackTap } from '@/utils/track' import './index.scss' const isH5 = process.env.TARO_ENV === 'h5' const SOCIAL_MESH_SVG = `` function HomePageInner() { usePageTrack('pages/community/index', '旅居社群') const theme = useNomadroTheme() const [tw, setTw] = useState('') const [joinOpen, setJoinOpen] = useState(false) const safe = useMemo(() => getSafeAreaMetrics(), []) const safeStyle = useMemo( () => ({ ['--safe-status-bar' as string]: `${safe.statusBarHeight}px`, ['--safe-nav-bar' as string]: `${safe.navBarHeight}px`, ['--safe-menu-pad' as string]: `${safe.menuRightPad}px`, ['--safe-header' as string]: `${safe.headerHeight}px`, }), [safe], ) useEffect(() => { void loadRemoteConfig(true) }, []) async function onJoinClick() { // 点击前强制拉最新远程配置(后台 VIP「加群→跳转」实时生效) try { await loadRemoteConfig(true) } catch { /* 用缓存 */ } const action = getCachedRemoteConfig().flags.joinGroupAction if (action === 'vip') { void Taro.navigateTo({ url: '/pages/vip/index' }) return } setJoinOpen(true) } useEffect(() => { let locale: 'zh' | 'en' = 'zh' try { const l = Taro.getStorageSync('nomadro-locale') if (l === 'en' || l === 'zh') locale = l } catch { /* ignore */ } const phrases = locale === 'en' ? TYPEWRITER_LINES_EN : TYPEWRITER_LINES let phraseIdx = 0 let charIdx = 0 let deleting = false let timer: ReturnType const type = () => { const current = phrases[phraseIdx] || '' if (!deleting) { setTw(current.substring(0, charIdx + 1)) charIdx++ if (charIdx === current.length) { deleting = true timer = setTimeout(type, 2500) return } timer = setTimeout(type, 60) } else { setTw(current.substring(0, charIdx - 1)) charIdx-- if (charIdx === 0) { deleting = false phraseIdx = (phraseIdx + 1) % phrases.length } timer = setTimeout(type, 30) } } timer = setTimeout(type, 400) return () => clearTimeout(timer) }, []) return ( 在任意城市 过你想要的生活 ✨ {tw} | {isH5 ? ( ) : ( ✈️ 💻 🏠 ☕ 🌏 🤝 👋 )} 💬 3 条新消息 🟢 128 人在线 🤝 同城聚会 setJoinOpen(false)} /> ) } function HomePage() { usePageShare({ title: 'nomadro · 旅居社群', path: '/pages/community/index' }) return ( ) } export default markPageShare(HomePage)