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.

135 lines
3.3 KiB

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