mirror of
https://github.com/vastxie/99AI.git
synced 2025-09-23 03:56:38 +08:00
10 lines
5.7 KiB
JavaScript
10 lines
5.7 KiB
JavaScript
|
||
/**
|
||
* 由 Fantastic-admin 提供技术支持
|
||
* Powered by Fantastic-admin
|
||
* Gitee https://gitee.com/hooray/fantastic-admin
|
||
* Github https://github.com/hooray/fantastic-admin
|
||
*/
|
||
|
||
import{d as Q,j as te,y as se,$ as ae,A as le,r as m,a0 as ne,B as oe,C as A,x as ue,M as D,D as h,a1 as J,h as H,o as b,c as R,a as i,m as z,e as n,f as u,b as p,V as re,k as x,l as k,t as B,J as O,S as F,U as G,G as q,_ as ce,I as ie,n as fe}from"./index-e656eb90.js";const de={class:"container"},pe={key:0,class:"tips"},ve={class:"tip"},he={class:"tip"},_e={class:"tip"},ge={class:"tip"},ye=["onClick","onMouseover"],me={class:"info"},be={class:"title"},ke={class:"breadcrumb"},Se={class:"path"},we=Q({name:"Search"}),Ce=Q({...we,setup(Re){const W=te(),_=se(),X=ae(),Y=le(),g=m(!1),f=m(""),L=m([]),r=m(-1),$=m(),S=m(),w=m([]);function Z(s){return w.value.push(s)}ne(()=>{w.value=[]});const C=oe(()=>{let s=[];return s=L.value.filter(e=>{let l=!1;return e.title&&(typeof e.title=="function"?e.title().includes(f.value)&&(l=!0):e.title.includes(f.value)&&(l=!0)),e.path.includes(f.value)&&(l=!0),e.breadcrumb.some(a=>{let t=!1;return a&&(typeof a=="function"?a().includes(f.value)&&(t=!0):a.includes(f.value)&&(t=!0)),t})&&(l=!0),l}),s});A(()=>g.value,s=>{s?(document.body.classList.add("hidden"),S.value.scrollTop=0,h("up",V),h("down",E),h("enter",I),setTimeout(()=>{$.value.focus()},500)):(document.body.classList.remove("hidden"),h.unbind("up",V),h.unbind("down",E),h.unbind("enter",I),setTimeout(()=>{f.value="",r.value=-1},500))}),A(()=>C.value,()=>{r.value=-1,w.value=[],M()}),ue(()=>{D.on("global-search-toggle",()=>{g.value=!g.value}),h("alt+s",s=>{_.settings.navSearch.enable&&_.settings.navSearch.enableHotkeys&&(s.preventDefault(),g.value=!0)}),h("esc",s=>{_.settings.navSearch.enable&&_.settings.navSearch.enableHotkeys&&(s.preventDefault(),g.value=!1)}),_.settings.app.routeBaseOn!=="filesystem"?X.routes.forEach(s=>{s.children&&U(s.children)}):Y.menus.forEach(s=>{N(s.children)})});function P(s){var l;let e=!0;return(l=s.children)!=null&&l.every(a=>{var t;return((t=a.meta)==null?void 0:t.sidebar)===!1})&&(e=!1),e}function U(s,e,l,a){s.forEach(t=>{var c,o,v,d,y,j,K;if(((c=t.meta)==null?void 0:c.sidebar)!==!1){const T=J(a)||[];t.children&&P(t)?(T.push((o=t.meta)==null?void 0:o.title),U(t.children,e?[e,t.path].join("/"):t.path,((v=t.meta)==null?void 0:v.icon)??l,T)):(T.push((d=t.meta)==null?void 0:d.title),L.value.push({path:e?[e,t.path].join("/"):t.path,icon:((y=t.meta)==null?void 0:y.icon)??l,title:(j=t.meta)==null?void 0:j.title,link:(K=t.meta)==null?void 0:K.link,breadcrumb:T}))}})}function N(s,e,l){s.forEach(a=>{var c,o,v,d,y;const t=J(l)||[];a.children&&a.children.length>0?(t.push((c=a.meta)==null?void 0:c.title),N(a.children,((o=a.meta)==null?void 0:o.icon)??e,t)):(t.push((v=a.meta)==null?void 0:v.title),L.value.push({icon:((d=a.meta)==null?void 0:d.icon)??e,title:(y=a.meta)==null?void 0:y.title,path:a.path,breadcrumb:t}))})}function V(){C.value.length&&(r.value-=1,r.value<0&&(r.value=C.value.length-1),M())}function E(){C.value.length&&(r.value+=1,r.value>C.value.length-1&&(r.value=0),M())}function I(){r.value!==-1&&w.value[r.value].click()}function M(){let s=0;if(r.value!==-1){s=S.value.scrollTop;const e=w.value[r.value].offsetTop,l=w.value[r.value].clientHeight,a=S.value.scrollTop,t=S.value.clientHeight;e+l>a+t?s=e+l-t:e<=a&&(s=e)}S.value.scrollTo({top:s})}function ee(s,e){e?window.open(e,"_blank"):W.push(s)}return(s,e)=>{const l=ce,a=H("el-icon"),t=H("el-input"),c=H("el-tag");return b(),R("div",{id:"search",class:q({searching:p(g)}),onClick:e[3]||(e[3]=o=>p(g)&&p(D).emit("global-search-toggle"))},[i("div",de,[i("div",{class:"search-box",onClick:e[2]||(e[2]=z(()=>{},["stop"]))},[n(t,{ref_key:"searchInputRef",ref:$,modelValue:p(f),"onUpdate:modelValue":e[0]||(e[0]=o=>re(f)?f.value=o:null),placeholder:"搜索页面,支持标题、URL模糊查询",clearable:"",onKeydown:[e[1]||(e[1]=x(o=>p(D).emit("global-search-toggle"),["esc"])),x(z(V,["prevent"]),["up"]),x(z(E,["prevent"]),["down"]),x(z(I,["prevent"]),["enter"])]},{prefix:u(()=>[n(a,null,{default:u(()=>[n(l,{name:"ep:search"})]),_:1})]),_:1},8,["modelValue","onKeydown"]),p(_).mode==="pc"?(b(),R("div",pe,[i("div",ve,[n(c,{type:"info",size:"large"},{default:u(()=>[k(B(p(_).os==="mac"?"⌥":"Alt")+" + S ",1)]),_:1}),n(c,{type:"info",size:"large"},{default:u(()=>[k(" 唤醒搜索面板 ")]),_:1})]),i("div",he,[n(c,{type:"info",size:"large"},{default:u(()=>[n(a,null,{default:u(()=>[n(l,{name:"search-up"})]),_:1})]),_:1}),n(c,{type:"info",size:"large"},{default:u(()=>[n(a,null,{default:u(()=>[n(l,{name:"search-down"})]),_:1})]),_:1}),n(c,{type:"info",size:"large"},{default:u(()=>[k(" 切换搜索结果 ")]),_:1})]),i("div",_e,[n(c,{type:"info",size:"large"},{default:u(()=>[n(a,null,{default:u(()=>[n(l,{name:"search-enter"})]),_:1})]),_:1}),n(c,{type:"info",size:"large"},{default:u(()=>[k(" 访问页面 ")]),_:1})]),i("div",ge,[n(c,{type:"info",size:"large"},{default:u(()=>[k(" ESC ")]),_:1}),n(c,{type:"info",size:"large"},{default:u(()=>[k(" 退出 ")]),_:1})])])):O("",!0)]),i("div",{ref_key:"searchResultRef",ref:S,class:"result"},[(b(!0),R(F,null,G(p(C),(o,v)=>(b(),R("a",{key:o.path,ref_for:!0,ref:Z,class:q(["item",{actived:v===p(r)}]),onClick:d=>ee(o.path,o.link),onMouseover:d=>r.value=v},[n(a,{class:"icon"},{default:u(()=>[o.icon?(b(),ie(l,{key:0,name:o.icon},null,8,["name"])):O("",!0)]),_:2},1024),i("div",me,[i("div",be,B(o.title??"[ 无标题 ]"),1),i("div",ke,[(b(!0),R(F,null,G(o.breadcrumb,(d,y)=>(b(),R("span",{key:y},[k(B(d??"[ 无标题 ]")+" ",1),n(a,null,{default:u(()=>[n(l,{name:"ep:arrow-right"})]),_:1})]))),128))]),i("div",Se,B(o.path),1)])],42,ye))),128))],512)])],2)}}});const ze=fe(Ce,[["__scopeId","data-v-7119310d"]]);export{ze as default};
|