left-window.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="cwg-sidebar bg-body" :class="{ 'sidebar-collapsed': isCollapsed, 'dark': isDark }" @mouseenter="handleHoverEnter" @mouseleave="handleHoverLeave">
  3. <view class="menu-list">
  4. <view class="menu" v-for="(item, index) in menus" :key="item.path + index">
  5. <view class="menu-item" @click="handleClick(index)">
  6. <cwg-icon :name="item.icon" :size="20" :color="!isDark ? '#6c8595' : '#fff'" />
  7. <view class="menu-label" v-t="item.label" />
  8. <view class="chevron-icon" :class="{ 'expanded': item.isOpenMenu }">
  9. <cwg-icon v-if="item.children && item.children.length" name="crm-chevron-down" :size="20"
  10. :color="!isDark ? '#97A1C0' : '#fff'" />
  11. </view>
  12. </view>
  13. <view :ref="(el) => setSubmenuRef(index, el)" class="submenu-box" :a="index" :key1="item.path + index" :b="item"
  14. :style="{
  15. height: !(item.children && item.children.length) ? '0px' : item.isOpenMenu ? item.submenuHeight + 'px' : '0px',
  16. transition: 'height 281ms cubic-bezier(0.4, 0, 0.2, 1)'
  17. }" :class="{ 'active': item.isOpenMenu }">
  18. <cwg-submenu v-if="item.children && item.children.length" :submenu-items="item.children" />
  19. </view>
  20. </view>
  21. </view>
  22. <view class="menu fixed">
  23. <view
  24. class="menu-item btn btn-outline-danger btn-app-nav btn-shadow mb-2 w-100 waves-effect ib-box btn-mode"
  25. @click="setMode('customer')" v-if="mode !== 'customer'">
  26. <cwg-icon name="crm-trade" :size="20" color="#000" />
  27. <view class="menu-label" v-t="'Home.msg.Custom'" />
  28. </view>
  29. <view
  30. class="menu-item btn btn-outline-danger btn-app-nav btn-shadow mb-2 w-100 waves-effect ib-box btn-mode"
  31. @click="setMode('ib')" v-if="mode !== 'ib' && ibStatus">
  32. <cwg-icon name="crm-ib" :size="20" color="#000" />
  33. <view class="menu-label" v-t="'Home.msg.Ib'" />
  34. </view>
  35. <view
  36. class="menu-item btn btn-outline-danger btn-app-nav btn-shadow mb-2 w-100 waves-effect ib-box btn-mode"
  37. @click="setMode('follow')" v-if="mode !== 'follow'">
  38. <cwg-icon name="crm-gd" :size="20" color="#000" />
  39. <view class="menu-label" v-t="'Documentary.title'" />
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script lang="ts" setup>
  45. import { computed, onMounted } from 'vue'
  46. import { storeToRefs } from 'pinia'
  47. import useUserStore from '@/stores/use-user-store'
  48. import { useMenuSplit } from '@/composables/useMenuSplit'
  49. import { useLeftSidebarCollapse } from '@/composables/useLeftSidebarCollapse'
  50. const { menus, setSubmenuRef, setMode, handleClick, handleSubmenuClick, mode } = useMenuSplit()
  51. const userStore = useUserStore()
  52. const { userInfo } = storeToRefs(userStore)
  53. import useGlobalStore from '@/stores/use-global-store'
  54. const globalStore = useGlobalStore()
  55. const isDark = computed(() => globalStore.theme === 'dark')
  56. const { isCollapsed, isCollapsedByToggle, syncCollapsedFromDom,toggleLeftSidebar } = useLeftSidebarCollapse()
  57. onMounted(() => {
  58. syncCollapsedFromDom()
  59. })
  60. // 处理侧边栏 hover 展开/折叠
  61. const handleHoverEnter = () => {
  62. if (isCollapsed.value) {
  63. toggleLeftSidebar(false)
  64. }
  65. }
  66. const handleHoverLeave = () => {
  67. if (!isCollapsed.value && isCollapsedByToggle.value) {
  68. toggleLeftSidebar(false)
  69. }
  70. }
  71. // ib按钮展示
  72. const ibStatus = computed(() => {
  73. return userInfo.value?.customInfo?.ibInvalid == 0 && !!userInfo.value?.ibInfo
  74. })
  75. </script>
  76. <style scoped lang="scss">
  77. @import "@/uni.scss";
  78. .cwg-sidebar {
  79. width: 100%;
  80. color: var(--bs-emphasis-color);
  81. height: calc(100vh - 56px);
  82. overflow: hidden;
  83. display: flex;
  84. flex-direction: column;
  85. align-items: center;
  86. padding: px2rpx(8);
  87. padding-top: px2rpx(20);
  88. padding-bottom: px2rpx(8);
  89. box-sizing: border-box;
  90. gap: px2rpx(8);
  91. border-right: 1px solid rgba(108, 133, 149, 0.12);
  92. .logo {
  93. width: px2rpx(54);
  94. }
  95. .menu-list {
  96. flex: 1;
  97. width: 100%;
  98. overflow-y: auto;
  99. display: flex;
  100. flex-direction: column;
  101. gap: px2rpx(8);
  102. }
  103. .submenu-box {
  104. width: 100%;
  105. height: 0;
  106. overflow: hidden;
  107. }
  108. .menu {
  109. width: 100%;
  110. position: relative;
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. box-sizing: border-box;
  115. }
  116. .menu-item {
  117. width: 100%;
  118. min-height: px2rpx(40);
  119. cursor: pointer;
  120. display: flex;
  121. align-items: center;
  122. justify-content: space-between;
  123. gap: px2rpx(8);
  124. padding: px2rpx(10);
  125. box-sizing: border-box;
  126. font-size: 14px;
  127. .menu-label {
  128. flex: 1;
  129. }
  130. .expanded .icon {
  131. transform: rotate(180deg);
  132. }
  133. }
  134. .ib-box {
  135. border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);
  136. border-radius: var(--bs-btn-border-radius);
  137. background-color: var(--bs-btn-bg);
  138. font-size: px2rpx(18);
  139. font-weight: 600;
  140. color: var(--bs-emphasis-color);
  141. :deep(.zui-svg-icon-image) {
  142. transition: filter 0.15s ease;
  143. }
  144. &:hover {
  145. color: var(--bs-btn-hover-color);
  146. background-color: var(--bs-btn-hover-bg);
  147. border-color: var(--bs-btn-hover-border-color);
  148. :deep(.zui-svg-icon-image) {
  149. filter: brightness(0) invert(1);
  150. }
  151. }
  152. }
  153. .btn-mode {
  154. justify-content: center;
  155. .menu-label {
  156. flex: none;
  157. max-width: px2rpx(150);
  158. white-space: normal;
  159. word-wrap: break-word;
  160. word-break: break-all;
  161. text-align: center;
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. }
  166. }
  167. .fixed {
  168. position: relative;
  169. width: 100%;
  170. display: flex;
  171. align-items: center;
  172. justify-content: center;
  173. gap: px2rpx(8);
  174. }
  175. }
  176. .sidebar-collapsed:not(:hover) .menu-label,
  177. .sidebar-collapsed:not(:hover) .submenu-box,
  178. .sidebar-collapsed:not(:hover) .chevron-icon {
  179. display: none;
  180. }
  181. .sidebar-collapsed:hover .menu-label,
  182. .sidebar-collapsed:hover .submenu-box,
  183. .sidebar-collapsed:hover .chevron-icon {
  184. display: block;
  185. //display: none;
  186. }
  187. .sidebar-collapsed .fixed {
  188. display: flex;
  189. }
  190. </style>