Skip to content

Commit 21bee7d

Browse files
committed
refactor: add operation log
1 parent 4c41a40 commit 21bee7d

File tree

7 files changed

+593
-13
lines changed

7 files changed

+593
-13
lines changed

ui/src/api/system/operate-log.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Result } from '@/request/Result'
2+
import { get, exportExcelPost } from '@/request/index'
3+
import type { pageRequest } from '@/api/type/common'
4+
import { type Ref } from 'vue'
5+
6+
const prefix = '/operate_log'
7+
/**
8+
* 日志分页列表
9+
* @param 参数
10+
* page {
11+
"current_page": "string",
12+
"page_size": "string",
13+
}
14+
* @query 参数
15+
param: any
16+
*/
17+
const getOperateLog: (
18+
page: pageRequest,
19+
param: any,
20+
loading?: Ref<boolean>
21+
) => Promise<Result<any>> = (page, param, loading) => {
22+
return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading)
23+
}
24+
25+
const getMenuList: () => Promise<Result<any>> = () => {
26+
return get(`${prefix}/menu_operation_option/`, undefined, undefined)
27+
}
28+
29+
const exportOperateLog: (
30+
param: any,
31+
loading?: Ref<boolean>
32+
) => void = (param, loading) => {
33+
exportExcelPost(
34+
'log.xlsx',
35+
`${prefix}/export/`,
36+
param,
37+
undefined,
38+
loading
39+
)
40+
}
41+
42+
export default {
43+
getOperateLog,
44+
getMenuList,
45+
exportOperateLog
46+
}

ui/src/locales/lang/zh-CN/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export default {
1616
common,
1717
chat,
1818
components,
19+
1920
}

ui/src/locales/lang/zh-CN/views/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import chatLog from './chat-log'
1717
import chatUser from './chat-user'
1818
// import notFound from './404'
1919

20-
// import operateLog from './operate-log'
20+
import operateLog from './operate-log'
2121
export default {
2222
login,
2323
model,
@@ -38,5 +38,5 @@ export default {
3838
chatUser,
3939
// notFound,
4040

41-
// operateLog
41+
operateLog
4242
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export default {
2+
title: '操作日志',
3+
table: {
4+
menu: {
5+
label: '操作菜单'
6+
},
7+
operate: {
8+
label: '操作',
9+
detail: '操作详情'
10+
},
11+
user: {
12+
label: '操作用户'
13+
},
14+
status: {
15+
label: '状态',
16+
success: '成功',
17+
fail: '失败',
18+
all: '全部'
19+
},
20+
ip_address: {
21+
label: 'IP地址'
22+
},
23+
opt: {
24+
label: 'API详情'
25+
},
26+
operateTime: {
27+
label: '操作时间'
28+
}
29+
},
30+
close: '关闭'
31+
}

ui/src/router/modules/system.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { PermissionConst, EditionConst, RoleConst } from '@/utils/permission/data'
2-
import { ComplexPermission } from '@/utils/permission/type'
1+
import {PermissionConst, EditionConst, RoleConst} from '@/utils/permission/data'
2+
import {ComplexPermission} from '@/utils/permission/type'
3+
34
const systemRouter = {
45
path: '/system',
56
name: 'system',
6-
meta: { title: 'views.system.title' },
7+
meta: {title: 'views.system.title'},
78
hidden: true,
89
component: () => import('@/layout/layout-template/SystemMainLayout.vue'),
910
children: [
@@ -17,7 +18,7 @@ const systemRouter = {
1718
activeMenu: '/system',
1819
parentPath: '/system',
1920
parentName: 'system',
20-
permission: [RoleConst.ADMIN,EditionConst.IS_EE],
21+
permission: [RoleConst.ADMIN, EditionConst.IS_EE],
2122
},
2223
component: () => import('@/views/user-manage/index.vue'),
2324
},
@@ -80,7 +81,7 @@ const systemRouter = {
8081
activeMenu: '/system',
8182
parentPath: '/system',
8283
parentName: 'system',
83-
permission:[new ComplexPermission([RoleConst.ADMIN,RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],[PermissionConst.ROLE_READ],[EditionConst.IS_EE],'OR'),],
84+
permission: [new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole], [PermissionConst.ROLE_READ], [EditionConst.IS_EE], 'OR'),],
8485
},
8586
component: () => import('@/views/role/index.vue'),
8687
},
@@ -94,7 +95,7 @@ const systemRouter = {
9495
activeMenu: '/system',
9596
parentPath: '/system',
9697
parentName: 'system',
97-
permission:[new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,RoleConst.ADMIN],[PermissionConst.WORKSPACE_WORKSPACE_READ],[EditionConst.IS_EE],'OR'),],
98+
permission: [new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, RoleConst.ADMIN], [PermissionConst.WORKSPACE_WORKSPACE_READ], [EditionConst.IS_EE], 'OR'),],
9899
},
99100
component: () => import('@/views/workspace/index.vue'),
100101
},
@@ -156,7 +157,7 @@ const systemRouter = {
156157
activeMenu: '/system',
157158
parentPath: '/system',
158159
parentName: 'system',
159-
permission:[new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,RoleConst.ADMIN],[PermissionConst.WORKSPACE_USER_GROUP_READ],[EditionConst.IS_EE,EditionConst.IS_PE],'OR'),],
160+
permission: [new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, RoleConst.ADMIN], [PermissionConst.WORKSPACE_USER_GROUP_READ], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR'),],
160161
},
161162
children: [
162163
{
@@ -167,7 +168,7 @@ const systemRouter = {
167168
activeMenu: '/system',
168169
parentPath: '/system',
169170
parentName: 'system',
170-
permission:[new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,RoleConst.ADMIN],[PermissionConst.WORKSPACE_CHAT_USER_READ],[EditionConst.IS_EE,EditionConst.IS_PE],'OR'),],
171+
permission: [new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, RoleConst.ADMIN], [PermissionConst.WORKSPACE_CHAT_USER_READ], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR'),],
171172
},
172173
component: () => import('@/views/system-chat-user/user-manage/index.vue'),
173174
},
@@ -179,7 +180,7 @@ const systemRouter = {
179180
activeMenu: '/system',
180181
parentPath: '/system',
181182
parentName: 'system',
182-
permission:[new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,RoleConst.ADMIN],[PermissionConst.WORKSPACE_USER_GROUP_READ],[EditionConst.IS_EE,EditionConst.IS_PE],'OR'),],
183+
permission: [new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, RoleConst.ADMIN], [PermissionConst.WORKSPACE_USER_GROUP_READ], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR'),],
183184
},
184185
component: () => import('@/views/system-chat-user/group/index.vue'),
185186
},
@@ -191,8 +192,8 @@ const systemRouter = {
191192
activeMenu: '/system',
192193
parentPath: '/system',
193194
parentName: 'system',
194-
permission:[new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,RoleConst.ADMIN],
195-
[PermissionConst.CHAT_USER_AUTH_READ],[EditionConst.IS_EE,EditionConst.IS_PE],'OR'),],
195+
permission: [new ComplexPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, RoleConst.ADMIN],
196+
[PermissionConst.CHAT_USER_AUTH_READ], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR'),],
196197
},
197198
component: () => import('@/views/system-chat-user/authentication/index.vue'),
198199
},
@@ -248,6 +249,20 @@ const systemRouter = {
248249
},
249250
],
250251
},
252+
{
253+
path: '/operate',
254+
name: 'operate',
255+
meta: {
256+
icon: 'app-document',
257+
iconActive: 'app-document-active',
258+
title: 'views.operateLog.title',
259+
activeMenu: '/system',
260+
parentPath: '/system',
261+
parentName: 'system',
262+
permission: [EditionConst.IS_PE, EditionConst.IS_EE],
263+
},
264+
component: () => import('@/views/operate-log/index.vue')
265+
}
251266
],
252267
}
253268

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<el-dialog
3+
:title="$t('views.operateLog.table.opt.label')"
4+
v-model="dialogVisible"
5+
:close-on-click-modal="false"
6+
:close-on-press-escape="false"
7+
>
8+
<div class="border border-r-4 mb-16" style="white-space: pre-wrap; height: 400px">
9+
<el-scrollbar>
10+
<div class="p-16">
11+
{{ details }}
12+
</div>
13+
</el-scrollbar>
14+
</div>
15+
<template #footer>
16+
<span class="dialog-footer mt-16">
17+
<el-button @click.prevent="dialogVisible = false">
18+
{{ $t('views.operateLog.close') }}
19+
</el-button>
20+
</span>
21+
</template>
22+
</el-dialog>
23+
</template>
24+
<script setup lang="ts">
25+
import { ref } from 'vue'
26+
const dialogVisible = ref<boolean>(false)
27+
const details = ref<string>()
28+
29+
const open = (data: any) => {
30+
details.value = JSON.stringify(data.details, null, 4)
31+
dialogVisible.value = true
32+
}
33+
34+
defineExpose({ open })
35+
</script>
36+
<style lang="scss" scoped></style>

0 commit comments

Comments
 (0)