main.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. orgId: {
  59. get () { return this.$store.state.user.orgId },
  60. set (val) { this.$store.commit('user/updateOrgId', val) }
  61. },
  62. msgCollection: {
  63. get () { return this.$store.state.common.msgCollection },
  64. set (val) { this.$store.commit('common/updateMsgCollection', val) }
  65. }
  66. },
  67. created () {
  68. this.getUserInfo()
  69. },
  70. mounted () {
  71. this.resetDocumentClientHeight()
  72. },
  73. methods: {
  74. // 重置窗口可视高度
  75. resetDocumentClientHeight () {
  76. this.documentClientHeight = document.documentElement['clientHeight']
  77. window.onresize = () => {
  78. this.documentClientHeight = document.documentElement['clientHeight']
  79. }
  80. },
  81. // 获取当前管理员信息
  82. getUserInfo () {
  83. this.$http({
  84. url: this.$http.adornUrl('/user-service/user/info'),
  85. method: 'get'
  86. }).then(({data}) => {
  87. if (data && data.code === '200') {
  88. this.loading = false
  89. this.userId = data.data.userId
  90. this.userName = data.data.username
  91. this.orgId = data.data.orgId
  92. this.$cookie.set('name', data.data.name)
  93. // websocket初始化
  94. // 开发地址
  95. this.$store.dispatch('websocket/WEBSOCKET_INIT', 'ws://116.62.189.171:10088/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
  96. // 正式地址
  97. // this.$store.dispatch('websocket/WEBSOCKET_INIT', 'wss://www.muzhikeji.cn/wss/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
  98. }
  99. })
  100. }
  101. }
  102. }
  103. </script>