提交 23006170 编写于 作者: LUCIFER-ZHU's avatar LUCIFER-ZHU

update:更新菜单默认选中

上级 4eb69ac1
......@@ -7,6 +7,7 @@
funcTag: "{{item.psAppFunc.id}}",
hidden: {{#if item.hidden}}true{{else}}false{{/if}},
disableClose: {{#if item.disableClose}}true{{else}}false{{/if}},
openDefault: {{#if item.openDefault}}true{{else}}false{{/if}},
{{#if item.counterId}}
counterId: "{{item.counterId}}",
{{/if}}
......
......@@ -70,14 +70,14 @@ export class MenuControl extends ControlBase {
const { funcs, defaultView, menuAlign } = this.state;
const defaultSelectRef = toRef(this.state, 'defaultSelect');
const dataRef = toRef(this.state, 'menus');
if (route.matched?.length == 2) {
if (route.matched?.length == 2) { // 存在二级路由
const [{ }, matched] = route.matched;
const appFunc: any = funcs.find((func: any) => Object.is(func.routePath, matched.path) && Object.is(func.funcType, 'APPVIEW'));
if (appFunc) {
this.computeMenuSelect(dataRef.value, appFunc.funcTag);
}
return;
} else if (defaultView) {
} else if (defaultView) { // 存在默认视图
const appFunc: any = funcs.find((func: any) => Object.is(func.appView, defaultView) && Object.is(func.funcType, 'APPVIEW'));
if (appFunc) {
this.computeMenuSelect(dataRef.value, appFunc.funcTag);
......@@ -110,12 +110,12 @@ export class MenuControl extends ControlBase {
if (Object.is(funcTag, '') && item.funcTag && item.openDefault && !item.hidden) {
const appFunc = funcs?.find((func: any) => Object.is(func.funcTag, item.funcTag));
if (appFunc) {
defaultSelectRef.value = [item.id];
defaultSelectRef.value = [item.name];
return true;
}
}
if (item.funcTag && Object.is(item.funcTag, funcTag)) {
defaultSelectRef.value = [item.id];
defaultSelectRef.value = [item.name];
return true;
}
if (item.items?.length > 0) {
......@@ -123,7 +123,7 @@ export class MenuControl extends ControlBase {
if (state) {
const defaultOpen = defaultOpensRef.value?.find((open: string) => Object.is(item.id, open));
if (!defaultOpen) {
defaultOpensRef.value = [...defaultOpensRef.value, item.id];
defaultOpensRef.value = [...defaultOpensRef.value, item.name];
}
return true;
}
......
......@@ -8,5 +8,5 @@ export const ctrlState = {
{{> @macro/front-end/widgets/menu-detail/include-menu.hbs type="MENUITEM" item=item}}
{{/each}}
],
funcs: [],
funcs: App.getAllFuncs(),
};
\ No newline at end of file
......@@ -22,10 +22,10 @@ interface CtrlEmit {
}
const emit = defineEmits <CtrlEmit> ();
const { name, state, onMenuSelect } = new MenuControl(ctrlState, props, emit).moduleInstall();
const { name, state, onMenuSelect, load } = new MenuControl(ctrlState, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ name, state });
defineExpose({ name, state, load });
</script>
<template>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册