You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.7 KiB

6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <div v-fireworks="'rain'"
  3. class="site-wrapper"
  4. :class="{ 'site-sidebar--fold': sidebarFold }"
  5. v-loading.fullscreen.lock="loading"
  6. element-loading-text="拼命加载中">
  7. <template v-if="!loading">
  8. <main-navbar/>
  9. <main-sidebar-hover v-if="useHoverMenu"/>
  10. <main-sidebar v-else/>
  11. <div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }">
  12. <main-content v-if="!$store.state.common.contentIsNeedRefresh"/>
  13. </div>
  14. </template>
  15. </div>
  16. </template>
  17. <script>
  18. import MainNavbar from './main-navbar'
  19. import MainSidebar from './main-sidebar'
  20. import MainSidebarHover from './main-sidebar-hover'
  21. import MainContent from './main-content'
  22. export default {
  23. provide() {
  24. return {
  25. // 刷新
  26. refresh() {
  27. this.$store.commit('common/updateContentIsNeedRefresh', true)
  28. this.$nextTick(() => {
  29. this.$store.commit('common/updateContentIsNeedRefresh', false)
  30. })
  31. }
  32. }
  33. },
  34. data() {
  35. return {
  36. loading: true
  37. }
  38. },
  39. components: {
  40. MainNavbar,
  41. MainSidebar,
  42. MainSidebarHover,
  43. MainContent
  44. },
  45. computed: {
  46. documentClientHeight: {
  47. get() {
  48. return this.$store.state.common.documentClientHeight
  49. },
  50. set(val) {
  51. this.$store.commit('common/updateDocumentClientHeight', val)
  52. }
  53. },
  54. sidebarFold: {
  55. get() {
  56. return this.$store.state.common.sidebarFold
  57. }
  58. },
  59. userId: {
  60. get() {
  61. return this.$store.state.user.id
  62. },
  63. set(val) {
  64. this.$store.commit('user/updateId', val)
  65. }
  66. },
  67. userName: {
  68. get() {
  69. return this.$store.state.user.name
  70. },
  71. set(val) {
  72. this.$store.commit('user/updateName', val)
  73. }
  74. },
  75. site: {
  76. get() {
  77. return this.$store.state.user.site
  78. },
  79. set(val) {
  80. this.$store.commit('user/updateSite', val)
  81. }
  82. },
  83. languageDefault: {
  84. get() {
  85. return this.$store.state.user.languageDefault
  86. },
  87. set(val) {
  88. this.$store.commit('user/updateLanguageDefault', val)
  89. }
  90. },
  91. userDisplay: {
  92. get() {
  93. return this.$store.state.user.userDisplay
  94. },
  95. set(val) {
  96. this.$store.commit('user/updateUserDisplay', val)
  97. }
  98. },
  99. useHoverMenu: {
  100. get() {
  101. return this.$store.state.common.useHoverMenu
  102. }
  103. },
  104. },
  105. created() {
  106. this.getUserInfo()
  107. // 确保悬浮菜单模式启用
  108. this.$store.commit('common/updateUseHoverMenu', true)
  109. },
  110. mounted() {
  111. this.resetDocumentClientHeight()
  112. },
  113. methods: {
  114. // 重置窗口可视高度
  115. resetDocumentClientHeight() {
  116. this.documentClientHeight = document.documentElement['clientHeight'] - 1
  117. window.onresize = () => {
  118. this.documentClientHeight = document.documentElement['clientHeight'] - 1
  119. }
  120. },
  121. // 获取当前管理员信息
  122. getUserInfo() {
  123. this.$http({
  124. url: this.$http.adornUrl('/sys/user/info'),
  125. method: 'get',
  126. params: this.$http.adornParams()
  127. }).then(({data}) => {
  128. if (data && data.code === 0) {
  129. this.loading = false
  130. this.userId = data.user.userId
  131. this.userName = data.user.username
  132. this.site = data.user.site
  133. this.languageDefault = data.user.languageDefault
  134. this.site = data.user.site
  135. this.userDisplay = data.user.userDisplay
  136. }
  137. })
  138. },
  139. }
  140. }
  141. </script>