Merge branch 'master' into dev

This commit is contained in:
冷冷 2024-10-13 19:05:46 +08:00
commit aab44b42d2
2 changed files with 75 additions and 73 deletions

View File

@ -1,30 +1,30 @@
<template> <template>
<div class="layout-search-dialog"> <div class="layout-search-dialog">
<el-dialog v-model="state.isShowSearch" destroy-on-close :show-close="false"> <el-dialog v-model="state.isShowSearch" destroy-on-close :show-close="false">
<template #footer> <template #footer>
<el-autocomplete <el-autocomplete
v-model="state.menuQuery" v-model="state.menuQuery"
:fetch-suggestions="menuSearch" :fetch-suggestions="menuSearch"
:placeholder="$t('user.searchPlaceholder')" :placeholder="$t('user.searchPlaceholder')"
ref="layoutMenuAutocompleteRef" ref="layoutMenuAutocompleteRef"
@select="onHandleSelect" @select="onHandleSelect"
:fit-input-width="true" :fit-input-width="true"
> >
<template #prefix> <template #prefix>
<el-icon class="el-input__icon"> <el-icon class="el-input__icon">
<ele-Search /> <ele-Search />
</el-icon> </el-icon>
</template> </template>
<template #default="{ item }"> <template #default="{ item }">
<div> <div>
<SvgIcon :name="item.meta.icon" class="mr5" /> <SvgIcon :name="item.meta.icon" class="mr5" />
{{ $t(item.name) }} {{ $t(item.name) }}
</div> </div>
</template> </template>
</el-autocomplete> </el-autocomplete>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup lang="ts" name="layoutBreadcrumbSearch"> <script setup lang="ts" name="layoutBreadcrumbSearch">
@ -38,80 +38,81 @@ const layoutMenuAutocompleteRef = ref();
const { t } = useI18n(); const { t } = useI18n();
const router = useRouter(); const router = useRouter();
const state = reactive<SearchState>({ const state = reactive<SearchState>({
isShowSearch: false, isShowSearch: false,
menuQuery: '', menuQuery: '',
tagsViewList: [], tagsViewList: [],
}); });
// //
const openSearch = () => { const openSearch = () => {
state.menuQuery = ''; state.menuQuery = '';
state.isShowSearch = true; state.isShowSearch = true;
initTageView(); initTageView();
nextTick(() => { nextTick(() => {
setTimeout(() => { setTimeout(() => {
layoutMenuAutocompleteRef.value.focus(); layoutMenuAutocompleteRef.value.focus();
}); });
}); });
}; };
// //
const closeSearch = () => { const closeSearch = () => {
state.isShowSearch = false; state.isShowSearch = false;
}; };
// //
const menuSearch = (queryString: string, cb: Function) => { const menuSearch = (queryString: string, cb: Function) => {
let results = queryString ? state.tagsViewList.filter(createFilter(queryString)) : state.tagsViewList; let results = queryString ? state.tagsViewList.filter(createFilter(queryString)) : state.tagsViewList;
cb(results); cb(results);
}; };
// //
const createFilter = (queryString: string) => { const createFilter = (queryString: string) => {
return (restaurant: RouteItem) => { return (restaurant: RouteItem) => {
return restaurant.path.toLowerCase().indexOf(queryString.toLowerCase()) > -1 || t(restaurant!.name!).indexOf(queryString.toLowerCase()) > -1; return restaurant.path.toLowerCase().indexOf(queryString.toLowerCase()) > -1 || t(restaurant!.name!).indexOf(queryString.toLowerCase()) > -1;
}; };
}; };
// //
const initTageView = () => { const initTageView = () => {
if (state.tagsViewList.length > 0) return false; if (state.tagsViewList.length > 0) return false;
tagsViewRoutes.value.map((v: RouteItem) => { tagsViewRoutes.value.map((v: RouteItem) => {
if (!v.meta?.isHide) state.tagsViewList.push({ ...v }); if (!v.meta?.isHide) state.tagsViewList.push({ ...v });
}); });
}; };
// //
const onHandleSelect = (item: RouteItem) => { const onHandleSelect = (item: RouteItem) => {
let { path, redirect } = item; let { path, redirect } = item;
if (item.meta?.isLink && !item.meta?.isIframe) window.open(item.meta?.isLink); if (item.meta?.isLink && !item.meta?.isIframe) window.open(item.meta?.isLink);
else if (redirect) router.push(redirect); else if (redirect) router.push(redirect);
else router.push(path); else router.push(path);
closeSearch(); closeSearch();
}; };
// //
defineExpose({ defineExpose({
openSearch, openSearch,
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout-search-dialog { .layout-search-dialog {
position: relative; position: relative;
:deep(.el-dialog) { :deep(.el-dialog) {
.el-dialog__header, width: 560px;
.el-dialog__body { .el-dialog__header,
display: none; .el-dialog__body {
} display: none;
.el-dialog__footer { }
position: absolute; .el-dialog__footer {
left: 50%; position: absolute;
transform: translateX(-50%); left: 50%;
top: -53vh; transform: translateX(-50%);
} top: -53vh;
} }
:deep(.el-autocomplete) { }
width: 560px; :deep(.el-autocomplete) {
position: absolute; position: absolute;
top: 150px; width: 560px;
left: 50%; top: 53vh;
transform: translateX(-50%); left: 50%;
} transform: translateX(-50%);
}
} }
</style> </style>

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/** /**
* *
* @param val * @param val