( self . webpackChunk_N_E = self . webpackChunk_N_E || []). push ([[ 931 ],{ 754 : function ( e , t , a ){ Promise . resolve (). then ( a . bind ( a , 7603 ))}, 7603 : function ( e , t , a ){ "use strict" ; a . r ( t ), a . d ( t ,{ default : function (){ return ea }}); var r = a ( 7437 ), s = a ( 2265 ); let n = null ; function i ( e ){ n = e , e ? localStorage . setItem ( "forumlify-token" , e ) : localStorage . removeItem ( "forumlify-token" )} async function l ( e ){ let t = arguments . length > 1 && void 0 !== arguments [ 1 ] ? arguments [ 1 ] : {}, a = {... t . headers || {}}; t . body && "string" == typeof t . body && ( a [ "Content-Type" ] = "application/json" ), n && ( a . Authorization = "Bearer " + n ); let r = await fetch ( "/api" + e ,{... t , headers : a }), s = await r . json (). catch (()=>({})); if ( ! r . ok || s . error ){ let e = Error ( s . error || "请求失败" ); throw e . status = r . status , e } return s } n = localStorage . getItem ( "forumlify-token" ) || null ; let o = { async login ( e , t ){ let a = await l ( "/auth/login" ,{ method : "POST" , body : JSON . stringify ({ email : e , password : t })}); return a . token && i ( a . token ), a }, register : ( e , t , a )=> l ( "/auth/register" ,{ method : "POST" , body : JSON . stringify ({ email : e , password : t , username : a })}), logout (){ i ( null )}, getMe : ()=> l ( "/auth/me" ), getPosts ( e , t ){ let a = arguments . length > 2 && void 0 !== arguments [ 2 ] ? arguments [ 2 ] : 1 , r = arguments . length > 3 && void 0 !== arguments [ 3 ] ? arguments [ 3 ] : 20 , s = "/posts?sort=" + ( e || "latest" ) + "&page=" + a + "&limit=" + r ; return t && ( s += "&user_id=" + t ), l ( s )}, getPost : e => l ( "/posts/" + e ), createPost : ( e , t , a )=> l ( "/posts" ,{ method : "POST" , body : JSON . stringify ({ title : e , content : t , images : a || []})}), updatePost : ( e , t , a , r )=> l ( "/posts/" + e ,{ method : "PUT" , body : JSON . stringify ({ title : t , content : a , images : r })}), togglePinPost : e => l ( "/posts/" + e + "/pin" ,{ method : "PUT" }), deletePost : e => l ( "/posts/" + e ,{ method : "DELETE" }), getReplies : e => l ( "/posts/" + e + "/replies" ), createReply : ( e , t )=> l ( "/posts/" + e + "/replies" ,{ method : "POST" , body : JSON . stringify ({ content : t })}), deleteReply : e => l ( "/replies/" + e ,{ method : "DELETE" }), getUsers : ()=> l ( "/users" ), getUsersByUsername : e => l ( "/users?username=" + encodeURIComponent ( e )), updateUserRole : ( e , t )=> l ( "/users/" + e + "/role" ,{ method : "PUT" , body : JSON . stringify ({ role : t })}), updateProfile : ( e , t , a , r )=> l ( "/users/" + e ,{ method : "PUT" , body : JSON . stringify ({ username : t , bio : a , signature : r })}), updateAvatar : ( e , t )=> l ( "/users/" + e + "/avatar" ,{ method : "PUT" , body : JSON . stringify ({ avatar_url : t })}), updatePassword : ( e , t , a )=> l ( "/users/" + e + "/password" ,{ method : "PUT" , body : JSON . stringify ({ oldPassword : t , newPassword : a })}), updateEmail : ( e , t , a )=> l ( "/users/" + e + "/email" ,{ method : "PUT" , body : JSON . stringify ({ password : t , newEmail : a })}), getReports : ()=> l ( "/reports" ), createReport : ( e , t )=> l ( "/reports" ,{ method : "POST" , body : JSON . stringify ({ post_id : e , reason : t })}), updateReport : ( e , t , a )=> l ( "/reports/" + e ,{ method : "PUT" , body : JSON . stringify ({ status : t , note : a })}), getStats : ()=> l ( "/stats" ), getSettings : ()=> l ( "/settings" ), updateSettings : e => l ( "/settings" ,{ method : "PUT" , body : JSON . stringify ({ forum_name : e })}), getLinks : ()=> l ( "/links" ), addLink : ( e , t )=> l ( "/links" ,{ method : "POST" , body : JSON . stringify ({ title : e , url : t })}), deleteLink : e => l ( "/links/" + e ,{ method : "DELETE" }), getEventLogs : ()=> l ( "/event-logs" ), logEvent : e => l ( "/event-logs" ,{ method : "POST" , body : JSON . stringify ({ action : e })}). catch (()=>{}), getConversations : ()=> l ( "/conversations" ), getOrCreateConversation : e => l ( "/conversations" ,{ method : "POST" , body : JSON . stringify ({ other_user_id : e })}), getMessages : e => l ( "/conversations/" + e + "/messages" ), sendMessage : ( e , t )=> l ( "/conversations/" + e + "/messages" ,{ method : "POST" , body : JSON . stringify ({ content : t })}), markMessageRead : e => l ( "/messages/" + e + "/read" ,{ method : "PUT" }), getCustomPages : ()=> l ( "/custom-pages" ), getCustomPage : e => l ( "/custom-pages/" + e ), adminGetCustomPages : ()=> l ( "/admin/custom-pages" ), adminCreateCustomPage : ( e , t , a )=> l ( "/admin/custom-pages" ,{ method : "POST" , body : JSON . stringify ({ name : e , title : t , content : a })}), adminUpdateCustomPage : ( e , t , a , r )=> l ( "/admin/custom-pages/" + e ,{ method : "PUT" , body : JSON . stringify ({ title : t , content : a , enabled : r })}), adminDeleteCustomPage : e => l ( "/admin/custom-pages/" + e ,{ method : "DELETE" }), uploadCustomCss ( e ){ let t = new FormData ; t . append ( "file" , e ); let a = {}; return n && ( a . Authorization = "Bearer " + n ), fetch ( "/api/admin/custom-css" ,{ method : "POST" , body : t , headers : a }). then ( async e =>{ let t = await e . json (). catch (()=>({})); if ( ! e . ok || t . error ) throw Error ( t . error || "上传失败" ); return t })}, deleteCustomCss : ()=> l ( "/admin/custom-css" ,{ method : "DELETE" }), getNotifications : ()=> l ( "/notifications" ), markNotificationRead : e => l ( "/notifications/" + e + "/read" ,{ method : "PUT" }), markAllNotificationsRead : ()=> l ( "/notifications/read-all" ,{ method : "PUT" }), generateRecoveryCodes : ()=> l ( "/auth/recovery-codes/generate" ,{ method : "POST" }), getRecoveryCodeCount : ()=> l ( "/auth/recovery-codes/count" ), resetPassword : ( e , t , a )=> l ( "/auth/reset-password" ,{ method : "POST" , body : JSON . stringify ({ email : e , recoveryCode : t , newPassword : a })})}; async function d ( e ){ let t = new FormData ; t . append ( "file" , e ); let a = {}; n && ( a . Authorization = "Bearer " + n ); let r = await fetch ( "/api/upload" ,{ method : "POST" , body : t , headers : a }), s = await r . json (). catch (()=>({})); if ( ! r . ok || s . error ) throw Error ( s . error || "上传失败" ); return s . url } function c (){ let e = Math . floor ( 9 * Math . random ()) + 1 , t = Math . floor ( 9 * Math . random ()) + 1 , a = [ "+" , "-" ][ Math . floor ( 2 * Math . random ())]; if ( "-" === a && e < t ){ let a = e ; e = t , t = a } return { question : e + " " + a + " " + t + " = ?" , answer : "+" === a ? e + t : e - t }} let u = ( 0 , s . createContext )( null ); function p (){ return ( 0 , s . useContext )( u )} function x ( e ){ let { children : t } = e ,[ a , l ] = ( 0 , s . useState )( null ),[ d , c ] = ( 0 , s . useState )(()=> localStorage . getItem ( "forumlify-forum-name" ) || "Forumlify" ),[ p , x ] = ( 0 , s . useState )( "light" ),[ h , m ] = ( 0 , s . useState )( "feed" ),[ g , y ] = ( 0 , s . useState )( null ),[ f , v ] = ( 0 , s . useState )( null ),[ j , b ] = ( 0 , s . useState )( null ),[ S , k ] = ( 0 , s . useState )( "latest" ),[ C , w ] = ( 0 , s . useState )( 0 ),[ N , z ] = ( 0 , s . useState )( ! 1 ),[ D , R ] = ( 0 , s . useState )( ! 1 ), E = ( 0 , s . useRef )( ! 1 ), P = ( 0 , s . useCallback )(()=> w ( e => e + 1 ),[]);( 0 , s . useEffect )(()=>{ let e = localStorage . getItem ( "forumlify-theme" ) || ( window . matchMedia && window . matchMedia ( "(prefers-color-scheme: dark)" ). matches ? "dark" : "light" ); x ( e ), document . documentElement . setAttribute ( "data-theme" , e ); let t = window . matchMedia && window . matchMedia ( "(prefers-color-scheme: dark)" ); if ( t && t . addEventListener ){ let e = ()=>{ if ( ! localStorage . getItem ( "forumlify-theme" )){ let e = t . matches ? "dark" : "light" ; x ( e ), document . documentElement . setAttribute ( "data-theme" , e )}}; return t . addEventListener ( "change" , e ),()=> t . removeEventListener ( "change" , e )}},[]),( 0 , s . useEffect )(()=>{ document . title = d ; let e = document . querySelector ( "title" ); e && ( e . textContent = d )},[ d ]); let T = ( 0 , s . useCallback )(()=>{ x ( e =>{ let t = "light" === e ? "dark" : "light" ; return document . documentElement . setAttribute ( "data-theme" , t ), localStorage . setItem ( "forumlify-theme" , t ), t })},[]);( 0 , s . useEffect )(()=>{ E . current || ( E . current =! 0 , e ()); async function e (){ if ( n ) try { let e = await o . getMe (); l ( e ), o . logEvent ( "login" ). catch (()=>{})} catch ( e ){ i ( null )} try { let e = await o . getSettings (); e . forum_name && ( c ( e . forum_name ), localStorage . setItem ( "forumlify-forum-name" , e . forum_name )), R ( ! 0 ), setTimeout (()=> z ( ! 0 ), 650 )} catch ( e ){ R ( ! 0 ), z ( ! 0 )}}},[]),( 0 , s . useEffect )(()=>{ if ( ! N ){ let e = [ "Loading." , "Loading.." , "Loading..." ], t = 0 ; document . title = e [ 0 ]; let a = setInterval (()=>{ t = ( t + 1 ) % e . length , document . title = e [ t ]}, 1e3 ); return ()=>{ clearInterval ( a )}} document . title = d ; let e = document . querySelector ( "title" ); e && ( e . textContent = d )},[ N , d ]),( 0 , s . useEffect )(()=>{ let e = new URLSearchParams ( window . location . search ), t = e . get ( "post" ), a = e . get ( "page" ), r = e . get ( "user" ); t ? ( m ( "post" ), y ( t )) : r ? ( m ( "user" ), v ( r )) : a && [ "messages" , "settings" , "admin" , "new" ]. includes ( a ) ? m ( a ) : a && ( m ( "custom" ), b ( a ))},[]); let _ = ( 0 , s . useCallback )( e =>{ let t = new URL ( window . location ); "feed" === e ? t . searchParams . delete ( "page" ) : t . searchParams . set ( "page" , e ), t . searchParams . delete ( "post" ), window . history . pushState ({ page : e }, "" , t ), m ( e ), y ( null ), P ()},[ P ]), B = ( 0 , s . useCallback )( e =>{ let t = new URL ( window . location ); t . searchParams . set ( "post" , e ), t . searchParams . delete ( "page" ), t . searchParams . delete ( "user" ), window . history . pushState ({ page : "post" , postId : e }, "" , t ), m ( "post" ), y ( e )},[]), M = ( 0 , s . useCallback )( e =>{ let t = new URL ( window . location ); t . searchParams . set ( "user" , e ), t . searchParams . delete ( "page" ), t . searchParams . delete ( "post" ), window . history . pushState ({ page : "user" , username : e }, "" , t ), m ( "user" ), v ( e )},[]), L = ( 0 , s . useCallback )( e =>{ let t = new URL ( window . location ); t . searchParams . set ( "page" , e ), t . searchParams . delete ( "post" ), t . searchParams . delete ( "user" ), window . history . pushState ({ page : "custom" , pageName : e }, "" , t ), m ( "custom" ), b ( e )},[]);( 0 , s . useEffect )(()=>{ let e = e =>{ let t = e . state || {}; t . postId ? ( m ( "post" ), y ( t . postId )) : t . username ? ( m ( "user" ), v ( t . username )) : t . pageName ? ( m ( "custom" ), b ( t . pageName )) : ( m ( t . page || "feed" ), y ( null ), v ( null ), b ( null ))}; return window . addEventListener ( "popstate" , e ),()=> window . removeEventListener ( "popstate" , e )},[]); let A = ( 0 , s . useCallback )( async ( e , t )=>{ let a = await o . login ( e , t ); return a . user && ( l ( a . user ), o . logEvent ( "login" ). catch (()=>{})), a },[]), I = ( 0 , s . useCallback )( async ( e , t , a )=>{ let r = await o . register ( e , t , a ), s = await o . login ( e , t ); return s . user && ( l ( s . user ), o . logEvent ( "register" ). catch (()=>{})), r },[]), W = ( 0 , s . useCallback )(()=>{ o . logout (), l ( null ), _ ( "feed" )},[ _ ]), U = ( 0 , s . useCallback )( e =>{ c ( e ), localStorage . setItem ( "forumlify-forum-name" , e )},[]); return ( 0 , r . jsx )( u . Provider ,{ value : { currentUser : a , setCurrentUser : l , forumName : d , forumNameLoaded : D , updateForumName : U , theme : p , toggleTheme : T , view : h , navigate : _ , currentPostId : g , openPost : B , currentUsername : f , openUser : M , currentPageName : j , openCustomPage : L , sort : S , setSort : k , refreshKey : C , refresh : P , ready : N , login : A , register : I , logout : W }, children : t })} let h = { xmlns : "http://www.w3.org/2000/svg" , width : 16 , height : 16 , viewBox : "0 0 24 24" , fill : "none" , stroke : "currentColor" , strokeWidth : 2 , strokeLinecap : "round" , strokeLinejoin : "round" , style : { display : "inline" , verticalAlign : "middle" }}; function m ( e ){ let { name : t , size : a = 16 ,... s } = e ; return ( 0 , r . jsx )( "svg" ,{... h , width : a , height : a ,... s , children : g [ t ] || null })} let g = { message : ( 0 , r . jsx )( r . Fragment ,{ children : ( 0 , r . jsx )( "path" ,{ d : "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })}), settings : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),( 0 , r . jsx )( "circle" ,{ cx : "12" , cy : "12" , r : "3" })]}), shieldAlert : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }),( 0 , r . jsx )( "path" ,{ d : "M12 8v4" }),( 0 , r . jsx )( "path" ,{ d : "M12 16h.01" })]}), user : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),( 0 , r . jsx )( "circle" ,{ cx : "12" , cy : "7" , r : "4" })]}), lock : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "rect" ,{ x : "3" , y : "11" , width : "18" , height : "11" , rx : "2" , ry : "2" }),( 0 , r . jsx )( "path" ,{ d : "M7 11V7a5 5 0 0 1 10 0v4" })]}), moon : ( 0 , r . jsx )( r . Fragment ,{ children : ( 0 , r . jsx )( "path" ,{ d : "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" })}), sun : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "circle" ,{ cx : "12" , cy : "12" , r : "5" }),( 0 , r . jsx )( "line" ,{ x1 : "12" , y1 : "1" , x2 : "12" , y2 : "3" }),( 0 , r . jsx )( "line" ,{ x1 : "12" , y1 : "21" , x2 : "12" , y2 : "23" }),( 0 , r . jsx )( "line" ,{ x1 : "4.22" , y1 : "4.22" , x2 : "5.64" , y2 : "5.64" }),( 0 , r . jsx )( "line" ,{ x1 : "18.36" , y1 : "18.36" , x2 : "19.78" , y2 : "19.78" }),( 0 , r . jsx )( "line" ,{ x1 : "1" , y1 : "12" , x2 : "3" , y2 : "12" }),( 0 , r . jsx )( "line" ,{ x1 : "21" , y1 : "12" , x2 : "23" , y2 : "12" }),( 0 , r . jsx )( "line" ,{ x1 : "4.22" , y1 : "19.78" , x2 : "5.64" , y2 : "18.36" }),( 0 , r . jsx )( "line" ,{ x1 : "18.36" , y1 : "5.64" , x2 : "19.78" , y2 : "4.22" })]}), logout : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),( 0 , r . jsx )( "polyline" ,{ points : "16 17 21 12 16 7" }),( 0 , r . jsx )( "line" ,{ x1 : "21" , y1 : "12" , x2 : "9" , y2 : "12" })]}), book : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M21 12V7H5a2 2 0 0 1 0-4h14v4" }),( 0 , r . jsx )( "path" ,{ d : "M3 5v14a2 2 0 0 0 2 2h16v-5" }),( 0 , r . jsx )( "line" ,{ x1 : "18" , y1 : "12" , x2 : "18" , y2 : "12" })]}), link : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),( 0 , r . jsx )( "path" ,{ d : "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]}), plus : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "line" ,{ x1 : "12" , y1 : "5" , x2 : "12" , y2 : "19" }),( 0 , r . jsx )( "line" ,{ x1 : "5" , y1 : "12" , x2 : "19" , y2 : "12" })]}), shield : ( 0 , r . jsx )( r . Fragment ,{ children : ( 0 , r . jsx )( "path" ,{ d : "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" })}), users : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" }),( 0 , r . jsx )( "circle" ,{ cx : "9" , cy : "7" , r : "4" }),( 0 , r . jsx )( "path" ,{ d : "M23 21v-2a4 4 0 0 0-3-3.87" }),( 0 , r . jsx )( "path" ,{ d : "M16 3.13a4 4 0 0 1 0 7.75" })]}), file : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),( 0 , r . jsx )( "polyline" ,{ points : "14 2 14 8 20 8" }),( 0 , r . jsx )( "line" ,{ x1 : "16" , y1 : "13" , x2 : "8" , y2 : "13" }),( 0 , r . jsx )( "line" ,{ x1 : "16" , y1 : "17" , x2 : "8" , y2 : "17" }),( 0 , r . jsx )( "polyline" ,{ points : "10 9 9 9 8 9" })]}), plus2 : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "path" ,{ d : "M12 5v14" }),( 0 , r . jsx )( "path" ,{ d : "M5 12h14" })]}), close : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "line" ,{ x1 : "18" , y1 : "6" , x2 : "6" , y2 : "18" }),( 0 , r . jsx )( "line" ,{ x1 : "6" , y1 : "6" , x2 : "18" , y2 : "18" })]}), trash : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "polyline" ,{ points : "3 6 5 6 21 6" }),( 0 , r . jsx )( "path" ,{ d : "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })]})}; function y ( e ){ let { onOpenChat : t , onClose : a } = e ,[ n , i ] = ( 0 , s . useState )( null ); return ( 0 , s . useEffect )(()=>{ o . getConversations (). then ( e => i ( e || [])). catch (()=> i ([]))},[]),( 0 , r . jsx )( "div" ,{ className : "modal active" , onClick : e =>{ e . target === e . currentTarget && a ()}, children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , style : { display : "flex" , flexDirection : "column" , height : "70vh" , maxHeight : "70vh" , padding : 0 , overflow : "hidden" }, children : [( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "space-between" , alignItems : "center" , padding : "16px 20px" , borderBottom : "1px solid var(--border)" }, children : [( 0 , r . jsx )( "h2" ,{ style : { fontSize : 18 , margin : 0 }, children : "✉️ 私信" }),( 0 , r . jsx )( "span" ,{ className : "close" , onClick : a , style : { fontSize : 24 , cursor : "pointer" , color : "var(--text-light)" , lineHeight : 1 }, children : "\xd7" })]}),( 0 , r . jsx )( "div" ,{ id : "messageListContent" , style : { flex : 1 , overflowY : "auto" , padding : 0 }, children : null === n ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "加载中..." }) : 0 === n . length ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "暂无私信" }) : n . map ( e =>{ let a = e . unread_count || 0 , s = e . last_message || "暂无消息" , n = e . last_message_time ? new Date ( e . last_message_time ). toLocaleString ( "zh-CN" ) : "" ; return ( 0 , r . jsxs )( "div" ,{ className : "message-list-item" , style : { display : "flex" , alignItems : "center" , gap : 12 , padding : "12px 16px" , borderBottom : "1px solid var(--border)" , cursor : "pointer" , transition : "background 0.15s" }, onClick : ()=> t ( e . id , e . other_user_id , e . other_username ), children : [( 0 , r . jsx )( "img" ,{ src : e . other_avatar_url || "https://ui-avatars.com/api/?name=" + encodeURIComponent ( e . other_username || "U" ) + "&background=6366f1&color=fff&size=64" , style : { width : 40 , height : 40 , borderRadius : "50%" , objectFit : "cover" }, alt : "" }),( 0 , r . jsxs )( "div" ,{ style : { flex : 1 , minWidth : 0 }, children : [( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "space-between" , alignItems : "center" }, children : [( 0 , r . jsx )( "span" ,{ style : { fontWeight : 600 }, children : e . other_username }),( 0 , r . jsx )( "span" ,{ style : { fontSize : 12 , color : "var(--text-light)" }, children : n })]}),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "space-between" , alignItems : "center" }, children : [( 0 , r . jsx )( "span" ,{ style : { fontSize : 13 , color : "var(--text-secondary)" , overflow : "hidden" , textOverflow : "ellipsis" , whiteSpace : "nowrap" , maxWidth : 200 }, children : s }), a > 0 && ( 0 , r . jsx )( "span" ,{ style : { background : "#ef4444" , color : "#fff" , borderRadius : "50%" , padding : "2px 8px" , fontSize : 11 , fontWeight : 600 }, children : a })]})]})]}, e . id )})})]})})} function f ( e ){ let { conversationId : t , otherUserId : a , otherUsername : n , onClose : i , onRefreshList : l } = e ,{ currentUser : d } = p (),[ c , u ] = ( 0 , s . useState )( null ),[ x , h ] = ( 0 , s . useState )( "" ), m = ( 0 , s . useRef )( null ), g = ( 0 , s . useCallback )( async function (){ let e = arguments . length > 0 && void 0 !== arguments [ 0 ] && arguments [ 0 ]; e || u ( null ); try { let e = await o . getMessages ( t ); u ( e || [])} catch ( t ){ e || u ([])}},[ t ]);( 0 , s . useEffect )(()=>{ g ()},[ g ]),( 0 , s . useEffect )(()=>{ let e = setInterval (()=> g ( ! 0 ), 3e3 ); return ()=> clearInterval ( e )},[ g ]),( 0 , s . useEffect )(()=>{ m . current && ( m . current . scrollTop = m . current . scrollHeight )},[ c ]); let y = async ()=>{ if ( x . trim ()) try { await o . sendMessage ( t , x . trim ()), h ( "" ), g (), l ()} catch ( e ){ alert ( "发送失败:" + e . message )}}; return ( 0 , r . jsx )( "div" ,{ className : "modal active" , onClick : e =>{ e . target === e . currentTarget && i ()}, children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , style : { display : "flex" , flexDirection : "column" , height : "70vh" , maxHeight : "70vh" , padding : 0 , overflow : "hidden" }, children : [( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "space-between" , alignItems : "center" , padding : "16px 20px" , borderBottom : "1px solid var(--border)" }, children : [( 0 , r . jsx )( "span" ,{ id : "chatTitle" , style : { fontWeight : 600 , fontSize : 16 }, children : n }),( 0 , r . jsx )( "span" ,{ className : "close" , onClick : i , style : { fontSize : 24 , cursor : "pointer" , color : "var(--text-light)" , lineHeight : 1 }, children : "\xd7" })]}),( 0 , r . jsx )( "div" ,{ id : "chatMessages" , ref : m , style : { flex : 1 , overflowY : "auto" , padding : 16 , minHeight : 0 }, children : null === c ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "加载中..." }) : 0 === c . length ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "还没有消息,打个招呼吧 \uD83D\uDC4B" }) : c . map ( e =>{ let t = e . sender_id === ( null == d ? void 0 : d . id ), a = e . created_at ? new Date ( e . created_at ). toLocaleString ( "zh-CN" ) : "" ; return ( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : t ? "flex-end" : "flex-start" , marginBottom : 12 }, children : [ ! t && ( 0 , r . jsx )( "img" ,{ src : e . sender_avatar_url || "https://ui-avatars.com/api/?name=" + encodeURIComponent ( e . sender_username || "U" ) + "&background=6366f1&color=fff&size=64" , style : { width : 32 , height : 32 , borderRadius : "50%" , objectFit : "cover" , marginRight : 8 , flexShrink : 0 }, alt : "" }),( 0 , r . jsxs )( "div" ,{ style : { maxWidth : "70%" }, children : [( 0 , r . jsx )( "div" ,{ style : { background : t ? "var(--primary)" : "var(--surface)" , color : t ? "#fff" : "var(--text)" , padding : "10px 14px" , borderRadius : 12 , border : t ? "none" : "1px solid var(--border)" , wordBreak : "break-word" }, children : e . content }),( 0 , r . jsxs )( "div" ,{ style : { fontSize : 11 , color : "var(--text-light)" , marginTop : 4 , textAlign : t ? "right" : "left" }, children : [ a , " " , t ? e . is_read ? "✓✓" : "✓" : "" ]})]})]}, e . id )})}),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , gap : 8 , padding : "12px 16px" , borderTop : "1px solid var(--border)" , flexShrink : 0 }, children : [( 0 , r . jsx )( "input" ,{ type : "text" , id : "chatInput" , placeholder : "输入消息..." , style : { flex : 1 , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 6 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" , outline : "none" }, value : x , onChange : e => h ( e . target . value ), onKeyDown : e =>{ "Enter" === e . key && y ()}}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "8px 16px" }, onClick : y , children : "发送" })]})]})})} function v (){ let { currentUser : e } = p (),[ t , a ] = ( 0 , s . useState )( 0 ); return (( 0 , s . useEffect )(()=>{ if ( ! e ){ a ( 0 ); return } let t = ()=>{ o . getConversations (). then ( e => a (( e || []). reduce (( e , t )=> e + ( t . unread_count || 0 ), 0 ))). catch (()=>{})}; t (); let r = setInterval ( t , 3e4 ); return ()=> clearInterval ( r )},[ e ]), e ) ? ( 0 , r . jsxs )( "button" ,{ className : "nav-icon-btn" , title : "私信" , style : { position : "relative" , padding : "6px 8px" , background : "none" , border : "none" , cursor : "pointer" , color : "var(--text-secondary)" , borderRadius : 4 , display : "inline-flex" , alignItems : "center" , justifyContent : "center" }, onClick : ()=> window . dispatchEvent ( new CustomEvent ( "forumlify-open-messages" )), children : [( 0 , r . jsx )( m ,{ name : "message" , size : 20 }), t > 0 && ( 0 , r . jsx )( "span" ,{ style : { position : "absolute" , top :- 2 , right :- 2 , background : "#ef4444" , color : "#fff" , borderRadius : "50%" , padding : "2px 6px" , fontSize : 10 , fontWeight : 600 , minWidth : 18 , textAlign : "center" , lineHeight : 1.4 }, children : t > 99 ? "99+" : t })]}) : null } function j (){ let [ e , t ] = ( 0 , s . useState )( ! 1 ),[ a , n ] = ( 0 , s . useState )( null ),[ i , l ] = ( 0 , s . useState )( 0 ), o = ( 0 , s . useCallback )(()=> l ( e => e + 1 ),[]); return ( 0 , s . useEffect )(()=>{ let e = e =>{ n ( e . detail ), t ( ! 1 )}, a = ()=> t ( ! 0 ); return window . addEventListener ( "forumlify-open-chat" , e ), window . addEventListener ( "forumlify-open-messages" , a ),()=>{ window . removeEventListener ( "forumlify-open-chat" , e ), window . removeEventListener ( "forumlify-open-messages" , a )}},[]),( 0 , r . jsxs )( r . Fragment ,{ children : [ e && ( 0 , r . jsx )( y ,{ onOpenChat : ( e , a , r )=>{ n ({ conversationId : e , otherUserId : a , otherUsername : r }), t ( ! 1 )}, onClose : ()=> t ( ! 1 )}), a && ( 0 , r . jsx )( f ,{ conversationId : a . conversationId , otherUserId : a . otherUserId , otherUsername : a . otherUsername , onClose : ()=>{ n ( null ), o ()}, onRefreshList : o })]})} function b ( e ){ let { onOpenModal : t } = e ,{ currentUser : a , forumName : n , theme : i , toggleTheme : l , navigate : d , openCustomPage : c , logout : u } = p (),[ x , h ] = ( 0 , s . useState )( ! 1 ),[ g , y ] = ( 0 , s . useState )([]);( 0 , s . useEffect )(()=>{ o . getCustomPages (). then ( y ). catch (()=>{})},[]),( 0 , s . useEffect )(()=>{ let e = e =>{ var t ; let a = document . getElementById ( "userDropdown" ), r = null === ( t = document . getElementById ( "userDropdown" )) || void 0 === t ? void 0 : t . querySelector ( ".avatar" ); ! ( a && a . contains ( e . target )) && ( r && r . contains ( e . target ) || h ( ! 1 ))}; return document . addEventListener ( "click" , e ),()=> document . removeEventListener ( "click" , e )},[]); let f = ( null == a ? void 0 : a . avatar_url ) || "https://ui-avatars.com/api/?name=" + encodeURIComponent (( null == a ? void 0 : a . username ) || "U" ) + "&background=6366f1&color=fff" , j = e =>{ if ( "admin" === e && ( null == a ? void 0 : a . role ) !== "admin" ){ alert ( "无权限访问" ); return } h ( ! 1 ), d ( e )}; return ( 0 , r . jsxs )( "nav" ,{ id : "navbar" , children : [( 0 , r . jsxs )( "div" ,{ className : "nav-left" , children : [( 0 , r . jsx )( "span" ,{ className : "forum-name" , onClick : ()=> d ( "feed" ), style : { cursor : "pointer" }, children : n }),( 0 , r . jsx )( "span" ,{ id : "customNavLinks" , style : { display : "inline-flex" , alignItems : "center" , gap : 6 , marginLeft : 16 }, children : g . map ( e =>( 0 , r . jsx )( "a" ,{ href : "#" , className : "custom-page-nav-link" , "data-custom" : e . name , onClick : t =>{ t . preventDefault (), c ( e . name )}, style : { color : "var(--text-secondary)" , textDecoration : "none" , fontSize : 14 , padding : "4px 10px" , borderRadius : 4 , transition : "color 0.15s" }, onMouseEnter : e =>{ e . currentTarget . style . color = "var(--text)" }, onMouseLeave : e =>{ e . currentTarget . style . color = "var(--text-secondary)" }, children : e . title }, e . id ))})]}),( 0 , r . jsxs )( "div" ,{ className : "nav-right" , children : [( 0 , r . jsx )( v ,{}),( 0 , r . jsx )( "div" ,{ id : "userMenu" , children : a ? ( 0 , r . jsxs )( "div" ,{ id : "userDropdown" , style : { display : "block" }, children : [( 0 , r . jsx )( "img" ,{ className : "avatar" , src : f , alt : "avatar" , onClick : e =>{ e . stopPropagation (), h ( ! x )}}), x && ( 0 , r . jsxs )( "div" ,{ className : "dropdown-menu show" , onClick : e => e . stopPropagation (), children : [( 0 , r . jsxs )( "a" ,{ href : "#" , onClick : e =>{ e . preventDefault (), h ( ! 1 ), d ( "messages" )}, children : [( 0 , r . jsx )( m ,{ name : "message" }), " 消息" ]}),( 0 , r . jsxs )( "a" ,{ href : "#" , onClick : e =>{ e . preventDefault (), j ( "settings" )}, children : [( 0 , r . jsx )( m ,{ name : "settings" }), " 设置" ]}), "admin" === a . role && ( 0 , r . jsxs )( "a" ,{ href : "#" , onClick : e =>{ e . preventDefault (), j ( "admin" )}, children : [( 0 , r . jsx )( m ,{ name : "shieldAlert" }), " 管理后台" ]}),( 0 , r . jsx )( "hr" ,{}),( 0 , r . jsxs )( "a" ,{ href : "#" , onClick : e =>{ e . preventDefault (), l (), h ( ! 1 )}, children : [( 0 , r . jsx )( m ,{ name : "dark" === i ? "sun" : "moon" }), " " , "dark" === i ? "亮色模式" : "暗色模式" ]}),( 0 , r . jsx )( "hr" ,{}),( 0 , r . jsxs )( "a" ,{ href : "#" , onClick : e =>{ e . preventDefault (), confirm ( "确定要退出吗?" ) && ( h ( ! 1 ), u ())}, children : [( 0 , r . jsx )( m ,{ name : "logout" }), " 退出" ]})]})]}) : ( 0 , r . jsxs )( "div" ,{ id : "authButtons" , children : [( 0 , r . jsx )( "button" ,{ className : "btn-ghost" , onClick : ()=> t ( "login" ), children : "登录" }),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , onClick : ()=> t ( "register" ), children : "注册" })]})})]})]})} function S (){ let [ e , t ] = ( 0 , s . useState )({ posts : 0 , users : 0 , topics : 0 , online : 0 }),[ a , n ] = ( 0 , s . useState )([]); return ( 0 , s . useEffect )(()=>{ o . getStats (). then ( t ). catch (()=>{}), o . getLinks (). then ( n ). catch (()=>{})},[]),( 0 , r . jsxs )( "aside" ,{ id : "sidebar" , children : [( 0 , r . jsxs )( "div" ,{ className : "stats-box" , children : [( 0 , r . jsxs )( "h4" ,{ children : [( 0 , r . jsx )( m ,{ name : "book" , size : 14 }), " 社区统计" ]}),( 0 , r . jsxs )( "div" ,{ className : "stat-item" , children : [( 0 , r . jsx )( "span" ,{ children : "主题" }),( 0 , r . jsx )( "span" ,{ children : e . topics || 0 })]}),( 0 , r . jsxs )( "div" ,{ className : "stat-item" , children : [( 0 , r . jsx )( "span" ,{ children : "帖子" }),( 0 , r . jsx )( "span" ,{ children : e . posts || 0 })]}),( 0 , r . jsxs )( "div" ,{ className : "stat-item" , children : [( 0 , r . jsx )( "span" ,{ children : "用户" }),( 0 , r . jsx )( "span" ,{ children : e . users || 0 })]}),( 0 , r . jsxs )( "div" ,{ className : "stat-item" , children : [( 0 , r . jsx )( "span" ,{ children : "在线" }),( 0 , r . jsx )( "span" ,{ children : e . online || 0 })]})]}),( 0 , r . jsxs )( "div" ,{ className : "links-box" , children : [( 0 , r . jsxs )( "h4" ,{ children : [( 0 , r . jsx )( m ,{ name : "link" , size : 14 }), " 友情链接" ]}),( 0 , r . jsx )( "ul" ,{ id : "friendlyLinks" , children : 0 === a . length ? ( 0 , r . jsx )( "li" ,{ style : { color : "#94a3b8" , fontSize : 13 }, children : "暂无链接" }) : a . map ( e =>( 0 , r . jsx )( "li" ,{ children : ( 0 , r . jsx )( "a" ,{ href : e . url , target : "_blank" , rel : "noreferrer" , children : e . title })}, e . id ))})]})]})} function k ( e ){ let { src : t , onClose : a } = e ; return ( 0 , s . useEffect )(()=>{ let e = e =>{ "Escape" === e . key && a ()}; return document . addEventListener ( "keydown" , e ),()=> document . removeEventListener ( "keydown" , e )},[ a ]),( 0 , r . jsx )( "div" ,{ className : "modal active" , style : { position : "fixed" , inset : 0 , background : "rgba(0,0,0,0.85)" , zIndex : 9999 , display : "flex" , alignItems : "center" , justifyContent : "center" , cursor : "pointer" , animation : "fadeIn 0.2s ease-out" }, onClick : a , children : ( 0 , r . jsx )( "img" ,{ src : t , alt : "" , style : { maxWidth : "90vw" , maxHeight : "90vh" , objectFit : "contain" , borderRadius : 8 , boxShadow : "0 8px 32px rgba(0,0,0,0.5)" , cursor : "default" , userSelect : "none" }, onClick : e => e . stopPropagation ()})})} var C = a ( 7970 ); function w ( e ){ if ( ! e ) return "" ; try { return C . TU . parse ( e )} catch ( t ){ return e . replace ( /\n/g , "<br>" )}} function N ( e ){ let { onOpenModal : t , onReport : a } = e ,{ currentUser : n , sort : i , setSort : l , openPost : d , openUser : c , navigate : u , refreshKey : x } = p (),[ h , g ] = ( 0 , s . useState )( null ),[ y , f ] = ( 0 , s . useState )( null ),[ v , j ] = ( 0 , s . useState )( ! 0 ),[ b , S ] = ( 0 , s . useState )( 1 ),[ C , N ] = ( 0 , s . useState )( 1 ),[ z , D ] = ( 0 , s . useState )( null ), R = ( 0 , s . useRef )( null ), E = ( 0 , s . useCallback )( async e =>{ g ( null ), f ( null ); try { var t , a ; let r = await o . getPosts ( i , null , e , 20 ); g ( r . data || []), N (( null === ( t = r . pagination ) || void 0 === t ? void 0 : t . totalPages ) || 1 ), S (( null === ( a = r . pagination ) || void 0 === a ? void 0 : a . page ) || 1 )} catch ( e ){ f ( e . message ), g ([])}},[ i , x ]);( 0 , s . useEffect )(()=>{ E ( b )},[ E ]),( 0 , s . useEffect )(()=>{ h && 0 !== h . length && R . current && R . current . querySelectorAll ( ".post-content" ). forEach ( e =>{ e . scrollHeight > e . clientHeight + 4 ? e . classList . add ( "has-fade" ) : e . classList . remove ( "has-fade" )})},[ h ]),( 0 , s . useEffect )(()=>{ S ( 1 )},[ i ]); let P = async e =>{ if ( confirm ( "确定要删除这条帖子吗?" )) try { await o . deletePost ( e ), E ( b )} catch ( e ){ alert ( "删除失败:" + e . message )}}; return ( 0 , r . jsxs )( "main" ,{ id : "feed" , children : [( 0 , r . jsxs )( "div" ,{ className : "feed-header" , children : [( 0 , r . jsxs )( "div" ,{ className : "feed-header-left" , children : [( 0 , r . jsx )( "button" ,{ className : "tab" + ( "latest" === i ? " active" : "" ), onClick : ()=> l ( "latest" ), children : "最新发布" }),( 0 , r . jsx )( "button" ,{ className : "tab" + ( "hot" === i ? " active" : "" ), onClick : ()=> l ( "hot" ), children : "最新回复" })]}),( 0 , r . jsxs )( "button" ,{ className : "btn-primary fab-btn" , onClick : ()=>{ if ( ! n ){ alert ( "请先登录" ); return } u ( "new" )}, children : [( 0 , r . jsx )( m ,{ name : "plus" }), " 发布新帖" ]})]}),( 0 , r . jsx )( "div" ,{ id : "postList" , ref : R , children : null === h ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "加载中..." }) : y ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : "40px 0" }, children : [ "加载失败:" , y ]}) : 0 === h . length ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "60px 0" }, children : "✨ 还没有帖子,快来发布第一条吧!" }) : h . map ( e =>{ let t = e . created_at ? new Date ( e . created_at ). toLocaleString ( "zh-CN" ) : "" ; return ( 0 , r . jsxs )( "div" ,{ className : "post-card" , style : { cursor : "pointer" }, onClick : ()=> d ( e . id ), children : [ e . is_pinned && ( 0 , r . jsx )( "div" ,{ style : { fontSize : 12 , color : "var(--primary)" , fontWeight : 600 , marginBottom : 4 }, children : "\uD83D\uDCCC 置顶" }),( 0 , r . jsxs )( "div" ,{ className : "post-header" , children : [( 0 , r . jsx )( "img" ,{ src : e . avatar_url || "https://ui-avatars.com/api/?name=" + encodeURIComponent ( e . username || "匿名用户" ) + "&background=6366f1&color=fff&size=64" , className : "post-avatar" , alt : "" }),( 0 , r . jsx )( "span" ,{ className : "post-username" , style : { cursor : "pointer" , color : "var(--primary)" }, onClick : t =>{ t . stopPropagation (), c ( e . username )}, children : e . username || "匿名用户" }),( 0 , r . jsx )( "span" ,{ className : "post-time" , children : t }), e . edited_at && ( 0 , r . jsx )( "span" ,{ style : { fontSize : 11 , color : "var(--text-light)" , marginLeft : 6 }, children : "(已编辑)" })]}),( 0 , r . jsx )( "div" ,{ className : "post-title" , children : e . title || "无标题" }),( 0 , r . jsx )( "div" ,{ className : "post-content" , dangerouslySetInnerHTML : { __html : w ( e . content )}}), e . images && e . images . length > 0 && ( 0 , r . jsx )( "div" ,{ className : "post-images" , children : e . images . map (( e , t )=>( 0 , r . jsx )( "img" ,{ src : e , className : "post-image" , alt : "" , style : { cursor : "pointer" }, onClick : t =>{ t . stopPropagation (), D ( e )}}, t ))}),( 0 , r . jsxs )( "div" ,{ className : "post-actions" , children : [( 0 , r . jsxs )( "span" ,{ children : [( 0 , r . jsx )( m ,{ name : "message" , size : 14 }), " " , e . reply_count || 0 ]}),( 0 , r . jsxs )( "button" ,{ className : "action-report" , onClick : t =>{ if ( t . stopPropagation (), ! n ){ alert ( "请先登录" ); return } a ( e . id )}, children : [( 0 , r . jsx )( m ,{ name : "flag" , size : 14 }), " 举报" ]}), n && ( n . id === e . user_id || "admin" === n . role ) && ( 0 , r . jsxs )( "button" ,{ className : "action-delete" , onClick : t =>{ t . stopPropagation (), P ( e . id )}, children : [( 0 , r . jsx )( m ,{ name : "trash" , size : 14 }), " 删除" ]})]})]}, e . id )})}), C > 1 && h && h . length > 0 && ( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "center" , alignItems : "center" , gap : 6 , padding : "16px 0" , marginTop : 8 , borderTop : "1px solid var(--border)" , flexWrap : "wrap" }, children : [( 0 , r . jsx )( "button" ,{ className : "page-btn" , disabled : b <= 1 , onClick : ()=> E ( b - 1 ), style : { padding : "6px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , color : "var(--text)" , cursor : b <= 1 ? "not-allowed" : "pointer" , fontSize : 13 , opacity : b <= 1 ? . 4 : 1 }, children : "\xab" }), Array . from ({ length : C },( e , t )=> t + 1 ). map ( e =>( 0 , r . jsx )( "button" ,{ className : "page-btn" , disabled : e === b , onClick : ()=> E ( e ), style : { padding : "6px 10px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 13 , minWidth : 32 , textAlign : "center" , background : e === b ? "var(--primary)" : "var(--surface)" , color : e === b ? "#fff" : "var(--text)" , cursor : e === b ? "default" : "pointer" , borderColor : e === b ? "var(--primary)" : "var(--border)" }, children : e }, e )),( 0 , r . jsx )( "button" ,{ className : "page-btn" , disabled : b >= C , onClick : ()=> E ( b + 1 ), style : { padding : "6px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , color : "var(--text)" , cursor : b >= C ? "not-allowed" : "pointer" , fontSize : 13 , opacity : b >= C ? . 4 : 1 }, children : "\xbb" })]}), z && ( 0 , r . jsx )( k ,{ src : z , onClose : ()=> D ( null )})]})} function z ( e ){ let { captcha : t , onRefresh : a } = e , n = ( 0 , s . useRef )( null ); return ( 0 , s . useEffect )(()=>{ let e = n . current ; if ( ! e ||! t ) return ; let a = e . getContext ( "2d" ), r = e . width , s = e . height ; a . clearRect ( 0 , 0 , r , s ), a . fillStyle = "rgba(91, 155, 213, 0.10)" , a . fillRect ( 0 , 0 , r , s ); for ( let e = 0 ; e < 4 ; e ++ ) a . strokeStyle = "rgba(" . concat ( 80 + 120 * Math . random (), ", " ). concat ( 80 + 120 * Math . random (), ", 200, " ). concat (. 2 + . 3 * Math . random (), ")" ), a . lineWidth = 1 + Math . random (), a . beginPath (), a . moveTo ( Math . random () * r , Math . random () * s ), a . lineTo ( Math . random () * r , Math . random () * s ), a . stroke (); for ( let e = 0 ; e < 30 ; e ++ ) a . fillStyle = "rgba(" . concat ( 200 * Math . random (), ", " ). concat ( 200 * Math . random (), ", 220, " ). concat (. 3 + . 5 * Math . random (), ")" ), a . beginPath (), a . arc ( Math . random () * r , Math . random () * s , 1 + 1.5 * Math . random (), 0 , 2 * Math . PI ), a . fill (); let i = t . question . replace ( " = ?" , "" ). split ( "" ), l = Math . floor (. 52 * s ), o = r / ( i . length + 1 ); i . forEach (( e , t )=>{ a . save (), a . translate ( o * ( t + 1 ) + ( Math . random () - . 5 ) * 6 , s / 2 + ( Math . random () - . 5 ) * 6 ), a . rotate (( Math . random () - . 5 ) * . 25 ), a . font = "bold " . concat ( l , 'px -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif' ), a . fillStyle = "rgba(" . concat ( 40 + 60 * Math . random (), ", " ). concat ( 50 + 50 * Math . random (), ", 90, 0.9)" ), a . textAlign = "center" , a . textBaseline = "middle" , a . fillText ( e , 0 , 0 ), a . restore ()})},[ t ]),( 0 , r . jsx )( "canvas" ,{ ref : n , width : 120 , height : 40 , onClick : a , title : "看不清?点击刷新" , style : { cursor : "pointer" , borderRadius : 6 , border : "1px solid var(--glass-border)" , verticalAlign : "middle" }})} function D ( e ){ let { postId : t , onRefresh : a } = e ,{ currentUser : n , openUser : i } = p (),[ l , d ] = ( 0 , s . useState )([]),[ u , x ] = ( 0 , s . useState )( "" ),[ h , g ] = ( 0 , s . useState )( null ),[ y , f ] = ( 0 , s . useState )( "" ), v = ( 0 , s . useCallback )( async ()=>{ try { let e = await o . getReplies ( t ); d ( e || [])} catch ( e ){ d ([])}},[ t ]);( 0 , s . useEffect )(()=>{ v ()},[ v ]),( 0 , s . useEffect )(()=>{ g ( c ())},[ t ]); let j = async ()=>{ if ( ! n ){ alert ( "请先登录" ); return } if ( ! u . trim ()){ alert ( "请填写回复内容" ); return } if ( ! h || parseInt ( y ) !== h . answer ){ alert ( "验证码错误,请重新计算" ), g ( c ()), f ( "" ); return } try { await o . createReply ( t , u . trim ()), o . logEvent ( "create_reply" ). catch (()=>{}), x ( "" ), f ( "" ), g ( c ()), v (), a ()} catch ( e ){ alert ( "回复失败:" + e . message )}}, b = async e =>{ if ( confirm ( "确定要删除这条回复吗?" )) try { await o . deleteReply ( e ), v ()} catch ( e ){ alert ( "删除失败:" + e . message )}}; return ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsxs )( "div" ,{ style : { marginTop : 20 , fontSize : 14 , color : "#64748b" }, children : [( 0 , r . jsx )( m ,{ name : "message" , size : 14 }), " " , l . length , " 条回复" ]}),( 0 , r . jsx )( "div" ,{ style : { marginTop : 12 }, children : 0 === l . length ? ( 0 , r . jsx )( "div" ,{ style : { color : "#94a3b8" , padding : "20px 0" , textAlign : "center" }, children : "还没有回复,快来抢沙发吧 \uD83D\uDECB️ " }) : l . map ( e =>{ let t = e . created_at ? new Date ( e . created_at ). toLocaleString ( "zh-CN" ) : "" ; return ( 0 , r . jsxs )( "div" ,{ className : "reply-item" , children : [( 0 , r . jsxs )( "div" ,{ className : "reply-header" , children : [( 0 , r . jsx )( "img" ,{ src : e . avatar_url || "https://ui-avatars.com/api/?name=" + encodeURIComponent ( e . username || "匿名用户" ) + "&background=6366f1&color=fff&size=64" , className : "reply-avatar" , alt : "" }),( 0 , r . jsx )( "span" ,{ className : "reply-username" , style : { cursor : "pointer" , color : "var(--primary)" }, onClick : ()=> i ( e . username ), children : e . username || "匿名用户" }),( 0 , r . jsx )( "span" ,{ className : "reply-time" , children : t }), n && ( n . id === e . user_id || "admin" === n . role ) && ( 0 , r . jsxs )( "button" ,{ className : "btn-sm btn-danger reply-delete-btn" , onClick : ()=> b ( e . id ), children : [( 0 , r . jsx )( m ,{ name : "trash" , size : 12 }), " 删除" ]})]}),( 0 , r . jsx )( "div" ,{ className : "reply-content" , dangerouslySetInnerHTML : { __html : w ( e . content )}})]}, e . id )})}),( 0 , r . jsxs )( "div" ,{ id : "replyArea" , style : { marginTop : 24 , borderTop : "1px solid var(--border)" , paddingTop : 20 }, children : [( 0 , r . jsxs )( "h3" ,{ style : { fontSize : 16 , marginBottom : 12 }, children : [( 0 , r . jsx )( m ,{ name : "message" , size : 16 }), " 发表回复" ]}),( 0 , r . jsx )( "textarea" ,{ rows : 3 , placeholder : "写下你的回复..." , style : { width : "100%" , padding : "10px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , fontFamily : "inherit" , resize : "vertical" , background : "var(--bg)" , color : "var(--text)" }, value : u , onChange : e => x ( e . target . value ), onKeyDown : e =>{ "Enter" === e . key && ( e . ctrlKey || e . metaKey ) && j ()}}),( 0 , r . jsxs )( "div" ,{ className : "captcha-row" , style : { margin : "10px 0" , display : "flex" , alignItems : "center" , gap : 10 }, children : [ h ? ( 0 , r . jsx )( z ,{ captcha : h , onRefresh : ()=>{ g ( c ()), f ( "" )}}) : ( 0 , r . jsx )( "span" ,{ style : { color : "var(--text-light)" }, children : "验证码加载中..." }),( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "答案" , style : { width : 80 , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--bg)" , color : "var(--text)" , outline : "none" }, value : y , onChange : e => f ( e . target . value )})]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "8px 24px" }, onClick : j , children : "提交回复" })]})]})} function R ( e ){ let { postId : t } = e ,{ currentUser : a , navigate : n , openUser : i , refreshKey : l } = p (),[ c , u ] = ( 0 , s . useState )( null ),[ x , h ] = ( 0 , s . useState )( null ),[ g , y ] = ( 0 , s . useState )( null ),[ f , v ] = ( 0 , s . useState )( ! 1 ),[ j , b ] = ( 0 , s . useState )( "" ),[ S , C ] = ( 0 , s . useState )( "" ),[ N , z ] = ( 0 , s . useState )([]),[ R , E ] = ( 0 , s . useState )( ! 1 ), P = ( 0 , s . useRef )( null ), T = ( 0 , s . useCallback )( async ()=>{ h ( null ); try { let e = await o . getPost ( t ); u ( e )} catch ( e ){ h ( e . message )}},[ t , l ]); if (( 0 , s . useEffect )(()=>{ T ()},[ T ]), x ) return ( 0 , r . jsxs )( "div" ,{ id : "pagePost" , className : "page-slide active" , style : { padding : "40px 0" , textAlign : "center" , color : "#ef4444" }, children : [ "加载失败:" , x ]}); if ( ! c ) return ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "加载中..." }); let _ = c . created_at ? new Date ( c . created_at ). toLocaleString ( "zh-CN" ) : "" , B = a && ( a . id === c . user_id || "admin" === a . role ); a && ( a . id , c . user_id ); let M = async ()=>{ if ( confirm ( "确定要删除这条帖子吗?" )) try { await o . deletePost ( t ), alert ( "删除成功" ), n ( "feed" )} catch ( e ){ alert ( "删除失败:" + e . message )}}, L = async ()=>{ if ( confirm ( "确定要" + ( c . is_pinned ? "取消" : "" ) + "置顶吗?" )) try { await o . togglePinPost ( t ), T ()} catch ( e ){ alert ( "操作失败:" + e . message )}}, A = async ()=>{ if ( ! S . trim ()){ alert ( "请填写内容" ); return } try { await o . updatePost ( t , j . trim () || "无标题" , S . trim (), N ), v ( ! 1 ), T ()} catch ( e ){ alert ( "编辑失败:" + e . message )}}, I = async e =>{ if ( e ){ if ( ! e . type . startsWith ( "image/" )){ alert ( "请选择图片文件" ); return } if ( e . size > 5242880 ){ alert ( "图片不能超过 5MB" ); return } E ( ! 0 ); try { let t = await d ( e ); z ( e =>[... e , t ])} catch ( e ){ alert ( "上传失败:" + e . message )} finally { E ( ! 1 )}}}, W = e =>{ z ( t => t . filter ( t => t !== e ))}; return ( 0 , r . jsxs )( "div" ,{ id : "pagePost" , className : "page-slide active" , children : [( 0 , r . jsx )( "div" ,{ className : "page-header" , style : { maxWidth : 700 , margin : "0 auto" , width : "100%" }, children : ( 0 , r . jsx )( "h2" ,{ children : c . title || "帖子详情" })}),( 0 , r . jsxs )( "div" ,{ id : "postDetailContent" , style : { maxWidth : 700 , margin : "0 auto" , width : "100%" }, children : [( 0 , r . jsxs )( "div" ,{ className : "post-detail-card" , children : [( 0 , r . jsxs )( "div" ,{ className : "post-header" , children : [( 0 , r . jsx )( "img" ,{ src : c . avatar_url || "https://ui-avatars.com/api/?name=" + encodeURIComponent ( c . username || "匿名用户" ) + "&background=6366f1&color=fff&size=64" , className : "post-avatar" , alt : "" }),( 0 , r . jsx )( "span" ,{ className : "post-username" , style : { cursor : "pointer" , color : "var(--primary)" }, onClick : ()=> i ( c . username ), children : c . username || "匿名用户" }),( 0 , r . jsx )( "span" ,{ className : "post-time" , children : _ }), c . edited_at && ( 0 , r . jsxs )( "span" ,{ style : { fontSize : 12 , color : "var(--text-light)" , marginLeft : 8 }, children : [ "(已编辑 " , new Date ( c . edited_at ). toLocaleString ( "zh-CN" ), ") " ]}), c . is_pinned && ( 0 , r . jsx )( "span" ,{ style : { fontSize : 12 , color : "var(--primary)" , marginLeft : 8 }, children : "\uD83D\uDCCC 置顶" }),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , gap : 4 , marginLeft : "auto" }, children : [ a && "admin" === a . role && ( 0 , r . jsx )( "button" ,{ className : "btn-sm btn-secondary" , style : { padding : "4px 10px" }, onClick : L , children : c . is_pinned ? "\uD83D\uDCCC 取消置顶" : "\uD83D\uDCCC 置顶" }), B && ( 0 , r . jsx )( "button" ,{ className : "btn-sm btn-secondary" , style : { padding : "4px 10px" }, onClick : ()=>{ b ( c . title || "" ), C ( c . content || "" ), z ( c . images || []), v ( ! 0 )}, children : "✏️ 编辑" }), B && ( 0 , r . jsxs )( "button" ,{ className : "btn-sm btn-danger" , style : { padding : "4px 10px" }, onClick : M , children : [( 0 , r . jsx )( m ,{ name : "trash" , size : 14 }), " 删除" ]})]})]}),( 0 , r . jsx )( "div" ,{ className : "post-content" , style : { fontSize : 16 , lineHeight : 1.8 }, dangerouslySetInnerHTML : { __html : w ( c . content )}}), c . images && c . images . length > 0 && ( 0 , r . jsx )( "div" ,{ className : "post-images" , children : c . images . map (( e , t )=>( 0 , r . jsx )( "img" ,{ src : e , className : "post-image" , alt : "" , style : { cursor : "pointer" }, onClick : ()=> y ( e )}, t ))}), c . signature && ( 0 , r . jsx )( "div" ,{ style : { marginTop : 16 , paddingTop : 12 , borderTop : "1px solid var(--border-light)" , fontSize : 12 , color : "var(--text-secondary)" }, dangerouslySetInnerHTML : { __html : w ( c . signature )}})]}),( 0 , r . jsx )( D ,{ postId : t , onRefresh : T })]}), f && ( 0 , r . jsx )( "div" ,{ className : "modal active" , style : { display : "flex" }, onClick : e =>{ e . target === e . currentTarget && v ( ! 1 )}, children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , style : { maxWidth : 600 , position : "relative" }, children : [( 0 , r . jsx )( "span" ,{ className : "close" , style : { position : "absolute" , top : 12 , right : 16 , fontSize : 24 , cursor : "pointer" , color : "var(--text-light)" }, onClick : ()=> v ( ! 1 ), children : "\xd7" }),( 0 , r . jsx )( "h2" ,{ style : { marginBottom : 16 }, children : "✏️ 编辑帖子" }),( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "标题" , value : j , onChange : e => b ( e . target . value ), style : { width : "100%" , padding : "10px 14px" , border : "1px solid var(--border)" , borderRadius : 6 , fontSize : 15 , fontWeight : 600 , marginBottom : 12 , background : "var(--bg)" , color : "var(--text)" }}),( 0 , r . jsx )( "textarea" ,{ rows : 6 , placeholder : "说点什么..." , value : S , onChange : e => C ( e . target . value ), style : { width : "100%" , padding : 12 , border : "1px solid var(--border)" , borderRadius : 6 , fontSize : 15 , fontFamily : "inherit" , resize : "vertical" , background : "var(--bg)" , color : "var(--text)" }}), N . length > 0 && ( 0 , r . jsx )( "div" ,{ style : { display : "flex" , flexWrap : "wrap" , gap : 8 , marginTop : 10 }, children : N . map (( e , t )=>( 0 , r . jsxs )( "div" ,{ style : { position : "relative" }, children : [( 0 , r . jsx )( "img" ,{ src : e , alt : "" , style : { width : 72 , height : 72 , objectFit : "cover" , borderRadius : 6 , border : "1px solid var(--border)" }}),( 0 , r . jsx )( "button" ,{ type : "button" , title : "删除图片" , onClick : ()=> W ( e ), style : { position : "absolute" , top :- 6 , right :- 6 , width : 20 , height : 20 , borderRadius : "50%" , background : "#ef4444" , color : "#fff" , border : "none" , cursor : "pointer" , fontSize : 12 , lineHeight : 1 , display : "flex" , alignItems : "center" , justifyContent : "center" }, children : "\xd7" })]}, e + t ))}),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , gap : 8 , marginTop : 12 }, children : [( 0 , r . jsx )( "button" ,{ type : "button" , className : "btn-secondary" , style : { padding : "8px 16px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : ()=>{ var e ; return null === ( e = P . current ) || void 0 === e ? void 0 : e . click ()}, children : R ? "上传中..." : "\uD83D\uDCF7 上传图片" }),( 0 , r . jsx )( "input" ,{ type : "file" , ref : P , accept : "image/*" , multiple :! 0 , style : { display : "none" }, onChange : e =>{ let t = e . target . files ; t && t . length > 0 && ([... t ]. forEach ( e => I ( e )), e . target . value = "" )}})]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "10px 32px" , fontSize : 15 , marginTop : 12 , width : "100%" }, onClick : A , children : "保存" })]})}), g && ( 0 , r . jsx )( k ,{ src : g , onClose : ()=> y ( null )})]})} var E = a ( 9505 ); function P (){ let { currentUser : e , navigate : t , refresh : a } = p (),{ toast : n } = ( 0 , E . p )(),[ i , l ] = ( 0 , s . useState )( "" ),[ u , x ] = ( 0 , s . useState )( "" ),[ h , g ] = ( 0 , s . useState )([]),[ y , f ] = ( 0 , s . useState )([]),[ v , j ] = ( 0 , s . useState )( null ),[ b , S ] = ( 0 , s . useState )( "" ),[ k , C ] = ( 0 , s . useState )( ! 1 );( 0 , s . useEffect )(()=>{ j ( c ())},[]); let w = async e =>{ C ( ! 0 ); try { let t = []; for ( let a of e ){ if ( ! a . type . startsWith ( "image/" )) continue ; if ( a . size > 5242880 ){ alert ( "图片 " + a . name + " 超过 5MB,请压缩后上传" ); continue } let e = await new Promise ( e =>{ let t = new FileReader ; t . onload = t => e ( t . target . result ), t . readAsDataURL ( a )}); t . push ( e ); let r = await d ( a ); g ( e =>[... e , r ])} f ( e =>[... e ,... t ])} catch ( e ){ alert ( "上传失败:" + e . message )} finally { C ( ! 1 )}},[ N , D ] = ( 0 , s . useState )( ! 1 ), R = ( 0 , s . useRef )( null ), P = async ()=>{ if ( ! e ||! e . id ){ n ( "请先登录" , "error" ), t ( "feed" ); return } if ( ! u . trim ()){ n ( "请填写内容" , "error" ); return } if ( ! v || parseInt ( b ) !== v . answer ){ n ( "验证码错误,请重新计算" , "error" ), j ( c ()), S ( "" ); return } try { await o . createPost ( i . trim () || "无标题" , u . trim (), h ), o . logEvent ( "create_post" ). catch (()=>{}), n ( "发布成功" , "success" ), t ( "feed" ), a ()} catch ( e ){ n ( "发布失败:" + e . message , "error" )}}; return ( 0 , r . jsxs )( "div" ,{ className : "page-slide active" , children : [( 0 , r . jsx )( "div" ,{ className : "page-header" , style : { maxWidth : 600 , margin : "0 auto" , width : "100%" }, children : ( 0 , r . jsxs )( "h2" ,{ children : [( 0 , r . jsx )( m ,{ name : "plus" , size : 20 }), " 发布新帖" ]})}),( 0 , r . jsxs )( "div" ,{ style : { maxWidth : 600 , margin : "0 auto" , width : "100%" }, children : [( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "标题" , style : { width : "100%" , padding : "10px 14px" , border : "1.5px solid var(--border)" , borderRadius : 6 , fontSize : 15 , fontWeight : 600 , marginBottom : 12 , fontFamily : "inherit" , background : "var(--bg)" , color : "var(--text)" }, value : i , onChange : e => l ( e . target . value )}),( 0 , r . jsx )( "textarea" ,{ rows : 6 , placeholder : "说点什么..." , style : { width : "100%" , padding : 12 , border : "1.5px solid var(--border)" , borderRadius : 6 , fontSize : 15 , fontFamily : "inherit" , resize : "vertical" , background : "var(--bg)" , color : "var(--text)" }, value : u , onChange : e => x ( e . target . value )}),( 0 , r . jsx )( "div" ,{ id : "imagePreview" , style : { display : "flex" , flexWrap : "wrap" , gap : 8 , margin : "8px 0" }, children : y . map (( e , t )=>( 0 , r . jsx )( "img" ,{ src : e , alt : "" , style : { width : 80 , height : 80 , objectFit : "cover" , borderRadius : 4 , border : "1px solid var(--border)" }}, t ))}),( 0 , r . jsx )( "div" ,{ id : "dropZone" , style : { border : "2px dashed " + ( N ? "var(--primary)" : "var(--border)" ), borderRadius : 8 , padding : 24 , textAlign : "center" , cursor : "pointer" , transition : "all 0.3s" , margin : "8px 0 12px" , background : N ? "var(--primary-bg)" : "var(--bg)" }, onClick : ()=>{ var e ; return null === ( e = R . current ) || void 0 === e ? void 0 : e . click ()}, onDragOver : e =>{ e . preventDefault (), D ( ! 0 )}, onDragLeave : e =>{ e . preventDefault (), D ( ! 1 )}, onDrop : e =>{ e . preventDefault (), D ( ! 1 ), e . dataTransfer . files && w ( Array . from ( e . dataTransfer . files ))}, children : ( 0 , r . jsx )( "div" ,{ style : { fontSize : 13 , color : "var(--text-secondary)" }, children : k ? "上传中..." : N ? "松开上传" : "\uD83D\uDCF7 点击或拖拽上传图片" })}),( 0 , r . jsx )( "input" ,{ type : "file" , id : "fileInput" , accept : "image/*" , multiple :! 0 , ref : R , style : { display : "none" }, onChange : e =>{ e . target . files && w ( Array . from ( e . target . files ))}}),( 0 , r . jsxs )( "div" ,{ className : "captcha-row" , style : { margin : "12px 0" , display : "flex" , alignItems : "center" , gap : 10 }, children : [ v ? ( 0 , r . jsx )( z ,{ captcha : v , onRefresh : ()=>{ j ( c ()), S ( "" )}}) : ( 0 , r . jsx )( "span" ,{ style : { color : "var(--text-light)" }, children : "验证码加载中..." }),( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "答案" , style : { width : 80 , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--bg)" , color : "var(--text)" , outline : "none" }, value : b , onChange : e => S ( e . target . value )})]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "10px 32px" , fontSize : 15 }, onClick : P , children : k ? "上传中..." : "发布帖子" })]})]})} let T = { pending : "⏳ 待处理" , approved : "✅ 已删除" , rejected : "❌ 已驳回" }; function _ (){ let [ e , t ] = ( 0 , s . useState )( null ),[ a , n ] = ( 0 , s . useState )( null ), i = ()=>{ o . getReports (). then ( e =>{ t ( e || []), n ( null )}). catch ( e =>{ n ( e . message ), t ([])})};( 0 , s . useEffect )( i ,[]); let l = async ( e , t )=>{ if ( "approve" !== t || confirm ( "确定要删除该帖子并标记举报为已处理吗?" )) try { await o . updateReport ( e . id , "approve" === t ? "approved" : "rejected" , "approve" === t ? "已删除违规帖子" : "举报不成立" ), "approve" === t && e . post_id && o . deletePost ( e . post_id ). catch (()=>{}), i ()} catch ( e ){ alert ( "操作失败:" + e . message )}}; return a ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : 20 }, children : [ "加载失败:" , a ]}) : e ? 0 === e . length ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 40 }, children : "✅ 暂无举报" }) : e . map ( e =>( 0 , r . jsxs )( "div" ,{ className : "report-item" , children : [( 0 , r . jsxs )( "div" ,{ children : [( 0 , r . jsx )( "strong" ,{ children : e . reporter_name || "匿名" }), " 举报了帖子" ]}),( 0 , r . jsxs )( "div" ,{ style : { fontSize : 13 , color : "#64748b" , margin : "4px 0" }, children : [ "原因:" , e . reason ]}),( 0 , r . jsxs )( "div" ,{ style : { fontSize : 13 , color : "#64748b" , margin : "4px 0" }, children : [ "帖子:" , e . post_title || "无标题" , " — " ,( e . post_content || "" ). substring ( 0 , 30 ),( e . post_content || "" ). length > 30 ? "..." : "" ]}),( 0 , r . jsxs )( "div" ,{ style : { fontSize : 13 , fontWeight : 600 }, children : [ "状态:" , T [ e . status ] || e . status ]}), e . handler_name && ( 0 , r . jsxs )( "div" ,{ style : { fontSize : 12 , color : "#94a3b8" }, children : [ "处理人:" , e . handler_name , e . handler_note ? " (" + e . handler_note + ")" : "" ]}), "pending" === e . status && ( 0 , r . jsxs )( "div" ,{ className : "report-actions" , children : [( 0 , r . jsxs )( "button" ,{ className : "btn-sm btn-danger" , onClick : ()=> l ( e , "approve" ), children : [( 0 , r . jsx )( m ,{ name : "trash" , size : 12 }), " 删除帖子" ]}),( 0 , r . jsxs )( "button" ,{ className : "btn-sm btn-secondary" , onClick : ()=> l ( e , "reject" ), children : [( 0 , r . jsx )( m ,{ name : "close" , size : 12 }), " 驳回举报" ]})]})]}, e . id )) : ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 20 }, children : "加载中..." })} function B (){ let { currentUser : e } = p (),[ t , a ] = ( 0 , s . useState )( null ),[ n , i ] = ( 0 , s . useState )( null ), l = ()=>{ o . getUsers (). then ( e =>{ a ( e || []), i ( null )}). catch ( e =>{ i ( e . message ), a ([])})};( 0 , s . useEffect )( l ,[]); let d = async ( e , t )=>{ let a = "admin" === t ? "管理员" : "普通用户" ; if ( confirm ( "确定要将该用户设为「" . concat ( a , "」吗?" ))) try { await o . updateUserRole ( e . id , t ), l ()} catch ( e ){ alert ( "操作失败:" + e . message )}}; return n ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : 20 }, children : [ "加载失败:" , n ]}) : t ? ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 , fontSize : 13 , color : "#94a3b8" }, children : [ "共 " ,( 0 , r . jsx )( "strong" ,{ children : t . length }), " 位用户" ]}),( 0 , r . jsx )( "div" ,{ style : { overflowX : "auto" }, children : ( 0 , r . jsxs )( "table" ,{ style : { width : "100%" , borderCollapse : "collapse" , fontSize : 14 }, children : [( 0 , r . jsx )( "thead" ,{ children : ( 0 , r . jsxs )( "tr" ,{ style : { textAlign : "left" , borderBottom : "2px solid var(--border)" }, children : [( 0 , r . jsx )( "th" ,{ style : { padding : "10px 12px" }, children : "用户" }),( 0 , r . jsx )( "th" ,{ style : { padding : "10px 12px" }, children : "角色" }),( 0 , r . jsx )( "th" ,{ style : { padding : "10px 12px" }, children : "注册时间" }),( 0 , r . jsx )( "th" ,{ style : { padding : "10px 12px" , textAlign : "center" }, children : "操作" })]})}),( 0 , r . jsx )( "tbody" ,{ children : t . map ( t =>{ let a = "admin" === t . role , s = e && e . id === t . id ; return ( 0 , r . jsxs )( "tr" ,{ style : { borderBottom : "1px solid #f1f5f9" }, children : [( 0 , r . jsx )( "td" ,{ style : { padding : "10px 12px" }, children : ( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , alignItems : "center" , gap : 8 }, children : [( 0 , r . jsx )( "img" ,{ src : t . avatar_url || "https://ui-avatars.com/api/?name=" + encodeURIComponent ( t . username ) + "&background=6366f1&color=fff&size=64" , style : { width : 28 , height : 28 , borderRadius : "50%" , objectFit : "cover" }, alt : "" }),( 0 , r . jsx )( "span" ,{ style : { fontWeight : 500 }, children : t . username }), s && ( 0 , r . jsx )( "span" ,{ style : { fontSize : 11 , color : "#94a3b8" , background : "#eef2ff" , padding : "1px 8px" , borderRadius : 4 }, children : "你" })]})}),( 0 , r . jsx )( "td" ,{ style : { padding : "10px 12px" }, children : ( 0 , r . jsx )( "span" ,{ style : { display : "inline-block" , padding : "2px 10px" , borderRadius : 4 , fontSize : 12 , fontWeight : 500 ,... a ? { background : "#6366f1" , color : "#fff" } : { background : "var(--border)" , color : "var(--text-secondary)" }}, children : a ? "管理员" : "普通用户" })}),( 0 , r . jsx )( "td" ,{ style : { padding : "10px 12px" , color : "#94a3b8" , fontSize : 13 }, children : t . created_at ? new Date ( t . created_at ). toLocaleDateString ( "zh-CN" ) : "—" }),( 0 , r . jsx )( "td" ,{ style : { padding : "10px 12px" , textAlign : "center" }, children : s ? ( 0 , r . jsx )( "span" ,{ style : { fontSize : 12 , color : "#94a3b8" }, children : "不可操作自己" }) : a ? ( 0 , r . jsx )( "button" ,{ className : "btn-sm btn-secondary" , style : { padding : "4px 12px" }, onClick : ()=> d ( t , "user" ), children : "设为普通用户" }) : ( 0 , r . jsx )( "button" ,{ className : "btn-sm btn-primary" , style : { padding : "4px 12px" , background : "#6366f1" , color : "#fff" , border : "none" , borderRadius : 4 , cursor : "pointer" }, onClick : ()=> d ( t , "admin" ), children : "设为管理员" })})]}, t . id )})})]})})]}) : ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 20 }, children : "加载中..." })} function M (){ let [ e , t ] = ( 0 , s . useState )( null ),[ a , n ] = ( 0 , s . useState )( null ); return (( 0 , s . useEffect )(()=>{ o . getEventLogs (). then ( e =>{ t ( e || []), n ( null )}). catch ( e =>{ n ( e . message ), t ([])})},[]), a ) ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : 20 }, children : [ "加载失败:" , a ]}) : e ? 0 === e . length ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 40 }, children : "暂无日志" }) : ( 0 , r . jsxs )( "table" ,{ style : { width : "100%" , borderCollapse : "collapse" , fontSize : 13 }, children : [( 0 , r . jsx )( "thead" ,{ children : ( 0 , r . jsxs )( "tr" ,{ style : { textAlign : "left" , borderBottom : "1px solid var(--border)" }, children : [( 0 , r . jsx )( "th" ,{ children : "时间" }),( 0 , r . jsx )( "th" ,{ children : "用户" }),( 0 , r . jsx )( "th" ,{ children : "操作" })]})}),( 0 , r . jsx )( "tbody" ,{ children : e . map ( e =>( 0 , r . jsxs )( "tr" ,{ style : { borderBottom : "1px solid #f1f5f9" }, children : [( 0 , r . jsx )( "td" ,{ style : { padding : "6px 0" }, children : new Date ( e . created_at ). toLocaleString ( "zh-CN" )}),( 0 , r . jsx )( "td" ,{ style : { padding : "6px 0" }, children : e . username || "系统" }),( 0 , r . jsx )( "td" ,{ style : { padding : "6px 0" }, children : e . action })]}, e . id ))})]}) : ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 20 }, children : "加载中..." })} function L (){ let [ e , t ] = ( 0 , s . useState )([]),[ a , n ] = ( 0 , s . useState )( "" ),[ i , l ] = ( 0 , s . useState )( "" ), d = ()=>{ o . getLinks (). then ( t ). catch (()=>{})};( 0 , s . useEffect )( d ,[]); let c = async ()=>{ if ( ! a . trim () ||! i . trim ()){ alert ( "请填写完整信息" ); return } try { await o . addLink ( a . trim (), i . trim ()), n ( "" ), l ( "" ), d ()} catch ( e ){ alert ( "添加失败:" + e . message )}}, u = async e =>{ if ( confirm ( "确定删除该链接吗?" )) try { await o . deleteLink ( e ), d ()} catch ( e ){ alert ( "删除失败:" + e . message )}}; return ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 16 , display : "flex" , gap : 8 , flexWrap : "wrap" }, children : [( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "链接名称" , style : { flex : 1 , minWidth : 120 , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--bg)" , color : "var(--text)" }, value : a , onChange : e => n ( e . target . value )}),( 0 , r . jsx )( "input" ,{ type : "url" , placeholder : "链接地址" , style : { flex : 2 , minWidth : 160 , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--bg)" , color : "var(--text)" }, value : i , onChange : e => l ( e . target . value )}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "8px 16px" }, onClick : c , children : "添加" })]}),( 0 , r . jsx )( "div" ,{ id : "linkList" , children : 0 === e . length ? ( 0 , r . jsx )( "div" ,{ style : { color : "#94a3b8" , fontSize : 13 }, children : "暂无友情链接" }) : e . map ( e =>( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "space-between" , alignItems : "center" , padding : "8px 0" , borderBottom : "1px solid #f1f5f9" }, children : [( 0 , r . jsx )( "span" ,{ children : ( 0 , r . jsx )( "a" ,{ href : e . url , target : "_blank" , rel : "noreferrer" , style : { color : "#6366f1" , textDecoration : "none" }, children : e . title })}),( 0 , r . jsxs )( "button" ,{ className : "btn-sm btn-danger" , onClick : ()=> u ( e . id ), children : [( 0 , r . jsx )( m ,{ name : "trash" , size : 12 }), " 删除" ]})]}, e . id ))})]})} function A (){ let { updateForumName : e } = p (),[ t , a ] = ( 0 , s . useState )( "" ),[ n , i ] = ( 0 , s . useState )( null );( 0 , s . useEffect )(()=>{ o . getSettings (). then ( e =>{ e . forum_name && a ( e . forum_name )}). catch (()=>{})},[]); let l = async ()=>{ if ( ! t . trim ()){ alert ( "请输入论坛名称" ); return } try { await o . updateSettings ( t . trim ()), e ( t . trim ()), i ({ ok :! 0 , msg : "✅ 保存成功!" })} catch ( e ){ i ({ ok :! 1 , msg : "❌ 保存失败" })}}; return ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsxs )( "h3" ,{ style : { marginBottom : 16 }, children : [( 0 , r . jsx )( m ,{ name : "settings" , size : 16 }), " 论坛设置" ]}),( 0 , r . jsxs )( "div" ,{ style : { maxWidth : 400 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 6 }, children : "论坛名称" }),( 0 , r . jsx )( "input" ,{ type : "text" , style : { width : "100%" , padding : "10px 14px" , border : "1.5px solid var(--border)" , borderRadius : 6 , fontSize : 15 , marginBottom : 12 , fontFamily : "inherit" , background : "var(--bg)" , color : "var(--text)" }, value : t , onChange : e => a ( e . target . value )}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "10px 24px" }, onClick : l , children : "保存" }), n && ( 0 , r . jsx )( "span" ,{ style : { marginLeft : 12 , fontSize : 14 , color : n . ok ? "#22c55e" : "#ef4444" }, children : n . msg })]})]})} function I ( e ){ let { page : t , onClose : a , onSaved : n } = e , i =!! t ,[ l , d ] = ( 0 , s . useState )(( null == t ? void 0 : t . name ) || "" ),[ c , u ] = ( 0 , s . useState )(( null == t ? void 0 : t . title ) || "" ),[ p , x ] = ( 0 , s . useState )(( null == t ? void 0 : t . content ) || "" ),[ h , m ] = ( 0 , s . useState )(( null == t ? void 0 : t . enabled ) !==! 1 ), g = async ()=>{ if ( ! l . trim ()){ alert ( "请输入页面名称" ); return } if ( ! c . trim ()){ alert ( "请输入导航栏显示名称" ); return } if ( ! p . trim ()){ alert ( "请输入页面内容" ); return } if ( ! /^[a-zA-Z0-9\-_]+$/ . test ( l . trim ())){ alert ( "页面名称只允许字母、数字、短横线和下划线" ); return } try { i ? await o . adminUpdateCustomPage ( t . id , c . trim (), p . trim (), h ) : await o . adminCreateCustomPage ( l . trim (), c . trim (), p . trim ()), n ()} catch ( e ){ alert ( "保存失败:" + e . message )}}; return ( 0 , r . jsx )( "div" ,{ className : "modal active" , style : { display : "flex" }, onClick : e =>{ e . target === e . currentTarget && a ()}, children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , style : { maxWidth : 600 , maxHeight : "90vh" , overflowY : "auto" , position : "relative" }, children : [( 0 , r . jsx )( "span" ,{ className : "close" , style : { position : "absolute" , top : 12 , right : 16 , fontSize : 24 , cursor : "pointer" , color : "var(--text-light)" }, onClick : a , children : "\xd7" }),( 0 , r . jsx )( "h2" ,{ style : { marginBottom : 16 }, children : i ? "✏️ 编辑页面" : "\uD83D\uDCC4 添加页面" }),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : "页面名称" }),( 0 , r . jsx )( "input" ,{ type : "text" , value : l , readOnly : i , placeholder : "about (用于 URL: ?custom=about)" , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : i ? "var(--border-light)" : "var(--bg)" , color : "var(--text)" }, onChange : e => d ( e . target . value )}), i ? ( 0 , r . jsx )( "div" ,{ style : { fontSize : 12 , color : "var(--text-light)" , marginTop : 2 }, children : "⚠️ 名称不可修改" }) : ( 0 , r . jsx )( "div" ,{ style : { fontSize : 12 , color : "var(--text-light)" , marginTop : 2 }, children : "只允许字母、数字、短横线和下划线" })]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : "导航栏显示名称" }),( 0 , r . jsx )( "input" ,{ type : "text" , value : c , placeholder : "关于我们" , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => u ( e . target . value )})]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : "状态" }),( 0 , r . jsxs )( "select" ,{ value : String ( h ), style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => m ( "true" === e . target . value ), children : [( 0 , r . jsx )( "option" ,{ value : "true" , children : "启用" }),( 0 , r . jsx )( "option" ,{ value : "false" , children : "禁用" })]})]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : "页面内容(HTML + CSS + JS) " }),( 0 , r . jsx )( "textarea" ,{ rows : 12 , value : p , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 13 , fontFamily : "monospace" , background : "var(--bg)" , color : "var(--text)" , resize : "vertical" }, onChange : e => x ( e . target . value )}),( 0 , r . jsx )( "div" ,{ style : { fontSize : 12 , color : "var(--text-light)" , marginTop : 2 }, children : "支持 HTML、CSS( <style>)、JS( <script>),内容会在独立的沙盒中渲染" })]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "10px 24px" , width : "100%" }, onClick : g , children : "保存" })]})})} function W (){ let [ e , t ] = ( 0 , s . useState )( null ),[ a , n ] = ( 0 , s . useState )( null ),[ i , l ] = ( 0 , s . useState )( null ), d = ()=>{ o . adminGetCustomPages (). then ( e =>{ t ( e || []), n ( null )}). catch ( e =>{ n ( e . message ), t ([])})};( 0 , s . useEffect )( d ,[]); let c = async e =>{ if ( confirm ( "确定要删除这个页面吗?" )) try { await o . adminDeleteCustomPage ( e . id ), d ()} catch ( e ){ alert ( "删除失败:" + e . message )}}; return a ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : 20 }, children : [ "加载失败:" , a ]}) : ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "space-between" , alignItems : "center" , marginBottom : 16 }, children : [( 0 , r . jsx )( "h3" ,{ style : { margin : 0 }, children : "\uD83D\uDCC4 自定义页面" }),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "8px 16px" }, onClick : ()=> l ( "new" ), children : "➕ 添加页面" })]}),( 0 , r . jsx )( "div" ,{ id : "customPageList" , children : null === e ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 20 }, children : "加载中..." }) : 0 === e . length ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : 20 }, children : "暂无自定义页面" }) : ( 0 , r . jsx )( "div" ,{ style : { overflowX : "auto" }, children : ( 0 , r . jsxs )( "table" ,{ style : { width : "100%" , borderCollapse : "collapse" , fontSize : 14 }, children : [( 0 , r . jsx )( "thead" ,{ children : ( 0 , r . jsxs )( "tr" ,{ style : { textAlign : "left" , borderBottom : "2px solid var(--border)" }, children : [( 0 , r . jsx )( "th" ,{ style : { padding : "8px 12px" }, children : "名称" }),( 0 , r . jsx )( "th" ,{ style : { padding : "8px 12px" }, children : "标题" }),( 0 , r . jsx )( "th" ,{ style : { padding : "8px 12px" }, children : "URL" }),( 0 , r . jsx )( "th" ,{ style : { padding : "8px 12px" }, children : "状态" }),( 0 , r . jsx )( "th" ,{ style : { padding : "8px 12px" , textAlign : "center" }, children : "操作" })]})}),( 0 , r . jsx )( "tbody" ,{ children : e . map ( e =>( 0 , r . jsxs )( "tr" ,{ style : { borderBottom : "1px solid var(--border-light)" }, children : [( 0 , r . jsx )( "td" ,{ style : { padding : "8px 12px" }, children : ( 0 , r . jsx )( "code" ,{ style : { background : "var(--bg)" , padding : "2px 6px" , borderRadius : 4 , fontSize : 12 }, children : e . name })}),( 0 , r . jsx )( "td" ,{ style : { padding : "8px 12px" }, children : e . title }),( 0 , r . jsx )( "td" ,{ style : { padding : "8px 12px" }, children : ( 0 , r . jsxs )( "code" ,{ style : { background : "var(--bg)" , padding : "2px 6px" , borderRadius : 4 , fontSize : 12 }, children : [ "?custom=" , e . name ]})}),( 0 , r . jsx )( "td" ,{ style : { padding : "8px 12px" }, children : ( 0 , r . jsx )( "span" ,{ style : { color : e . enabled ? "#22c55e" : "#ef4444" }, children : e . enabled ? "✅ 启用" : "❌ 禁用" })}),( 0 , r . jsxs )( "td" ,{ style : { padding : "8px 12px" , textAlign : "center" , display : "flex" , gap : 6 , justifyContent : "center" }, children : [( 0 , r . jsx )( "button" ,{ className : "btn-sm btn-secondary" , onClick : ()=> l ( e ), children : "✏️" }),( 0 , r . jsx )( "button" ,{ className : "btn-sm btn-danger" , onClick : ()=> c ( e ), children : "\uD83D\uDDD1️ " })]})]}, e . id ))})]})})}), i && ( 0 , r . jsx )( I ,{ page : "new" === i ? null : i , onClose : ()=> l ( null ), onSaved : ()=>{ l ( null ), d ()}})]})} function U (){ let [ e , t ] = ( 0 , s . useState )( null ),[ a , n ] = ( 0 , s . useState )( ! 1 ),[ i , l ] = ( 0 , s . useState )( null ), d = ( 0 , s . useRef )( null ), c = async e =>{ if ( e ){ if ( "style.css" !== e . name ){ t ({ ok :! 1 , msg : "❌ 文件名必须是 style.css" }); return } if ( e . size > 1048576 ){ t ({ ok :! 1 , msg : "❌ CSS 文件不能超过 1MB" }); return } l ( e )}}, u = async ()=>{ try { await o . uploadCustomCss ( i ), t ({ ok :! 0 , msg : "✅ 自定义 CSS 已生效(刷新页面后应用)" }); let e = document . getElementById ( "custom-css-link" ); e && ( e . href = "/api/custom-css?t=" + Date . now ())} catch ( e ){ t ({ ok :! 1 , msg : "❌ " + e . message })} finally { l ( null )}}, p = async ()=>{ if ( confirm ( "确定要删除自定义 CSS 吗?" )) try { await o . deleteCustomCss (), t ({ ok :! 0 , msg : "✅ 已删除自定义 CSS" }); let e = document . getElementById ( "custom-css-link" ); e && e . remove ()} catch ( e ){ t ({ ok :! 1 , msg : "❌ " + e . message })}}; return ( 0 , r . jsxs )( r . Fragment ,{ children : [( 0 , r . jsx )( "h3" ,{ style : { marginBottom : 16 }, children : "\uD83C\uDFA8 自定义 CSS" }),( 0 , r . jsxs )( "p" ,{ style : { fontSize : 13 , color : "var(--text-secondary)" , marginBottom : 12 }, children : [ "上传一个 " ,( 0 , r . jsx )( "code" ,{ children : "style.css" }), " 文件覆盖默认样式(支持 CSS 变量、暗色模式等)。" ]}),( 0 , r . jsx )( "div" ,{ style : { border : "2px dashed " + ( a ? "var(--primary)" : "var(--border)" ), borderRadius : 8 , padding : 32 , textAlign : "center" , cursor : "pointer" , transition : "all 0.3s" , background : a ? "var(--primary-bg)" : "var(--bg)" }, onClick : ()=>{ var e ; return null === ( e = d . current ) || void 0 === e ? void 0 : e . click ()}, onDragOver : e =>{ e . preventDefault (), n ( ! 0 )}, onDragLeave : ()=> n ( ! 1 ), onDrop : e =>{ var t ; e . preventDefault (), n ( ! 1 ),( null === ( t = e . dataTransfer . files ) || void 0 === t ? void 0 : t [ 0 ]) && c ( e . dataTransfer . files [ 0 ])}, children : ( 0 , r . jsx )( "span" ,{ style : { fontSize : 13 , color : "var(--text-secondary)" }, children : a ? "松开上传" : "\uD83D\uDCC4 点击或拖拽上传 style.css" })}),( 0 , r . jsx )( "input" ,{ type : "file" , ref : d , accept : ".css" , style : { display : "none" }, onChange : e =>{ var t ;( null === ( t = e . target . files ) || void 0 === t ? void 0 : t [ 0 ]) && c ( e . target . files [ 0 ])}}), e && ( 0 , r . jsx )( "div" ,{ style : { fontSize : 13 , marginTop : 8 , color : e . ok ? "#22c55e" : "#ef4444" }, children : e . msg }),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , gap : 8 , marginTop : 16 }, children : [( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "8px 20px" }, onClick : ()=>{ var e ; return null === ( e = d . current ) || void 0 === e ? void 0 : e . click ()}, children : "\uD83D\uDCBE 保存 CSS" }),( 0 , r . jsx )( "button" ,{ className : "btn-secondary" , style : { padding : "8px 20px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : p , children : "\uD83D\uDDD1️ 删除自定义 CSS" })]}), i && ( 0 , r . jsx )( "div" ,{ className : "modal active" , style : { display : "flex" }, onClick : ()=> l ( null ), children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , style : { maxWidth : 420 }, onClick : e => e . stopPropagation (), children : [( 0 , r . jsx )( "h2" ,{ style : { marginBottom : 12 }, children : "⚠️ 警告" }),( 0 , r . jsxs )( "p" ,{ style : { fontSize : 14 , color : "var(--text-secondary)" , marginBottom : 16 }, children : [ "若上传的 " ,( 0 , r . jsx )( "strong" ,{ children : "style.css" }), " 存在问题,将导致整个论坛界面样式错乱,甚至无法正常使用。" ]}),( 0 , r . jsx )( "p" ,{ style : { fontSize : 13 , color : "var(--text-light)" , marginBottom : 20 }, children : "请确保 CSS 文件是完整的、经过测试的版本。如出现问题,可点击「删除自定义 CSS」恢复默认样式。" }),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , gap : 8 }, children : [( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { padding : "8px 24px" }, onClick : u , children : "我了解,继续上传" }),( 0 , r . jsx )( "button" ,{ className : "btn-secondary" , style : { padding : "8px 24px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : ()=> l ( null ), children : "取消" })]})]})})]})} let F = [{ key : "reports" , label : "举报" , icon : "shieldAlert" },{ key : "users" , label : "用户" , icon : "users" },{ key : "logs" , label : "日志" , icon : "file" },{ key : "links" , label : "友链" , icon : "link" },{ key : "settings" , label : "论坛设置" , icon : "settings" },{ key : "custom" , label : "自定义页面" , icon : "file" },{ key : "css" , label : "自定义CSS" , icon : "file" }]; function O (){ let [ e , t ] = ( 0 , s . useState )( "reports" ); return ( 0 , r . jsxs )( "div" ,{ className : "page-slide active" , children : [( 0 , r . jsx )( "div" ,{ className : "page-header" , style : { maxWidth : 1200 , margin : "0 auto" , width : "100%" }, children : ( 0 , r . jsxs )( "h2" ,{ children : [( 0 , r . jsx )( m ,{ name : "shieldAlert" , size : 20 }), " 管理后台" ]})}),( 0 , r . jsxs )( "div" ,{ className : "admin-layout" , style : { maxWidth : 1200 , margin : "0 auto" , width : "100%" }, children : [( 0 , r . jsx )( "aside" ,{ className : "admin-sidebar" , children : ( 0 , r . jsx )( "nav" ,{ className : "admin-nav" , children : F . map ( a =>( 0 , r . jsxs )( "a" ,{ href : "#" , className : "admin-nav-item" + ( e === a . key ? " active" : "" ), "data-tab" : a . key , onClick : e =>{ e . preventDefault (), t ( a . key )}, children : [( 0 , r . jsx )( "span" ,{ className : "nav-icon" , children : ( 0 , r . jsx )( m ,{ name : a . icon , size : 18 })}), a . label ]}, a . key ))})}),( 0 , r . jsxs )( "main" ,{ className : "admin-content" , id : "adminContent" , children : [ "reports" === e && ( 0 , r . jsx )( _ ,{}), "users" === e && ( 0 , r . jsx )( B ,{}), "logs" === e && ( 0 , r . jsx )( M ,{}), "links" === e && ( 0 , r . jsx )( L ,{}), "custom" === e && ( 0 , r . jsx )( W ,{}), "css" === e && ( 0 , r . jsx )( U ,{}), "settings" === e && ( 0 , r . jsx )( A ,{})]})]})]})} function H (){ let { currentUser : e , setCurrentUser : t } = p (),[ a , n ] = ( 0 , s . useState )(( null == e ? void 0 : e . username ) || "" ),[ i , l ] = ( 0 , s . useState )(( null == e ? void 0 : e . bio ) || "" ),[ c , u ] = ( 0 , s . useState )(( null == e ? void 0 : e . signature ) || "" ),[ x , h ] = ( 0 , s . useState )(( null == e ? void 0 : e . avatar_url ) || "" ),[ m , g ] = ( 0 , s . useState )( null ), y = ( 0 , s . useRef )( null ), f = async a =>{ if ( a ){ if ( ! a . type . startsWith ( "image/" )){ g ({ ok :! 1 , msg : "❌ 请选择图片文件" }); return } if ( a . size > 5242880 ){ g ({ ok :! 1 , msg : "❌ 图片不能超过 5MB" }); return } try { let r = await d ( a ); await o . updateAvatar ( e . id , r ), h ( r ), t ({... e , avatar_url : r }), g ({ ok :! 0 , msg : "✅ 头像已更新" })} catch ( e ){ g ({ ok :! 1 , msg : "❌ " + e . message })}}}, v = async ()=>{ if ( ! e ){ alert ( "请先登录" ); return } if ( ! a . trim ()){ alert ( "用户名不能为空" ); return } try { let r = await o . updateProfile ( e . id , a . trim (), i . trim (), c . trim ()); if ( r . error ) throw Error ( r . error ); t ({... e , username : a . trim (), bio : i . trim (), signature : c . trim ()}), alert ( "保存成功!" )} catch ( e ){ alert ( "保存失败:" + e . message )}}, j = x || "https://ui-avatars.com/api/?name=" + encodeURIComponent (( null == e ? void 0 : e . username ) || "U" ) + "&background=6366f1&color=fff&size=128" ; return ( 0 , r . jsxs )( "div" ,{ children : [( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , marginBottom : 24 }, children : [( 0 , r . jsxs )( "div" ,{ style : { position : "relative" , display : "inline-block" }, children : [( 0 , r . jsx )( "img" ,{ src : j , style : { width : 100 , height : 100 , borderRadius : "50%" , objectFit : "cover" , border : "3px solid var(--primary)" }, alt : "" }),( 0 , r . jsx )( "button" ,{ style : { position : "absolute" , bottom : 0 , right : 0 , background : "var(--primary)" , color : "#fff" , border : "none" , borderRadius : "50%" , width : 32 , height : 32 , cursor : "pointer" , fontSize : 16 , display : "flex" , alignItems : "center" , justifyContent : "center" , boxShadow : "0 2px 8px rgba(99,102,241,0.4)" }, onClick : ()=>{ var e ; return null === ( e = y . current ) || void 0 === e ? void 0 : e . click ()}, children : "\uD83D\uDCF7" })]}),( 0 , r . jsx )( "input" ,{ type : "file" , ref : y , accept : "image/*" , style : { display : "none" }, onChange : e =>{ var t ;( null === ( t = e . target . files ) || void 0 === t ? void 0 : t [ 0 ]) && f ( e . target . files [ 0 ])}}),( 0 , r . jsx )( "h2" ,{ style : { margin : "12px 0 4px" }, children : null == e ? void 0 : e . username }),( 0 , r . jsx )( "p" ,{ style : { color : "var(--text-secondary)" , fontSize : 14 }, children : i || "这个人很懒,什么都没写" }), m && ( 0 , r . jsx )( "div" ,{ style : { fontSize : 13 , marginTop : 8 , color : m . ok ? "#22c55e" : "#ef4444" }, children : m . msg })]}),( 0 , r . jsxs )( "div" ,{ style : { background : "var(--surface)" , border : "1px solid var(--border)" , borderRadius : 8 , padding : 20 }, children : [( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 16 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : "用户名" }),( 0 , r . jsx )( "input" ,{ type : "text" , value : a , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => n ( e . target . value )})]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 16 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : "个人简介" }),( 0 , r . jsx )( "textarea" ,{ rows : 3 , value : i , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" , resize : "vertical" }, onChange : e => l ( e . target . value )})]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 16 }, children : [( 0 , r . jsxs )( "label" ,{ style : { fontWeight : 600 , fontSize : 14 , display : "block" , marginBottom : 4 }, children : [ "个性签名 " ,( 0 , r . jsx )( "span" ,{ style : { color : "var(--text-light)" , fontWeight : 400 }, children : "(显示在每篇帖子底部,支持 Markdown) " })]}),( 0 , r . jsx )( "textarea" ,{ rows : 2 , value : c , placeholder : "签名..." , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" , resize : "vertical" , fontFamily : "inherit" }, onChange : e => u ( e . target . value )})]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { width : "100%" , padding : 10 }, onClick : v , children : "保存设置" })]})]})} function J (){ let { currentUser : e } = p (),[ t , a ] = ( 0 , s . useState )( "" ),[ n , i ] = ( 0 , s . useState )( "" ),[ l , d ] = ( 0 , s . useState )( null ),[ c , u ] = ( 0 , s . useState )( "" ),[ x , h ] = ( 0 , s . useState )( "" ),[ m , g ] = ( 0 , s . useState )( null ), y = async ()=>{ if ( ! t ||! n ){ alert ( "请填写完整信息" ); return } if ( n . length < 6 ){ alert ( "新密码至少6位" ); return } try { await o . updatePassword ( e . id , t , n ), d ({ ok :! 0 , msg : "✅ 密码修改成功" }), a ( "" ), i ( "" )} catch ( e ){ d ({ ok :! 1 , msg : "❌ " + e . message })}}, f = async ()=>{ if ( ! c ||! x ){ alert ( "请填写完整信息" ); return } try { await o . updateEmail ( e . id , c , x ), g ({ ok :! 0 , msg : "✅ 邮箱修改成功" }), u ( "" ), h ( "" )} catch ( e ){ g ({ ok :! 1 , msg : "❌ " + e . message })}}; return ( 0 , r . jsxs )( "div" ,{ style : { marginTop : 16 , background : "var(--surface)" , border : "1px solid var(--border)" , borderRadius : 8 , padding : 20 }, children : [( 0 , r . jsx )( "h3" ,{ style : { fontSize : 16 , marginBottom : 12 }, children : "\uD83D\uDD12 账户安全" }),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 13 , display : "block" , marginBottom : 4 }, children : "当前密码" }),( 0 , r . jsx )( "input" ,{ type : "password" , value : t , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => a ( e . target . value )})]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 13 , display : "block" , marginBottom : 4 }, children : "新密码" }),( 0 , r . jsx )( "input" ,{ type : "password" , value : n , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => i ( e . target . value )})]}),( 0 , r . jsx )( "button" ,{ className : "btn-secondary" , style : { padding : "8px 16px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : y , children : "修改密码" }), l && ( 0 , r . jsx )( "div" ,{ style : { fontSize : 13 , marginTop : 6 , color : l . ok ? "#22c55e" : "#ef4444" }, children : l . msg }),( 0 , r . jsx )( "div" ,{ style : { borderTop : "1px solid var(--border)" , margin : "16px 0" }}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 13 , display : "block" , marginBottom : 4 }, children : "当前密码(验证身份)" }),( 0 , r . jsx )( "input" ,{ type : "password" , value : c , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => u ( e . target . value )})]}),( 0 , r . jsxs )( "div" ,{ style : { marginBottom : 12 }, children : [( 0 , r . jsx )( "label" ,{ style : { fontWeight : 600 , fontSize : 13 , display : "block" , marginBottom : 4 }, children : "新邮箱" }),( 0 , r . jsx )( "input" ,{ type : "email" , value : x , style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , fontSize : 14 , background : "var(--bg)" , color : "var(--text)" }, onChange : e => h ( e . target . value )})]}),( 0 , r . jsx )( "button" ,{ className : "btn-secondary" , style : { padding : "8px 16px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : f , children : "修改邮箱" }), m && ( 0 , r . jsx )( "div" ,{ style : { fontSize : 13 , marginTop : 6 , color : m . ok ? "#22c55e" : "#ef4444" }, children : m . msg })]})} var V = a ( 4887 ); function q (){ let [ e , t ] = ( 0 , s . useState )( 0 ),[ a , n ] = ( 0 , s . useState )( null ), i = ()=>{ o . getRecoveryCodeCount (). then ( e => t ( e . count || 0 )). catch (()=>{})};( 0 , s . useEffect )( i ,[]); let l = async ()=>{ if ( confirm ( "重新生成将使所有旧恢复码失效,确定继续吗?" )) try { let e = await o . generateRecoveryCodes (); n ({ codes : e . codes || [], isNew :! 0 }), i ()} catch ( e ){ alert ( "生成失败:" + e . message )}}, d = async ()=>{ try { let e = await o . generateRecoveryCodes (); n ({ codes : e . codes || [], isNew :! 1 }), i ()} catch ( e ){ alert ( "获取失败:" + e . message )}}; return ( 0 , r . jsxs )( "div" ,{ style : { marginTop : 16 , background : "var(--surface)" , border : "1px solid var(--border)" , borderRadius : 8 , padding : 20 }, children : [( 0 , r . jsx )( "h3" ,{ style : { fontSize : 16 , marginBottom : 8 }, children : "\uD83D\uDD11 恢复码" }),( 0 , r . jsx )( "p" ,{ style : { fontSize : 13 , color : "var(--text-secondary)" , marginBottom : 12 }, children : "用于忘记密码时重置账户。每个恢复码只能使用一次。" }),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , gap : 8 , flexWrap : "wrap" }, children : [( 0 , r . jsx )( "button" ,{ className : "btn-secondary" , style : { padding : "8px 16px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : d , children : "\uD83D\uDCCB 查看恢复码" }),( 0 , r . jsx )( "button" ,{ className : "btn-secondary" , style : { padding : "8px 16px" , border : "1px solid var(--border)" , borderRadius : 4 , background : "var(--surface)" , cursor : "pointer" , color : "var(--text)" }, onClick : l , children : "\uD83D\uDD04 重新生成" })]}),( 0 , r . jsxs )( "div" ,{ id : "recoveryCodesStatus" , style : { fontSize : 13 , color : "var(--text-light)" , marginTop : 8 }, children : [ "剩余 " , e , " 个可用恢复码" ]}), a && "undefined" != typeof document && ( 0 , V . createPortal )(( 0 , r . jsx )( "div" ,{ className : "modal active" , style : { display : "flex" }, onClick : e =>{ e . target === e . currentTarget && n ( null )}, children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , style : { maxWidth : 480 , position : "relative" }, children : [( 0 , r . jsx )( "span" ,{ className : "close" , style : { position : "absolute" , top : 12 , right : 16 , fontSize : 24 , cursor : "pointer" , color : "var(--text-light)" }, onClick : ()=> n ( null ), children : "\xd7" }),( 0 , r . jsx )( "h2" ,{ style : { marginBottom : 12 }, children : a . isNew ? "\uD83C\uDD95 新恢复码" : "\uD83D\uDD11 恢复码" }),( 0 , r . jsx )( "p" ,{ style : { fontSize : 13 , color : "#ef4444" , marginBottom : 12 }, children : "⚠️ 请妥善保存这些恢复码,关闭窗口后无法再次查看。" }),( 0 , r . jsx )( "div" ,{ style : { display : "grid" , gridTemplateColumns : "1fr 1fr" , gap : 8 }, children : a . codes . map (( e , t )=>( 0 , r . jsx )( "code" ,{ style : { background : "var(--bg)" , padding : "8px 12px" , borderRadius : 6 , fontSize : 13 , textAlign : "center" , userSelect : "all" }, children : e }, t ))}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { width : "100%" , padding : 10 , marginTop : 16 }, onClick : ()=> n ( null ), children : "我已保存" })]})}), document . body )]})} let K = [{ key : "profile" , label : "个人资料" , icon : "user" },{ key : "security" , label : "安全设置" , icon : "shieldAlert" },{ key : "recovery" , label : "恢复码" , icon : "lock" }]; function Y (){ let [ e , t ] = ( 0 , s . useState )( "profile" ); return ( 0 , r . jsxs )( "div" ,{ className : "page-slide active" , children : [( 0 , r . jsx )( "div" ,{ className : "page-header" , style : { maxWidth : 1200 , margin : "0 auto" , width : "100%" }, children : ( 0 , r . jsxs )( "h2" ,{ children : [( 0 , r . jsx )( m ,{ name : "settings" , size : 20 }), " 设置" ]})}),( 0 , r . jsxs )( "div" ,{ className : "settings-layout" , style : { maxWidth : 1200 , margin : "0 auto" , width : "100%" , display : "flex" , gap : 28 , alignItems : "flex-start" }, children : [( 0 , r . jsx )( "aside" ,{ className : "settings-sidebar" , style : { width : 200 , flexShrink : 0 }, children : ( 0 , r . jsx )( "nav" ,{ className : "settings-nav" , children : K . map ( a =>( 0 , r . jsxs )( "a" ,{ href : "#" , className : "settings-nav-item" + ( e === a . key ? " active" : "" ), "data-settings-tab" : a . key , onClick : e =>{ e . preventDefault (), t ( a . key )}, children : [( 0 , r . jsx )( "span" ,{ className : "nav-icon" , children : ( 0 , r . jsx )( m ,{ name : a . icon , size : 18 })}), a . label ]}, a . key ))})}),( 0 , r . jsxs )( "main" ,{ className : "settings-content" , id : "settingsContent" , children : [ "profile" === e && ( 0 , r . jsx )( H ,{}), "security" === e && ( 0 , r . jsx )( J ,{}), "recovery" === e && ( 0 , r . jsx )( q ,{})]})]})]})} function G ( e ){ let { username : t } = e ,{ currentUser : a , openPost : n } = p (), i = function (){ let { currentUser : e } = p (); return async ( t , a )=>{ if ( ! e ){ alert ( "请先登录" ); return } try { let e = await o . getOrCreateConversation ( t ); window . dispatchEvent ( new CustomEvent ( "forumlify-open-chat" ,{ detail : { conversationId : e . id , otherUserId : t , otherUsername : a }}))} catch ( e ){ alert ( "打开私信失败:" + e . message )}}}(),[ l , d ] = ( 0 , s . useState )( null ),[ c , u ] = ( 0 , s . useState )([]),[ x , h ] = ( 0 , s . useState )( null ), g = ( 0 , s . useCallback )( async ()=>{ h ( null ); try { let e = await o . getUsersByUsername ( t ), a = e && e . length > 0 ? e [ 0 ] : null ; if ( ! a ){ h ( "用户不存在" ); return } d ( a ); let r = await o . getPosts ( "latest" , a . id ); u ( r . data || [])} catch ( e ){ h ( e . message || "加载失败" )}},[ t ]); return (( 0 , s . useEffect )(()=>{ g ()},[ g ]), x ) ? ( 0 , r . jsx )( "div" ,{ className : "page-slide active" , children : ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : "40px 0" }, children : [ "加载失败:" , x ]})}) : l ? ( 0 , r . jsxs )( "div" ,{ className : "page-slide active" , children : [( 0 , r . jsx )( "div" ,{ className : "page-header" , style : { maxWidth : 700 , margin : "0 auto" , width : "100%" }, children : ( 0 , r . jsxs )( "h2" ,{ children : [( 0 , r . jsx )( m ,{ name : "users" , size : 20 }), " 用户主页" ]})}),( 0 , r . jsxs )( "div" ,{ style : { maxWidth : 700 , margin : "0 auto" , width : "100%" }, children : [( 0 , r . jsxs )( "div" ,{ style : { background : "var(--surface)" , border : "1px solid var(--border)" , borderRadius : 8 , padding : 32 , textAlign : "center" }, children : [( 0 , r . jsx )( "img" ,{ src : function ( e ){ let t = arguments . length > 1 && void 0 !== arguments [ 1 ] ? arguments [ 1 ] : 128 ; return "https://ui-avatars.com/api/?name=" + encodeURIComponent ( e || "U" ) + "&background=6366f1&color=fff&size=" + t }( l . username ), style : { width : 96 , height : 96 , borderRadius : "50%" , objectFit : "cover" , border : "3px solid var(--primary)" }, alt : "" }),( 0 , r . jsx )( "h2" ,{ style : { margin : "16px 0 4px" , fontSize : 24 }, children : l . username }),( 0 , r . jsx )( "p" ,{ style : { color : "var(--text-secondary)" , fontSize : 14 }, children : l . bio || "这个人很懒,什么都没写" }), a && a . id !== l . id && ( 0 , r . jsxs )( "button" ,{ className : "btn-primary" , style : { marginTop : 12 , padding : "8px 20px" }, onClick : ()=> i ( l . id , l . username ), children : [( 0 , r . jsx )( m ,{ name : "message" , size : 14 }), " 发私信" ]}),( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , justifyContent : "center" , gap : 32 , marginTop : 16 , fontSize : 14 , color : "var(--text-secondary)" , flexWrap : "wrap" }, children : [( 0 , r . jsxs )( "span" ,{ children : [ "\uD83D\uDCC5 加入于 " , l . created_at ? new Date ( l . created_at ). toLocaleDateString ( "zh-CN" ) : "未知" ]}),( 0 , r . jsxs )( "span" ,{ children : [ "\uD83D\uDCDD 发了 " , c . length , " 个帖子" ]}), "admin" === l . role && ( 0 , r . jsx )( "span" ,{ style : { color : "var(--primary)" , fontWeight : 600 }, children : "\uD83D\uDEE1️ 管理员" })]})]}),( 0 , r . jsx )( "h3" ,{ style : { margin : "24px 0 16px" , fontSize : 18 }, children : "\uD83D\uDCDD 发布的帖子" }), 0 === c . length ? ( 0 , r . jsx )( "div" ,{ style : { color : "#94a3b8" , padding : "20px 0" , textAlign : "center" }, children : "还没有发帖" }) : c . map ( e =>{ let t = e . created_at ? new Date ( e . created_at ). toLocaleString ( "zh-CN" ) : "" ; return ( 0 , r . jsxs )( "div" ,{ className : "post-card" , style : { cursor : "pointer" }, onClick : ()=> n ( e . id ), children : [( 0 , r . jsx )( "div" ,{ className : "post-title" , style : { fontSize : 16 , fontWeight : 600 }, children : e . title || "无标题" }),( 0 , r . jsxs )( "div" ,{ className : "post-content" , style : { fontSize : 14 , color : "var(--text-secondary)" }, children : [( e . content || "" ). substring ( 0 , 100 ),( e . content || "" ). length > 100 ? "..." : "" ]}),( 0 , r . jsx )( "div" ,{ style : { fontSize : 12 , color : "var(--text-light)" , marginTop : 8 }, children : t })]}, e . id )})]})]}) : ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "加载中..." })} function X ( e ){ let { pageName : t } = e ,[ a , n ] = ( 0 , s . useState )( null ),[ i , l ] = ( 0 , s . useState )( null ); return (( 0 , s . useEffect )(()=>{ n ( null ), l ( null ), o . getCustomPage ( t ). then ( e => n ( e . content )). catch ( e => l ( e . message ))},[ t ]), i ) ? ( 0 , r . jsxs )( "div" ,{ style : { padding : "84px 32px" , textAlign : "center" , color : "#ef4444" }, children : [ "页面加载失败:" , i ]}) : null === a ? ( 0 , r . jsx )( "div" ,{ style : { padding : "84px 32px" , textAlign : "center" , color : "#94a3b8" }, children : "加载中..." }) : ( 0 , r . jsx )( "div" ,{ style : { padding : "84px 32px 40px" , background : "var(--bg)" , minHeight : "100vh" }, children : ( 0 , r . jsx )( "iframe" ,{ style : { width : "100%" , minHeight : "70vh" , border : "none" , borderRadius : 8 , background : "var(--surface)" }, sandbox : "allow-scripts allow-modals allow-same-origin" , srcDoc : '<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<meta name="viewport" content="width=device-width, initial-scale=1.0">\n<style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body {\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n padding: 24px;\n background: var(--bg, #f6f8fc);\n color: var(--text, #0a0e1a);\n }\n @media (prefers-color-scheme: dark) {\n body { background: #0f1117; color: #e8edf5; }\n }\n</style>\n</head>\n<body>' . concat ( a , "</body>\n</html>" ), title : t })})} let Z = { reply : "\uD83D\uDCAC" , post_deleted : "\uD83D\uDDD1️ " , report_handled : "\uD83D\uDEE1️ " , system : "\uD83D\uDCE2" }; function $ (){ let { currentUser : e } = p (),[ t , a ] = ( 0 , s . useState )( null ),[ n , i ] = ( 0 , s . useState )( null ); return (( 0 , s . useEffect )(()=>{ e && o . getNotifications (). then ( e =>{ a ( e || []), i ( null ), o . markAllNotificationsRead (). catch (()=>{})}). catch ( e =>{ i ( e . message ), a ([])})},[ e ]), e ) ? ( 0 , r . jsxs )( "div" ,{ className : "page-slide active" , children : [( 0 , r . jsx )( "div" ,{ className : "page-header" , style : { maxWidth : 700 , margin : "0 auto" , width : "100%" }, children : ( 0 , r . jsxs )( "h2" ,{ children : [( 0 , r . jsx )( m ,{ name : "message" , size : 20 }), " 消息" ]})}),( 0 , r . jsx )( "div" ,{ style : { maxWidth : 700 , margin : "0 auto" , width : "100%" }, children : n ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#ef4444" , padding : 20 }, children : [ "加载失败:" , n ]}) : null === t ? ( 0 , r . jsx )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "加载中..." }) : 0 === t . length ? ( 0 , r . jsxs )( "div" ,{ style : { textAlign : "center" , color : "#94a3b8" , padding : "60px 0" }, children : [( 0 , r . jsx )( m ,{ name : "message" , size : 48 }),( 0 , r . jsx )( "p" ,{ style : { fontSize : 16 }, children : "暂无消息" }),( 0 , r . jsx )( "p" ,{ style : { fontSize : 13 }, children : "当有人回复你的帖子或处理你的举报时,会在这里通知你" })]}) : t . map ( e =>{ let t = Z [ e . type ] || "\uD83D\uDCCC" , a = e . created_at ? new Date ( e . created_at ). toLocaleString ( "zh-CN" ) : "" ; return ( 0 , r . jsxs )( "div" ,{ style : { display : "flex" , alignItems : "flex-start" , gap : 12 , padding : "14px 16px" , borderBottom : "1px solid var(--border-light)" , background : "var(--surface)" , borderRadius : 6 , marginBottom : 6 }, children : [( 0 , r . jsx )( "span" ,{ style : { fontSize : 20 }, children : t }),( 0 , r . jsxs )( "div" ,{ style : { flex : 1 , minWidth : 0 }, children : [( 0 , r . jsx )( "div" ,{ style : { fontWeight : 600 , fontSize : 14 }, children : e . title }),( 0 , r . jsx )( "div" ,{ style : { color : "var(--text-secondary)" , fontSize : 13 , marginTop : 2 }, children : e . content }), e . link && ( 0 , r . jsx )( "a" ,{ href : e . link , style : { color : "var(--primary)" , fontSize : 13 , textDecoration : "none" , marginTop : 4 , display : "inline-block" }, children : "查看详情 →" }),( 0 , r . jsx )( "div" ,{ style : { fontSize : 12 , color : "var(--text-light)" , marginTop : 4 }, children : a })]})]}, e . id )})})]}) : ( 0 , r . jsx )( "div" ,{ className : "page-slide active" , style : { textAlign : "center" , color : "#94a3b8" , padding : "40px 0" }, children : "请先登录" })} function Q ( e ){ let { modal : t , onClose : a , reportPostId : n } = e ,{ login : i , register : l , currentUser : d , refresh : u } = p (),[ x , h ] = ( 0 , s . useState )( "" ),[ g , y ] = ( 0 , s . useState )( "" ),[ f , v ] = ( 0 , s . useState )( "" ),[ j , b ] = ( 0 , s . useState )( "" ),[ S , k ] = ( 0 , s . useState )( "" ),[ C , w ] = ( 0 , s . useState )( null ),[ N , D ] = ( 0 , s . useState )( "" ),[ R , E ] = ( 0 , s . useState )( "spam" ); if (( 0 , s . useEffect )(()=>{ "register" === t && w ( c ())},[ t ]), ! t ) return null ; let P = e =>{ e && e . target !== e . currentTarget || a ()}, T = async ()=>{ if ( ! x . trim () ||! g ){ alert ( "请填写完整信息" ); return } try {( await i ( x . trim (), g )). user && ( a (), h ( "" ), y ( "" ), u ())} catch ( e ){ alert ( "登录失败:" + e . message )}}, _ = async ()=>{ if ( ! f . trim () ||! j . trim () ||! S ){ alert ( "请填写完整信息" ); return } if ( S . length < 6 ){ alert ( "密码至少6位" ); return } if ( ! C || parseInt ( N ) !== C . answer ){ alert ( "验证码错误,请重新计算" ), w ( c ()), D ( "" ); return } try { await l ( j . trim (), S , f . trim ()), a (), v ( "" ), b ( "" ), k ( "" ), D ( "" ), alert ( "注册成功!" ), u ()} catch ( e ){ alert ( "注册失败:" + e . message )}}, B = async ()=>{ if ( n ) try { await o . createReport ( n , R ), a (), alert ( "举报已提交,管理员将尽快处理" )} catch ( e ){ alert ( "举报失败:" + e . message )}}; return ( 0 , r . jsxs )( r . Fragment ,{ children : [ "login" === t && ( 0 , r . jsx )( "div" ,{ className : "modal active" , onClick : P , children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , children : [( 0 , r . jsx )( "span" ,{ className : "close" , onClick : a , children : ( 0 , r . jsx )( m ,{ name : "close" , size : 20 })}),( 0 , r . jsx )( "h2" ,{ style : { marginBottom : 16 }, children : "登录" }),( 0 , r . jsx )( "input" ,{ type : "email" , placeholder : "邮箱" , value : x , onChange : e => h ( e . target . value )}),( 0 , r . jsx )( "input" ,{ type : "password" , placeholder : "密码" , value : g , onChange : e => y ( e . target . value ), onKeyDown : e =>{ "Enter" === e . key && T ()}}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { width : "100%" }, onClick : T , children : "登录" })]})}), "register" === t && ( 0 , r . jsx )( "div" ,{ className : "modal active" , onClick : P , children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , children : [( 0 , r . jsx )( "span" ,{ className : "close" , onClick : a , children : ( 0 , r . jsx )( m ,{ name : "close" , size : 20 })}),( 0 , r . jsx )( "h2" ,{ style : { marginBottom : 16 }, children : "注册" }),( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "用户名" , value : f , onChange : e => v ( e . target . value )}),( 0 , r . jsx )( "input" ,{ type : "email" , placeholder : "邮箱" , value : j , onChange : e => b ( e . target . value )}),( 0 , r . jsx )( "input" ,{ type : "password" , placeholder : "密码(至少6位)" , value : S , onChange : e => k ( e . target . value )}),( 0 , r . jsxs )( "div" ,{ className : "captcha-row" , style : { display : "flex" , alignItems : "center" , gap : 10 , margin : "12px 0" }, children : [ C ? ( 0 , r . jsx )( z ,{ captcha : C , onRefresh : ()=>{ w ( c ()), D ( "" )}}) : ( 0 , r . jsx )( "span" ,{ style : { color : "var(--text-light)" }, children : "验证码加载中..." }),( 0 , r . jsx )( "input" ,{ type : "text" , placeholder : "答案" , style : { width : 80 , background : "var(--bg)" , color : "var(--text)" , border : "1px solid var(--border)" , padding : "8px 12px" , borderRadius : 4 }, value : N , onChange : e => D ( e . target . value )})]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { width : "100%" }, onClick : _ , children : "注册" })]})}), "report" === t && d && ( 0 , r . jsx )( "div" ,{ className : "modal active" , onClick : P , children : ( 0 , r . jsxs )( "div" ,{ className : "modal-content" , children : [( 0 , r . jsx )( "span" ,{ className : "close" , onClick : a , children : ( 0 , r . jsx )( m ,{ name : "close" , size : 20 })}),( 0 , r . jsxs )( "h2" ,{ style : { marginBottom : 16 }, children : [( 0 , r . jsx )( m ,{ name : "shieldAlert" , size : 20 }), " 举报帖子" ]}),( 0 , r . jsx )( "p" ,{ style : { fontSize : 14 , color : "#64748b" , marginBottom : 12 }, children : "请选择举报原因:" }),( 0 , r . jsxs )( "select" ,{ style : { width : "100%" , padding : "8px 12px" , border : "1px solid var(--border)" , borderRadius : 4 , marginBottom : 16 , background : "var(--bg)" , color : "var(--text)" }, value : R , onChange : e => E ( e . target . value ), children : [( 0 , r . jsx )( "option" ,{ value : "spam" , children : "垃圾广告" }),( 0 , r . jsx )( "option" ,{ value : "abuse" , children : "人身攻击" }),( 0 , r . jsx )( "option" ,{ value : "illegal" , children : "违法内容" }),( 0 , r . jsx )( "option" ,{ value : "nsfw" , children : "不适当内容" }),( 0 , r . jsx )( "option" ,{ value : "other" , children : "其他" })]}),( 0 , r . jsx )( "button" ,{ className : "btn-primary" , style : { width : "100%" }, onClick : B , children : "提交举报" })]})})]})} function ee ( e ){ let { forumName : t , forumNameLoaded : a } = e ; return ( 0 , r . jsx )( "div" ,{ className : "loading-screen" , children : ( 0 , r . jsxs )( "div" ,{ className : "loading-inner" , children : [( 0 , r . jsx )( "div" ,{ className : "loading-spinner" }), a && t && ( 0 , r . jsx )( "div" ,{ className : "loading-title loading-title-appear" , children : t }),( 0 , r . jsx )( "div" ,{ className : "loading-sub" , children : "加载中..." })]})})} function et (){ let { view : e , currentPostId : t , currentUsername : a , currentPageName : n , ready : i , forumName : l , forumNameLoaded : o } = p (),[ d , c ] = ( 0 , s . useState )( null ),[ u , x ] = ( 0 , s . useState )( null ), h = e => c ( e ); return i ? ( 0 , r . jsxs )( "div" ,{ className : "app-fade-in" , children : [( 0 , r . jsx )( b ,{ onOpenModal : h }),( 0 , r . jsx )( j ,{}),( 0 , r . jsxs )( "div" ,{ id : "app" , style : { display : "feed" === e ? "flex" : "none" }, children : [( 0 , r . jsx )( S ,{}),( 0 , r . jsx )( N ,{ onOpenModal : h , onReport : e =>{ x ( e ), c ( "report" )}})]}),( 0 , r . jsxs )( "div" ,{ style : { display : "feed" !== e ? "block" : "none" }, children : [ "post" === e && t && ( 0 , r . jsx )( R ,{ postId : t }), "user" === e && a && ( 0 , r . jsx )( G ,{ username : a }), "custom" === e && n && ( 0 , r . jsx )( X ,{ pageName : n }), "new" === e && ( 0 , r . jsx )( P ,{}), "admin" === e && ( 0 , r . jsx )( O ,{}), "settings" === e && ( 0 , r . jsx )( Y ,{}), "messages" === e && ( 0 , r . jsx )( $ ,{})]}),( 0 , r . jsx )( Q ,{ modal : d , onClose : ()=> c ( null ), reportPostId : u })]}) : ( 0 , r . jsx )( ee ,{ forumName : l , forumNameLoaded : o })} function ea (){ return ( 0 , r . jsx )( x ,{ children : ( 0 , r . jsx )( et ,{})})}}, 9505 : function ( e , t , a ){ "use strict" ; a . d ( t ,{ ToastProvider : function (){ return d }, p : function (){ return l }}); var r = a ( 7437 ), s = a ( 2265 ), n = a ( 4887 ); let i = ( 0 , s . createContext )( null ); function l (){ return ( 0 , s . useContext )( i )} let o = 0 ; function d ( e ){ let { children : t } = e ,[ a , l ] = ( 0 , s . useState )([]), d = ( 0 , s . useRef )({}), c = ( 0 , s . useCallback )( function ( e ){ let t = arguments . length > 1 && void 0 !== arguments [ 1 ] ? arguments [ 1 ] : "success" , a = arguments . length > 2 && void 0 !== arguments [ 2 ] ? arguments [ 2 ] : 3e3 , r =++ o ; l ( a =>[... a ,{ id : r , message : e , type : t }]), d . current [ r ] && clearTimeout ( d . current [ r ]), d . current [ r ] = setTimeout (()=>{ l ( e => e . filter ( e => e . id !== r )), delete d . current [ r ]}, a )},[]), u = ( 0 , s . useCallback )( e =>{ l ( t => t . filter ( t => t . id !== e )), d . current [ e ] && ( clearTimeout ( d . current [ e ]), delete d . current [ e ])},[]); return ( 0 , r . jsxs )( i . Provider ,{ value : { toast : c }, children : [ t , "undefined" != typeof document && ( 0 , n . createPortal )(( 0 , r . jsx )( "div" ,{ className : "toast-container" , children : a . map ( e =>( 0 , r . jsx )( "div" ,{ className : "toast toast-" + e . type , onClick : ()=> u ( e . id ), children : e . message }, e . id ))}), document . body )]})}}}, function ( e ){ e . O ( 0 ,[ 970 , 971 , 117 , 744 ], function (){ return e ( e . s = 754 )}), _N_E = e . O ()}]);