Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 控制菜单显隐属性添加 #90

Merged
merged 6 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="menu-router">
<tiny-tree-menu
ref="tree"
:data="treeData"
:data="treeDataFilter"
:show-filter="false"
node-key="id"
wrap
Expand Down Expand Up @@ -37,6 +37,7 @@
import { TreeMenu as tinyTreeMenu } from '@opentiny/vue';
import router from '@/router';
import { useUserStore } from '@/store';
import { TabItem } from '@opentiny/vue';

// icon图标
const iconDownloadCloud = IconDownloadCloud();
Expand Down Expand Up @@ -204,6 +205,18 @@
const userStore = useUserStore();
const role = computed(() => userStore.role);
let treeData = ref(copyRouter);
const treeDataForEach = (arr: any[]) => {
return arr.filter((e: { children: any[]; meta: { hideInMenu: any } }) => {
if (e.children) {
e.children = e.children.filter((v: { meta: { hideInMenu: any } }) => {
return !v.meta.hideInMenu;
});
treeDataForEach(e.children);
}
return !e.meta.hideInMenu;
});
};
const treeDataFilter = treeDataForEach(treeData.value);

watch(
role,
Expand Down Expand Up @@ -255,7 +268,6 @@
</script>

<style lang="less" scoped>

.main-title {
height: 20px;
font-size: 14px;
Expand Down Expand Up @@ -284,12 +296,22 @@
height: 1.3em;
}
}
:deep(.tiny-tree-menu .tiny-tree .tiny-tree-node.is-current>.tiny-tree-node__content) {
:deep(.tiny-tree-node__wrapper > .is-current > .tiny-tree-node__content) {
background: var(--ti-tree-menu-node-hover-bg-color);
margin-left: 0 !important;
&:hover {
background: var(--ti-tree-menu-node-hover-bg-color) !important;
background: var(--ti-tree-menu-node-hover-bg-color) !important;
}
}
.tiny-tree-menu .tiny-tree .tiny-tree-node.is-current > .tiny-tree-node__content .tree-node-name .tiny-svg {
:deep(.tiny-tree-node > .tiny-tree-node__content) {
margin-left: 0 !important;
}
.tiny-tree-menu
.tiny-tree
.tiny-tree-node.is-current
> .tiny-tree-node__content
.tree-node-name
.tiny-svg {
fill: var(--ti-base-icon-color);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@

// 路由子菜单选中后的样式
:deep(.tiny-tree-node__children .tiny-tree-node__content) {
padding-left: 28px !important;
.tree-node-name {
margin-left: 60px !important;
padding-left: 6px !important;
}
}

:deep(.tiny-tree-node__children > .tree-node-body) {
padding-left: 50px;
}
.theme-box {
position: fixed;
top: 88%;
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
'messageBox.userCenter': 'User Center',
'messageBox.userSettings': 'User Settings',
'messageBox.logout': 'Logout',
'menu.cloud': 'Cloud service capability display',
'menu.cloud': 'Cloud service capability',
...localeTheme,
...localeSettings,
...localeLogin,
Expand Down