main.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="site-wrapper" :class="{ 'site-sidebar--fold': sidebarFold }" v-loading.fullscreen.lock="loading"
  3. element-loading-text="拼命加载中">
  4. <template v-if="!loading">
  5. <main-navbar />
  6. <main-sidebar />
  7. <div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }">
  8. <main-content v-if="!$store.state.common.contentIsNeedRefresh" />
  9. </div>
  10. </template>
  11. </div>
  12. </template>
  13. <script>
  14. import MainNavbar from './main-navbar'
  15. import MainSidebar from './main-sidebar'
  16. import MainContent from './main-content'
  17. import config from '../../config/index'
  18. export default {
  19. provide() {
  20. return {
  21. // 刷新
  22. refresh() {
  23. this.$store.commit('common/updateContentIsNeedRefresh', true)
  24. this.$nextTick(() => {
  25. this.$store.commit('common/updateContentIsNeedRefresh', false)
  26. })
  27. }
  28. }
  29. },
  30. data() {
  31. return {
  32. loading: true
  33. }
  34. },
  35. components: {
  36. MainNavbar,
  37. MainSidebar,
  38. MainContent
  39. },
  40. computed: {
  41. documentClientHeight: {
  42. get() { return this.$store.state.common.documentClientHeight },
  43. set(val) { this.$store.commit('common/updateDocumentClientHeight', val) }
  44. },
  45. sidebarFold: {
  46. get() { return this.$store.state.common.sidebarFold }
  47. },
  48. userId: {
  49. get() { return this.$store.state.user.id },
  50. set(val) { this.$store.commit('user/updateId', val) }
  51. },
  52. userName: {
  53. get() { return this.$store.state.user.name },
  54. set(val) { this.$store.commit('user/updateName', val) }
  55. },
  56. orgId: {
  57. get() { return this.$store.state.user.orgId },
  58. set(val) { this.$store.commit('user/updateOrgId', val) }
  59. },
  60. msgCollection: {
  61. get() { return this.$store.state.common.msgCollection },
  62. set(val) { this.$store.commit('common/updateMsgCollection', val) }
  63. }
  64. },
  65. created() {
  66. this.getUserInfo()
  67. },
  68. mounted() {
  69. this.resetDocumentClientHeight()
  70. },
  71. methods: {
  72. // 重置窗口可视高度
  73. resetDocumentClientHeight() {
  74. this.documentClientHeight = document.documentElement['clientHeight']
  75. window.onresize = () => {
  76. this.documentClientHeight = document.documentElement['clientHeight']
  77. }
  78. },
  79. // 获取当前管理员信息
  80. getUserInfo() {
  81. this.$http({
  82. url: this.$http.adornUrl('/user-service/user/info'),
  83. method: 'get'
  84. }).then(({ data }) => {
  85. if (data && data.code === '200') {
  86. this.loading = false
  87. this.userId = data.data.userId
  88. this.userName = data.data.username
  89. this.orgId = data.data.orgId
  90. this.$cookie.set('name', data.data.name)
  91. // websocket初始化
  92. // 线上地址
  93. this.$store.dispatch('websocket/WEBSOCKET_INIT', `wss://${config.currentHost}/wss/web_socket/${data.data.userId}_${Math.ceil(Math.random() * 100000000)}`)
  94. // 东齐环境
  95. // this.$store.dispatch('websocket/WEBSOCKET_INIT', 'wss://192.168.2.124/wss/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
  96. // 昌柘环境
  97. // this.$store.dispatch('websocket/WEBSOCKET_INIT', 'wss://192.168.110.222/wss/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
  98. }
  99. })
  100. }
  101. }
  102. }
  103. </script>