LayoutMain.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <a-layout class="layout" :class="device">
  3. <a-drawer
  4. v-if="device === 'mobile'"
  5. :wrapClassName="'drawer-sider ' + theme"
  6. placement="left"
  7. @close="() => this.collapsed = false"
  8. :closable="false"
  9. :visible="collapsed"
  10. >
  11. <sider-menu
  12. mode="inline"
  13. :menus="menus"
  14. @menuSelect="menuSelect"
  15. :theme="theme"
  16. :collapsed="false"
  17. :collapsible="true"></sider-menu>
  18. </a-drawer>
  19. <sider-menu
  20. v-else
  21. :menus="menus"
  22. :theme="theme"
  23. :mode="menuMode"
  24. :collapsed="collapsed"
  25. :collapsible="true"></sider-menu>
  26. <a-layout>
  27. <!-- layout header -->
  28. <layout-header :collapsed="collapsed" :device="device" @toggle="toggle"/>
  29. <!-- layout content -->
  30. <a-layout-content :style="{ margin: '24px 24px 0', height: '100%' }">
  31. <!-- content -->
  32. <slot/>
  33. </a-layout-content>
  34. <a-layout-footer style="padding: 0px">
  35. <layout-footer/>
  36. </a-layout-footer>
  37. </a-layout>
  38. <setting-drawer></setting-drawer>
  39. </a-layout>
  40. </template>
  41. <script>
  42. import SiderMenu from '@/components/menu/SiderMenu'
  43. import LayoutHeader from './LayoutHeader'
  44. import LayoutFooter from './LayoutFooter'
  45. import SettingDrawer from '@/components/tools/SettingDrawer'
  46. import { mapState, mapActions } from 'vuex'
  47. export default {
  48. name: "LayoutView",
  49. components: {
  50. SiderMenu,
  51. LayoutHeader,
  52. LayoutFooter,
  53. SettingDrawer
  54. },
  55. data() {
  56. return {
  57. // light, dark
  58. menuTheme: 'light',
  59. // inline, horizontal
  60. menuMode: 'inline',
  61. collapsed: false,
  62. menus: []
  63. }
  64. },
  65. created() {
  66. this.menus = this.mainMenu
  67. },
  68. computed: {
  69. ...mapState({
  70. mainMenu: state => state.permission.addRouters,
  71. sidebarOpened: state => state.app.sidebar.opened,
  72. theme: state => state.app.theme,
  73. device: state => state.app.device,
  74. })
  75. },
  76. mounted() {
  77. this.collapsed = this.sidebarOpened
  78. },
  79. methods: {
  80. ...mapActions(['setSidebar']),
  81. toggle() {
  82. this.collapsed = !this.collapsed;
  83. this.setSidebar(this.collapsed)
  84. },
  85. menuSelect() {
  86. if (this.device !== 'desktop') {
  87. this.collapsed = false
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. body {
  95. // 打开滚动条固定显示
  96. overflow-y: scroll;
  97. &.userLayout {
  98. overflow-y: auto;
  99. }
  100. }
  101. .layout {
  102. min-height: 100vh;
  103. overflow-x: hidden;
  104. &.mobile {
  105. .ant-layout-content {
  106. .content {
  107. margin: 24px 0 0;
  108. }
  109. }
  110. .ant-table-wrapper {
  111. .ant-table-body {
  112. overflow-y: auto;
  113. }
  114. }
  115. }
  116. &.ant-layout-has-sider {
  117. flex-direction: row;
  118. }
  119. .trigger {
  120. font-size: 20px;
  121. line-height: 64px;
  122. padding: 0 24px;
  123. cursor: pointer;
  124. transition: color .3s;
  125. &:hover {
  126. color: #1890ff;
  127. background: #e6f7ff;
  128. }
  129. }
  130. .header {
  131. height: 64px;
  132. padding: 0 12px 0 0;
  133. background: #fff;
  134. box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
  135. position: relative;
  136. .user-wrapper {
  137. float: right;
  138. height: 100%;
  139. .action {
  140. cursor: pointer;
  141. padding: 0 12px;
  142. display: inline-block;
  143. transition: all .3s;
  144. height: 100%;
  145. &:hover {
  146. background: #e6f7ff;
  147. }
  148. .avatar {
  149. margin: 20px 8px 20px 0;
  150. color: #1890ff;
  151. background: hsla(0, 0%, 100%, .85);
  152. vertical-align: middle;
  153. }
  154. .icon {
  155. font-size: 16px;
  156. padding: 4px;
  157. }
  158. }
  159. }
  160. }
  161. // 内容区
  162. .layout-content {
  163. margin: 24px 24px 0px;
  164. height: 100%;
  165. }
  166. }
  167. // drawer-sider 自定义
  168. .ant-drawer.drawer-sider {
  169. .sider {
  170. box-shadow: none;
  171. }
  172. &.dark {
  173. .ant-drawer-content {
  174. background-color: rgb(0, 21, 41);
  175. }
  176. }
  177. &.light {
  178. box-shadow: none;
  179. .ant-drawer-content {
  180. background-color: #fff;
  181. }
  182. }
  183. .ant-drawer-body {
  184. padding: 0
  185. }
  186. }
  187. // 菜单样式
  188. .sider {
  189. box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
  190. position: relative;
  191. z-index: 10;
  192. .logo {
  193. height: 64px;
  194. position: relative;
  195. line-height: 64px;
  196. padding-left: 24px;
  197. -webkit-transition: all .3s;
  198. transition: all .3s;
  199. background: #002140;
  200. overflow: hidden;
  201. img, h1 {
  202. display: inline-block;
  203. vertical-align: middle;
  204. }
  205. img {
  206. height: 32px;
  207. }
  208. h1 {
  209. color: #fff;
  210. font-size: 20px;
  211. margin: 0 0 0 12px;
  212. font-family: "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  213. font-weight: 600;
  214. }
  215. }
  216. &.light {
  217. background-color: #fff;
  218. box-shadow: 2px 0px 8px 0px rgba(29, 35, 41, 0.05);
  219. .logo {
  220. background: #fff;
  221. box-shadow: 1px 1px 0px 0px #e8e8e8;
  222. h1 {
  223. color: unset;
  224. }
  225. }
  226. .ant-menu-light {
  227. border-right-color: transparent;
  228. }
  229. }
  230. }
  231. // 外置的样式控制
  232. .user-dropdown-menu-wrapper.ant-dropdown-menu {
  233. padding: 4px 0;
  234. .ant-dropdown-menu-item {
  235. width: 160px;
  236. }
  237. .ant-dropdown-menu-item > .anticon:first-child,
  238. .ant-dropdown-menu-item > a > .anticon:first-child,
  239. .ant-dropdown-menu-submenu-title > .anticon:first-child
  240. .ant-dropdown-menu-submenu-title > a > .anticon:first-child {
  241. min-width: 12px;
  242. margin-right: 8px;
  243. }
  244. }
  245. // 数据列表 样式
  246. .table-alert {
  247. margin-bottom: 16px;
  248. }
  249. .table-page-search-wrapper {
  250. .ant-form-inline {
  251. .ant-form-item {
  252. display: flex;
  253. margin-bottom: 24px;
  254. margin-right: 0;
  255. .ant-form-item-control-wrapper {
  256. flex: 1 1;
  257. display: inline-block;
  258. vertical-align: middle;
  259. }
  260. >.ant-form-item-label {
  261. line-height: 32px;
  262. padding-right: 8px;
  263. width: auto;
  264. }
  265. .ant-form-item-control {
  266. height: 32px;
  267. line-height: 32px;
  268. }
  269. }
  270. }
  271. .table-page-search-submitButtons {
  272. display: block;
  273. margin-bottom: 24px;
  274. white-space: nowrap;
  275. }
  276. }
  277. .content {
  278. .table-operator {
  279. margin-bottom: 18px;
  280. button {
  281. margin-right: 8px;
  282. }
  283. }
  284. }
  285. </style>