✨系统通知新增小红点提醒
This commit is contained in:
parent
9df1b77aee
commit
35cc1579d8
@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-popover placement="bottom" trigger="click" width="400px" popper-class="el-popover-pupop-user-news">
|
<el-popover placement="bottom" trigger="click" width="400px" popper-class="el-popover-pupop-user-news">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-badge :hidden="noticeDot <= 0" :value="noticeDot" style="line-height: 18px">
|
<el-badge :hidden="allDotNum <= 0" :value="allDotNum" style="line-height: 18px">
|
||||||
<el-icon><bell /></el-icon>
|
<el-icon><bell /></el-icon>
|
||||||
</el-badge>
|
</el-badge>
|
||||||
</template>
|
</template>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
<el-tabs v-model="noticeType">
|
<el-tabs v-model="noticeType">
|
||||||
<el-tab-pane name="0">
|
<el-tab-pane name="0">
|
||||||
<template #label>
|
<template #label>
|
||||||
<el-badge :is-dot="newsDot" class="new-item"> 通知 </el-badge>
|
<el-badge :hidden="newsDot <= 0" :value="newsDot" class="new-item"> 通知 </el-badge>
|
||||||
</template>
|
</template>
|
||||||
<div class="content-box">
|
<div class="content-box">
|
||||||
<div class="content-box-item" v-for="item in noticeList" @click="handleDetails(item, 0)">
|
<div class="content-box-item" v-for="item in noticeList" @click="handleDetails(item, 0)">
|
||||||
@ -76,12 +76,14 @@ import { formatTime } from '@/utils/index'
|
|||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const noticeType = ref('0')
|
const noticeType = ref('0')
|
||||||
// 小红点
|
// 小红点
|
||||||
const newsDot = ref(false)
|
const newsDot = computed(() => {
|
||||||
|
return useSocketStore().newNotice
|
||||||
|
})
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
const noticeList = computed(() => {
|
const noticeList = computed(() => {
|
||||||
return useSocketStore().noticeList
|
return useSocketStore().noticeList
|
||||||
})
|
})
|
||||||
const noticeDot = computed(() => {
|
const allDotNum = computed(() => {
|
||||||
return useSocketStore().getAllDotNum()
|
return useSocketStore().getAllDotNum()
|
||||||
})
|
})
|
||||||
const chatList = computed(() => {
|
const chatList = computed(() => {
|
||||||
@ -101,12 +103,7 @@ function handleDetails(item, type) {
|
|||||||
}
|
}
|
||||||
// 全部已读点击
|
// 全部已读点击
|
||||||
function onAllReadClick() {
|
function onAllReadClick() {
|
||||||
newsDot.value = false
|
useSocketStore().readAll(noticeType.value)
|
||||||
if (noticeType.value == 1) {
|
|
||||||
useSocketStore().readAll()
|
|
||||||
} else {
|
|
||||||
proxy.$modal.msg('请自行实现!!!')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 前往通知中心点击
|
// 前往通知中心点击
|
||||||
function onGoToGiteeClick() {
|
function onGoToGiteeClick() {
|
||||||
@ -152,7 +149,7 @@ function onGoToGiteeClick() {
|
|||||||
}
|
}
|
||||||
.foot-box {
|
.foot-box {
|
||||||
height: 35px;
|
height: 35px;
|
||||||
color: #1890ff;
|
color: var(--el-color-primary);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
@ -164,21 +161,17 @@ function onGoToGiteeClick() {
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:deep(.el-empty__description p) {
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.head-box-title {
|
|
||||||
color: var(--base-color-white);
|
|
||||||
}
|
|
||||||
.layout-navbars-breadcrumb-user-news {
|
.layout-navbars-breadcrumb-user-news {
|
||||||
position: relative;
|
position: relative;
|
||||||
.read {
|
.read {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5px;
|
top: 7px;
|
||||||
right: 0;
|
right: 0;
|
||||||
color: #1890ff;
|
color: var(--el-color-primary);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.n_right {
|
.n_right {
|
||||||
|
|||||||
@ -5,30 +5,31 @@
|
|||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
mounted(el, binding) {
|
mounted(el, binding) {
|
||||||
el.classList.add('waves-effect');
|
el.classList.add('waves-effect')
|
||||||
binding.value && el.classList.add(`waves-${binding.value}`);
|
binding.value && el.classList.add(`waves-${binding.value}`)
|
||||||
|
|
||||||
function setConvertStyle(obj) {
|
function setConvertStyle(obj) {
|
||||||
let style = '';
|
let style = ''
|
||||||
for (let i in obj) {
|
for (let i in obj) {
|
||||||
if (obj.hasOwnProperty(i)) style += `${i}:${obj[i]};`;
|
if (obj.hasOwnProperty(i)) style += `${i}:${obj[i]};`
|
||||||
}
|
}
|
||||||
return style;
|
return style
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCurrentClick(e) {
|
function onCurrentClick(e) {
|
||||||
let elDiv = document.createElement('div');
|
let elDiv = document.createElement('div')
|
||||||
elDiv.classList.add('waves-ripple');
|
elDiv.classList.add('waves-ripple')
|
||||||
el.appendChild(elDiv);
|
el.appendChild(elDiv)
|
||||||
let styles = {
|
let styles = {
|
||||||
left: `${e.layerX}px`,
|
left: `${e.layerX}px`,
|
||||||
top: `${e.layerY}px`,
|
top: `${e.layerY}px`,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
transform: `scale(${(el.clientWidth / 100) * 10})`,
|
transform: `scale(${(el.clientWidth / 100) * 10})`,
|
||||||
'transition-duration': `750ms`,
|
'transition-duration': `750ms`,
|
||||||
'transition-timing-function': `cubic-bezier(0.250, 0.460, 0.450, 0.940)`,
|
'transition-timing-function': `cubic-bezier(0.250, 0.460, 0.450, 0.940)`
|
||||||
};
|
}
|
||||||
elDiv.setAttribute('style', setConvertStyle(styles));
|
|
||||||
|
elDiv.setAttribute('style', setConvertStyle(styles))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
elDiv.setAttribute(
|
elDiv.setAttribute(
|
||||||
'style',
|
'style',
|
||||||
@ -36,17 +37,17 @@ export default {
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
transform: styles.transform,
|
transform: styles.transform,
|
||||||
left: styles.left,
|
left: styles.left,
|
||||||
top: styles.top,
|
top: styles.top
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
elDiv && el.removeChild(elDiv);
|
elDiv && el.removeChild(elDiv)
|
||||||
}, 750);
|
}, 750)
|
||||||
}, 450);
|
}, 450)
|
||||||
}
|
}
|
||||||
el.addEventListener('mousedown', onCurrentClick, false);
|
el.addEventListener('mousedown', onCurrentClick, false)
|
||||||
},
|
},
|
||||||
unmounted(el) {
|
unmounted(el) {
|
||||||
el.addEventListener('mousedown', () => {});
|
el.addEventListener('mousedown', () => {})
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
@ -2,20 +2,21 @@ import useUserStore from './user'
|
|||||||
import signalR from '@/signalr/signalr'
|
import signalR from '@/signalr/signalr'
|
||||||
const useSocketStore = defineStore('socket', {
|
const useSocketStore = defineStore('socket', {
|
||||||
persist: {
|
persist: {
|
||||||
paths: ['chatMessage', 'chatList', 'sessionList', 'newChat'] //存储指定key
|
paths: ['chatMessage', 'chatList', 'sessionList', 'newChat', 'noticeIdArr', 'newNotice'] //存储指定key
|
||||||
},
|
},
|
||||||
state: () => ({
|
state: () => ({
|
||||||
onlineNum: 0,
|
onlineNum: 0,
|
||||||
onlineUsers: [],
|
onlineUsers: [],
|
||||||
noticeList: [],
|
noticeList: [],
|
||||||
noticeDot: false,
|
|
||||||
//在线用户信息
|
//在线用户信息
|
||||||
onlineInfo: {},
|
onlineInfo: {},
|
||||||
// 聊天数据
|
// 聊天数据
|
||||||
chatList: {},
|
chatList: {},
|
||||||
leaveUser: {},
|
leaveUser: {},
|
||||||
sessionList: {},
|
sessionList: {},
|
||||||
newChat: 0
|
newChat: 0,
|
||||||
|
newNotice: 0,
|
||||||
|
noticeIdArr: []
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
/**
|
/**
|
||||||
@ -30,7 +31,7 @@ const useSocketStore = defineStore('socket', {
|
|||||||
return (userid) => state.sessionList[userid] || []
|
return (userid) => state.sessionList[userid] || []
|
||||||
},
|
},
|
||||||
getAllDotNum(state) {
|
getAllDotNum(state) {
|
||||||
return () => state.newChat
|
return () => state.newChat + state.newNotice
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -41,7 +42,18 @@ const useSocketStore = defineStore('socket', {
|
|||||||
// 更新系统通知
|
// 更新系统通知
|
||||||
setNoticeList(data) {
|
setNoticeList(data) {
|
||||||
this.noticeList = data
|
this.noticeList = data
|
||||||
this.noticeDot = data.length > 0
|
|
||||||
|
const idArr = []
|
||||||
|
data.forEach((ele) => {
|
||||||
|
idArr.push(ele.noticeId)
|
||||||
|
})
|
||||||
|
|
||||||
|
var diffArr = idArr.filter((v) => !this.noticeIdArr.some((item) => item == v))
|
||||||
|
|
||||||
|
if (diffArr.length > 0) {
|
||||||
|
this.newNotice = diffArr.length
|
||||||
|
this.noticeIdArr = idArr
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setOnlineUsers(data) {
|
setOnlineUsers(data) {
|
||||||
const { onlineClients, num, leaveUser } = data
|
const { onlineClients, num, leaveUser } = data
|
||||||
@ -95,9 +107,13 @@ const useSocketStore = defineStore('socket', {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
readAll() {
|
readAll(type) {
|
||||||
|
if (type == 0) {
|
||||||
|
this.newNotice = 0
|
||||||
|
} else if (type == 1) {
|
||||||
this.newChat = 0
|
this.newChat = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
export default useSocketStore
|
export default useSocketStore
|
||||||
|
|||||||
@ -14,9 +14,6 @@
|
|||||||
<el-button type="primary" icon="Search" @click="handleQuery">刷新</el-button>
|
<el-button type="primary" icon="Search" @click="handleQuery">刷新</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<!-- <el-row :gutter="10" class="mb8">
|
|
||||||
<el-col :span="2"> </el-col>
|
|
||||||
</el-row> -->
|
|
||||||
<el-table :data="onlineUsers" v-loading="loading" ref="tableRef" border highlight-current-row v-if="viewSwitch == 1">
|
<el-table :data="onlineUsers" v-loading="loading" ref="tableRef" border highlight-current-row v-if="viewSwitch == 1">
|
||||||
<el-table-column label="No" type="index" width="50" align="center">
|
<el-table-column label="No" type="index" width="50" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -36,7 +33,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" width="160">
|
<el-table-column label="操作" align="center" width="160">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button text @click="onChat(scope.row)" icon="bell" v-hasRole="['admin']">通知</el-button>
|
<el-button text @click="onChat(scope.row)" icon="ChatDotRound" v-hasRole="['admin']">私信</el-button>
|
||||||
<el-button text @click="onLock(scope.row)" icon="lock" v-hasPermi="['monitor:online:forceLogout']">强退</el-button>
|
<el-button text @click="onLock(scope.row)" icon="lock" v-hasPermi="['monitor:online:forceLogout']">强退</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -54,8 +51,8 @@
|
|||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
<el-text truncated>{{ item.browser }}</el-text>
|
<el-text truncated>{{ item.browser }}</el-text>
|
||||||
<div>
|
<div>
|
||||||
<el-button text @click="onChat(item)" icon="bell" title="通知" v-hasRole="['admin']"></el-button>
|
<el-button text @click="onChat(item)" size="small" icon="ChatDotRound" title="私信" v-hasRole="['admin']">私信</el-button>
|
||||||
<el-button text @click="onLock(item)" icon="lock" title="强退" v-hasPermi="['monitor:online:forceLogout']"></el-button>
|
<el-button text @click="onLock(item)" size="small" icon="lock" title="强退" v-hasPermi="['monitor:online:forceLogout']">强退</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -104,7 +101,7 @@ getList()
|
|||||||
|
|
||||||
function onChat(item) {
|
function onChat(item) {
|
||||||
proxy
|
proxy
|
||||||
.$prompt('请输入通知内容', '', {
|
.$prompt('请输入消息内容', '', {
|
||||||
confirmButtonText: '发送',
|
confirmButtonText: '发送',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
inputPattern: /\S/,
|
inputPattern: /\S/,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user