LayoutMain.vue 7.0 KB

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