123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <template>
- <div
- class="site-wrapper"
- :class="{ 'site-sidebar--fold': sidebarFold }"
- v-loading.fullscreen.lock="loading"
- element-loading-text="拼命加载中">
- <template v-if="!loading">
- <main-navbar />
- <main-sidebar />
- <div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }">
- <main-content v-if="!$store.state.common.contentIsNeedRefresh" />
- </div>
- </template>
- </div>
- </template>
- <script>
- import MainNavbar from './main-navbar'
- import MainSidebar from './main-sidebar'
- import MainContent from './main-content'
- export default {
- provide () {
- return {
- // 刷新
- refresh () {
- this.$store.commit('common/updateContentIsNeedRefresh', true)
- this.$nextTick(() => {
- this.$store.commit('common/updateContentIsNeedRefresh', false)
- })
- }
- }
- },
- data () {
- return {
- loading: true
- }
- },
- components: {
- MainNavbar,
- MainSidebar,
- MainContent
- },
- computed: {
- documentClientHeight: {
- get () { return this.$store.state.common.documentClientHeight },
- set (val) { this.$store.commit('common/updateDocumentClientHeight', val) }
- },
- sidebarFold: {
- get () { return this.$store.state.common.sidebarFold }
- },
- userId: {
- get () { return this.$store.state.user.id },
- set (val) { this.$store.commit('user/updateId', val) }
- },
- userName: {
- get () { return this.$store.state.user.name },
- set (val) { this.$store.commit('user/updateName', val) }
- },
- orgId: {
- get () { return this.$store.state.user.orgId },
- set (val) { this.$store.commit('user/updateOrgId', val) }
- },
- msgCollection: {
- get () { return this.$store.state.common.msgCollection },
- set (val) { this.$store.commit('common/updateMsgCollection', val) }
- }
- },
- created () {
- this.getUserInfo()
- },
- mounted () {
- this.resetDocumentClientHeight()
- },
- methods: {
- // 重置窗口可视高度
- resetDocumentClientHeight () {
- this.documentClientHeight = document.documentElement['clientHeight']
- window.onresize = () => {
- this.documentClientHeight = document.documentElement['clientHeight']
- }
- },
- // 获取当前管理员信息
- getUserInfo () {
- this.$http({
- url: this.$http.adornUrl('/user-service/user/info'),
- method: 'get'
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.loading = false
- this.userId = data.data.userId
- this.userName = data.data.username
- this.orgId = data.data.orgId
- this.$cookie.set('name', data.data.name)
- // websocket初始化
- // 开发地址
- this.$store.dispatch('websocket/WEBSOCKET_INIT', 'ws://116.62.189.171:10088/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
- // 正式地址
- // this.$store.dispatch('websocket/WEBSOCKET_INIT', 'wss://www.muzhikeji.cn/wss/web_socket/' + data.data.userId + '_' + (Math.ceil(Math.random() * 100000000)).toString())
- }
- })
- }
- }
- }
- </script>
|