吴雨瞳添加了注释

master
wyt 4 months ago
parent c72d0cef02
commit 788812084c

@ -1,117 +1,155 @@
<template>
<!-- 主卡片容器包含整个在线用户页面内容 -->
<el-card class="main-card">
<!-- 页面标题显示当前路由名称 -->
<div class="title">{{ this.$route.name }}</div>
<!-- 操作区域容器包含搜索功能 -->
<div class="operation-container">
<div style="margin-left: auto">
<!-- 搜索输入框用于根据用户昵称搜索在线用户 -->
<el-input
v-model="keywords"
prefix-icon="el-icon-search"
size="small"
placeholder="请输入用户昵称"
style="width: 200px"
@keyup.enter.native="listOnlineUsers" />
v-model="keywords"
prefix-icon="el-icon-search"
size="small"
placeholder="请输入用户昵称"
style="width: 200px"
@keyup.enter.native="listOnlineUsers" /> <!-- 回车触发搜索 -->
<!-- 搜索按钮点击触发搜索 -->
<el-button type="primary" size="small" icon="el-icon-search" style="margin-left: 1rem" @click="listOnlineUsers">
搜索
</el-button>
</div>
</div>
<!-- 在线用户表格加载状态由loading控制 -->
<el-table v-loading="loading" :data="users">
<!-- 选择列用于批量操作 -->
<el-table-column type="selection" width="55" align="center" />
<!-- 头像列展示用户头像 -->
<el-table-column prop="avatar" label="头像" align="center" width="100">
<template slot-scope="scope">
<img :src="scope.row.avatar" width="40" height="40" />
</template>
</el-table-column>
<!-- 昵称列展示用户昵称 -->
<el-table-column prop="nickname" label="昵称" align="center" />
<!-- IP地址列展示用户登录IP -->
<el-table-column prop="ipAddress" label="ip地址" align="center" />
<!-- 登录地址列展示IP对应的地理位置 -->
<el-table-column prop="ipSource" label="登录地址" align="center" width="200" />
<!-- 浏览器列展示用户使用的浏览器 -->
<el-table-column prop="browser" label="浏览器" align="center" width="160" />
<!-- 操作系统列展示用户使用的操作系统 -->
<el-table-column prop="os" label="操作系统" align="center" />
<!-- 登录时间列展示用户最后登录时间使用日期过滤器格式化 -->
<el-table-column prop="lastLoginTime" label="登录时间" align="center" width="200">
<template slot-scope="scope">
<i class="el-icon-time" style="margin-right: 5px" />
{{ scope.row.lastLoginTime | dateTime }}
</template>
</el-table-column>
<!-- 操作列包含下线功能 -->
<el-table-column label="操作" align="center" width="150">
<template slot-scope="scope">
<!-- 下线确认弹窗点击确认后执行下线操作 -->
<el-popconfirm title="确定下线吗?" style="margin-left: 10px" @confirm="removeOnlineUser(scope.row)">
<el-button size="mini" type="text" slot="reference"> <i class="el-icon-delete" /> 下线 </el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<el-pagination
class="pagination-container"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="current"
:page-size="size"
:total="count"
:page-sizes="[10, 20]"
layout="total, sizes, prev, pager, next, jumper" />
class="pagination-container"
background
@size-change="sizeChange" <!-- 每页条数变化事件 -->
@current-change="currentChange" <!-- 当前页码变化事件 -->
:current-page="current" <!-- 当前页码 -->
:page-size="size" <!-- 每页条数 -->
:total="count" <!-- 总条数 -->
:page-sizes="[10, 20]" <!-- 可选每页条数 -->
layout="total, sizes, prev, pager, next, jumper" /> <!-- 分页布局 -->
</el-card>
</template>
<script>
import router from '@/router'
import router from '@/router' //
export default {
//
created() {
// Vuex
this.current = this.$store.state.pageState.online
// 线
this.listOnlineUsers()
},
data() {
return {
loading: true,
users: [],
keywords: null,
current: 1,
size: 10,
count: 0,
isCheck: false,
optLog: {}
loading: true, //
users: [], // 线
keywords: null, //
current: 1, //
size: 10, //
count: 0, //
isCheck: false, // 使
optLog: {} // 使
}
},
methods: {
// 线
listOnlineUsers() {
this.axios
.get('/api/admin/users/online', {
params: {
current: this.current,
size: this.size,
keywords: this.keywords
}
})
.then(({ data }) => {
this.users = data.data.records
this.count = data.data.count
this.loading = false
})
.get('/api/admin/users/online', {
params: {
current: this.current, //
size: this.size, //
keywords: this.keywords //
}
})
.then(({ data }) => {
this.users = data.data.records // 线
this.count = data.data.count //
this.loading = false //
})
},
//
sizeChange(size) {
this.size = size
this.listOnlineUsers()
this.size = size //
this.listOnlineUsers() //
},
//
currentChange(current) {
this.current = current
this.current = current //
// Vuex
this.$store.commit('updateOnlinePageState', current)
this.listOnlineUsers()
this.listOnlineUsers() //
},
// 线
removeOnlineUser(user) {
this.axios.delete('/api/admin/users/' + user.userInfoId + '/online').then(({ data }) => {
if (data.flag) {
if (data.flag) { // 线
this.$notify.success({
title: '成功',
message: data.message
})
// 线token
if (user.userInfoId == this.$store.state.userInfo.id) {
router.push({ path: '/login' })
sessionStorage.removeItem('token')
}
this.listOnlineUsers()
} else {
this.listOnlineUsers() //
} else { // 线
this.$notify.error({
title: '失败',
message: data.message
@ -121,6 +159,7 @@ export default {
}
},
computed: {
// 使
tagType() {
return function (type) {
switch (type) {
@ -140,7 +179,8 @@ export default {
</script>
<style scoped>
/* 标签样式,设置为粗体 */
label {
font-weight: bold !important;
}
</style>
</style>
Loading…
Cancel
Save