mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-28 10:21:34 +08:00
feat: Optimize menu display sorting (#10666)
This commit is contained in:
parent
4ed2a03222
commit
7367d47d27
4 changed files with 18 additions and 7 deletions
|
|
@ -51,7 +51,7 @@
|
|||
highlight-current-row
|
||||
height="40vh"
|
||||
@row-click="handleRowClick"
|
||||
class="cursor-pointer"
|
||||
class="cursor-pointer dialog-file-list"
|
||||
>
|
||||
<el-table-column prop="name" show-overflow-tooltip fix>
|
||||
<template #default="{ row }">
|
||||
|
|
@ -442,4 +442,7 @@ defineExpose({
|
|||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
:deep(.dialog-file-list .el-table__body tr.current-row > td.el-table__cell) {
|
||||
background-color: var(--panel-main-bg-color-4);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ const search = async () => {
|
|||
});
|
||||
let rstMenuList: RouteRecordRaw[] = [];
|
||||
let resMenuList: RouteRecordRaw[] = [];
|
||||
for (const menu of menuStore.menuList) {
|
||||
resMenuList = adjustAndCleanMenu(hideMenu, menuStore.menuList);
|
||||
for (const menu of resMenuList) {
|
||||
let menuItem = JSON.parse(JSON.stringify(menu));
|
||||
if (!showMap[menuItem.name]) {
|
||||
continue;
|
||||
|
|
@ -133,8 +134,7 @@ const search = async () => {
|
|||
const indexB = rootMap.get(labelB) ?? Infinity;
|
||||
return indexA - indexB;
|
||||
});
|
||||
resMenuList = adjustAndCleanMenu(hideMenu, rstMenuList);
|
||||
menuStore.menuList = resMenuList;
|
||||
menuStore.menuList = rstMenuList;
|
||||
};
|
||||
|
||||
function buildIndexMap(list: any[]): Map<string, number> {
|
||||
|
|
@ -177,7 +177,15 @@ function adjustAndCleanMenu(menuItem, list) {
|
|||
if (!matched) continue;
|
||||
|
||||
if (Array.isArray(ref.children) && ref.children.length > 0) {
|
||||
const childMap = buildIndexMap(ref.children || []);
|
||||
matched.children = buildTree(ref.children);
|
||||
matched.children.sort((a, b) => {
|
||||
const labelA = a.name;
|
||||
const labelB = b.name;
|
||||
const indexA = childMap.get(labelA) ?? Infinity;
|
||||
const indexB = childMap.get(labelB) ?? Infinity;
|
||||
return indexA - indexB;
|
||||
});
|
||||
} else {
|
||||
delete matched.children;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const req = reactive({
|
|||
});
|
||||
const open = ref(false);
|
||||
const data = ref([]);
|
||||
const em = defineEmits(['close', 'jump', 'toFavorite']);
|
||||
const em = defineEmits(['close', 'jump', 'to-favorite']);
|
||||
|
||||
const handleClose = () => {
|
||||
open.value = false;
|
||||
|
|
@ -46,7 +46,7 @@ const handleClose = () => {
|
|||
|
||||
const toFavorite = (row: File.Favorite) => {
|
||||
open.value = false;
|
||||
em('toFavorite', row);
|
||||
em('to-favorite', row);
|
||||
};
|
||||
const openDir = (url: string) => {
|
||||
open.value = false;
|
||||
|
|
|
|||
|
|
@ -642,7 +642,7 @@
|
|||
<Detail ref="detailRef" />
|
||||
<DeleteFile ref="deleteRef" @close="search" />
|
||||
<RecycleBin ref="recycleBinRef" @close="search" />
|
||||
<Favorite ref="favoriteRef" @close="search" @jump="jump" @toFavorite="toFavorite" />
|
||||
<Favorite ref="favoriteRef" @close="search" @jump="jump" @to-favorite="toFavorite" />
|
||||
<BatchRole ref="batchRoleRef" @close="search" />
|
||||
<VscodeOpenDialog ref="dialogVscodeOpenRef" />
|
||||
<Preview ref="previewRef" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue