'admin-22.12.12:发布v2.4.21版本,具体更新内容查看CHANGELOG.md' !42 修复 工作流无法添加新节点问题 Merge pull request !42 from beta/bugfix_workflow 修复 工作流无法添加新节点问题 1. 修复 工作流无法添加新节点问题 2. 修复 左侧导航无法隐藏问题 'admin-22.12.09:发布v2.4.2版本,具体更新内容查看CHANGELOG.md' !41 修复get请求传递嵌套对象或数组时无法正常编码问题 Merge pull request !41 from 随心/master !40 开启TagsView缓存后,刷新后所有的路由都变成组件缓存了 Merge pull request !40 from mrjimin/master 修复get请求传递嵌套对象或数组时无法正常编码问题 update src/layout/routerView/parent.vue. Signed-off-by: mrjimin <z8888788@163.com> update src/layout/routerView/parent.vue. 这里应该拿到的是已经设置开启组件缓存的路由,而不是全部,需要先判断item.meta.isKeepAlive Signed-off-by: mrjimin <z8888788@163.com> 'admin-22.11.30:发布v2.4.1版本,具体更新内容查看CHANGELOG.md' Merge branch 'master' of https://gitee.com/lyt-top/vue-next-admin 'admin-22.11.30:删除v2.4.0版本不需要的依赖' update src/views/error/404.vue. Signed-off-by: lyt-Top <1105290566@qq.com> update src/components/table/index.vue. Signed-off-by: lyt-Top <1105290566@qq.com> 'admin-22.11.30:修改v2.4.0文字说明' 'admin-22.11.30:修改v2.4.0文字说明' 'admin-22.11.29:发布v2.4.0版本,具体更新内容查看CHANGELOG.md' 'admin-22.11.19:修复v2.3.0版本动态路由事件调用关闭当前tagsview、普通路由刷新界面参数丢失问题' 'admin-22.11.18:优化v2.3.0版本tagsview风格5兼容火狐' 'admin-22.11.17:优化v2.3.0版本iframe右键菜单刷新问题' ...
125 lines
3.1 KiB
Vue
125 lines
3.1 KiB
Vue
<template>
|
|
<div class="layout-search-dialog">
|
|
<el-dialog v-model="state.isShowSearch" destroy-on-close :show-close="false">
|
|
<template #footer>
|
|
<el-autocomplete
|
|
v-model="state.menuQuery"
|
|
:fetch-suggestions="menuSearch"
|
|
:placeholder="$t('message.user.searchPlaceholder')"
|
|
ref="layoutMenuAutocompleteRef"
|
|
@select="onHandleSelect"
|
|
:fit-input-width="true"
|
|
>
|
|
<template #prefix>
|
|
<el-icon class="el-input__icon">
|
|
<ele-Search />
|
|
</el-icon>
|
|
</template>
|
|
<template #default="{ item }">
|
|
<div>
|
|
<SvgIcon :name="item.meta.icon" class="mr5" />
|
|
{{ $t(item.meta.title) }}
|
|
</div>
|
|
</template>
|
|
</el-autocomplete>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="layoutBreadcrumbSearch">
|
|
import { reactive, ref, nextTick } from 'vue';
|
|
import { useRouter } from 'vue-router';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { storeToRefs } from 'pinia';
|
|
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
|
|
|
|
// 定义变量内容
|
|
const storesTagsViewRoutes = useTagsViewRoutes();
|
|
const { tagsViewRoutes } = storeToRefs(storesTagsViewRoutes);
|
|
const layoutMenuAutocompleteRef = ref();
|
|
const { t } = useI18n();
|
|
const router = useRouter();
|
|
const state = reactive<SearchState>({
|
|
isShowSearch: false,
|
|
menuQuery: '',
|
|
tagsViewList: [],
|
|
});
|
|
|
|
// 搜索弹窗打开
|
|
const openSearch = () => {
|
|
state.menuQuery = '';
|
|
state.isShowSearch = true;
|
|
initTageView();
|
|
nextTick(() => {
|
|
setTimeout(() => {
|
|
layoutMenuAutocompleteRef.value.focus();
|
|
});
|
|
});
|
|
};
|
|
// 搜索弹窗关闭
|
|
const closeSearch = () => {
|
|
state.isShowSearch = false;
|
|
};
|
|
// 菜单搜索数据过滤
|
|
const menuSearch = (queryString: string, cb: Function) => {
|
|
let results = queryString ? state.tagsViewList.filter(createFilter(queryString)) : state.tagsViewList;
|
|
cb(results);
|
|
};
|
|
// 菜单搜索过滤
|
|
const createFilter = (queryString: string) => {
|
|
return (restaurant: RouteItem) => {
|
|
return (
|
|
restaurant.path.toLowerCase().indexOf(queryString.toLowerCase()) > -1 ||
|
|
restaurant.meta!.title!.toLowerCase().indexOf(queryString.toLowerCase()) > -1 ||
|
|
t(restaurant.meta!.title!).indexOf(queryString.toLowerCase()) > -1
|
|
);
|
|
};
|
|
};
|
|
// 初始化菜单数据
|
|
const initTageView = () => {
|
|
if (state.tagsViewList.length > 0) return false;
|
|
tagsViewRoutes.value.map((v: RouteItem) => {
|
|
if (!v.meta?.isHide) state.tagsViewList.push({ ...v });
|
|
});
|
|
};
|
|
// 当前菜单选中时
|
|
const onHandleSelect = (item: RouteItem) => {
|
|
let { path, redirect } = item;
|
|
if (item.meta?.isLink && !item.meta?.isIframe) window.open(item.meta?.isLink);
|
|
else if (redirect) router.push(redirect);
|
|
else router.push(path);
|
|
closeSearch();
|
|
};
|
|
|
|
// 暴露变量
|
|
defineExpose({
|
|
openSearch,
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.layout-search-dialog {
|
|
position: relative;
|
|
:deep(.el-dialog) {
|
|
.el-dialog__header,
|
|
.el-dialog__body {
|
|
display: none;
|
|
}
|
|
.el-dialog__footer {
|
|
position: absolute;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
top: -53vh;
|
|
}
|
|
}
|
|
:deep(.el-autocomplete) {
|
|
width: 560px;
|
|
position: absolute;
|
|
top: 150px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
}
|
|
}
|
|
</style>
|