福州一menuBar 调整

This commit is contained in:
fan 2022-11-22 09:50:53 +08:00
parent 00c2dfc377
commit 6601bdac1b
2 changed files with 41 additions and 2 deletions

View File

@ -16,7 +16,7 @@
</div> </div>
</template> </template>
<script> <script>
// import MenuContextHandler from '@/scripts/cmdPlugin/MenuContextHandler'; import { menuBarConvert } from '@/scripts/MenuContextHandler';
import EachChildMenu from './eachChildMenu'; import EachChildMenu from './eachChildMenu';
export default { export default {
@ -64,7 +64,7 @@ export default {
return true; return true;
}, },
initMenu() { initMenu() {
// this.menu = MenuContextHandler.menuBarConvert(this.menuNormal, this.$store.state.training.operatemode); this.menu = menuBarConvert(this.menuNormal, this.$store.state.training.operatemode);
}, },
noShowingChildren(children) { noShowingChildren(children) {
if (!children || children.length <= 0) { if (!children || children.length <= 0) {

View File

@ -0,0 +1,39 @@
import { OperateMode } from '@/scripts/ConstDic';
export function menuBarConvert(menu, mode) {
if (menu) {
if (mode === OperateMode.NORMAL) {
menu.forEach(item => {
if (item.type === 'separator') {
item.show = true;
return;
}
item.show = false;
if (!item.click) {
item.click = () => { };
}
if (!item.force) {
item.show = true;
if (item.children && item.children.length > 0) {
this.menuBarConvert(item.children, mode);
}
}
});
} else if (mode === OperateMode.ADMIN) {
menu.forEach(item => {
item.show = true;
if (!item.click) {
item.click = () => { };
}
if (item.children && item.children.length > 0) {
this.menuBarConvert(item.children, mode);
}
});
}
}
return menu || [];
}