index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. </ui-editor-menu>
  20. </template>
  21. <script setup lang="ts">
  22. import Item from "./item/index.vue";
  23. import { findMenuLocals, MenuAtom, MenuRaw } from "./menu";
  24. import { isEdit, showToolbar } from "@/store";
  25. import { computed } from "vue";
  26. import { router } from "@/router";
  27. import { os } from "@/utils";
  28. import { customMap } from "@/hook";
  29. import { currentApp } from "@/store/app";
  30. const props = defineProps<{
  31. disabledGoto?: boolean;
  32. menu: MenuRaw;
  33. activeKey?: string;
  34. }>();
  35. const emit = defineEmits<{
  36. (e: "update:activeKey", v: MenuAtom["name"]): void;
  37. }>();
  38. const gotoMenuItem = (item: MenuAtom) => {
  39. console.error(item)
  40. //test
  41. if(item['key'] =='structure'){
  42. item.onClick()
  43. return
  44. }
  45. if (!props.disabledGoto) {
  46. if (item.onClick) {
  47. item.onClick();
  48. } else if (item.isRoute) {
  49. router.push({ name: item.name as string });
  50. }
  51. emit("update:activeKey", item.name);
  52. }
  53. };
  54. const active = computed(() =>
  55. findMenuLocals(
  56. props.activeKey || (router.currentRoute.value.name as string),
  57. currentApp.menu.value.relation as any
  58. )
  59. );
  60. </script>
  61. <style lang="sass" scoped>
  62. @import './style.scss'
  63. </style>
  64. <style lang="scss">
  65. .global-menu {
  66. display: flex;
  67. flex-direction: column;
  68. .ui-editor-menu-item {
  69. position: relative;
  70. }
  71. > div:not(.logo, .menu-close) {
  72. flex: 1;
  73. }
  74. .logo {
  75. flex: none;
  76. width: auto;
  77. height: auto;
  78. a {
  79. color: inherit;
  80. text-decoration: none;
  81. }
  82. }
  83. }
  84. .global-menu,
  85. .menu-children {
  86. .ui-menu-item span {
  87. font-size: 14px;
  88. }
  89. .ui-menu-item .icon {
  90. font-size: 20px !important;
  91. }
  92. }
  93. .readonly .menu-item {
  94. cursor: inherit;
  95. pointer-events: none;
  96. color: var(--editor-men-color) !important;
  97. }
  98. </style>