Files
wzdj/components/streamer-ref-capture.tsx

21 lines
615 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client"
import { useSearchParams } from "next/navigation"
import { useEffect } from "react"
import { setPendingStreamerRef } from "@/lib/streamer-bind"
/**
* 捕获 URL 中的 ref主播 ID 或短码),写入 localStorage供登录后绑定参考 Soul 创业实验)
* 放在根 layout 下,仅客户端执行
*/
export function StreamerRefCapture() {
const searchParams = useSearchParams()
useEffect(() => {
const ref = searchParams.get("ref") ?? searchParams.get("streamerId") ?? ""
if (ref && ref.trim()) setPendingStreamerRef(ref.trim())
}, [searchParams])
return null
}