File size: 619 Bytes
4d70170 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import { getBridge } from '@front/features/bridge'
import { BridgeEvents } from '@vue-devtools/shared-utils'
import type { Ref } from 'vue'
import throttle from 'lodash/throttle'
const throttledSend = throttle((id?: string) => {
if (id) {
getBridge().send(BridgeEvents.TO_BACK_COMPONENT_MOUSE_OVER, id)
}
else {
getBridge().send(BridgeEvents.TO_BACK_COMPONENT_MOUSE_OUT)
}
}, 200)
export function useComponentHighlight(id: Ref<string>) {
function highlight() {
throttledSend(id.value)
}
function unhighlight() {
throttledSend(null)
}
return {
highlight,
unhighlight,
}
}
|