@runeya/runeya
Version:
Monitor processes as a stack
2 lines (1 loc) • 3.45 kB
JavaScript
import{Y as U,r as u,c as x,w as b,j as F,m as A,aF as K,a as c,o as l,g as D,b as o,v as M,F as B,q as E,s as R,f as j,t as r,a1 as f,n as _,i as I,k as L}from"./index-CXxIspfv.js";import{d as P}from"./index-DzbsgEyi.js";import{u as V}from"./router-CdfdQZKk.js";import{_ as q}from"./Section-D0z9MjV4.js";import{_ as N}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./Editor-B--wgkn6.js";const O={key:0,class:"hint"},S={class:"groups"},$={class:"choices"},z=["onClick"],G={class:"left"},Y={class:"icon"},H={class:"title"},J={class:"description"},Q={class:"right"},W={class:"title"},X={class:"description"},Z={class:"left"},ee={key:0},se={class:"title"},te={class:"description"},oe={__name:"Index",setup(ae){const h=V(),m=async t=>{t.ctrlKey&&t.altKey&&t.code==="KeyP"&&(t.preventDefault(),i.value=!i.value,d.value="",await I(),y.value.focus()),t.code==="Escape"&&(t.preventDefault(),i.value=!1)};window.addEventListener("keyup",m),U(()=>window.removeEventListener("keyup",m));const p=u({}),d=u(""),y=u(),i=u(!1),v=x(()=>h.currentRoute.value.path.includes("/Finder"));b(()=>i.value,()=>{v.value&&(i.value=!0)},{immediate:!0});const k=x(()=>Object.keys(p.value).map(t=>{var e,n,a;const s=p.value[t];return{label:s.label,choices:(e=s.choices)==null?void 0:e.slice(0,4),otherChoices:(a=s.choices)==null?void 0:a.slice(4,(n=s.choices)==null?void 0:n.length)}}));async function w(){const{data:t}=await L.get("/finder/search",{params:{q:d.value}}),s={};t[0]&&(t[0].active=!0),t.map(e=>(e.group||(e.group="Others"),s[e.group]||(s[e.group]={label:e.group,choices:[],otherChoices:[]}),s[e.group].choices.push(e),null)),p.value=s}F(w),b(()=>d.value,P(w,200));function g(t){t!=null&&t.url&&(h.push(t.url),i.value=!1)}async function T(t){const s=k.value.flatMap(e=>e.choices);if(["ArrowUp","ArrowDown"].includes(t.code))for(let e=0;e<s.length;e+=1){const n=s[e];if(n.active){n.active=!1;const a=t.code==="ArrowUp"?s[s.length-1]:s[0],C=(t.code==="ArrowUp"?s[e-1]:s[e+1])||a;C.active=!0;break}}t.code==="Enter"&&g(s.find(e=>e.active))}return(t,s)=>A((l(),c("div",{class:_(["finder-root",{isComponent:v.value}]),onClick:s[3]||(s[3]=e=>i.value=!1)},[v.value?(l(),c("div",O," Press Ctrl+Alt+P To open it anywhere ")):D("",!0),o("div",{class:"finder-container",onClick:s[2]||(s[2]=f(()=>{},["stop"]))},[A(o("input",{type:"text",autofocus:"","onUpdate:modelValue":s[0]||(s[0]=e=>d.value=e),placeholder:"Type to find something...",ref_key:"inputRef",ref:y,onKeyup:T},null,544),[[M,d.value]]),o("div",S,[(l(!0),c(B,null,E(k.value,e=>(l(),R(q,{class:"group",key:`${e}`},{default:j(()=>{var n;return[o("h2",null,r(e.label),1),o("div",$,[(l(!0),c(B,null,E(e.choices,a=>(l(),c("div",{class:_(["choice",{active:a.active}]),key:`${a}`,onClick:f(C=>g(a),["stop"])},[o("div",G,[o("div",Y,[o("i",{class:_(a.icon||"fas fa-cog")},null,2)]),o("div",null,[o("div",H,r(a.title),1),o("div",J,r(a.description),1)])]),o("div",Q,[o("div",W,r(a.secondaryTitle),1),o("div",X,r(a.secondaryDescription),1)])],10,z))),128)),o("div",{class:"choice",onClick:s[1]||(s[1]=f(()=>{},["stop"]))},[o("div",Z,[(n=e.otherChoices)!=null&&n.length?(l(),c("div",ee,[o("div",se,"And "+r(e.otherChoices.length)+" others...",1),o("div",te,r(e.otherChoices.map(a=>a.title).slice(0,20).map(a=>a.slice(0,40)+"...").join(", "))+" ... ",1)])):D("",!0)])])])]}),_:2},1024))),128))])])],2)),[[K,i.value]])}},pe=N(oe,[["__scopeId","data-v-de00cded"]]);export{pe as default};