forked from TencentBlueKing/bk-job
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request TencentBlueKing#1752 from Tencent/master
merge: master to 3.7.x
- Loading branch information
Showing
9 changed files
with
264 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...rontend/src/components/task-step/common/execute-target/components/dropdown-menu/group.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div> | ||
<div | ||
ref="handleRef" | ||
class="dropdown-menu-group" | ||
:class="{ | ||
active: isActive | ||
}"> | ||
<slot /> | ||
<i class="toggle-flag bk-icon icon-angle-right" /> | ||
</div> | ||
<div | ||
ref="popRef" | ||
style="padding: 5px 0; margin: -0.3rem -0.6rem;" | ||
@click="handleClick"> | ||
<slot name="action" /> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup> | ||
import Tippy from 'bk-magic-vue/lib/utils/tippy'; | ||
import { | ||
onBeforeUnmount, | ||
onMounted, | ||
ref, | ||
} from 'vue'; | ||
const handleRef = ref(); | ||
const popRef = ref(); | ||
const isActive = ref(false); | ||
let tippyInstance; | ||
const handleClick = () => { | ||
tippyInstance.hide(); | ||
}; | ||
onMounted(() => { | ||
tippyInstance = Tippy(handleRef.value, { | ||
arrow: false, | ||
allowHTML: false, | ||
content: popRef.value, | ||
placement: 'right-start', | ||
trigger: 'mouseenter', | ||
theme: 'light', | ||
hideOnClick: false, | ||
ignoreAttributes: true, | ||
animateFill: false, | ||
boundary: 'window', | ||
interactive: true, | ||
distance: 6, | ||
onShow () { | ||
isActive.value = true; | ||
}, | ||
onHide () { | ||
isActive.value = false; | ||
}, | ||
}); | ||
}); | ||
onBeforeUnmount(() => { | ||
if (tippyInstance) { | ||
tippyInstance.hide(); | ||
tippyInstance.destroy(); | ||
tippyInstance = null; | ||
} | ||
}); | ||
</script> | ||
<style lang="postcss"> | ||
.dropdown-menu-group { | ||
display: flex; | ||
height: 32px; | ||
padding: 0 10px; | ||
font-size: 12px; | ||
color: #63656e; | ||
align-items: center; | ||
cursor: pointer; | ||
&.active { | ||
color: #3a84ff; | ||
background: #f5f6fa; | ||
} | ||
.toggle-flag { | ||
margin-left: auto; | ||
font-size: 16px; | ||
} | ||
} | ||
</style> |
68 changes: 68 additions & 0 deletions
68
...rontend/src/components/task-step/common/execute-target/components/dropdown-menu/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<div class="host-dropdown-menu"> | ||
<div | ||
ref="handleRef" | ||
@mouseenter="handleShow"> | ||
<slot /> | ||
</div> | ||
<div | ||
ref="popRef" | ||
style="width: 98px; padding: 5px 0; margin: -0.3rem -0.6rem;"> | ||
<slot name="menu" /> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup> | ||
import Tippy from 'bk-magic-vue/lib/utils/tippy'; | ||
import { | ||
onBeforeUnmount, | ||
onMounted, | ||
ref, | ||
} from 'vue'; | ||
const handleRef = ref(); | ||
const popRef = ref(); | ||
const isActive = ref(false); | ||
let tippyInstance; | ||
const handleShow = () => { | ||
tippyInstance.show(); | ||
}; | ||
onMounted(() => { | ||
tippyInstance = Tippy(handleRef.value, { | ||
arrow: false, | ||
allowHTML: false, | ||
content: popRef.value, | ||
placement: 'bottom-start', | ||
trigger: 'manual', | ||
theme: 'light', | ||
hideOnClick: true, | ||
animateFill: false, | ||
interactive: true, | ||
boundary: 'window', | ||
distance: 6, | ||
onShow () { | ||
isActive.value = true; | ||
}, | ||
onHide () { | ||
isActive.value = false; | ||
}, | ||
}); | ||
}); | ||
onBeforeUnmount(() => { | ||
if (tippyInstance) { | ||
tippyInstance.hide(); | ||
tippyInstance.destroy(); | ||
tippyInstance = null; | ||
} | ||
}); | ||
</script> | ||
<style lang="postcss" scoped> | ||
.host-dropdown-menu { | ||
display: block; | ||
} | ||
</style> |
29 changes: 29 additions & 0 deletions
29
...frontend/src/components/task-step/common/execute-target/components/dropdown-menu/item.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<div | ||
class="dropdown-menu-item" | ||
v-on="listeners"> | ||
<slot /> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { useListeners } from 'vue'; | ||
const listeners = useListeners(); | ||
</script> | ||
<style lang="postcss" scoped> | ||
.dropdown-menu-item { | ||
display: flex; | ||
height: 32px; | ||
padding: 0 10px; | ||
font-size: 12px; | ||
color: #63656e; | ||
align-items: center; | ||
cursor: pointer; | ||
&:hover { | ||
color: #3a84ff; | ||
background: #f5f6fa; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.