新增在线用户显示
This commit is contained in:
parent
89b96a367e
commit
b524672b05
@ -18,6 +18,7 @@ const getters = {
|
|||||||
defaultRoutes: state => state.permission.defaultRoutes,
|
defaultRoutes: state => state.permission.defaultRoutes,
|
||||||
sidebarRouters: state => state.permission.sidebarRouters,
|
sidebarRouters: state => state.permission.sidebarRouters,
|
||||||
onlineUserNum: state => state.socket.onlineNum,
|
onlineUserNum: state => state.socket.onlineNum,
|
||||||
noticeList: state => state.socket.noticeList
|
noticeList: state => state.socket.noticeList,
|
||||||
|
onlineUsers: state => state.socket.onlineUsers
|
||||||
}
|
}
|
||||||
export default getters
|
export default getters
|
||||||
@ -1,5 +1,6 @@
|
|||||||
const state = {
|
const state = {
|
||||||
onlineNum: 0,
|
onlineNum: 0,
|
||||||
|
onlineUsers: [],
|
||||||
noticeList: []
|
noticeList: []
|
||||||
}
|
}
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@ -8,6 +9,9 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
SET_NOTICE_list: (state, data) => {
|
SET_NOTICE_list: (state, data) => {
|
||||||
state.noticeList = data;
|
state.noticeList = data;
|
||||||
|
},
|
||||||
|
SET_ONLINE_USERS: (state, data) => {
|
||||||
|
state.onlineUsers = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +23,9 @@ const actions = {
|
|||||||
// 更新系统通知
|
// 更新系统通知
|
||||||
getNoticeList({ commit }, data) {
|
getNoticeList({ commit }, data) {
|
||||||
commit('SET_NOTICE_list', data)
|
commit('SET_NOTICE_list', data)
|
||||||
|
},
|
||||||
|
getOnlineUsers({ commit }, data) {
|
||||||
|
commit('SET_ONLINE_USERS', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 接收消息处理
|
// 接收消息处理
|
||||||
receiveMsg(connection) {
|
receiveMsg(connection) {
|
||||||
|
console.log(connection)
|
||||||
connection.on("onlineNum", (data) => {
|
connection.on("onlineNum", (data) => {
|
||||||
store.dispatch("socket/changeOnlineNum", data);
|
store.dispatch("socket/changeOnlineNum", data);
|
||||||
});
|
});
|
||||||
@ -84,5 +85,10 @@ export default {
|
|||||||
store.dispatch("socket/getNoticeList", data.data);
|
store.dispatch("socket/getNoticeList", data.data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 接收在线用户
|
||||||
|
connection.on("onlineUser", (data) => {
|
||||||
|
store.dispatch("socket/getOnlineUsers", data);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,20 +64,21 @@
|
|||||||
<el-card shadow="hover">
|
<el-card shadow="hover">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div>
|
<div>
|
||||||
<span>最新文章</span>
|
<span>在线用户</span>
|
||||||
<el-button class="home-card-more" type="text" @click="onOpenGitee">更多</el-button>
|
<el-button class="home-card-more" type="text" @click="onOpenGitee">更多</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<vue3-seamless-scroll :list="newArticleList" class="info-scroll" :step="0.2" :limitScrollNum="2">
|
<!-- <vue3-seamless-scroll :list="onlineUsers" class="info-scroll" :step="0.2" :limitScrollNum="1"> -->
|
||||||
|
<div class="info-scroll">
|
||||||
<ul class="info-ul">
|
<ul class="info-ul">
|
||||||
<li v-for="(v, k) in newArticleList" :key="k" class="info-item">
|
<li v-for="(v, k) in onlineUsers" :key="k" class="info-item">
|
||||||
<div class="info-item-left" v-text="v.title"></div>
|
<div class="info-item-left" v-text="v.name"></div>
|
||||||
<div class="info-item-right" v-text="parseTime(v.updateTime, '{m}/{d}')"></div>
|
<div class="info-item-right" v-text="dayjs(v.loginTime).format('HH:mm:ss')"></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</vue3-seamless-scroll>
|
</div>
|
||||||
|
<!-- </vue3-seamless-scroll> -->
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -120,6 +121,7 @@ import PieChart from './dashboard/PieChart'
|
|||||||
import BarChart from './dashboard/BarChart'
|
import BarChart from './dashboard/BarChart'
|
||||||
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'
|
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'
|
||||||
import { listNewArticle } from '@/api/article/article.js'
|
import { listNewArticle } from '@/api/article/article.js'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
newVisitis: {
|
newVisitis: {
|
||||||
@ -146,6 +148,9 @@ const userInfo = computed(() => {
|
|||||||
const currentTime = computed(() => {
|
const currentTime = computed(() => {
|
||||||
return proxy.parseTime(new Date())
|
return proxy.parseTime(new Date())
|
||||||
})
|
})
|
||||||
|
const onlineUsers = computed(() => {
|
||||||
|
return proxy.$store.getters.onlineUsers
|
||||||
|
})
|
||||||
let newArticleList = reactive([])
|
let newArticleList = reactive([])
|
||||||
|
|
||||||
listNewArticle().then((res) => {
|
listNewArticle().then((res) => {
|
||||||
@ -210,10 +215,11 @@ function onOpenGitee() {}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.info {
|
.info {
|
||||||
height: 198px;
|
height: 189px;
|
||||||
|
// overflow-y: scroll;
|
||||||
.info-scroll {
|
.info-scroll {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow-y: scroll;
|
||||||
.info-ul {
|
.info-ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -236,8 +242,9 @@ function onOpenGitee() {}
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.info-item-right {
|
.info-item-right {
|
||||||
width: 60px;
|
width: 160px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user