mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
36 lines
804 B
TypeScript
36 lines
804 B
TypeScript
import { type Ref, ref, onMounted } from 'vue'
|
|
import { CustomNavbarItem } from './custom-navbar-item'
|
|
|
|
export const popupProps = {
|
|
item: {
|
|
type: CustomNavbarItem,
|
|
required: true,
|
|
},
|
|
container: {
|
|
type: HTMLElement,
|
|
required: true,
|
|
},
|
|
}
|
|
|
|
export const usePopup = (props: {
|
|
item: CustomNavbarItem
|
|
container: HTMLElement
|
|
}): {
|
|
el: Ref<HTMLElement | null>
|
|
popupShow: () => void
|
|
} => {
|
|
const el = ref<HTMLElement | null>(null)
|
|
onMounted(() => {
|
|
const navBarItem = props.item
|
|
const containerElement = props.container
|
|
if (containerElement) {
|
|
navBarItem?.usePopper(containerElement, el.value.parentElement)
|
|
}
|
|
})
|
|
const popupShow = (): void => {
|
|
const navBarItem = props.item
|
|
navBarItem?.popper?.update().then()
|
|
}
|
|
return { el, popupShow }
|
|
}
|