赫艾前端
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.

109 lines
3.4 KiB

4 years ago
2 years ago
4 years 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 () { return this.$store.state.common.documentClientHeight },
  45. set (val) { this.$store.commit('common/updateDocumentClientHeight', val) }
  46. },
  47. sidebarFold: {
  48. get () { return this.$store.state.common.sidebarFold }
  49. },
  50. userId: {
  51. get () { return this.$store.state.user.id },
  52. set (val) { this.$store.commit('user/updateId', val) }
  53. },
  54. userName: {
  55. get () { return this.$store.state.user.name },
  56. set (val) { this.$store.commit('user/updateName', val) }
  57. },
  58. site: {
  59. get () { return this.$store.state.user.site },
  60. set (val) { this.$store.commit('user/updateSite', val) }
  61. },
  62. languageDefault: {
  63. get () { return this.$store.state.user.languageDefault },
  64. set (val) { this.$store.commit('user/updateLanguageDefault', val) }
  65. },
  66. userDisplay: {
  67. get () { return this.$store.state.user.userDisplay },
  68. set (val) { this.$store.commit('user/updateUserDisplay', val) }
  69. }
  70. },
  71. created () {
  72. this.getUserInfo()
  73. },
  74. mounted () {
  75. this.resetDocumentClientHeight()
  76. },
  77. methods: {
  78. // 重置窗口可视高度
  79. resetDocumentClientHeight () {
  80. this.documentClientHeight = document.documentElement['clientHeight']-1
  81. window.onresize = () => {
  82. this.documentClientHeight = document.documentElement['clientHeight']-1
  83. }
  84. },
  85. // 获取当前管理员信息
  86. getUserInfo () {
  87. this.$http({
  88. url: this.$http.adornUrl('/sys/user/info'),
  89. method: 'get',
  90. params: this.$http.adornParams()
  91. }).then(({data}) => {
  92. if (data && data.code === 0) {
  93. this.loading = false
  94. this.userId = data.user.userId
  95. this.userName = data.user.username
  96. this.site = data.user.site
  97. this.languageDefault = data.user.languageDefault
  98. this.userDisplay = data.user.userDisplay
  99. // let match = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
  100. // if (match) {
  101. // this.$router.replace({ name: 'padCODelNotify' })
  102. // }
  103. }
  104. })
  105. }
  106. }
  107. }
  108. </script>