import { useCallback, useEffect, useState } from 'react' import { api } from '../api' type JoinCfg = { ok?: boolean flags: { joinGroupWechat: boolean joinGroupDouyin: boolean socialFollowAuto: boolean } copy: { joinGroupDouyinHint: string joinGroupDouyinQr: string wechatOaName: string } updatedAt?: string } /** * 加群引导 — 挂在抖音控制台内。 * 微信开 → 弹公众号;抖音开 → 弹抖音群。「稍后再说」= 关弹窗。 */ export default function JoinGroupAdmin() { const [cfg, setCfg] = useState(null) const [err, setErr] = useState('') const [msg, setMsg] = useState('') const [busy, setBusy] = useState(false) const load = useCallback(async () => { setErr('') try { const data = await api('/api/admin/join-group') setCfg(data) } catch (e) { setErr(e instanceof Error ? e.message : String(e)) } }, []) useEffect(() => { void load() }, [load]) async function save() { if (!cfg) return setBusy(true) setMsg('') setErr('') try { const data = await api('/api/admin/join-group', { method: 'PUT', body: JSON.stringify({ flags: cfg.flags, copy: cfg.copy, }), }) setCfg(data) setMsg(`已保存 · ${data.updatedAt || 'OK'}`) } catch (e) { setErr(e instanceof Error ? e.message : String(e)) } finally { setBusy(false) } } if (!cfg && !err) return
加载加群引导…
return (
Join Group

加群引导

用户点「加群」时按开关出弹窗。用户端没有开关,只改内容。「稍后再说」= 关闭。

{err ?

{err}

: null} {msg ?

{msg}

: null} {cfg ? ( <>

渠道开关

💬
微信公众号 {cfg.flags.joinGroupWechat ? '开' : '关'} 开 → 加群弹窗引导关注公众号
🎵
抖音群 {cfg.flags.joinGroupDouyin ? '开' : '关'} 开 → 加群弹窗引导进抖音群
⏱
自动弹出 {cfg.flags.socialFollowAuto ? '开' : '关'} 门户首页延迟自动弹(默认关)

文案 / 素材

保存后真机联网即时生效(无需发版)
) : null}
) }