live-sfu-demo/internal/server/static/assets/rooms-Qe281PmY.js

1 line
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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

import{C as e,D as t,E as n,F as r,G as i,L as a,M as o,Q as s,T as c,U as l,V as u,Y as d,Z as f,a as ee,b as p,c as m,g as h,i as g,n as _,p as v,q as y,r as b,t as te}from"./ui-CTx2ZrLp.js";import{t as x}from"./arrow-right-BCxmjqZf.js";import{t as S}from"./globe-C1LJ7PVd.js";import{n as ne,r as C,t as re}from"./users-3wlaTGls.js";import{t as ie}from"./radio-tower-Beh88DAK.js";import{a as w,n as ae}from"./index-LUhOsKYd.js";import{r as T}from"./sse-BNt7h9If.js";var E=[[`path`,{d:`M11 20H2`,key:`nlcfvz`}],[`path`,{d:`M11 4.562v16.157a1 1 0 0 0 1.242.97L19 20V5.562a2 2 0 0 0-1.515-1.94l-4-1A2 2 0 0 0 11 4.561z`,key:`au4z13`}],[`path`,{d:`M11 4H8a2 2 0 0 0-2 2v14`,key:`74r1mk`}],[`path`,{d:`M14 12h.01`,key:`1jfl7z`}],[`path`,{d:`M22 20h-3`,key:`vhrsz`}]],oe=e=>u(p,d(e,{iconNode:E,name:`door-open`})),D=[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]],se=e=>u(p,d(e,{iconNode:D,name:`search`})),ce=o(`<div><p class="mono-label text-muted-foreground">rooms / registry</p><h1 class="display mt-2 text-4xl sm:text-5xl">房间</h1><p class="mt-3 max-w-xl text-sm text-muted-foreground">创建或进入房间。已接入实时推送(<code class=font-mono>/api/rooms/events</code> SSE)· 新房间 / LIVE 状态变化自动刷新。`),le=o(`<input class="h-8 flex-1 border border-line bg-background px-2 text-xs outline-none"placeholder=描述(可选)>`),ue=o(`<label class="flex items-center gap-1.5 text-xs"><input type=checkbox>`),de=o(`<div class="flex flex-wrap items-center gap-3 border-t border-line/50 pt-3"><label class="flex items-center gap-2 text-xs"><input type=checkbox>高级`),fe=o(`<div class="relative max-w-3xl border border-line bg-card/60 p-3 sm:p-4"><div class="flex flex-col gap-3"><div class="flex flex-col gap-2 sm:flex-row"><div class="flex h-10 flex-1 items-center gap-2.5 border border-line bg-background/70 px-3 transition-colors focus-within:border-ring"><input class="field-mono h-full w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/50"placeholder="新房间名,如 live-demo"aria-label=房间名>`),pe=o(`<span class="font-mono text-[10px] text-muted-foreground">· `),me=o(`<span class="mono-label animate-pulse text-muted-foreground">loading…`),he=o(`<div class="flex items-center justify-between gap-3 border-b border-line pb-3"><h2 class="flex items-center gap-2 font-semibold">房间列表<span class="flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-normal"><span class="size-1.5 rounded-full">`),ge=o(`<div class=space-y-2>`),_e=o(`<div class="mx-auto max-w-[1400px] space-y-8 px-4 py-8 sm:px-6 sm:py-10"><div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"><div class="flex flex-1 items-center gap-2"><div class="flex h-9 flex-1 max-w-sm items-center gap-2 border border-line bg-background px-3"><input class="h-full w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/50"placeholder="搜索房间名 / 展示名"></div></div><div class="flex items-center gap-2 text-xs text-muted-foreground"><span class=font-mono> rooms · 第 <!>/<!> 页</span></div></div><section class=space-y-3>`),ve=o(`<div class="flex flex-col items-center gap-3 border border-dashed border-line px-6 py-12 text-center"><span class="flex size-10 items-center justify-center border border-line bg-card text-muted-foreground"></span><div><p class=font-medium>暂无房间</p><p class="mt-1 text-sm text-muted-foreground">`),ye=o(`<span class="font-mono text-xs text-muted-foreground">/`),be=o(`<span class=truncate>· `),xe=o(`<div class="group relative border border-line/70 bg-card/40 px-4 py-4 transition-colors hover:border-line hover:bg-accent/30 sm:px-5"><div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"><div class="flex min-w-0 flex-1 items-start gap-3"><div class="min-w-0 flex-1"><div class="flex flex-wrap items-center gap-2"><p class="display truncate text-xl sm:text-2xl"></p></div><div class="mt-1 flex flex-wrap items-center gap-3 text-xs text-muted-foreground"><span class="flex items-center gap-1"></span><span class="flex items-center gap-1"> 成员</span><span class=font-mono> 路分发</span></div></div></div><div class="flex shrink-0 items-center gap-2">`),O=()=>{let o=w(),[c,d]=y([]),[p,E]=y(0),[D,O]=y(1),[k,A]=y(``),[j,M]=y(``),[N,P]=y(``),[Se,F]=y(!1),[I,L]=y(``),[Ce,R]=y(!1),[z,B]=y(``),[V,we]=y(!0),[H,Te]=y(!1),[U,W]=y(!1),[G,Ee]=y(``),K=async()=>{R(!0),L(``);try{if(v.isAdminOrAbove())try{let e=((await h.manageRooms()).rooms||[]).map(e=>({name:e.room.name,display_name:e.room.display_name,description:e.room.description,creator:e.room.creator,is_public:e.room.is_public,status:e.room.status,member_count:e.member_count,targets:e.targets,live:e.live,created_at:e.room.created_at})),t=k().trim().toLowerCase();t&&(e=e.filter(e=>e.name.toLowerCase().includes(t)||e.display_name&&e.display_name.toLowerCase().includes(t))),E(e.length);let n=(D()-1)*12;d(e.slice(n,n+12));return}catch{}try{let e=await h.queryRooms({page:D(),page_size:12,search:k().trim()||void 0}),t=(e.rooms||[]).map(e=>({name:e.name,display_name:e.display_name,description:e.description,creator:e.creator,is_public:e.is_public,status:e.status,member_count:e.member_count??0,targets:[],live:!1,created_at:e.created_at}));try{let e=await h.listRooms(),n=new Map((e.rooms||[]).map(e=>[e.name,(e.targets?.length??0)>0?e.targets:[]]));for(let e of t){let t=n.get(e.name);t&&(e.targets=t,e.live=t.length>0)}}catch{}d(t),E(e.total??t.length);return}catch{}let e=((await h.listRooms()).rooms||[]).map(e=>({name:e.name,display_name:e.name,description:``,creator:``,is_public:!0,status:`active`,member_count:0,targets:e.targets||[],live:(e.targets?.length??0)>0})),t=k().trim().toLowerCase();t&&(e=e.filter(e=>e.name.toLowerCase().includes(t))),E(e.length);let n=(D()-1)*12;d(e.slice(n,n+12))}catch(e){L(String(e?.message||e))}finally{R(!1)}};l(()=>{v.can(`room:list`)&&K()}),l(()=>{D(),k(),v.can(`room:list`)&&K()}),s(()=>v.can(`room:list`)&&K());let q=null,J=null,Y=()=>{if(!q)try{q=T(()=>{Ee(new Date().toLocaleTimeString()),J&&clearTimeout(J),J=setTimeout(()=>K(),350)},e=>W(e))}catch{W(!1)}},X=()=>{if(q){try{q()}catch{}q=null}J&&=(clearTimeout(J),null),W(!1)};l(()=>{v.can(`room:list`)?Y():X()}),Y(),f(()=>X());let Z=()=>{A(j().trim()),O(1)},Q=async()=>{let e=N().trim();if(e){F(!0),L(``);try{if(v.isAdminOrAbove()&&H())await h.manageCreateRoom({name:e,display_name:e,description:z().trim()||void 0,is_public:V(),require_approval:!1,max_members:100});else try{await h.manageCreateRoom({name:e,display_name:e,description:z().trim()||void 0,is_public:V()})}catch{await h.createRoom(e)}P(``),B(``),await K(),o({to:`/room`,search:{room:e}})}catch(e){L(String(e?.message||e))}finally{F(!1)}}},De=e=>o({to:`/room`,search:{room:e}}),$=()=>Math.max(1,Math.ceil(p()/12));return(()=>{var o=_e(),s=o.firstChild,l=s.firstChild,d=l.firstChild,f=d.firstChild,h=l.nextSibling,y=h.firstChild,w=y.firstChild,T=w.nextSibling,E=T.nextSibling.nextSibling;E.nextSibling;var F=s.nextSibling;return n(o,u(m,{get children(){return ce()}}),s),n(o,u(a,{get when(){return I()},get children(){return u(te,{tone:`error`,get children(){return I()}})}}),s),n(o,u(a,{get when(){return v.can(`room:list`)},get children(){return u(m,{delay:1,get children(){var e=fe(),r=e.firstChild,o=r.firstChild,s=o.firstChild,c=s.firstChild;return n(e,u(g,{}),r),n(s,u(ne,{class:`size-4 shrink-0 text-muted-foreground`}),c),c.$$keydown=e=>{e.key===`Enter`&&Q()},c.$$input=e=>P(e.currentTarget.value),n(o,u(b,{class:`h-10 shrink-0`,onClick:Q,get disabled(){return Se()||!N().trim()},get children(){return[u(x,{class:`size-4`}),`创建并进入`]}}),null),n(r,u(a,{get when(){return v.isAdminOrAbove()},get children(){var e=de(),r=e.firstChild.firstChild;return r.addEventListener(`change`,e=>Te(e.target.checked)),n(e,u(a,{get when(){return H()},get children(){return[(()=>{var e=le();return e.$$input=e=>B(e.currentTarget.value),i(()=>e.value=z()),e})(),(()=>{var e=ue(),r=e.firstChild;return r.addEventListener(`change`,e=>we(e.target.checked)),n(e,(()=>{var e=t(()=>!!V());return()=>e()?u(S,{class:`size-3`}):u(C,{class:`size-3`})})(),null),n(e,()=>V()?`公开`:`私密`,null),i(()=>r.checked=V()),e})()]}}),null),i(()=>r.checked=H()),e}}),null),i(()=>c.value=N()),e}})}}),s),n(d,u(se,{class:`size-4 text-muted-foreground`}),f),f.$$keydown=e=>{e.key===`Enter`&&Z()},f.$$input=e=>M(e.currentTarget.value),n(l,u(b,{variant:`outline`,class:`h-9`,onClick:Z,children:`搜索`}),null),n(l,u(a,{get when(){return k()},get children(){return u(b,{variant:`ghost`,class:`h-9`,onClick:()=>{M(``),A(``),O(1)},children:`清除`})}}),null),n(y,p,w),n(y,D,T),n(y,$,E),n(h,u(b,{variant:`outline`,class:`h-7 px-2 text-xs`,get disabled(){return D()<=1},onClick:()=>O(e=>Math.max(1,e-1)),children:`上一页`}),null),n(h,u(b,{variant:`outline`,class:`h-7 px-2 text-xs`,get disabled(){return D()>=$()},onClick:()=>O(e=>e+1),children:`下一页`}),null),n(F,u(m,{get children(){var t=he(),r=t.firstChild,o=r.firstChild,s=o.nextSibling,c=s.firstChild;return n(r,u(ie,{class:`size-4 text-muted-foreground`}),o),n(s,()=>U()?`实时`:`离线`,null),n(r,u(a,{get when(){return G()},get children(){var e=pe();return e.firstChild,n(e,G,null),e}}),null),n(t,u(a,{get when(){return Ce()},get children(){return me()}}),null),i(t=>{var n={"border-emerald-500/40 bg-emerald-500/10 text-emerald-600":U(),"border-line bg-muted text-muted-foreground":!U()},r={"bg-emerald-500 animate-pulse":U(),"bg-muted-foreground/40":!U()};return t.e=e(s,n,t.e),t.t=e(c,r,t.t),t},{e:void 0,t:void 0}),t}}),null),n(F,u(a,{get when(){return c().length>0},get fallback(){return(()=>{var e=ve(),r=e.firstChild,i=r.nextSibling.firstChild.nextSibling;return n(r,u(oe,{class:`size-5`})),n(i,(()=>{var e=t(()=>!!k());return()=>e()?`无匹配 "${k()}" 的房间`:`创建一个房间后,分发拓扑会在这里出现。`})()),e})()},get children(){var e=ge();return n(e,u(r,{get each(){return c()},children:(e,r)=>u(m,{get delay(){return Math.min(r()+1,6)},get children(){var r=xe(),i=r.firstChild,o=i.firstChild,s=o.firstChild,c=s.firstChild,l=c.firstChild,d=c.nextSibling,f=d.firstChild,p=f.nextSibling,m=p.firstChild,h=p.nextSibling,v=h.firstChild,y=o.nextSibling;return n(r,u(g,{}),i),n(o,u(ee,{get active(){return!!e.live}}),s),n(l,()=>e.display_name||e.name),n(c,u(a,{get when(){return e.name!==e.display_name},get children(){var t=ye();return t.firstChild,n(t,()=>e.name,null),t}}),null),n(c,u(_,{get variant(){return e.live?`success`:`muted`},class:`text-[10px]`,get children(){return e.live?`LIVE`:`IDLE`}}),null),n(c,u(_,{variant:`outline`,class:`gap-1 text-[10px]`,get children(){return[t(()=>t(()=>e.is_public===!1)()?u(C,{class:`size-3`}):u(S,{class:`size-3`})),t(()=>e.is_public===!1?`私密`:`公开`)]}}),null),n(c,u(a,{get when(){return t(()=>!!e.status)()&&e.status!==`active`},get children(){return u(_,{variant:`outline`,class:`border-destructive/40 text-destructive text-[10px]`,get children(){return e.status}})}}),null),n(f,u(ae,{class:`size-3`}),null),n(f,()=>e.creator||`-`,null),n(p,u(re,{class:`size-3`}),m),n(p,()=>e.member_count??0,m),n(h,()=>e.targets?.length??0,v),n(d,u(a,{get when(){return e.description},get children(){var t=be();return t.firstChild,n(t,()=>e.description,null),t}}),null),n(y,u(b,{variant:`outline`,class:`h-9`,onClick:()=>De(e.name),get children(){return[`进入房间`,u(x,{class:`size-4`})]}})),r}})})),e}}),null),i(()=>f.value=j()),o})()};c([`input`,`keydown`]);export{O as Rooms};