rightClick.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <ul
  3. v-if="show"
  4. :style="{ top: y + 'px', left: x + 'px' }"
  5. class="absolute c-#fff right-box py-1 flex flex-col items-center justify-center bg-#2262acb3"
  6. >
  7. <li
  8. class="px-4 py-1 cursor-pointer hover:bg-#2262ac mb-2 last:mb-0"
  9. @click="item.handler"
  10. v-for="(item, i) in menu"
  11. :key="i"
  12. >{{ item.label }}</li
  13. >
  14. </ul>
  15. </template>
  16. <script setup>
  17. import { useModal } from 'naive-ui'
  18. import { useOutsideSystemStore } from '@/stores/modules/system.js'
  19. import AddTag from './addTag.vue'
  20. const show = defineModel()
  21. const modal = useModal()
  22. const useSystem = useOutsideSystemStore()
  23. const props = defineProps({
  24. x: {
  25. type: Number,
  26. default: 0
  27. },
  28. y: {
  29. type: Number,
  30. default: 0
  31. }
  32. })
  33. const menu = [
  34. {
  35. label: '创建标签',
  36. handler: () => {
  37. show.value = false
  38. modal.create({
  39. title: '新建标签',
  40. draggable: true,
  41. preset: 'card',
  42. maskClosable: false,
  43. content: () =>
  44. h(AddTag, {
  45. baseInfo: {
  46. X: props.x / useSystem.ratio.wR,
  47. Y: props.y / useSystem.ratio.hR
  48. },
  49. onCloseAddTagModal: () => modal.destroyAll()
  50. })
  51. })
  52. }
  53. }
  54. ]
  55. </script>