|
|
|
|
@ -1,16 +1,21 @@
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { nextTick, onMounted, ref } from 'vue'
|
|
|
|
|
import { debounce } from 'lodash-es'
|
|
|
|
|
import { asideMap } from '@/config/aside'
|
|
|
|
|
import type { SearchEntity } from '/#/home'
|
|
|
|
|
import { useConfig } from '@/store/modules/asideConfig'
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const searchContent = route.query.searchContent as string;
|
|
|
|
|
defineOptions({ name: 'Search' })
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
(e: 'close'): void
|
|
|
|
|
(e: 'select', key: string): void
|
|
|
|
|
(e: 'inputChange', value: string): void
|
|
|
|
|
(e: 'showSearch'): void
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const data = ref<SearchEntity[]>([])
|
|
|
|
|
@ -63,16 +68,29 @@ const close = () => {
|
|
|
|
|
emit('close');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const initSerach = () => {
|
|
|
|
|
if (searchContent) {
|
|
|
|
|
emit('showSearch')
|
|
|
|
|
const id_param = searchContent.match(/-\d+-/);
|
|
|
|
|
if (id_param) {
|
|
|
|
|
searchKeyword.value = id_param[0].slice(1, -1);
|
|
|
|
|
emit('inputChange', searchKeyword.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
initSerach()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="wrapper">
|
|
|
|
|
<n-popover
|
|
|
|
|
ref="popover" :style="{ padding: '0px' }" style="width: 248px" :show-arrow="false" placement="bottom-start"
|
|
|
|
|
trigger="focus"
|
|
|
|
|
>
|
|
|
|
|
<n-popover ref="popover" :style="{ padding: '0px' }" style="width: 248px" :show-arrow="false"
|
|
|
|
|
placement="bottom-start" trigger="focus">
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<n-input v-model:value="searchKeyword" style="width: 260px;height: 32px;" placeholder="请输入你需要搜索的内容" @input="inputHandler">
|
|
|
|
|
<n-input v-model:value="searchKeyword" style="width: 260px;height: 32px;" placeholder="请输入你需要搜索的内容"
|
|
|
|
|
@input="inputHandler">
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<SvgIcon size="14px" name="magnifying-1" @click="searchName" style="cursor: pointer;" />
|
|
|
|
|
</template>
|
|
|
|
|
|