feat: Add My Login log
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function list (params) {
|
||||||
|
return request({
|
||||||
|
url: '/my/login_log/list',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/login_log/delete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function batchDelete (data) {
|
||||||
|
return request({
|
||||||
|
url: '/my/login_log/batchDelete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -91,6 +91,12 @@ export const asyncRoutes = [
|
|||||||
meta: { title: 'ShareRecord', icon: 'Share' /*keepAlive: true*/ },
|
meta: { title: 'ShareRecord', icon: 'Share' /*keepAlive: true*/ },
|
||||||
component: () => import('@/views/my/share_record/index.vue'),
|
component: () => import('@/views/my/share_record/index.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'loginLog',
|
||||||
|
name: 'MyLoginLog',
|
||||||
|
meta: { title: 'LoginLog', icon: 'List' /*keepAlive: true*/ },
|
||||||
|
component: () => import('@/views/my/login_log/index.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+15
-10
@@ -1,13 +1,18 @@
|
|||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { batchDelete, list, remove } from '@/api/login_log'
|
import { list as admin_fetchPeers } from '@/api/peer'
|
||||||
import { list as fetchPeers } from '@/api/peer'
|
import { list as my_fetchPeers } from '@/api/my/peer'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
|
import { batchDelete as admin_batchDelete, list as admin_list, remove as admin_remove } from '@/api/login_log'
|
||||||
|
import { batchDelete as my_batchDelete, list as my_list, remove as my_remove } from '@/api/my/login_log'
|
||||||
|
|
||||||
export function useRepositories () {
|
const apis = {
|
||||||
const route = useRoute()
|
admin: { batchDelete: admin_batchDelete, list: admin_list, remove: admin_remove, fetchPeers: admin_fetchPeers },
|
||||||
const user_id = route.query?.user_id
|
my: { batchDelete: my_batchDelete, list: my_list, remove: my_remove, fetchPeers: my_fetchPeers },
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRepositories (api_type = 'my') {
|
||||||
|
|
||||||
const listRes = reactive({
|
const listRes = reactive({
|
||||||
list: [], total: 0, loading: false,
|
list: [], total: 0, loading: false,
|
||||||
@@ -16,16 +21,16 @@ export function useRepositories () {
|
|||||||
page: 1,
|
page: 1,
|
||||||
page_size: 10,
|
page_size: 10,
|
||||||
is_my: 0,
|
is_my: 0,
|
||||||
user_id: user_id ? parseInt(user_id) : null,
|
user_id: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
listRes.loading = true
|
listRes.loading = true
|
||||||
const res = await list(listQuery).catch(_ => false)
|
const res = await apis[api_type].list(listQuery).catch(_ => false)
|
||||||
listRes.loading = false
|
listRes.loading = false
|
||||||
if (res) {
|
if (res) {
|
||||||
const uuids = res.data.list.filter(item => item.uuid).map(item => item.uuid)
|
const uuids = res.data.list.filter(item => item.uuid).map(item => item.uuid)
|
||||||
const peers = await fetchPeers({ uuids }).catch(_ => false)
|
const peers = await apis[api_type].fetchPeers({ uuids }).catch(_ => false)
|
||||||
if (peers?.data?.list) {
|
if (peers?.data?.list) {
|
||||||
res.data.list.forEach(item => {
|
res.data.list.forEach(item => {
|
||||||
if (item.uuid) {
|
if (item.uuid) {
|
||||||
@@ -55,7 +60,7 @@ export function useRepositories () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await remove({ id: row.id }).catch(_ => false)
|
const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
@@ -77,7 +82,7 @@ export function useRepositories () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await batchDelete({ ids }).catch(_ => false)
|
const res = await apis[api_type].batchDelete({ ids }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
ElMessage.success(T('OperationSuccess'))
|
ElMessage.success(T('OperationSuccess'))
|
||||||
getList()
|
getList()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<el-table-column prop="uuid" label="uuid" align="center"/>
|
<el-table-column prop="uuid" label="uuid" align="center"/>
|
||||||
<el-table-column prop="ip" label="ip" align="center" width="150"/>
|
<el-table-column prop="ip" label="ip" align="center" width="150"/>
|
||||||
<el-table-column prop="type" label="type" align="center" width="100"/>
|
<el-table-column prop="type" label="type" align="center" width="100"/>
|
||||||
<el-table-column prop="platform" label="platform" align="center" width="120" show-overflow-tooltip/>
|
<el-table-column prop="platform" label="Platform/UA" align="center" width="120" show-overflow-tooltip/>
|
||||||
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
||||||
<el-table-column :label="T('Actions')" align="center" width="400">
|
<el-table-column :label="T('Actions')" align="center" width="400">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
handlerQuery,
|
handlerQuery,
|
||||||
del,
|
del,
|
||||||
batchdel,
|
batchdel,
|
||||||
} = useRepositories()
|
} = useRepositories('admin')
|
||||||
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
onActivated(getList)
|
onActivated(getList)
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-card class="list-query" shadow="hover">
|
||||||
|
<el-form inline label-width="80px">
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
||||||
|
<el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="list-body" shadow="hover">
|
||||||
|
<el-table :data="listRes.list" v-loading="listRes.loading" border @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" align="center" width="50"/>
|
||||||
|
<el-table-column prop="client" label="client" align="center" width="120"/>
|
||||||
|
<el-table-column prop="peer.id" :label="T('Peer')" align="center"/>
|
||||||
|
<el-table-column prop="uuid" label="uuid" align="center"/>
|
||||||
|
<el-table-column prop="ip" label="ip" align="center" width="150"/>
|
||||||
|
<el-table-column prop="type" label="type" align="center" width="100"/>
|
||||||
|
<el-table-column prop="platform" label="Platform/UA" align="center" width="120" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
||||||
|
<el-table-column :label="T('Actions')" align="center" width="400">
|
||||||
|
<template #default="{row}">
|
||||||
|
<el-button type="danger" @click="del(row)">{{ T('Delete') }}</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="list-page" shadow="hover">
|
||||||
|
<el-pagination background
|
||||||
|
layout="prev, pager, next, sizes, jumper"
|
||||||
|
:page-sizes="[10,20,50,100]"
|
||||||
|
v-model:page-size="listQuery.page_size"
|
||||||
|
v-model:current-page="listQuery.page"
|
||||||
|
:total="listRes.total">
|
||||||
|
</el-pagination>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { onActivated, onMounted, ref, watch } from 'vue'
|
||||||
|
import { useRepositories } from '@/views/login/log.js'
|
||||||
|
import { T } from '@/utils/i18n'
|
||||||
|
|
||||||
|
const {
|
||||||
|
listRes,
|
||||||
|
listQuery,
|
||||||
|
getList,
|
||||||
|
handlerQuery,
|
||||||
|
del,
|
||||||
|
batchdel,
|
||||||
|
} = useRepositories('my')
|
||||||
|
|
||||||
|
onMounted(getList)
|
||||||
|
onActivated(getList)
|
||||||
|
|
||||||
|
watch(() => listQuery.page, getList)
|
||||||
|
|
||||||
|
watch(() => listQuery.page_size, handlerQuery)
|
||||||
|
const multipleSelection = ref([])
|
||||||
|
const handleSelectionChange = (val) => {
|
||||||
|
multipleSelection.value = val
|
||||||
|
}
|
||||||
|
const toBatchDelete = () => {
|
||||||
|
if (multipleSelection.value.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
batchdel(multipleSelection.value)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.list-query .el-select {
|
||||||
|
--el-select-width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user