import{d as M,r,u as R,C as B,o as O,c as u,a as d,e as n,h,a2 as U,t as l,F as x,j as _,v as L}from"./vendor-nt8ldNfT.js";import{_ as V}from"./tailwind-Bkcu6GYy.js";const F={class:"card bg-base-100 shadow-md"},Z={class:"card-body"},q={class:"flex items-center justify-between mb-4"},z={class:"flex items-center gap-3"},E=["disabled"],N={class:"text-xs opacity-70"},A={class:"flex flex-wrap gap-2 mb-4"},G=["onClick"],H={class:"flex gap-4 mb-4"},J={class:"overflow-x-auto max-h-[700px]"},K={class:"table table-zebra w-full"},Q={class:"space-x-2"},W=["onClick"],X=["onClick"],Y=["onClick"],tt=M({__name:"Zaixianwanjia",setup(et){const m=r([]),f=r([]),c=r(""),o=r(!1),g=r(!1),a=R(),v=B();async function b(e){try{const t=await(await fetch(e)).json();return t.success&&t.status===200?t:(a.warning(t.msg||"请求失败"),null)}catch(s){return a.error("请求出错："+s),null}}async function p(){try{const t=(await(await fetch("/gamepanel.html?Registrationrestrictions=true&query=true")).json()).msg;o.value=t===!0||t==="true"||t===1||t==="1"}catch(e){a.error("获取注册限制状态失败："+e)}}async function w(e){const s=o.value;g.value=!0;try{const i=await(await fetch(`/gamepanel.html?Registrationrestrictions=true&Settings=${e}`)).json();i.success===!1?(o.value=s,a.error(i.msg||"修改失败")):a.success(i.msg||"修改成功")}catch(t){o.value=s,a.error("修改失败："+t)}finally{g.value=!1}}function y(){w(o.value)}async function C(){const e=await b("/api/gameplayers");e!=null&&e.data&&(m.value=e.data)}async function j(){var t;const e=[{codeid:1,codeming:"欢迎",codetxt:"欢迎加入服务器！"},{codeid:2,codeming:"公告",codetxt:"请遵守服务器规则。"}],s=await b("/api/playing");(t=s==null?void 0:s.data)!=null&&t.codelist?f.value=[...e,...s.data.codelist]:f.value=e}function k(e){c.value=e}async function D(){if(!c.value.trim()){a.warning("消息内容不能为空");return}try{const s=await(await fetch(`/api/game?msg=${encodeURIComponent(c.value)}`,{method:"POST"})).json();s.success?(a.success(s.msg||"发送成功"),c.value=""):a.error(s.msg||"发送失败")}catch(e){a.error("发送异常："+e)}}function I(e){v.warning({title:"封禁确认",content:`确定要封禁玩家 ${e.玩家昵称}（ID：${e.玩家ID}）吗？`,positiveText:"确认",negativeText:"取消",onPositiveClick:()=>T(e.玩家ID)})}function $(e){v.info({title:"解封确认",content:`确定要解封玩家 ${e.玩家昵称}（ID：${e.玩家ID}）吗？`,positiveText:"确认",negativeText:"取消",onPositiveClick:()=>S(e.玩家ID)})}async function T(e){const t=await(await fetch(`/api/users/ban?id=${e}&fenlei=1`,{method:"POST"})).json();a[t.success?"success":"error"](t.msg||"封禁失败")}async function S(e){const t=await(await fetch(`/api/users/ban?id=${e}&fenlei=2`,{method:"POST"})).json();a[t.success?"success":"error"](t.msg||"解封失败")}function P(e){navigator.clipboard.writeText(e).then(()=>a.success(`SteamID ${e} 已复制`)).catch(s=>a.error("复制失败："+s))}return O(()=>{p(),C(),j()}),(e,s)=>(d(),u("div",F,[n("div",Z,[n("div",q,[n("div",z,[s[2]||(s[2]=n("span",{class:"font-semibold"},"注册时必须在线",-1)),h(n("input",{type:"checkbox",class:"toggle toggle-primary","onUpdate:modelValue":s[0]||(s[0]=t=>o.value=t),disabled:g.value,onChange:y},null,40,E),[[U,o.value]]),n("span",N,l(o.value?"当前：必须在线才能注册":"当前：离线也可以注册"),1)])]),n("div",A,[(d(!0),u(x,null,_(f.value,t=>(d(),u("button",{key:t.codeid,class:"btn btn-sm btn-outline",onClick:i=>k(t.codetxt)},l(t.codeming),9,G))),128))]),n("div",H,[h(n("textarea",{"onUpdate:modelValue":s[1]||(s[1]=t=>c.value=t),class:"textarea textarea-bordered w-full",rows:"3",placeholder:"请输入要发送的消息"},null,512),[[L,c.value]]),n("button",{class:"btn btn-primary",onClick:D},"发送内容")]),n("div",J,[n("table",K,[s[3]||(s[3]=n("thead",null,[n("tr",null,[n("th",null,"玩家ID"),n("th",null,"昵称"),n("th",null,"最后在线"),n("th",null,"状态"),n("th",null,"操作")])],-1)),n("tbody",null,[(d(!0),u(x,null,_(m.value,t=>(d(),u("tr",{key:t.玩家ID},[n("td",null,l(t.玩家ID),1),n("td",null,l(t.玩家昵称),1),n("td",null,l(t.最后在线时间戳),1),n("td",null,l(t.在线状态),1),n("td",Q,[n("button",{class:"btn btn-xs btn-error",onClick:i=>I(t)},"封禁",8,W),n("button",{class:"btn btn-xs btn-success",onClick:i=>$(t)},"解封",8,X),n("button",{class:"btn btn-xs btn-info",onClick:i=>P(t.玩家ID)},"复制",8,Y)])]))),128))])])])])]))}}),at=V(tt,[["__scopeId","data-v-1f833ea4"]]);export{at as default};
