"use client"; import React, { useEffect, useState, useCallback } from "react"; import { Image, Avatar, Divider, Dialog, Toast } from "antd-mobile"; import { redirect, useRouter, useSearchParams } from "next/navigation"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft, faAngleRight, faCalendar, } from "@fortawesome/free-solid-svg-icons"; import { getSpaceData } from "@/api/space"; import requireAPI from "@/utils/requireAPI"; export default function Setting() { const router = useRouter(); const searchParams = useSearchParams(); const [streamerInfo, setStreamerInfo] = useState(null); useEffect(() => { (async () => { const currentData = searchParams.get("data"); if (currentData) { let data = await JSON.parse( decodeURIComponent(searchParams.get("data")) ); // console.log("data",data) await getSpaceData(Number(data.mid)).then((res) => { setStreamerInfo({ ...data, refund_enable: res?.refund_enable }); }); } })(); }, []); const handleShowDialog = () => { const result = Dialog.show({ title: "是否确认退出空间?", content: "一旦退出,您的空间成员身份将会被取消,若当前空间为付费空间,下次加入时,需要再次付费。请确保知晓以上内容后谨慎选择退出。", bodyStyle: { maxHeight: "none", width: "80vw", position: "fixed", top: "200px", left: "10vw", "--text-color": "#fff", color: "#fff", }, // cancelText:"确认", // confirmText:"取消", style: { "--text-color": "#fff", }, closeOnAction: true, actions: [ [ { key: "submit", text: "确认", style: { color: "#ffffff80" }, onClick: handleExitSpace, }, { key: "close", text: "取消", bold: true, style: { color: "#fff" }, onClick: () => { Dialog?.clear(); }, }, ], ], }); // if (result) { // Toast.show({ content: "点击了确认", position: "bottom" }); // } }; //格式化时间 const formatDate = useCallback((timestamp) => { const date = new Date(timestamp * 1000); const year = date.getFullYear(); const month = date.getMonth() + 1; // 月份从0开始,所以需要加1 const day = date.getDate(); return `${year}/${month}/${day}`; }, []); const handleExitSpace = async () => { try { const _data = await requireAPI("POST", "/api/zone/exit", { body: { zid: streamerInfo?.id, }, }); if (_data.ret === -1) { Toast.show({ icon: "fail", content: _data.msg, position: "top", }); return; } Toast.show({ icon: "success", content: "退出空间成功", position: "top", }); setTimeout(() => router.replace("/"), 500); } catch (error) { // console.error(error); } }; return (
空间设置
{streamerInfo?.name}