diff --git a/backend/services/connection_service.go b/backend/services/connection_service.go index b27fe53..0737bbe 100644 --- a/backend/services/connection_service.go +++ b/backend/services/connection_service.go @@ -1040,6 +1040,7 @@ func (c *connectionService) RenameKey(connName string, db int, key, newKey strin return } +// GetCmdHistory get redis command history func (c *connectionService) GetCmdHistory(pageNo, pageSize int) (resp types.JSResp) { resp.Success = true if pageSize <= 0 || pageNo <= 0 { @@ -1062,6 +1063,13 @@ func (c *connectionService) GetCmdHistory(pageNo, pageSize int) (resp types.JSRe return } +// CleanCmdHistory clean redis command history +func (c *connectionService) CleanCmdHistory() (resp types.JSResp) { + c.cmdHistory = []cmdHistoryItem{} + resp.Success = true + return +} + // update or insert key info to database //func (c *connectionService) updateDBKey(connName string, db int, keys []string, separator string) { // dbStruct := map[string]any{} diff --git a/frontend/src/components/content/ContentLogPane.vue b/frontend/src/components/content/ContentLogPane.vue index 3701949..a1e4f90 100644 --- a/frontend/src/components/content/ContentLogPane.vue +++ b/frontend/src/components/content/ContentLogPane.vue @@ -5,6 +5,7 @@ import Refresh from '@/components/icons/Refresh.vue' import useConnectionStore from 'stores/connections.js' import { map, uniqBy } from 'lodash' import { useI18n } from 'vue-i18n' +import Delete from '@/components/icons/Delete.vue' import dayjs from 'dayjs' const connectionStore = useConnectionStore() @@ -43,6 +44,20 @@ const loadHistory = () => { }) } +const cleanHistory = async () => { + $dialog.warning(i18n.t('confirm_clean_log'), () => { + data.loading = true + connectionStore.cleanCmdHistory().then((success) => { + if (success) { + data.history = [] + data.loading = false + tableRef.value?.scrollTo({ top: 0 }) + $message.success(i18n.t('success')) + } + }) + }) +} + defineExpose({ refresh: () => nextTick().then(loadHistory), }) @@ -67,6 +82,9 @@ defineExpose({ + + +
} + */ + async cleanCmdHistory() { + try { + const { success } = await CleanCmdHistory() + return success === true + } catch { + return false + } + }, + /** * get key filter pattern and filter type * @param {string} server diff --git a/frontend/src/utils/discrete.js b/frontend/src/utils/discrete.js index ffbbe0c..b2019fe 100644 --- a/frontend/src/utils/discrete.js +++ b/frontend/src/utils/discrete.js @@ -12,8 +12,8 @@ function setupMessage(message) { info: (content, option = null) => { return message.info(content, option) }, - loading: (content, option = null) => { - option.duration = option.duration || 30000 + loading: (content, option = {}) => { + option.duration = option.duration != null ? option.duration : 30000 option.keepAliveOnHover = option.keepAliveOnHover !== undefined ? option.keepAliveOnHover : true return message.loading(content, option) }, @@ -28,20 +28,24 @@ function setupMessage(message) { function setupNotification(notification) { return { - error: (content, option = null) => { + error: (content, option = {}) => { + option.content = content option.title = option.title || i18nGlobal.t('error') - return notification.error(content, option) + return notification.error(option) }, - info: (content, option = null) => { - return notification.info(content, option) + info: (content, option = {}) => { + option.content = content + return notification.info(option) }, - success: (content, option = null) => { + success: (content, option = {}) => { + option.content = content option.title = option.title || i18nGlobal.t('success') - return notification.success(content, option) + return notification.success(option) }, - warning: (content, option = null) => { + warning: (content, option = {}) => { + option.content = content option.title = option.title || i18nGlobal.t('warning') - return notification.warning(content, option) + return notification.warning(option) }, } } @@ -81,6 +85,7 @@ export async function setupDiscreteApi() { placement: 'bottom-right', }, notificationProviderProps: { + max: 5, placement: 'top-right', keepAliveOnHover: true, },