childMenus.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="graphic-child-menus">
  3. <div class="header">
  4. <ui-icon type="return" class="icon" ctrl @click="$emit('quit')" />
  5. <p>{{ title }}</p>
  6. </div>
  7. <div class="menu-list">
  8. <div
  9. v-for="menu in menus"
  10. :key="menu.key"
  11. class="menu"
  12. :class="{ active: uiType.current === menu.key }"
  13. @click="clickHandler(menu)"
  14. >
  15. <ui-icon :type="menu.icon" class="icon" />
  16. <p>{{ menu.text }}</p>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import { MenusRaw, findMainMenuByAttr } from "@/views/graphic/menus";
  23. import UiIcon from "@/components/base/components/icon/index.vue";
  24. import { uiType } from "@/hook/useGraphic";
  25. import { computed } from "vue";
  26. const props = defineProps<{ menus: MenusRaw }>();
  27. const title = computed(() => findMainMenuByAttr(props.menus)?.text);
  28. const emit = defineEmits<{ (e: "quit") }>();
  29. const clickHandler = (menu) => {
  30. uiType.change(menu.key as any);
  31. emit("quit");
  32. };
  33. </script>
  34. <style lang="scss" scoped>
  35. .graphic-child-menus {
  36. background-color: var(--editor-menu-back);
  37. position: absolute;
  38. top: calc(var(--editor-head-height) + var(--header-top));
  39. bottom: 0;
  40. left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  41. padding: 16px;
  42. overflow-y: auto;
  43. .menu-list {
  44. display: grid;
  45. grid-template-columns: repeat(3, 80px);
  46. grid-gap: 16px;
  47. }
  48. }
  49. .menu {
  50. display: flex;
  51. flex-direction: column;
  52. cursor: pointer;
  53. height: 100px;
  54. pointer-events: none;
  55. transition: color 0.3s ease;
  56. //&:hover,
  57. &.active {
  58. color: var(--colors-primary-base);
  59. }
  60. &.active {
  61. background-color: rgba(255, 255, 255, 0.06);
  62. }
  63. .icon {
  64. display: flex;
  65. align-items: center;
  66. justify-content: center;
  67. flex: 1;
  68. font-size: 40px;
  69. text-align: center;
  70. background: #383838;
  71. }
  72. p {
  73. padding: 4px;
  74. font-size: 12px;
  75. text-align: center;
  76. }
  77. }
  78. .header {
  79. margin-bottom: 10px;
  80. padding: 5px 0;
  81. text-align: center;
  82. font-size: 16px;
  83. position: relative;
  84. .icon {
  85. position: absolute;
  86. top: 50%;
  87. transform: translateY(-50%);
  88. left: 0;
  89. }
  90. }
  91. </style>