index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <ui-editor-menu
  3. :menu="menu"
  4. class="menu global-menu"
  5. :class="{ show: !isEdit, disabled: showToolbar, readonly: disabledGoto }"
  6. >
  7. <template #first v-if="!os.isPc">
  8. <div class="menu-close" @click="customMap.sysView = 'full'">
  9. <ui-icon type="close"></ui-icon>
  10. </div>
  11. </template>
  12. <template v-slot="{ raw }">
  13. <Item :menu="raw" :active="active" @select="gotoMenuItem">
  14. <template #attach="{ raw, active }">
  15. <slot name="attach" :raw="raw" :active="active"></slot>
  16. </template>
  17. </Item>
  18. </template>
  19. <template #attach>
  20. <div class="logo">
  21. <a :href="void 0" target="_blank">
  22. <img src="@/assets/images/Logo_4DVison.png" />
  23. </a>
  24. </div>
  25. </template>
  26. </ui-editor-menu>
  27. </template>
  28. <script setup lang="ts">
  29. import Item from "./item/index.vue";
  30. import { findMenuLocals, MenuAtom, MenuRaw } from "./menu";
  31. import { isEdit, showToolbar } from "@/store";
  32. import { computed } from "vue";
  33. import { router } from "@/router";
  34. import { os } from "@/utils";
  35. import { customMap } from "@/hook";
  36. import { currentApp } from "@/store/app";
  37. const props = defineProps<{
  38. disabledGoto?: boolean;
  39. menu: MenuRaw
  40. activeKey?: string
  41. }>();
  42. const emit = defineEmits<{
  43. (e: "update:activeKey", v: MenuAtom['name']): void;
  44. }>()
  45. const gotoMenuItem = (item: MenuAtom) => {
  46. if (!props.disabledGoto) {
  47. if (item.onClick) {
  48. item.onClick();
  49. } else if (item.isRoute) {
  50. router.push({ name: item.name as string });
  51. }
  52. emit('update:activeKey', item.name);
  53. }
  54. };
  55. const active = computed(() =>
  56. findMenuLocals(
  57. props.activeKey || router.currentRoute.value.name as string,
  58. currentApp.menu.value.relation as any
  59. )
  60. );
  61. </script>
  62. <style lang="sass" scoped>
  63. @import './style.scss'
  64. </style>
  65. <style lang="scss">
  66. .global-menu {
  67. display: flex;
  68. flex-direction: column;
  69. .ui-menu-item span {
  70. font-size: 12px;
  71. }
  72. .ui-editor-menu-item {
  73. position: relative;
  74. }
  75. > div:not(.logo, .menu-close) {
  76. flex: 1;
  77. }
  78. .logo {
  79. flex: none;
  80. width: auto;
  81. height: auto;
  82. a {
  83. color: inherit;
  84. text-decoration: none;
  85. }
  86. }
  87. }
  88. .readonly .menu-item {
  89. cursor: inherit;
  90. pointer-events: none;
  91. color: var(--editor-men-color) !important;
  92. }
  93. </style>