Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
09810ccf
提交
09810ccf
authored
4月 21, 2025
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化菜单搜索查询页
上级
0d9fb8b5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
89 行增加
和
54 行删除
+89
-54
index.vue
ruoyi-ui/src/components/HeaderSearch/index.vue
+89
-54
没有找到文件。
ruoyi-ui/src/components/HeaderSearch/index.vue
浏览文件 @
09810ccf
<
template
>
<
template
>
<div
:class=
"
{'show':show}"
class="header-search">
<div
class=
"header-search"
>
<svg-icon
class-name=
"search-icon"
icon-class=
"search"
@
click
.
stop=
"click"
/>
<svg-icon
class-name=
"search-icon"
icon-class=
"search"
@
click
.
stop=
"click"
/>
<el-select
<el-dialog
ref=
"headerSearchSelect"
:visible
.
sync=
"show"
v-model=
"search"
width=
"600px"
:remote-method=
"querySearch"
@
close=
"close"
filterable
:show-close=
"false"
default-first-option
append-to-body
remote
placeholder=
"Search"
class=
"header-search-select"
@
change=
"change"
>
>
<el-option
v-for=
"option in options"
:key=
"option.item.path"
:value=
"option.item"
:label=
"option.item.title.join(' > ')"
/>
<el-input
</el-select>
v-model=
"search"
ref=
"headerSearchSelectRef"
size=
"large"
@
input=
"querySearch"
prefix-icon=
"Search"
placeholder=
"菜单搜索,支持标题、URL模糊查询"
>
</el-input>
<el-scrollbar
wrap-class=
"right-scrollbar-wrapper"
>
<div
class=
"result-wrap"
>
<div
class=
"search-item"
v-for=
"item in options"
:key=
"item.path"
>
<div
class=
"left"
>
<svg-icon
class=
"menu-icon"
:icon-class=
"item.icon"
/>
</div>
<div
class=
"search-info"
@
click=
"change(item)"
>
<div
class=
"menu-title"
>
{{
item
.
title
.
join
(
" / "
)
}}
</div>
<div
class=
"menu-path"
>
{{
item
.
path
}}
</div>
</div>
</div>
</div>
</el-scrollbar>
</el-dialog>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
// fuse is a lightweight fuzzy-search module
// make search results more in line with expectations
import
Fuse
from
'fuse.js/dist/fuse.min.js'
import
Fuse
from
'fuse.js/dist/fuse.min.js'
import
path
from
'path'
import
path
from
'path'
import
{
isHttp
}
from
'@/utils/validate'
import
{
isHttp
}
from
'@/utils/validate'
...
@@ -46,13 +65,6 @@ export default {
...
@@ -46,13 +65,6 @@ export default {
},
},
searchPool
(
list
)
{
searchPool
(
list
)
{
this
.
initFuse
(
list
)
this
.
initFuse
(
list
)
},
show
(
value
)
{
if
(
value
)
{
document
.
body
.
addEventListener
(
'click'
,
this
.
close
)
}
else
{
document
.
body
.
removeEventListener
(
'click'
,
this
.
close
)
}
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -63,23 +75,25 @@ export default {
...
@@ -63,23 +75,25 @@ export default {
this
.
show
=
!
this
.
show
this
.
show
=
!
this
.
show
if
(
this
.
show
)
{
if
(
this
.
show
)
{
this
.
$refs
.
headerSearchSelect
&&
this
.
$refs
.
headerSearchSelect
.
focus
()
this
.
$refs
.
headerSearchSelect
&&
this
.
$refs
.
headerSearchSelect
.
focus
()
this
.
options
=
this
.
searchPool
}
}
},
},
close
()
{
close
()
{
this
.
$refs
.
headerSearchSelect
&&
this
.
$refs
.
headerSearchSelect
.
blur
()
this
.
$refs
.
headerSearchSelect
&&
this
.
$refs
.
headerSearchSelect
.
blur
()
this
.
search
=
''
this
.
options
=
[]
this
.
options
=
[]
this
.
show
=
false
this
.
show
=
false
},
},
change
(
val
)
{
change
(
val
)
{
const
path
=
val
.
path
;
const
path
=
val
.
path
const
query
=
val
.
query
;
const
query
=
val
.
query
if
(
isHttp
(
val
.
path
))
{
if
(
isHttp
(
val
.
path
))
{
// http(s):// 路径新窗口打开
// http(s):// 路径新窗口打开
const
pindex
=
path
.
indexOf
(
"http"
);
const
pindex
=
path
.
indexOf
(
"http"
);
window
.
open
(
path
.
substr
(
pindex
,
path
.
length
),
"_blank"
)
;
window
.
open
(
path
.
substr
(
pindex
,
path
.
length
),
"_blank"
)
}
else
{
}
else
{
if
(
query
)
{
if
(
query
)
{
this
.
$router
.
push
({
path
:
path
,
query
:
JSON
.
parse
(
query
)
})
;
this
.
$router
.
push
({
path
:
path
,
query
:
JSON
.
parse
(
query
)
})
}
else
{
}
else
{
this
.
$router
.
push
(
path
)
this
.
$router
.
push
(
path
)
}
}
...
@@ -117,11 +131,13 @@ export default {
...
@@ -117,11 +131,13 @@ export default {
const
data
=
{
const
data
=
{
path
:
!
isHttp
(
router
.
path
)
?
path
.
resolve
(
basePath
,
router
.
path
)
:
router
.
path
,
path
:
!
isHttp
(
router
.
path
)
?
path
.
resolve
(
basePath
,
router
.
path
)
:
router
.
path
,
title
:
[...
prefixTitle
]
title
:
[...
prefixTitle
],
icon
:
''
}
}
if
(
router
.
meta
&&
router
.
meta
.
title
)
{
if
(
router
.
meta
&&
router
.
meta
.
title
)
{
data
.
title
=
[...
data
.
title
,
router
.
meta
.
title
]
data
.
title
=
[...
data
.
title
,
router
.
meta
.
title
]
data
.
icon
=
router
.
meta
.
icon
if
(
router
.
redirect
!==
'noRedirect'
)
{
if
(
router
.
redirect
!==
'noRedirect'
)
{
// only push the routes with title
// only push the routes with title
...
@@ -146,51 +162,70 @@ export default {
...
@@ -146,51 +162,70 @@ export default {
},
},
querySearch
(
query
)
{
querySearch
(
query
)
{
if
(
query
!==
''
)
{
if
(
query
!==
''
)
{
this
.
options
=
this
.
fuse
.
search
(
query
)
this
.
options
=
this
.
fuse
.
search
(
query
)
.
map
((
item
)
=>
item
.
item
)
??
this
.
searchPool
}
else
{
}
else
{
this
.
options
=
[]
this
.
options
=
this
.
searchPool
}
}
}
}
}
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
'scss'
scoped
>
.header-search
{
::v-deep
{
font-size
:
0
!
important
;
.el-dialog__header
{
padding
:
0
!
important
;
}
}
.header-search
{
.search-icon
{
.search-icon
{
cursor
:
pointer
;
cursor
:
pointer
;
font-size
:
18px
;
font-size
:
18px
;
vertical-align
:
middle
;
vertical-align
:
middle
;
}
}
}
.header-search-select
{
.result-wrap
{
font-size
:
18px
;
height
:
280px
;
transition
:
width
0
.2s
;
margin
:
12px
0
;
width
:
0
;
overflow
:
hidden
;
background
:
transparent
;
border-radius
:
0
;
display
:
inline-block
;
vertical-align
:
middle
;
::v-deep
.el-input__inner
{
.search-item
{
border-radius
:
0
;
display
:
flex
;
border
:
0
;
height
:
48px
;
padding-left
:
0
;
padding-right
:
0
;
.left
{
box-shadow
:
none
!
important
;
width
:
60px
;
border-bottom
:
1px
solid
#d9d9d9
;
text-align
:
center
;
vertical-align
:
middle
;
.menu-icon
{
width
:
18px
;
height
:
18px
;
margin-top
:
5px
;
}
}
}
}
&
.show
{
.search-info
{
.header-search-select
{
padding-left
:
5px
;
width
:
210px
;
width
:
100%
;
margin-left
:
10px
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
flex-start
;
.menu-title
,
.menu-path
{
height
:
20px
;
}
.menu-path
{
color
:
#ccc
;
font-size
:
10px
;
}
}
}
}
}
.search-item
:hover
{
cursor
:
pointer
;
}
}
}
</
style
>
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论