Top.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div :class="classObj" class="app__wrap">
  3. <!-- Top -->
  4. <div class="sidebar__wrap--Top">
  5. <div>
  6. <logo
  7. v-if="showLogo"
  8. :collapsed="collapsed"
  9. />
  10. </div>
  11. <div class="sidebar__item--Top">
  12. <sider :layout="layout" mode="horizontal" />
  13. </div>
  14. <div>
  15. <div v-if="showScreenfull || showUserInfo" class="navbar__wrap--right">
  16. <screenfull v-if="showScreenfull" class="hover-container screenfull-container" />
  17. <user-info v-if="showUserInfo" class="hover-container user-container" />
  18. </div>
  19. </div>
  20. </div>
  21. <!-- Top -->
  22. <div
  23. class="main__wrap"
  24. :class="{
  25. 'main__wrap--collapsed': collapsed
  26. }"
  27. >
  28. <el-scrollbar
  29. class="main__wrap--content"
  30. :class="{
  31. 'main__wrap--fixed--all': fixedHeader && showNavbar && showTags,
  32. 'main__wrap--fixed--nav': fixedHeader && showNavbar && !showTags,
  33. 'main__wrap--fixed--tags': fixedHeader && !showNavbar && showTags
  34. }"
  35. >
  36. <div
  37. class="header__wrap"
  38. :class="{
  39. 'header__wrap--fixed': fixedHeader,
  40. 'header__wrap--collapsed': fixedHeader && collapsed
  41. }"
  42. >
  43. <!-- <div
  44. v-if="showNavbar && layout !== 'Top'"
  45. class="navbar__wrap"
  46. >
  47. <hamburger
  48. v-if="showHamburger"
  49. :collapsed="collapsed"
  50. class="hover-container"
  51. @toggleClick="setCollapsed"
  52. />
  53. <breadcrumb v-if="showBreadcrumb" />
  54. <div v-if="showScreenfull || showUserInfo" class="navbar__wrap--right">
  55. <screenfull v-if="showScreenfull" class="hover-container screenfull-container" />
  56. <user-info v-if="showUserInfo" class="hover-container user-container" />
  57. </div>
  58. </div> -->
  59. <div
  60. v-if="showTags"
  61. class="tags__wrap"
  62. >
  63. <tags-view />
  64. </div>
  65. </div>
  66. <app-main />
  67. </el-scrollbar>
  68. </div>
  69. <!-- setting -->
  70. <setting />
  71. <!-- setting -->
  72. </div>
  73. </template>
  74. <script lang="ts">
  75. import { defineComponent, computed } from 'vue'
  76. import { appStore } from '_p/index/store/modules/app'
  77. import AppMain from '../components/AppMain.vue'
  78. import TagsView from '_c/TagsView/index.vue'
  79. import Logo from '_c/Logo/index.vue'
  80. import Sider from '_c/Sider/index.vue'
  81. // import Hamburger from '_c/Hamburger/index.vue'
  82. // import Breadcrumb from '_c/Breadcrumb/index.vue'
  83. import Screenfull from '_c/Screenfull/index.vue'
  84. import UserInfo from '_c/UserInfo/index.vue'
  85. import Setting from '_c/Setting/index.vue'
  86. export default defineComponent({
  87. name: 'Top',
  88. components: {
  89. Sider,
  90. // Hamburger,
  91. // Breadcrumb,
  92. Screenfull,
  93. UserInfo,
  94. AppMain,
  95. TagsView,
  96. Logo,
  97. Setting
  98. },
  99. setup() {
  100. const layout = computed(() => appStore.layout)
  101. const collapsed = computed(() => appStore.collapsed)
  102. const showLogo = computed(() => appStore.showLogo)
  103. const showTags = computed(() => appStore.showTags)
  104. const showBreadcrumb = computed(() => appStore.showBreadcrumb)
  105. const showHamburger = computed(() => appStore.showHamburger)
  106. const showScreenfull = computed(() => appStore.showScreenfull)
  107. const showUserInfo = computed(() => appStore.showUserInfo)
  108. const showNavbar = computed(() => appStore.showNavbar)
  109. // const fixedNavbar = computed(() => appStore.fixedNavbar)
  110. // const fixedTags = computed(() => appStore.fixedTags)
  111. const fixedHeader = computed(() => appStore.fixedHeader)
  112. const classObj = computed(() => {
  113. const obj = {}
  114. obj[`app__wrap--${layout.value}`] = true
  115. return obj
  116. })
  117. function setCollapsed(collapsed: boolean): void {
  118. appStore.SetCollapsed(collapsed)
  119. }
  120. return {
  121. classObj,
  122. layout,
  123. collapsed,
  124. showLogo,
  125. showTags,
  126. showBreadcrumb,
  127. showHamburger,
  128. showScreenfull,
  129. showUserInfo,
  130. showNavbar,
  131. fixedHeader,
  132. // fixedNavbar,
  133. // fixedTags,
  134. setCollapsed
  135. }
  136. }
  137. })
  138. </script>
  139. <style lang="less" scoped>
  140. .app__wrap {
  141. position: relative;
  142. height: 100%;
  143. width: 100%;
  144. .sidebar__wrap {
  145. position: fixed;
  146. width: @menuWidth;
  147. top: 0;
  148. left: 0;
  149. height: 100%;
  150. transition: width 0.2s;
  151. }
  152. .sidebar__wrap--collapsed {
  153. width: @menuMinWidth;
  154. @{deep}(.anticon-item) {
  155. display: none;
  156. }
  157. }
  158. .main__wrap {
  159. position: absolute;
  160. width: calc(~"100% - @{menuWidth}");
  161. height: 100%;
  162. top: 0;
  163. left: @menuWidth;
  164. transition: all 0.2s;
  165. z-index: 1;
  166. .header__wrap {
  167. transition: all 0.2s;
  168. .navbar__wrap {
  169. display: flex;
  170. align-items: center;
  171. height: @navbarHeight;
  172. padding: 0 20px 0 15px;
  173. position: relative;
  174. background: @contentBg;
  175. &:after {
  176. content: "";
  177. width: 100%;
  178. height: 1px;
  179. border-top: 1px solid #d8dce5;
  180. position: absolute;
  181. bottom: 0;
  182. left: 0;
  183. }
  184. @{deep}(.hover-container) {
  185. transition: background 0.2s;
  186. height: 100%;
  187. line-height: @navbarHeight + 5px;
  188. padding: 0 5px;
  189. text-align: center;
  190. &:hover {
  191. background: #f6f6f6;
  192. }
  193. }
  194. .navbar__wrap--right {
  195. display: flex;
  196. align-items: center;
  197. height: @navbarHeight;
  198. position: absolute;
  199. top: 0;
  200. right: 20px;
  201. @{deep}(.screenfull-container),
  202. @{deep}(.user-container) {
  203. line-height: @navbarHeight !important;
  204. }
  205. }
  206. }
  207. }
  208. // content样式
  209. .main__wrap--content {
  210. height: 100%;
  211. @{deep}(.el-scrollbar__wrap) {
  212. overflow-x: hidden;
  213. }
  214. }
  215. // content样式
  216. }
  217. .main__wrap--collapsed {
  218. width: calc(~"100% - @{menuMinWidth}");
  219. left: @menuMinWidth;
  220. }
  221. }
  222. // 顶部模式
  223. .app__wrap--Top {
  224. .sidebar__wrap--Top {
  225. height: @topSiderHeight;
  226. display: flex;
  227. flex-direction: row;
  228. justify-content: space-between;
  229. padding: 0 20px;
  230. background-color: @topMenuBg;
  231. position: relative;
  232. &:after {
  233. content: "";
  234. width: 100%;
  235. height: 1px;
  236. border-top: 1px solid #d8dce5;
  237. position: absolute;
  238. bottom: 0;
  239. left: 0;
  240. }
  241. .sidebar__item--Top {
  242. flex: 1;
  243. margin: 0 50px;
  244. }
  245. .navbar__wrap--right {
  246. display: flex;
  247. align-items: center;
  248. height: @topSiderHeight;
  249. @{deep}(.hover-container) {
  250. transition: background 0.2s;
  251. height: 100%;
  252. line-height: @topSiderHeight;
  253. padding: 0 5px;
  254. text-align: center;
  255. &:hover {
  256. background: #f6f6f6;
  257. }
  258. }
  259. }
  260. }
  261. .header__wrap--fixed {
  262. position: fixed !important;
  263. width: 100% !important;
  264. top: @topSiderHeight !important;
  265. left: 0 !important;
  266. z-index: 200;
  267. }
  268. .main__wrap {
  269. width: 100%;
  270. left: 0;
  271. height: calc(~"100% - @{topSiderHeight}");
  272. top: @topSiderHeight;
  273. }
  274. .main__wrap--fixed--all,
  275. .main__wrap--fixed--tags {
  276. margin-top: @navbarHeight !important;
  277. height: calc(~"100% - @{navbarHeight}") !important;
  278. }
  279. }
  280. </style>