2022-06-14 09:32:49 +08:00
|
|
|
<!--
|
|
|
|
* @Author: hisense.wuhongjian
|
|
|
|
* @Date: 2022-05-06 11:12:00
|
2022-11-16 16:25:56 +08:00
|
|
|
* @LastEditors: Light
|
2022-11-29 17:37:10 +08:00
|
|
|
* @LastEditTime: 2022-11-29 17:28:20
|
2022-06-14 09:32:49 +08:00
|
|
|
* @Description: 告诉大家这是什么
|
|
|
|
-->
|
|
|
|
<template>
|
|
|
|
<div id="vue-admin-beautiful">
|
|
|
|
<a-config-provider :locale="locale">
|
|
|
|
<router-view />
|
|
|
|
</a-config-provider>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-21 15:36:01 +08:00
|
|
|
<script setup>
|
2022-11-16 16:25:56 +08:00
|
|
|
import onWholeWaterMark from '@/utils/waterMark'
|
|
|
|
import * as moment from 'moment'
|
|
|
|
import { getUser } from '@/api/home'
|
|
|
|
import { getCategoryTreePage } from '@/api/personalCenter'
|
|
|
|
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
|
|
|
import Cookies from 'js-cookie'
|
2022-11-29 17:37:10 +08:00
|
|
|
import { onBeforeUnmount, onMounted, watch, ref } from 'vue'
|
2022-11-16 16:25:56 +08:00
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
import mybus from '@/myplugins/mybus'
|
|
|
|
const router = useRouter()
|
2022-06-14 09:32:49 +08:00
|
|
|
|
2022-11-16 16:25:56 +08:00
|
|
|
const locale = zhCN
|
|
|
|
const token = Cookies.get('ucsToken')
|
2022-11-29 17:37:10 +08:00
|
|
|
const whoShow1 = ref(whoShow)
|
2022-11-16 16:25:56 +08:00
|
|
|
console.log('token=================>', token)
|
|
|
|
let ws = new WebSocket(
|
2022-07-21 15:36:01 +08:00
|
|
|
`ws://${window.SITE_CONFIG['websocketURL']}/websocket?token=${token}`
|
|
|
|
)
|
2022-11-16 16:25:56 +08:00
|
|
|
// ws.send()给服务器发送信息
|
|
|
|
// 服务器每次返回信息都会执行一次onmessage方法
|
|
|
|
ws.onmessage = function (e) {
|
|
|
|
console.log('WebSocket服务器返回的信息: ' + e.data)
|
|
|
|
mybus.emit('getMynotice')
|
|
|
|
// 判断当前路由是否是消息中心
|
|
|
|
if (router.currentRoute.value.name === 'mynoticeView') {
|
|
|
|
mybus.emit('noticeListInit')
|
|
|
|
}
|
2022-11-29 17:37:10 +08:00
|
|
|
// 判断当前路由是否是待办列表
|
|
|
|
if (
|
|
|
|
router.currentRoute.value.name === 'DetailsPageconetent' &&
|
|
|
|
whoShow1.value.itShowXiHaiAn
|
|
|
|
) {
|
|
|
|
mybus.emit('initDetailsPageconetent')
|
|
|
|
}
|
2022-11-16 16:25:56 +08:00
|
|
|
}
|
|
|
|
ws.onerror = function (e) {
|
|
|
|
console.log('WebSocket连接异常============================>', e)
|
|
|
|
ws = new WebSocket(
|
|
|
|
`ws://${window.SITE_CONFIG['websocketURL']}/websocket?token=${token}`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
ws.onclose = function (e) {
|
|
|
|
console.log('WebSocket连接断开============================>', e)
|
|
|
|
}
|
|
|
|
let realName = '默认水印'
|
|
|
|
const arr = []
|
|
|
|
const changeWaterMark = (newValue) => {
|
|
|
|
console.log('监听', newValue, arr)
|
|
|
|
if (document.getElementById(realName.charCodeAt())) {
|
|
|
|
if (arr.indexOf(newValue) > -1) {
|
|
|
|
document.getElementById(realName.charCodeAt()).style.opacity = 1
|
|
|
|
document.getElementById(
|
|
|
|
moment().format('YYYY-MM-DD').charCodeAt()
|
|
|
|
).style.opacity = 1
|
|
|
|
} else {
|
|
|
|
document.getElementById(realName.charCodeAt()).style.opacity = 0
|
|
|
|
document.getElementById(
|
|
|
|
moment().format('YYYY-MM-DD').charCodeAt()
|
|
|
|
).style.opacity = 0
|
|
|
|
}
|
|
|
|
} else if (document.getElementById('默认水印'.charCodeAt())) {
|
|
|
|
if (arr.indexOf(newValue) > -1) {
|
|
|
|
document.getElementById('默认水印'.charCodeAt()).style.opacity = 1
|
|
|
|
document.getElementById(
|
|
|
|
moment().format('YYYY-MM-DD').charCodeAt()
|
|
|
|
).style.opacity = 1
|
|
|
|
} else {
|
|
|
|
document.getElementById('默认水印'.charCodeAt()).style.opacity = 0
|
|
|
|
document.getElementById(
|
|
|
|
moment().format('YYYY-MM-DD').charCodeAt()
|
|
|
|
).style.opacity = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const waterMarkInit = (newValue) => {
|
|
|
|
getUser().then((res) => {
|
|
|
|
if (res.data.code == 0) {
|
|
|
|
realName = res.data.data.realName
|
|
|
|
}
|
|
|
|
onWholeWaterMark(
|
|
|
|
[realName, moment().format('YYYY-MM-DD')],
|
2022-11-24 10:57:13 +08:00
|
|
|
800,
|
|
|
|
200,
|
|
|
|
24,
|
|
|
|
40
|
2022-11-16 16:25:56 +08:00
|
|
|
)
|
|
|
|
getCategoryTreePage({
|
|
|
|
page: 1,
|
|
|
|
limit: 999,
|
|
|
|
dictTypeId: '1592357067014803457',
|
|
|
|
}).then((res) => {
|
|
|
|
arr.length = 0
|
|
|
|
res.data.data.list.map((val) => {
|
|
|
|
arr.push(val.dictValue)
|
|
|
|
})
|
|
|
|
if (newValue) {
|
|
|
|
changeWaterMark(newValue)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
watch(
|
|
|
|
() => router.currentRoute.value.path,
|
|
|
|
(newValue, oldValue) => {
|
|
|
|
console.log(
|
|
|
|
'路由变化',
|
|
|
|
newValue,
|
|
|
|
oldValue,
|
|
|
|
realName,
|
|
|
|
realName.charCodeAt()
|
|
|
|
)
|
|
|
|
// 如果刚登陆 初始化水印
|
2022-11-21 10:51:54 +08:00
|
|
|
if (newValue == '/home') {
|
2022-11-16 16:25:56 +08:00
|
|
|
waterMarkInit(newValue)
|
|
|
|
}
|
|
|
|
changeWaterMark(newValue)
|
|
|
|
},
|
|
|
|
{ immediate: true }
|
|
|
|
)
|
|
|
|
onMounted(() => {
|
2022-11-21 10:51:54 +08:00
|
|
|
// waterMarkInit()
|
2022-11-16 16:25:56 +08:00
|
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
// 4.卸载前, 关闭链接
|
|
|
|
ws.close()
|
|
|
|
})
|
2022-06-14 09:32:49 +08:00
|
|
|
</script>
|
|
|
|
<style lang="less">
|
2022-11-16 16:25:56 +08:00
|
|
|
@import '~@/vab/styles/vab.less';
|
2022-09-13 09:38:26 +08:00
|
|
|
|
2022-11-16 16:25:56 +08:00
|
|
|
#vue-admin-beautiful {
|
|
|
|
max-width: 1920px;
|
|
|
|
// max-height: 1080px;
|
|
|
|
margin: auto;
|
|
|
|
height: 100%;
|
|
|
|
position: relative;
|
|
|
|
background-color: #fff;
|
|
|
|
}
|
2022-09-13 09:38:26 +08:00
|
|
|
|
2022-11-16 16:25:56 +08:00
|
|
|
body {
|
|
|
|
font-size: 0.14rem;
|
|
|
|
}
|
2022-06-14 09:32:49 +08:00
|
|
|
</style>
|