fix: SimpleRootMenuContextProps type error
parent
abb7466c7e
commit
d819fd8e47
|
@ -55,7 +55,7 @@ const getProps = computed((): DrawerProps => {
|
||||||
opt.rootClassName = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls
|
opt.rootClassName = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls
|
||||||
|
|
||||||
if (!getContainer)
|
if (!getContainer)
|
||||||
opt.getContainer = `.${prefixVar}-layout-content` as any
|
opt.getContainer = `.${prefixVar}-layout-content`
|
||||||
}
|
}
|
||||||
return opt as DrawerProps
|
return opt as DrawerProps
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, getCurrentInstance, nextTick, onMounted, provide, ref, watch, watchEffect } from 'vue'
|
import { computed, getCurrentInstance, nextTick, onMounted, provide, ref, watch, watchEffect } from 'vue'
|
||||||
import type { SubMenuProvider } from './types'
|
import type { SubMenuProvider } from './types'
|
||||||
import { createSimpleRootMenuContext } from './useSimpleMenuContext'
|
import { createSimpleRootMenuContext, type MenuEmitterEvents } from './useSimpleMenuContext'
|
||||||
import { useDesign } from '@/hooks/web/useDesign'
|
import { useDesign } from '@/hooks/web/useDesign'
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { mitt } from '@/utils/mitt'
|
import { mitt } from '@/utils/mitt'
|
||||||
|
@ -28,14 +28,7 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['select', 'open-change'])
|
const emit = defineEmits(['select', 'open-change'])
|
||||||
|
|
||||||
const rootMenuEmitter = mitt<{
|
const rootMenuEmitter = mitt<MenuEmitterEvents>()
|
||||||
'on-update-opened': (string | number)[]
|
|
||||||
'on-menu-item-select': string | number
|
|
||||||
'open-name-change': {
|
|
||||||
name: string
|
|
||||||
opened: boolean
|
|
||||||
}
|
|
||||||
}>()
|
|
||||||
const instance = getCurrentInstance()
|
const instance = getCurrentInstance()
|
||||||
|
|
||||||
const currentActiveName = ref<string | number>('')
|
const currentActiveName = ref<string | number>('')
|
||||||
|
|
|
@ -53,7 +53,7 @@ export function useMenuItem(instance: ComponentInternalInstance | null) {
|
||||||
list: [],
|
list: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const ret: any[] = []
|
const ret: ComponentInternalInstance[] = []
|
||||||
while (parent && parent.type.name !== 'Menu') {
|
while (parent && parent.type.name !== 'Menu') {
|
||||||
if (parent.type.name === 'SubMenu')
|
if (parent.type.name === 'SubMenu')
|
||||||
ret.push(parent)
|
ret.push(parent)
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
import type { InjectionKey, Ref } from 'vue'
|
import type { InjectionKey, Ref, ComponentInternalInstance } from 'vue'
|
||||||
import type { Emitter } from '@/utils/mitt'
|
import type { Emitter } from '@/utils/mitt'
|
||||||
import { createContext, useContext } from '@/hooks/core/useContext'
|
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 {
|
export interface SimpleRootMenuContextProps {
|
||||||
rootMenuEmitter: Emitter
|
rootMenuEmitter: Emitter<MenuEmitterEvents>
|
||||||
activeName: Ref<string | number>
|
activeName: Ref<string | number>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue