From d5eace6a05b2a68a7c9c8e51fe5cb0d490972012 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sat, 22 Jan 2022 22:33:25 +0800 Subject: [PATCH] refactor: action logs ui (#419) Signed-off-by: Ryan Wang --- src/config/router.config.js | 7 + src/core/constant.js | 58 ++++++ src/styles/tailwind.css | 4 +- src/views/dashboard/Dashboard.vue | 102 ++-------- .../dashboard/components/LogListDrawer.vue | 187 ------------------ src/views/system/ActionLogs.vue | 171 ++++++++++++++++ tailwind.config.js | 3 + 7 files changed, 255 insertions(+), 277 deletions(-) create mode 100644 src/core/constant.js delete mode 100644 src/views/dashboard/components/LogListDrawer.vue create mode 100644 src/views/system/ActionLogs.vue diff --git a/src/config/router.config.js b/src/config/router.config.js index 5d7a8b14b..f94d0c14d 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -205,6 +205,13 @@ export const asyncRouterMap = [ component: () => import('@/views/system/ToolList'), meta: { title: '小工具', hiddenHeaderContent: false } }, + { + path: '/system/actionlogs', + name: 'SystemActionLogs', + hidden: true, + component: () => import('@/views/system/ActionLogs'), + meta: { title: '操作日志', hiddenHeaderContent: false } + }, { path: '/system/about', name: 'About', diff --git a/src/core/constant.js b/src/core/constant.js new file mode 100644 index 000000000..aa3273a94 --- /dev/null +++ b/src/core/constant.js @@ -0,0 +1,58 @@ +export const actionLogTypes = { + BLOG_INITIALIZED: { + value: 0, + text: '博客初始化' + }, + POST_PUBLISHED: { + value: 5, + text: '文章发布' + }, + POST_EDITED: { + value: 15, + text: '文章修改' + }, + POST_DELETED: { + value: 20, + text: '文章删除' + }, + LOGGED_IN: { + value: 25, + text: '用户登录' + }, + LOGGED_OUT: { + value: 30, + text: '注销登录' + }, + LOGIN_FAILED: { + value: 35, + text: '登录失败' + }, + PASSWORD_UPDATED: { + value: 40, + text: '修改密码' + }, + PROFILE_UPDATED: { + value: 45, + text: '资料修改' + }, + SHEET_PUBLISHED: { + value: 50, + text: '页面发布' + }, + SHEET_EDITED: { + value: 55, + text: '页面修改' + }, + SHEET_DELETED: { + value: 60, + text: '页面删除' + }, + MFA_UPDATED: { + value: 65, + text: '两步验证' + }, + LOGGED_PRE_CHECK: { + value: 70, + text: '登录验证' + } +} diff --git a/src/styles/tailwind.css b/src/styles/tailwind.css index 3db5b698c..b5c61c956 100644 --- a/src/styles/tailwind.css +++ b/src/styles/tailwind.css @@ -1 +1,3 @@ -@tailwind utilities; \ No newline at end of file +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index 9789a3ceb..cf2220318 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -95,17 +95,17 @@ - + - {{ item.type }} + {{ item.type | typeConvert }} {{ item.content }} @@ -113,8 +113,6 @@ - - @@ -123,9 +121,9 @@ import { PageView } from '@/layouts' import AnalysisCard from './components/AnalysisCard' import JournalPublishCard from './components/JournalPublishCard' import RecentCommentTab from './components/RecentCommentTab' -import LogListDrawer from './components/LogListDrawer' import apiClient from '@/utils/api-client' +import { actionLogTypes } from '@/core/constant' export default { name: 'Dashboard', @@ -133,73 +131,13 @@ export default { PageView, AnalysisCard, JournalPublishCard, - RecentCommentTab, - LogListDrawer + RecentCommentTab }, data() { return { - logTypes: { - BLOG_INITIALIZED: { - value: 0, - text: '博客初始化' - }, - POST_PUBLISHED: { - value: 5, - text: '文章发布' - }, - POST_EDITED: { - value: 15, - text: '文章修改' - }, - POST_DELETED: { - value: 20, - text: '文章删除' - }, - LOGGED_IN: { - value: 25, - text: '用户登录' - }, - LOGGED_OUT: { - value: 30, - text: '注销登录' - }, - LOGIN_FAILED: { - value: 35, - text: '登录失败' - }, - PASSWORD_UPDATED: { - value: 40, - text: '修改密码' - }, - PROFILE_UPDATED: { - value: 45, - text: '资料修改' - }, - SHEET_PUBLISHED: { - value: 50, - text: '页面发布' - }, - SHEET_EDITED: { - value: 55, - text: '页面修改' - }, - SHEET_DELETED: { - value: 60, - text: '页面删除' - }, - MFA_UPDATED: { - value: 65, - text: '两步验证' - }, - LOGGED_PRE_CHECK: { - value: 70, - text: '登录验证' - } - }, activityLoading: false, logLoading: false, statisticsLoading: true, - logListDrawerVisible: false, latestPosts: [], latestLogs: [], statisticsData: {}, @@ -214,19 +152,6 @@ export default { this.handleListLatestPosts() this.handleListLatestLogs() }, - computed: { - formattedLogDatas() { - return this.latestLogs.map(log => { - log.type = this.logTypes[log.type].text - return log - }) - } - }, - destroyed: function () { - if (this.logListDrawerVisible) { - this.logListDrawerVisible = false - } - }, beforeRouteEnter(to, from, next) { next(vm => { vm.interval = setInterval(() => { @@ -240,9 +165,6 @@ export default { this.interval = null this.$log.debug('Cleared interval') } - if (this.logListDrawerVisible) { - this.logListDrawerVisible = false - } next() }, methods: { @@ -285,10 +207,12 @@ export default { apiClient.post.getPreviewLinkById(postId).then(response => { window.open(response.data, '_blank') }) - }, - handleLogListClose() { - this.logListDrawerVisible = false - this.handleListLatestLogs() + } + }, + filters: { + typeConvert(key) { + const type = actionLogTypes[key] + return type ? type.text : key } } } diff --git a/src/views/dashboard/components/LogListDrawer.vue b/src/views/dashboard/components/LogListDrawer.vue deleted file mode 100644 index b01c421aa..000000000 --- a/src/views/dashboard/components/LogListDrawer.vue +++ /dev/null @@ -1,187 +0,0 @@ - - - diff --git a/src/views/system/ActionLogs.vue b/src/views/system/ActionLogs.vue new file mode 100644 index 000000000..05b72cbdf --- /dev/null +++ b/src/views/system/ActionLogs.vue @@ -0,0 +1,171 @@ + + + diff --git a/tailwind.config.js b/tailwind.config.js index b3dc7184f..0875e1e4c 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -3,5 +3,8 @@ module.exports = { theme: { extend: {} }, + corePlugins: { + preflight: false + }, plugins: [] }