diff --git a/src/api/audit.js b/src/api/audit.js index acda64a..36de712 100644 --- a/src/api/audit.js +++ b/src/api/audit.js @@ -14,3 +14,18 @@ export function remove (data) { data, }) } + +export function fileList (params) { + return request({ + url: '/audit_file/list', + params, + }) +} + +export function fileRemove (data) { + return request({ + url: '/audit_file/delete', + method: 'post', + data, + }) +} diff --git a/src/router/index.js b/src/router/index.js index 71ad9f0..370f2c5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -136,6 +136,12 @@ export const asyncRoutes = [ meta: { title: 'AuditConnLog', icon: 'Tickets' /*keepAlive: true*/ }, component: () => import('@/views/audit/connList.vue'), }, + { + path: '/auditFile', + name: 'AuditFile', + meta: { title: 'AuditFileLog', icon: 'Files' /*keepAlive: true*/ }, + component: () => import('@/views/audit/fileList.vue'), + }, ], }, ] diff --git a/src/utils/file.js b/src/utils/file.js index fa84f9f..bffbbfc 100644 --- a/src/utils/file.js +++ b/src/utils/file.js @@ -55,3 +55,15 @@ export function downBlob (blob, filename) { document.body.removeChild(a) }) } + +export function sizeFormat (size) { + if (size < 1024) { + return size + 'B' + } else if (size < 1024 * 1024) { + return (size / 1024).toFixed(2) + 'KB' + } else if (size < 1024 * 1024 * 1024) { + return (size / 1024 / 1024).toFixed(2) + 'MB' + } else { + return (size / 1024 / 1024 / 1024).toFixed(2) + 'GB' + } +} diff --git a/src/utils/i18n/en.json b/src/utils/i18n/en.json index 8da331d..715a783 100644 --- a/src/utils/i18n/en.json +++ b/src/utils/i18n/en.json @@ -366,5 +366,38 @@ }, "CloseTime": { "One": "Close Time" + }, + "AuditFileLog": { + "One": "File Log" + }, + "Common": { + "One": "Common" + }, + "File": { + "One": "File" + }, + "Num": { + "One": "Num" + }, + "Ip": { + "One": "Ip" + }, + "FileName": { + "One": "File Name" + }, + "FileInfo": { + "One": "File Info" + }, + "Path": { + "One": "Path" + }, + "IndexNum": { + "One": "Index Num" + }, + "ToRemote": { + "One": "To Remote" + }, + "ToLocal": { + "One": "To Local" } } diff --git a/src/utils/i18n/zh_CN.json b/src/utils/i18n/zh_CN.json index 5e4e6a7..9189a47 100644 --- a/src/utils/i18n/zh_CN.json +++ b/src/utils/i18n/zh_CN.json @@ -352,5 +352,38 @@ }, "CloseTime": { "One": "关闭时间" + }, + "AuditFileLog": { + "One": "文件日志" + }, + "Common": { + "One": "普通" + }, + "File": { + "One": "文件" + }, + "Num": { + "One": "数量" + }, + "Ip": { + "One": "IP" + }, + "FileName": { + "One": "文件名" + }, + "FileInfo": { + "One": "文件信息" + }, + "Path": { + "One": "路径" + }, + "IndexNum": { + "One": "序号" + }, + "ToRemote": { + "One": "到远程" + }, + "ToLocal": { + "One": "到本地" } } diff --git a/src/views/audit/connList.vue b/src/views/audit/connList.vue index 7593c35..24e550a 100644 --- a/src/views/audit/connList.vue +++ b/src/views/audit/connList.vue @@ -14,16 +14,22 @@ - + + + + - + diff --git a/src/views/audit/fileList.vue b/src/views/audit/fileList.vue new file mode 100644 index 0000000..0b22534 --- /dev/null +++ b/src/views/audit/fileList.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/src/views/audit/reponsitories.js b/src/views/audit/reponsitories.js index a026789..317be6c 100644 --- a/src/views/audit/reponsitories.js +++ b/src/views/audit/reponsitories.js @@ -1,8 +1,10 @@ import { reactive } from 'vue' -import { list, remove } from '@/api/audit' +import { list, remove, fileList, fileRemove } from '@/api/audit' import { ElMessage, ElMessageBox } from 'element-plus' import { useRoute } from 'vue-router' -import {formatTime} from '@/utils/time' +import { formatTime } from '@/utils/time' +import { T } from '@/utils/i18n' + export function useRepositories () { const listRes = reactive({ list: [], total: 0, loading: false, @@ -20,7 +22,7 @@ export function useRepositories () { listRes.loading = false if (res) { listRes.list = res.data.list.map(item => { - item.close_time = item.close_time ? formatTime(item.close_time*1000) : '-' + item.close_time = item.close_time ? formatTime(item.close_time * 1000) : '-' return item }) listRes.total = res.data.total @@ -35,9 +37,9 @@ export function useRepositories () { } const del = async (row) => { - const cf = await ElMessageBox.confirm('确定删除么?', { - confirmButtonText: '确定', - cancelButtonText: '取消', + const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), { + confirmButtonText: T('Confirm'), + cancelButtonText: T('Cancel'), type: 'warning', }).catch(_ => false) if (!cf) { @@ -46,7 +48,64 @@ export function useRepositories () { const res = await remove({ id: row.id }).catch(_ => false) if (res) { - ElMessage.success('操作成功') + ElMessage.success(T('OperationSuccess')) + getList() + } + } + + return { + listRes, + listQuery, + getList, + handlerQuery, + del, + } +} + +export function useFileRepositories () { + const listRes = reactive({ + list: [], total: 0, loading: false, + }) + const listQuery = reactive({ + page: 1, + page_size: 10, + peer_id: null, + from_peer: null, + }) + + const getList = async () => { + listRes.loading = true + const res = await fileList(listQuery).catch(_ => false) + listRes.loading = false + if (res) { + listRes.list = res.data.list.map(item => { + item.info = item.info ? JSON.parse(item.info) : '-' + return item + }) + listRes.total = res.data.total + } + } + const handlerQuery = () => { + if (listQuery.page === 1) { + getList() + } else { + listQuery.page = 1 + } + } + + const del = async (row) => { + const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), { + confirmButtonText: T('Confirm'), + cancelButtonText: T('Cancel'), + type: 'warning', + }).catch(_ => false) + if (!cf) { + return false + } + + const res = await fileRemove({ id: row.id }).catch(_ => false) + if (res) { + ElMessage.success(T('OperationSuccess')) getList() } } diff --git a/src/views/login/log.js b/src/views/login/log.js index 0c1f2dc..56edc7d 100644 --- a/src/views/login/log.js +++ b/src/views/login/log.js @@ -2,6 +2,7 @@ import { reactive } from 'vue' import { list, remove } from '@/api/login_log' import { ElMessage, ElMessageBox } from 'element-plus' import { useRoute } from 'vue-router' +import { T } from '@/utils/i18n' export function useRepositories () { const route = useRoute() @@ -35,9 +36,9 @@ export function useRepositories () { } const del = async (row) => { - const cf = await ElMessageBox.confirm('确定删除么?', { - confirmButtonText: '确定', - cancelButtonText: '取消', + const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('Delete') }), { + confirmButtonText: T('Confirm'), + cancelButtonText: T('Cancel'), type: 'warning', }).catch(_ => false) if (!cf) { @@ -46,7 +47,7 @@ export function useRepositories () { const res = await remove({ id: row.id }).catch(_ => false) if (res) { - ElMessage.success('操作成功') + ElMessage.success(T('OperationSuccess')) getList() } }