ci(document): 新增文档内容检索

This commit is contained in:
就眠仪式 2021-10-09 16:15:02 +08:00
parent b4ff364b49
commit 831bad517f
2 changed files with 48 additions and 8 deletions

View File

@ -9,9 +9,9 @@
<input
type="text"
placeholder="请选择"
:value="name"
class="layui-input layui-unselect"
@input="change"
:value="name"
style="
background: rgba(255, 255, 255, 0.05);
border: none;
@ -20,10 +20,11 @@
/><i class="layui-edge"></i>
</div>
<dl class="layui-anim layui-anim-upbit" style="">
<dd lay-value="" class="layui-select-tips">请选择</dd>
<dd v-if="menus.length <= 0" class="layui-select-tips">无内容</dd>
<dd
v-for="data in datas"
lay-value=""
v-else
v-for="data in menus"
:value = "name"
@click="jump(data)"
:key="data"
class="layui-select-tips"
@ -47,7 +48,7 @@ const route = useRoute()
const router = useRouter()
const openState = ref(false)
const menus = ref(props.datas)
const name = ref('')
const open = function () {
@ -55,7 +56,48 @@ const open = function () {
}
const jump = function (data: any) {
router.push(data.path)
name.value = data.title
router.push(data.path)
}
const change = function(e: any) {
name.value = e.target.value
if(e.target.value === ""){
menus.value = props.datas
}else{
menus.value = searchList(e.target.value, props.datas);
}
}
const searchList = function (str: String, container: any) {
var newList = []
var startChar = str.charAt(0)
var strLen = str.length
for (var i = 0; i < container.length; i++) {
var obj = container[i]
var isMatch = false
for (var p in obj) {
if (typeof obj[p] == 'function') {
obj[p]()
} else {
var curItem = ''
if (obj[p] != null) {
curItem = obj[p]
}
for (var j = 0; j < curItem.length; j++) {
if (curItem.charAt(j) == startChar) {
if (curItem.substring(j).substring(0, strLen) == str) {
isMatch = true
break
}
}
}
}
}
if (isMatch) {
newList.push(obj)
}
}
return newList
}
</script>

View File

@ -175,9 +175,7 @@ const searchList = function (str: String, container: any) {
}
for (var j = 0; j < curItem.length; j++) {
if (curItem.charAt(j) == startChar) {
//,
if (curItem.substring(j).substring(0, strLen) == str) {
//jstrok
isMatch = true
break
}