Test.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div :class="classObj" class="app__wrap">
  3. <!-- Classic -->
  4. <div
  5. v-if="layout === 'Classic' || layout === 'LeftTop'"
  6. class="sidebar__wrap"
  7. :class="{'sidebar__wrap--collapsed': collapsed}"
  8. >
  9. <logo
  10. v-if="showLogo && layout === 'Classic'"
  11. :collapsed="collapsed"
  12. />
  13. <sider :layout="layout" mode="vertical" />
  14. </div>
  15. <!-- Classic -->
  16. <!-- Top -->
  17. <div v-if="layout !== 'Classic'" class="sidebar__wrap--Top">
  18. <div>
  19. <logo
  20. v-if="showLogo"
  21. :collapsed="collapsed"
  22. />
  23. </div>
  24. <div v-if="layout === 'Top'" class="sidebar__item--Top">
  25. <sider :layout="layout" mode="horizontal" />
  26. </div>
  27. <div>
  28. <div v-if="showScreenfull || showUserInfo" class="navbar__wrap--right">
  29. <screenfull v-if="showScreenfull" class="hover-container screenfull-container" />
  30. <user-info v-if="showUserInfo" class="hover-container user-container" />
  31. </div>
  32. </div>
  33. </div>
  34. <!-- Top -->
  35. <div
  36. class="main__wrap"
  37. :class="{
  38. 'main__wrap--collapsed': collapsed
  39. }"
  40. >
  41. <el-scrollbar
  42. class="main__wrap--content"
  43. :class="{
  44. 'main__wrap--fixed--all': fixedHeader && showNavbar && showTags,
  45. 'main__wrap--fixed--nav': fixedHeader && showNavbar && !showTags,
  46. 'main__wrap--fixed--tags': fixedHeader && !showNavbar && showTags
  47. }"
  48. >
  49. <div
  50. class="header__wrap"
  51. :class="{
  52. 'header__wrap--fixed': fixedHeader,
  53. 'header__wrap--collapsed': fixedHeader && collapsed
  54. }"
  55. >
  56. <div
  57. v-if="showNavbar && layout !== 'Top'"
  58. class="navbar__wrap"
  59. >
  60. <hamburger
  61. v-if="showHamburger"
  62. :collapsed="collapsed"
  63. class="hover-container"
  64. @toggleClick="setCollapsed"
  65. />
  66. <breadcrumb v-if="showBreadcrumb" />
  67. <div v-if="showScreenfull || showUserInfo" class="navbar__wrap--right">
  68. <screenfull v-if="showScreenfull" class="hover-container screenfull-container" />
  69. <user-info v-if="showUserInfo" class="hover-container user-container" />
  70. </div>
  71. </div>
  72. <div
  73. v-if="showTags"
  74. class="tags__wrap"
  75. >
  76. <tags-view />
  77. </div>
  78. </div>
  79. <app-main />
  80. </el-scrollbar>
  81. </div>
  82. <!-- setting -->
  83. <div class="setting__wrap" @click="toggleClick">
  84. <i class="el-icon-setting" />
  85. </div>
  86. <el-drawer
  87. v-model="drawer"
  88. direction="rtl"
  89. size="20%"
  90. >
  91. <template #title>
  92. <div class="setting__title">项目配置</div>
  93. </template>
  94. <setting />
  95. </el-drawer>
  96. <!-- setting -->
  97. </div>
  98. </template>
  99. <script lang="ts">
  100. import { defineComponent, computed, ref } from 'vue'
  101. import { appStore } from '_p/index/store/modules/app'
  102. import AppMain from '../components/AppMain.vue'
  103. import TagsView from '_c/TagsView/index.vue'
  104. import Logo from '_c/Logo/index.vue'
  105. import Sider from '_c/Sider/index.vue'
  106. import Hamburger from '_c/Hamburger/index.vue'
  107. import Breadcrumb from '_c/Breadcrumb/index.vue'
  108. import Screenfull from '_c/Screenfull/index.vue'
  109. import UserInfo from '_c/UserInfo/index.vue'
  110. import Setting from '_c/Setting/index.vue'
  111. export default defineComponent({
  112. name: 'Layout',
  113. components: {
  114. Sider,
  115. Hamburger,
  116. Breadcrumb,
  117. Screenfull,
  118. UserInfo,
  119. AppMain,
  120. TagsView,
  121. Logo,
  122. Setting
  123. },
  124. setup() {
  125. const drawer = ref<boolean>(false)
  126. const layout = computed(() => appStore.layout)
  127. const collapsed = computed(() => appStore.collapsed)
  128. const showLogo = computed(() => appStore.showLogo)
  129. const showTags = computed(() => appStore.showTags)
  130. const showBreadcrumb = computed(() => appStore.showBreadcrumb)
  131. const showHamburger = computed(() => appStore.showHamburger)
  132. const showScreenfull = computed(() => appStore.showScreenfull)
  133. const showUserInfo = computed(() => appStore.showUserInfo)
  134. const showNavbar = computed(() => appStore.showNavbar)
  135. // const fixedNavbar = computed(() => appStore.fixedNavbar)
  136. // const fixedTags = computed(() => appStore.fixedTags)
  137. const fixedHeader = computed(() => appStore.fixedHeader)
  138. const classObj = computed(() => {
  139. const obj = {}
  140. obj[`app__wrap--${layout.value}`] = true
  141. return obj
  142. })
  143. function setCollapsed(collapsed: boolean): void {
  144. appStore.SetCollapsed(collapsed)
  145. }
  146. function toggleClick(): void {
  147. drawer.value = !drawer.value
  148. }
  149. return {
  150. drawer,
  151. classObj,
  152. layout,
  153. collapsed,
  154. showLogo,
  155. showTags,
  156. showBreadcrumb,
  157. showHamburger,
  158. showScreenfull,
  159. showUserInfo,
  160. showNavbar,
  161. fixedHeader,
  162. // fixedNavbar,
  163. // fixedTags,
  164. setCollapsed,
  165. toggleClick
  166. }
  167. }
  168. })
  169. </script>
  170. <style lang="less" scoped>
  171. .app__wrap {
  172. position: relative;
  173. height: 100%;
  174. width: 100%;
  175. .sidebar__wrap {
  176. position: fixed;
  177. width: @menuWidth;
  178. top: 0;
  179. left: 0;
  180. height: 100%;
  181. transition: width 0.2s;
  182. }
  183. .sidebar__wrap--collapsed {
  184. width: @menuMinWidth;
  185. @{deep}(.anticon-item) {
  186. display: none;
  187. }
  188. }
  189. .main__wrap {
  190. position: absolute;
  191. width: calc(~"100% - @{menuWidth}");
  192. height: 100%;
  193. top: 0;
  194. left: @menuWidth;
  195. transition: all 0.2s;
  196. z-index: 1;
  197. .header__wrap {
  198. transition: all 0.2s;
  199. .navbar__wrap {
  200. display: flex;
  201. align-items: center;
  202. height: @navbarHeight;
  203. padding: 0 20px 0 15px;
  204. position: relative;
  205. background: @contentBg;
  206. &:after {
  207. content: "";
  208. width: 100%;
  209. height: 1px;
  210. border-top: 1px solid #d8dce5;
  211. position: absolute;
  212. bottom: 0;
  213. left: 0;
  214. }
  215. @{deep}(.hover-container) {
  216. transition: background 0.2s;
  217. height: 100%;
  218. line-height: @navbarHeight + 5px;
  219. padding: 0 5px;
  220. text-align: center;
  221. &:hover {
  222. background: #f6f6f6;
  223. }
  224. }
  225. .navbar__wrap--right {
  226. display: flex;
  227. align-items: center;
  228. height: @navbarHeight;
  229. position: absolute;
  230. top: 0;
  231. right: 20px;
  232. @{deep}(.screenfull-container),
  233. @{deep}(.user-container) {
  234. line-height: @navbarHeight !important;
  235. }
  236. }
  237. }
  238. }
  239. // content样式
  240. .main__wrap--content {
  241. height: 100%;
  242. @{deep}(.el-scrollbar__wrap) {
  243. overflow-x: hidden;
  244. }
  245. }
  246. // content样式
  247. }
  248. .main__wrap--collapsed {
  249. width: calc(~"100% - @{menuMinWidth}");
  250. left: @menuMinWidth;
  251. }
  252. }
  253. // 经典模式
  254. .app__wrap--Classic {
  255. .main__wrap--fixed--all {
  256. margin-top: @navbarHeight + @tagsViewHeight !important;
  257. height: calc(~"100% - @{navbarHeight} - @{tagsViewHeight}") !important;
  258. }
  259. .main__wrap--fixed--nav {
  260. margin-top: @navbarHeight !important;
  261. height: calc(~"100% - @{navbarHeight}") !important;
  262. }
  263. .main__wrap--fixed--tags {
  264. margin-top: @tagsViewHeight !important;
  265. height: calc(~"100% - @{tagsViewHeight}") !important;
  266. }
  267. .header__wrap--fixed {
  268. position: fixed !important;
  269. width: calc(~"100% - @{menuWidth}") !important;
  270. top: 0 !important;
  271. left: @menuWidth !important;
  272. z-index: 200;
  273. }
  274. .header__wrap--collapsed {
  275. width: calc(~"100% - @{menuMinWidth}") !important;
  276. left: @menuMinWidth !important;
  277. }
  278. }
  279. // 顶部模式
  280. .app__wrap--Top,
  281. .app__wrap--LeftTop {
  282. .sidebar__wrap--Top {
  283. height: @topSiderHeight;
  284. display: flex;
  285. flex-direction: row;
  286. justify-content: space-between;
  287. padding: 0 20px;
  288. background-color: @topMenuBg;
  289. position: relative;
  290. &:after {
  291. content: "";
  292. width: 100%;
  293. height: 1px;
  294. border-top: 1px solid #d8dce5;
  295. position: absolute;
  296. bottom: 0;
  297. left: 0;
  298. }
  299. .sidebar__item--Top(2) {
  300. flex: 1;
  301. margin: 0 50px;
  302. }
  303. .navbar__wrap--right {
  304. display: flex;
  305. align-items: center;
  306. height: @topSiderHeight;
  307. @{deep}(.hover-container) {
  308. transition: background 0.2s;
  309. height: 100%;
  310. line-height: @topSiderHeight;
  311. padding: 0 5px;
  312. text-align: center;
  313. &:hover {
  314. background: #f6f6f6;
  315. }
  316. }
  317. }
  318. }
  319. .header__wrap--fixed {
  320. position: fixed !important;
  321. width: 100% !important;
  322. top: @topSiderHeight !important;
  323. left: 0 !important;
  324. z-index: 200;
  325. }
  326. .main__wrap {
  327. width: 100%;
  328. left: 0;
  329. height: calc(~"100% - @{topSiderHeight}");
  330. top: @topSiderHeight;
  331. }
  332. .main__wrap--fixed--all,
  333. .main__wrap--fixed--tags {
  334. margin-top: @navbarHeight !important;
  335. height: calc(~"100% - @{navbarHeight}") !important;
  336. }
  337. }
  338. .app__wrap--LeftTop {
  339. .sidebar__wrap {
  340. top: @topSiderHeight;
  341. left: 0;
  342. height: calc(~"100% - @{topSiderHeight}");
  343. }
  344. .header__wrap {
  345. }
  346. .main__wrap {
  347. width: calc(~"100% - @{menuWidth}");
  348. left: @menuWidth;
  349. height: calc(~"100% - @{topSiderHeight}");
  350. top: @topSiderHeight;
  351. }
  352. .main__wrap--collapsed {
  353. width: calc(~"100% - @{menuMinWidth}");
  354. left: @menuMinWidth;
  355. }
  356. }
  357. // 项目配置
  358. .setting__wrap {
  359. position: fixed;
  360. top: 45%;
  361. right: 0;
  362. z-index: 10;
  363. display: flex;
  364. padding: 10px;
  365. color: #fff;
  366. cursor: pointer;
  367. background: #018ffb;
  368. border-radius: 6px 0 0 6px;
  369. justify-content: center;
  370. align-items: center;
  371. }
  372. .setting__title {
  373. font-weight: bold;
  374. color: black;
  375. }
  376. // 项目配置
  377. </style>