index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div v-show="!isGroup">
  3. <n-icon
  4. class="go-ml-1 icon-item"
  5. :class="{ active: status.lock }"
  6. size="15"
  7. :component="status.lock ? LockClosedOutlineIcon : LockOpenOutlineIcon"
  8. @click="lockHandle"
  9. />
  10. <n-icon
  11. class="go-ml-1 icon-item"
  12. :class="{ active: status.hide }"
  13. size="15"
  14. :component="status.hide ? EyeOffOutlineIcon : EyeOutlineIcon"
  15. @click="showHandle"
  16. />
  17. </div>
  18. </template>
  19. <script setup lang="ts">
  20. import { computed, PropType } from 'vue'
  21. import { useDesignStore } from '@/store/modules/designStore/designStore'
  22. import { PublicConfigType } from '@/packages/index.d'
  23. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  24. import { LayerModeEnum } from '../../index.d'
  25. import { icon } from '@/plugins'
  26. const props = defineProps({
  27. isGroup: {
  28. type: Boolean,
  29. default: false
  30. },
  31. hover: {
  32. type: Boolean,
  33. default: false
  34. },
  35. status: {
  36. type: Object as PropType<Pick<PublicConfigType, 'status'>>,
  37. default: () => ({
  38. lock: false,
  39. hide: false
  40. })
  41. }
  42. })
  43. const { LockClosedOutlineIcon, LockOpenOutlineIcon, EyeOutlineIcon, EyeOffOutlineIcon } = icon.ionicons5
  44. const chartEditStore = useChartEditStore()
  45. const designStore = useDesignStore()
  46. // 颜色
  47. const themeColor = computed(() => {
  48. return designStore.getAppTheme
  49. })
  50. // 隐藏 / 展示
  51. const showHandle = (e: MouseEvent) => {
  52. e.stopPropagation()
  53. props.status.hide ? chartEditStore.setShow() : chartEditStore.setHide()
  54. }
  55. // 锁定 / 解锁
  56. const lockHandle = (e: MouseEvent) => {
  57. e.stopPropagation()
  58. props.status.lock ? chartEditStore.setUnLock() : chartEditStore.setLock()
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. $activeColor: v-bind('themeColor');
  63. .icon-item {
  64. opacity: 0;
  65. padding-top: 5px;
  66. &.active,
  67. &:hover {
  68. color: $activeColor;
  69. }
  70. &.active {
  71. opacity: 1 !important;
  72. }
  73. }
  74. </style>