fix: SimpleRootMenuContextProps type error (#3176)

This commit is contained in:
bowen 2023-10-20 09:55:34 +08:00 committed by GitHub
parent 6f7d840128
commit 83aa1da3de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 14 deletions

View File

@ -97,8 +97,7 @@
opt.rootClassName = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls;
if (!getContainer) {
// TODO type error?
opt.getContainer = `.${prefixVar}-layout-content` as any;
opt.getContainer = `.${prefixVar}-layout-content`;
}
}
return opt as DrawerProps;

View File

@ -21,7 +21,7 @@
import { useDesign } from '/@/hooks/web/useDesign';
import { propTypes } from '/@/utils/propTypes';
import { createSimpleRootMenuContext } from './useSimpleMenuContext';
import { createSimpleRootMenuContext, type MenuEmitterEvents } from './useSimpleMenuContext';
import { mitt } from '/@/utils/mitt';
export default defineComponent({
@ -45,14 +45,7 @@
},
emits: ['select', 'open-change'],
setup(props, { emit }) {
const rootMenuEmitter = mitt<{
'on-update-opened': (string | number)[];
'on-menu-item-select': string | number;
'open-name-change': {
name: string;
opened: boolean;
};
}>();
const rootMenuEmitter = mitt<MenuEmitterEvents>();
const instance = getCurrentInstance();
const currentActiveName = ref<string | number>('');

View File

@ -49,7 +49,7 @@ export function useMenuItem(instance: ComponentInternalInstance | null) {
uidList: [],
list: [],
};
const ret: any[] = [];
const ret: ComponentInternalInstance[] = [];
while (parent && parent.type.name !== 'Menu') {
if (parent.type.name === 'SubMenu') {
ret.push(parent);

View File

@ -1,9 +1,25 @@
import type { InjectionKey, Ref } from 'vue';
import type { InjectionKey, Ref, ComponentInternalInstance } from 'vue';
import type { Emitter } from '/@/utils/mitt';
import { createContext, useContext } from '/@/hooks/core/useContext';
export type MenuEmitterEvents = {
'on-update-opened':
| (string | number)[]
| {
opend: boolean;
parent?: ComponentInternalInstance | null;
uidList: number[];
};
'on-menu-item-select': string | number;
'open-name-change': {
name: string | number;
opened: boolean;
};
'on-update-active-name:submenu': number[];
};
export interface SimpleRootMenuContextProps {
rootMenuEmitter: Emitter;
rootMenuEmitter: Emitter<MenuEmitterEvents>;
activeName: Ref<string | number>;
}